You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入face_recognition模块遇RuntimeError:浮点数反序列化错误求助

Fixing "Error deserializing a floating point number" When Importing face_recognition

Hey there, let's work through this face_recognition import error together! That deserialization error you're seeing is almost always tied to a corrupted or incomplete dlib face landmark model file—here's how to fix it:

What's Causing This?

When you import face_recognition, it automatically tries to load the shape_predictor_68_face_landmarks.dat model (used to detect key facial points). If this file was interrupted during download, got corrupted, or is missing critical data, dlib can't parse the floating-point values stored in it, hence the runtime error.

Step-by-Step Solutions

1. Replace the Corrupted Model File

The quickest fix is to get a fresh copy of the official model:

  • Grab the latest shape_predictor_68_face_landmarks.dat model file (from dlib's official resources). Make sure it's fully downloaded and uncompressed.
  • Locate your face_recognition installation directory—your error message shows it's at /home/.local/lib/python3.7/site-packages/face_recognition/.
  • Swap out the existing shape_predictor_68_face_landmarks.dat file in that folder with your new, intact model file.

2. Reinstall face_recognition (and Dependencies)

If replacing the model doesn't resolve the issue, a clean reinstall will ensure all components are properly set up:

  • Uninstall the current packages first:
    pip uninstall -y dlib face_recognition
    
  • Reinstall face_recognition—this will automatically pull a compatible version of dlib and fresh, uncorrupted model files:
    pip install face_recognition
    

3. Manually Specify the Model Path (Optional)

If you prefer keeping the model in a custom location, you can explicitly point to it in your code to avoid path issues:

import dlib
import face_recognition

# Replace this path with the actual location of your intact model file
custom_predictor = dlib.shape_predictor("/your/custom/path/shape_predictor_68_face_landmarks.dat")

# Now you can use face_recognition functions normally

Any of these steps should fix the deserialization error by ensuring dlib has access to a complete, uncorrupted model file.

内容的提问来源于stack exchange,提问作者Aman Malhotra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 14:47:49