Closed TransAmMan closed 3 weeks ago
I also getting the above error,anyone know how to go about it?
Here's a suggested response to the GitHub issue regarding the AttributeError
related to np.float
:
I encountered the same AttributeError: module 'numpy' has no attribute 'float'
issue while running SimSwap in Colab. The error occurs because np.float
was 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:
pip install numpy==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! :)
Here's a suggested response to the GitHub issue regarding the
AttributeError
related tonp.float
:I encountered the same
AttributeError: module 'numpy' has no attribute 'float'
issue while running SimSwap in Colab. The error occurs becausenp.float
was 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:
pip install numpy==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 :(
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.
if use_mask:
target_image = np.array(target_image, dtype=float) * 255 # Change np.float to float
else:
target_image = np.array(target_image, dtype=float)[..., ::-1] * 255 # Change np.float to float
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
if use_mask: target_image = np.array(target_image, dtype=float) * 255 # Change np.float to float else: target_image = np.array(target_image, dtype=float)[..., ::-1] * 255 # Change np.float to float
i tried ( i changed line 168 too) but i get this error message:
AttributeError Traceback (most recent call last)
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.float
was a deprecated alias for the builtin float
. To avoid this error in existing code, use float
by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64
here.
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
Here's a suggested response to the GitHub issue regarding the
AttributeError
related tonp.float
:I encountered the same
AttributeError: module 'numpy' has no attribute 'float'
issue while running SimSwap in Colab. The error occurs becausenp.float
was 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:
pip install numpy==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 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.
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
if use_mask: target_image = np.array(target_image, dtype=float) * 255 # Change np.float to float else: target_image = np.array(target_image, dtype=float)[..., ::-1] * 255 # Change np.float to float
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??"
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.float
was a deprecated alias for the builtinfloat
. To avoid this error in existing code, usefloat
by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.float64
here. 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#deprecationsGemini 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.