Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zaZaza7979 opened this issue Mar 3, 2024 · 23 comments

Comments

@zaZaza7979
Copy link

zaZaza7979 commented Mar 3, 2024

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

@zaZaza7979 zaZaza7979 changed the title After updating WebUI 1.8, a Sadtalker error appears and the tab is not visible After updating WebUI 1.8, Sadtalker error appears and the tab is not visible Mar 3, 2024
@ericz024
Copy link

ericz024 commented Mar 5, 2024

same here

@oisilener1982
Copy link

oisilener1982 commented Mar 5, 2024

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

@vin901
Copy link

vin901 commented Mar 10, 2024

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
Copy link

Why cant sadtalker just upgrade to the latest torch and xformers

@Nemesis-the-Warlock
Copy link

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\librosa_init_.py", line 211, in
from . import core
File "H:\stable-diffusion-webui\venv\lib\site-packages\librosa\core_init_.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\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

@oisilener1982
Copy link

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

@Helge666
Copy link

Helge666 commented Mar 16, 2024

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
Copy link

Thanks Buddy working perfect

@Zhjhp2020
Copy link

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
Copy link

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

#839

@SirDuffy
Copy link

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
Copy link

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

@ivied7
Copy link

ivied7 commented Apr 9, 2024

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
Copy link

oisilener1982 commented Apr 10, 2024

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
Copy link

AppStolz commented Apr 14, 2024

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
Copy link

oisilener1982 commented Apr 14, 2024

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
Copy link

crispin-nosidam commented Apr 14, 2024

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 #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
Copy link

ReinerBforartists commented Apr 25, 2024

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

@Timo9Madrid7
Copy link

Timo9Madrid7 commented Apr 25, 2024

嘿,感谢您提供的所有信息和提示。可悲的是这一切并不能解决我的问题。我已经更新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
Copy link

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
Copy link

kingljl commented Apr 29, 2024

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
Copy link

kingljl commented Apr 29, 2024

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
Copy link

xqyd commented May 4, 2024

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])])

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

No branches or pull requests