OpenTalker / SadTalker

[CVPR 2023] SadTalker:Learning Realistic 3D Motion Coefficients for Stylized Audio-Driven Single Image Talking Face Animation
https://sadtalker.github.io/
Other
11.84k stars 2.21k forks source link

After updating WebUI 1.8, Sadtalker error appears and the tab is not visible #822

Open zaZaza7979 opened 7 months ago

zaZaza7979 commented 7 months ago

After updating webUI 1.8, Sadtalker error appears and the tab is not visible in the webUI. Is there any solution for this? 123131

ericz024 commented 7 months ago

same here

oisilener1982 commented 7 months ago

same here. Sad talker not working after updating to 1.8. Just rollback to 1.7 and everything will be fine

vin901 commented 7 months ago

If you upgrade from v1.7 to v1.8 Automatic1111 then it's ok as long as you DON'T upgrade torch & xformers (by running webui.bat with --reinstall-torch --reinstall-xformer)

SadTalker works ok with version: v1.8.0  •  python: 3.10.13  •  torch: 2.0.1+cu118  •  xformers: 0.0.20 SadTalker does NOT work with version: v1.8.0  •  python: 3.10.13  •  torch: 2.1.2+cu121  •  xformers: 0.0.23.post1

I find that Automatic v1.8 runs about 25% faster than v1.7 for image generation, haven't tested speed difference of SadTalker, so yeah would be good to have SadTalker work with the latest v1.8 and latest torch & xformers.

oisilener1982 commented 7 months ago

Why cant sadtalker just upgrade to the latest torch and xformers

Nemesis-the-Warlock commented 7 months ago

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] Version: 1.8.0-RC Commit hash: Launching Web UI with arguments: --xformers [-] ADetailer initialized. version: 24.3.0, num models: 12 ControlNet preprocessor location: H:\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads 2024-03-11 09:49:53,800 - ControlNet - INFO - ControlNet v1.1.441 2024-03-11 09:49:54,046 - ControlNet - INFO - ControlNet v1.1.441 Loading weights [9b61f620fe] from H:\stable-diffusion-webui\models\Stable-diffusion\rdbsg_v5025D.safetensors Creating model from config: H:\stable-diffusion-webui\configs\v1-inference.yaml 2024-03-11 09:49:55,902 - ControlNet - INFO - ControlNet UI callback registered. load Sadtalker Checkpoints from .\extensions\SadTalker\checkpoints ** Error executing callback ui_tabs_callback for H:\stable-diffusion-webui\extensions\SadTalker\scripts\extension.py Traceback (most recent call last): File "H:\stable-diffusion-webui\modules\script_callbacks.py", line 180, in ui_tabs_callback res += c.callback() or [] File "H:\stable-diffusion-webui\extensions\SadTalker\scripts\extension.py", line 172, in on_ui_tabs from app_sadtalker import sadtalker_demo File "H:\stable-diffusion-webui/extensions/SadTalker\app_sadtalker.py", line 3, in from src.gradio_demo import SadTalker File "H:\stable-diffusion-webui/extensions/SadTalker\src\gradio_demo.py", line 6, in from src.generate_batch import get_data File "H:\stable-diffusion-webui/extensions/SadTalker\src\generate_batch.py", line 8, in import src.utils.audio as audio File "H:\stable-diffusion-webui/extensions/SadTalker\src\utils\audio.py", line 1, in import librosa File "H:\stable-diffusion-webui\venv\lib\site-packages\librosainit.py", line 211, in from . import core File "H:\stable-diffusion-webui\venv\lib\site-packages\librosa\coreinit.py", line 9, in from .constantq import # pylint: disable=wildcard-import File "H:\stable-diffusion-webui\venv\lib\site-packages\librosa\core\constantq.py", line 1058, in dtype=np.complex, File "H:\stable-diffusion-webui\venv\lib\site-packages\numpyinit.py", line 338, in getattr raise AttributeError(former_attrs[attr]) AttributeError: module 'numpy' has no attribute 'complex'.

- np.complex_ was a deprecated alias for the builtin complex. To avoid this error in existing code, use complex by itself. Doing this - will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.complex128 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
oisilener1982 commented 7 months ago

is there a plan for sadtalker to be compatible with v 1.8?

Helge666 commented 7 months ago

The bug seems not to be with SadTalker, but with the librosa python library. You can fix it by first finding the file "constantq.py" in your venv directory:

venv\lib\site-packages\librosa\core\constantq.py

Stop your WebGUI. Then edit this file and find the line 1058. It should read:

dtype=np.complex,

which is outdated and causes the error. Change that to:

dtype=complex,

Save and restart your WebGUI. Now, everything should start without error and the SadTalker tab re-appears.

WARNING: This may cause problems at a later point in time when the librosa library is updated. Or maybe it won't, I don't know. Just be careful and make a backup before changing stuff :-)

salamchacha commented 7 months ago

Thanks Buddy working perfect

Zhjhp2020 commented 7 months ago

thanks buddy

