deepinsight / deepinsight/insightface

'NoneType' object has no attribute 'shape' when creating executable with pyinstaller

Open
#2,761 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
29.7k
Forks
6.1k
PR merge metrics
No merged PRs in 30d

Description

The issue was encountered when building an executable with pyinstaller. While the whole process works fine when deployed via Python, I receive a

```
faces = self.model.get(image)
File "insightface\app\face_analysis.py", line 75, in get
File "insightface\model_zoo\landmark.py", line 107, in get
File "insightface\utils\transform.py", line 67, in estimate_affine_matrix_3d23d
AttributeError: 'NoneType' object has no attribute 'shape'
```

Model is initiated with
```
self.model = insightface.app.FaceAnalysis(
name='buffalo_l',
root=model_dir,
providers=[provider]
)
self.model.prepare(ctx_id=ctx_id)
```

Logging the model and the image before calling the get() method shows that both exist with valid values.
```

```
```

####
[[[ 40 39 37]
[ 40 39 37]
[ 40 39 37]
...
```

Using:

pyinstaller 6.13.0
pyinstaller-hooks-contrib 2025.4
numpy 2.2.5
onnx 1.17.0
onnxruntime 1.21.1
opencv-python-headless 4.11.0.86
insightface 0.7.3

Tried using hidden imports with all sorts of requirements, collecting submodules for the respective imports, but error persists. Any ideas would be appreciated

Tried bundling with nuitka instead of pyinstaller, but the app crashes with the exact same error

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reported call from self.model.get(image) and trace through insightface/app/face_analysis.py, insightface/model_zoo/landmark.py, and insightface/utils/transform.py to determine why a value becomes None only in the bundled executable. Reproduce with the listed Python, PyInstaller, NumPy, ONNX, OpenCV, and InsightFace versions; done means identifying a reproducible packaging or runtime cause and documenting a verified fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, opencv, python
Domain
computer-vision, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.