Skip to content

Fix numpy 2.x compatibility: remove deprecated type aliases and fix scalar conversion#1045

Open
trungkienkts-creator wants to merge 1 commit into
OpenTalker:mainfrom
trungkienkts-creator:main
Open

Fix numpy 2.x compatibility: remove deprecated type aliases and fix scalar conversion#1045
trungkienkts-creator wants to merge 1 commit into
OpenTalker:mainfrom
trungkienkts-creator:main

Conversation

@trungkienkts-creator

Copy link
Copy Markdown

Summary

numpy 2.0 made two breaking changes that crash SadTalker on import and during inference:

  1. Removed deprecated scalar-type aliases - np.float, np.int, np.bool, np.complex, np.object, np.str are gone.
  2. Tightened float() / int() conversion - these now only accept 0-dimensional arrays; passing a 1-element 1-D array raises TypeError: only 0-dimensional arrays can be converted to Python scalars.

Files changed

File Change
src/face3d/util/my_awing_arch.py np.float ? np.float64
src/face3d/models/arcface_torch/torch2onnx.py np.float ? np.float64
src/face3d/models/arcface_torch/eval_ijbc.py np.int ? np.int_ (x4)
src/face3d/models/arcface_torch/onnx_ijbc.py np.int ? np.int_ (x4)
src/face3d/models/arcface_torch/utils/plot.py np.int ? np.int_ (x3)
src/face3d/util/preprocess.py Fix np.VisibleDeprecationWarning; extract scalar s/t via np.squeeze() before int() in resize_n_crop_img; wrap t/s in float(np.squeeze(...)) in align_img
src/utils/preprocess.py Replace float(item) with item.item() for np.hsplit results in CropAndExtract

Testing

Verified end-to-end with:

python inference.py --driven_audio test.wav --source_image avatar.jpg --result_dir output/ --still --preprocess full --size 256 --cpu

Environment: Python 3.14, numpy 2.4.6, torch 2.12.0+cpu, Windows 11.

…float() casts

numpy 2.0 removed the deprecated scalar aliases (np.float, np.int, np.bool,
etc.) and tightened float()/int() conversion to reject non-0-dimensional arrays.

- np.float  -> np.float64  (my_awing_arch.py, torch2onnx.py)
- np.int    -> np.int_     (eval_ijbc.py, onnx_ijbc.py, plot.py)
- np.VisibleDeprecationWarning -> DeprecationWarning (preprocess.py)
- resize_n_crop_img: extract scalar s/t0/t1 via np.squeeze() before int()
  arithmetic so PIL.Image.resize() receives plain Python ints
- align_img: wrap t[0]/t[1]/s in float(np.squeeze()) before np.array()
  to avoid inhomogeneous-shape error
- CropAndExtract: use .item() instead of float() on np.hsplit() sub-arrays

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant