AttributeError: module 'numpy' has no attribute 'float' #463
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I am running SimSwap in Colab.
I am getting an AttrbuteError, but I have no clue how to fix it.
The failure is on the last line
"video_swap(opt.video_path, latend_id, model, app, opt.output_path, temp_results_dir=opt.temp_path, use_mask=opt.use_mask)"
AttributeError: module 'numpy' has no attribute 'float'.
np.floatwas a deprecated alias for the builtinfloat. To avoid this error in existing code, usefloatby itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.float64here.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
Gemini Suggested Changes:
To fix the error, replace all instances of np.float with float in the code. however I cannot find places in the code to make the change.
I also getting the above error,anyone know how to go about it?
Here's a suggested response to the GitHub issue regarding the
AttributeErrorrelated tonp.float:I encountered the same
AttributeError: module 'numpy' has no attribute 'float'issue while running SimSwap in Colab. The error occurs becausenp.floatwas deprecated in NumPy 1.20 and later removed.I found a solution by downgrading the NumPy version from 1.25.2 to 1.23.5. Here are the steps I followed:
Downgrade NumPy to version 1.23.5:
Restart the Colab session to apply the changes.
After performing these steps, the code ran successfully without the
AttributeError.I hope this helps anyone facing the same issue! :)
Thank you so much....but exactly where can I put pip install numpy==1.23.5 ? sorry for the stupid question :(
Can you tell me what environment you’re running the code in? Are you using venv or conda? :)
on the left side of the colab click on the simswap folder, scroll down to the util folder look for the reverse2original.py file, line 157 -160 replace it with the code below and then reinstall everything and run and its good to go.
In the file /content/SimSwap/util/reverse2original.py
i tried ( i changed line 168 too) but i get this error message:
AttributeError Traceback (most recent call last)
in <cell line: 22>()
39 latend_id = latend_id.to('cuda')
40
---> 41 video_swap(opt.video_path, latend_id, model, app, opt.output_path, temp_results_dir=opt.temp_path, use_mask=opt.use_mask)
2 frames
/usr/local/lib/python3.10/dist-packages/numpy/__init__.py in getattr(attr)
317
318 if attr in former_attrs:
--> 319 raise AttributeError(former_attrs[attr])
320
321 if attr == 'testing':
AttributeError: module 'numpy' has no attribute 'float'.
np.floatwas a deprecated alias for the builtinfloat. To avoid this error in existing code, usefloatby itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.float64here.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
Thank you elisa5626 I tried every way to implement this, but was not successful. What I found that NumPy is installed as part of other packages, and the 1.23.5 version is overwriten. Also if you If you could elaborate on how you did this, it would help.
Thank you orlandomendozagarrido I tried your change. I may be doing it wrong, but I found that if I "reinstall everything and run" a new, original, file is loaded and the change is lost, or not used. I may be missing something maybe you mean "reinstall a single cell??"