The bug seems not to be with SadTalker, but with the librosa python library. You can fix it by first finding the file "constantq.py" in your venv directory:

venv\lib\site-packages\librosa\core\constantq.py

Stop your WebGUI. Then edit this file and find the line 1058. It should read:

dtype=np.complex,

which is outdated and causes the error. Change that to:

dtype=complex,

Save and restart your WebGUI. Now, everything should start without error and the SadTalker tab re-appears.

WARNING: This may cause problems at a later point in time when the librosa library is updated. Or maybe it won't, I don't know. Just be careful and make a backup before changing stuff :-)

oisilener1982 commented 7 months ago

THis worked and allowed the Sadtalker to be in the tab again but there is an error

https://github.com/OpenTalker/SadTalker/issues/839

SirDuffy commented 7 months ago

i am running webui forge. is it possible to install a stable diffusion webui 1.7 with sadtalker on the same drive as a standalone version? where do i get the older installation files?

duldduld commented 7 months ago

I upgraded librosa (command: python -m pip install -U librosa) to the latest version (0.10.1) and found it fixed.

ivied7 commented 6 months ago

I upgraded librosa (command: python -m pip install -U librosa) to the latest version (0.10.1) and found it fixed.

it works.well done,thanks.

oisilener1982 commented 6 months ago

Sadtalker will show again in the tab after fixing with the work arounds mentioned above but if you try to click generate another error will appear: AttributeError: module 'numpy' has no attribute 'float'

AppStolz commented 6 months ago

Sadtalker will show again in the tab after fixing with the work arounds mentioned above but if you try to click generate another error will appear: AttributeError: module 'numpy' has no attribute 'float'

To resolve the issue with Sad Talker in the WebUI, please follow the instructions below:

Changes in my_awing_arch.py

  1. Navigate to extensions/SadTalker/src/face3d/util.
  2. Open the file my_awing_arch.py.
  3. Locate the line:
    preds = preds.astype(np.float, copy=False)
  4. Replace this line with:
    preds = preds.astype(float, copy=False)

Changes in preprocess.py

  1. Navigate to extensions/SadTalker/src/face3d/util.
  2. Open the file preprocess.py.
  3. Add the following import at the beginning of the file where you use the array:
    from numpy import array
  4. Find the line in the same file:
    trans_params = np.array([w0, h0, s, t[0], t[1]])
  5. Replace this line with:
    trans_params = array([float(w0), float(h0), float(s), float(t[0]), float(t[1])])

Changes in audio.py

  1. Navigate to extensions/SadTalker/src/utils.
  2. Open the file audio.py.
  3. Find the line:
    return librosa.stft(y=y, n_fft=hp.n_fft, hop_length=get_hop_size(), win_length=hp.win_size)
  4. Replace this line with:
    return librosa.stft(y=y, n_fft=hp.n_fft, hop_length=get_hop_size(), win_length=hp.win_size, dtype=float)

After making these changes, save the files and run your WebUI again. These modifications should fix any issues with Sad Talker in the WebUI.

I hope this guide helps you out. If you need further assistance, please don't hesitate to reach out.

oisilener1982 commented 6 months ago

Its working fine now. Thx. I used https://www.sublimetext.com/download_thanks?target=win-x64 because IDLE 3.10 64 bit cant open my_awing_arch.py in my win 10 pc.

Sadtalker is now running fine in version 1.8. Im just wondering: is it that hard to just update sadtalker so that we wont have to edit the .py files manually? Im not a programmer so i have no idea

crispin-nosidam commented 6 months ago

Sadtalker will show again in the tab after fixing with the work arounds mentioned above but if you try to click generate another error will appear: AttributeError: module 'numpy' has no attribute 'float'

To resolve the issue with Sad Talker in the WebUI, please follow the instructions below:

Changes in my_awing_arch.py

  1. Navigate to extensions/SadTalker/src/face3d/util.
  2. Open the file my_awing_arch.py.
  3. Locate the line:
    preds = preds.astype(np.float, copy=False)
  4. Replace this line with:
    preds = preds.astype(float, copy=False)

Changes in preprocess.py

  1. Navigate to extensions/SadTalker/src/face3d/util.
  2. Open the file preprocess.py.
  3. Add the following import at the beginning of the file where you use the array:
    from numpy import array
  4. Find the line in the same file:
    trans_params = np.array([w0, h0, s, t[0], t[1]])
  5. Replace this line with:
    trans_params = array([float(w0), float(h0), float(s), float(t[0]), float(t[1])])

Changes in audio.py

  1. Navigate to extensions/SadTalker/src/utils.
  2. Open the file audio.py.
  3. Find the line:
    return librosa.stft(y=y, n_fft=hp.n_fft, hop_length=get_hop_size(), win_length=hp.win_size)
  4. Replace this line with:
    return librosa.stft(y=y, n_fft=hp.n_fft, hop_length=get_hop_size(), win_length=hp.win_size, dtype=float)

After making these changes, save the files and run your WebUI again. These modifications should fix any issues with Sad Talker in the WebUI.

I hope this guide helps you out. If you need further assistance, please don't hesitate to reach out.

