choyingw / SynergyNet

3DV 2021: Synergy between 3DMM and 3D Landmarks for Accurate 3D Facial Geometry
MIT License
381 stars 57 forks source link

support numpy >= 1.20.0 ( np.int --> np.int64) #28

Closed sbelharbi closed 1 year ago

sbelharbi commented 1 year ago

hi, there seems to be a minor issue with numpy version. it is not specified what version you are using. this pr fixed the below errors to suppoer numpy >= 1.20.0.

thanks

$ python singleImage.py -f img
Traceback (most recent call last):
  File "~/SynergyNet/singleImage.py", line 129, in <module>
    main(args)
  File "~/SynergyNet/singleImage.py", line 28, in main
    model = SynergyNet(args)
  File "~/SynergyNet/model_building.py", line 69, in __init__
    self.triangles = torch.Tensor(self.triangles.astype(np.int)).long().cuda()
  File "~/venvs/env1/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?

# Edit SynergyNet/model_building.py

$ python singleImage.py -f img
Process the image:  img/sample_1.jpg
Traceback (most recent call last):
  File "~/SynergyNet/singleImage.py", line 129, in <module>
    main(args)
  File "~/SynergyNet/singleImage.py", line 60, in main
    rects = face_boxes(img_ori)
  File "~/SynergyNet/FaceBoxes/FaceBoxes.py", line 122, in __call__
    keep = nms(dets, nms_threshold)
  File "~/SynergyNet/FaceBoxes/utils/nms_wrapper.py", line 18, in nms
    return cpu_nms(dets, thresh)
  File "nms/cpu_nms.pyx", line 29, in nms.cpu_nms.cpu_nms
  File "~/venvs/env1/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

# Edit  SynergyNet/FaceBoxes/utils/nms/cpu_nms.pyx 

$ python singleImage.py -f img
Process the image:  img/sample_1.jpg
Save mesh result to inference_output/rendering_overlay/sample_1.jpg
Save landmark result to inference_output/landmarks/sample_1.jpg
Save pose result to inference_output/poses/sample_1.jpg
Process the image:  img/sample_2.jpg
Save mesh result to inference_output/rendering_overlay/sample_2.jpg
Save landmark result to inference_output/landmarks/sample_2.jpg
Save pose result to inference_output/poses/sample_2.jpg
Process the image:  img/sample_3.jpg
Save mesh result to inference_output/rendering_overlay/sample_3.jpg
Save landmark result to inference_output/landmarks/sample_3.jpg
Save pose result to inference_output/poses/sample_3.jpg
Process the image:  img/sample_4.jpg
Save mesh result to inference_output/rendering_overlay/sample_4.jpg
Save landmark result to inference_output/landmarks/sample_4.jpg
Save pose result to inference_output/poses/sample_4.jpg
sbelharbi commented 1 year ago

pr merged. issue fixed. thanks