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

ImportError: cannot import name 'LogitsWarper' from 'transformers' #454

Open
Username1111111111 opened this issue Feb 26, 2025 · 4 comments

Comments

@Username1111111111
Copy link

Fresh install. Everything works except Tortoise:

diagnostic.txt

Generating tortoise with params:
TortoiseParameters(
text='Test tortoise input prompt',
voice='deniro',
preset='ultra_fast',
seed='1772520238',
cvvp_amount=0.0,
split_prompt=True,
num_autoregressive_samples=16,
diffusion_iterations=30,
temperature=0.8,
length_penalty=1.0,
repetition_penalty=2.0,
top_p=0.8,
max_mel_tokens=500,
cond_free=False,
cond_free_k=2,
diffusion_temperature=1.0,
model='Default',
name=''
)
Traceback (most recent call last):
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\gradio\queueing.py", line 624, in process_events
response = await route_utils.call_process_api(
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\gradio\route_utils.py", line 323, in call_process_api
output = await app.get_blocks().process_api(
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\gradio\blocks.py", line 2015, in process_api
result = await self.call_function(
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\gradio\blocks.py", line 1574, in call_function
prediction = await utils.async_iteration(iterator)
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\gradio\utils.py", line 710, in async_iteration
return await anext(iterator)
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\gradio\utils.py", line 704, in anext
return await anyio.to_thread.run_sync(
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\anyio_backends_asyncio.py", line 2461, in run_sync_in_worker_thread
return await future
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\anyio_backends_asyncio.py", line 962, in run
result = context.run(func, *args)
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\gradio\utils.py", line 687, in run_sync_iterator_async
return next(iterator)
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\gradio\utils.py", line 848, in gen_wrapper
response = next(iterator)
File "C:\Utils\tts-generation-webui-main\tts_webui\tortoise\tortoise_tab.py", line 145, in gen
yield from generate_tortoise_long(
File "C:\Utils\tts-generation-webui-main\tts_webui\tortoise\gen_tortoise.py", line 246, in generate_tortoise_long
datas = generate_tortoise(
File "C:\Utils\tts-generation-webui-main\tts_webui\tortoise\gen_tortoise.py", line 160, in generate_tortoise
tts = get_tts()
File "C:\Utils\tts-generation-webui-main\tts_webui\tortoise\gen_tortoise.py", line 104, in get_tts
from tortoise.api import MODELS_DIR, TextToSpeech
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\tortoise\api.py", line 14, in
from tortoise.models.autoregressive import UnifiedVoice
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\tortoise\models\autoregressive.py", line 10, in
from tortoise.utils.typical_sampling import TypicalLogitsWarper
File "C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\tortoise\utils\typical_sampling.py", line 2, in
from transformers import LogitsWarper
ImportError: cannot import name 'LogitsWarper' from 'transformers' (C:\Utils\tts-generation-webui-main\installer_files\env\lib\site-packages\transformers_init_.py)

@rsxdalv
Copy link
Owner

rsxdalv commented Feb 28, 2025

This would mean that transformers has the wrong version.

Could you please check it for me:
use installer_scripts/conda_env_cmd.bat
and inside of it
pip show transformers

@Username1111111111
Copy link
Author

@rsxdalv

(C:\Utils\tts-generation-webui-main\installer_files\env) C:\Utils\tts-generation-webui-main>pip show transformers
Name: transformers
Version: 4.49.0
Summary: State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow
Home-page: https://github.com/huggingface/transformers
Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)
Author-email: [email protected]
License: Apache 2.0 License
Location: c:\utils\tts-generation-webui-main\installer_files\env\lib\site-packages
Requires: filelock, huggingface-hub, numpy, packaging, pyyaml, regex, requests, safetensors, tokenizers, tqdm
Required-by: audiocraft, audiolm-pytorch, bark_hubert_quantizer, laion-clap, maha_tts, stable-audio-tools, styletts2, suno-bark, tortoise-tts

@rsxdalv
Copy link
Owner

rsxdalv commented Feb 28, 2025

Thanks!

This is the last known version that should work:
4.48.3
In that same terminal, if you do

pip install transformers==4.48.3

and restart the webui, it should work.

I'm not going to patch it just yet, because I see others having the same problem in text-generation-webui and elsewhere, so I'm not sure if the transformers team made a mistake or if it's an intentional change.
(In formal terms, this problem should not happen for any 4.x version, only versions such as 5.x should permit such a change.)

@Username1111111111
Copy link
Author

Thank you!

I can confirm it fixes the import error.

Image

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

2 participants