@AppStolz Thanks for providing the fix. Seems firstly need to fix venv/Lib/site-packages/librosa/core/constantq.py line 1058 as mentioned by @Zhjhp2020. And I suspect updating the venv's librosa version to 0.10.1 as mentioned by @Timo9Madrid7 on thread https://github.com/OpenTalker/SadTalker/issues/862 also work tho I didn't try.

Otherwise it will give the following when importing librosa

** Error executing callback ui_tabs_callback for D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui\extensions\SadTalker\scripts\extension.py Traceback (most recent call last): File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui\modules\script_callbacks.py", line 180, in ui_tabs_callback res += c.callback() or [] File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui\extensions\SadTalker\scripts\extension.py", line 172, in on_ui_tabs from app_sadtalker import sadtalker_demo File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui/extensions/SadTalker\app_sadtalker.py", line 3, in from src.gradio_demo import SadTalker File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui/extensions/SadTalker\src\gradio_demo.py", line 6, in from src.generate_batch import get_data File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui/extensions/SadTalker\src\generate_batch.py", line 8, in import src.utils.audio as audio File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui/extensions/SadTalker\src\utils\audio.py", line 1, in import librosa File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui\venv\lib\site-packages\librosa__init.py", line 211, in from . import core File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui\venv\lib\site-packages\librosa\core\init__.py", line 9, in from .constantq import # pylint: disable=wildcard-import File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui\venv\lib\site-packages\librosa\core\constantq.py", line 1058, in dtype=np.complex, File "D:\PycharmProjects\CSCI-E104-FinalProjTest\stable-diffusion-webui\venv\lib\site-packages\numpy__init.py", line 338, in getattr raise AttributeError(former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'complex'. np.complex was a deprecated alias for the builtin complex. To avoid this error in existing code, use complex by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.complex128 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

After that, it will still say various np.float problem as you described and your solution helped fixing that.

my librosa is librosa 0.9.2

ReinerBforartists commented 5 months ago

Hey, thanks for all the info and tips. Sadly this all doesn't fix it for me. I have updated librosa, no success. I have done the mentioned changes, no success. I am still stuck with the "complex" error.

EDIT; also tried the pull request here: https://github.com/OpenTalker/SadTalker/pull/869

Any further ideas?

doesnotwork

Timo9Madrid7 commented 5 months ago

嘿,感谢您提供的所有信息和提示。可悲的是这一切并不能解决我的问题。我已经更新librosa了,没有成功。我已经完成了提到的更改,但没有成功。我仍然遇到“复杂”错误。

编辑;还尝试了这里的拉取请求:#869

还有其他想法吗?

不起作用

Hi @ReinerBforartists,

Could you please visit to "E: automattic111\stable-diffusion-webuilvenvlib\site-packages\librosalcorelconstantq.py"?

If you have updated librosa to 0.10.1, you will find np.complex has been changed to np.complex64 like the image I show below:

image

Otherwise, you have probably updated librosa for other environments rather than for the environment of stable-diffusion-web-ui. You can clarify it by entering your ~<stable-diffusion-web-ui venv>/Scripts folder through your terminal where it has files activate and activate.bat. Then you can activate the environment using the command activate or activate.bat. After that, you can use the command pip list | findstr librosa (Windows) or pip list | grep librosa (Linux) to see if the version is correct, such as 0.10.1.

ReinerBforartists commented 5 months ago

Gotcha. The global pip is version librosa 10.1. But when calling from the console in the venv of stable-diffusion-webui it told me librosa version 0.8.0. I have updated it with python -m pip install -U librosa now. And now it shows version 0.10.1. And now i have my sadtalker tab and no errors anymore.

Many thanks. This solved it for me :)

kingljl commented 5 months ago

Hey, thanks for all the info and tips. Sadly this all doesn't fix it for me. I have updated librosa, no success. I have done the mentioned changes, no success. I am still stuck with the "complex" error.

EDIT; also tried the pull request here: #869

Any further ideas?

doesnotwork

This is correct. I don't have a Windows machine and cannot reproduce it. It should be related to the environment. Your library should still be incorrect

kingljl commented 5 months ago

Gotcha. The global pip is version librosa 10.1. But when calling from the console in the venv of stable-diffusion-webui it told me librosa version 0.8.0. I have updated it with python -m pip install -U librosa now. And now it shows version 0.10.1. And now i have my sadtalker tab and no errors anymore.

Many thanks. This solved it for me :)

I see you solved it. Sorry for the late reply

xqyd commented 5 months ago

Great solution!!! One simple typo: Changes in preprocess.py

trans_params = np.array([w0, h0, s, t[0], t[1]])

Replace this line with:

trans_params = np.array([float(w0), float(h0), float(s), float(t[0]), float(t[1])])

gayshub commented 4 months ago

I upgraded librosa (command: python -m pip install -U librosa) to the latest version (0.10.1) and found it fixed.

holyshit, it works in sd 1.9.4

HyunJae5463 commented 1 month ago

Tried like every fix here its still not showing