stable-diffusion icon indicating copy to clipboard operation
stable-diffusion copied to clipboard

cannot import name 'SAFE_WEIGHTS_NAME' from 'transformers.utils'

Open sunbyemj opened this issue 2 years ago • 12 comments

Installation successful, error reported after running

ImportError: cannot import name 'SAFE_WEIGHTS_NAME' from 'transformers.utils'

transformers==4.19.2

sunbyemj avatar Feb 23 '23 09:02 sunbyemj

Try this answer: https://www.reddit.com/r/StableDiffusion/comments/115fmc9/cannot_import_name_safe_weights_name_from/

Edit environments.yaml, "diffusers" --> "diffusers==0.12.1"

zogondragon avatar Feb 23 '23 11:02 zogondragon

Updating the env afterwards via: conda env update -f environment.yaml

kungfooman avatar Mar 18 '23 16:03 kungfooman

I'm installing the project from fresh (though not my first time) and I get this error right off the bat.

It seems init.py in site-packages\transformers\utils_init_.py no longer has the referenced conference of SAFE_WEIGHTS_NAME, seems like it used to be there and isn't now

ClaireCJS avatar May 02 '23 11:05 ClaireCJS

Aha! Fix found!

pip install diffusers==0.12.1

This project is rife with libraries that don't get installed automatically when they should. If someone would fix that, I think we'd have fewer threads like this

ClaireCJS avatar May 02 '23 11:05 ClaireCJS

@ClioCJS In my case, I downgraded from diffusers-0.16.1 to 0.12.1, and it solved the import error.

Developer-42 avatar May 02 '23 18:05 Developer-42

Updating the env afterwards via: conda env update -f environment.yaml

Would you please be more specific about where to find environment.yaml and what this command does? Also, should we do this in any specific conda environment?

newptcai avatar May 18 '23 01:05 newptcai

Updating the env afterwards via: conda env update -f environment.yaml

Would you please be more specific about where to find environment.yaml and what this command does? Also, should we do this in any specific conda environment?

the environment.yaml is in stable-diffusion-main and it is used to set up the environment that is then used to execute the program. you can use conda env create -f environment.yaml to create the virtual environment based on the configurations. the environment is then called ldm

flowerboyworld avatar May 21 '23 10:05 flowerboyworld

diffusers 0.15.0 transformers 4.28.1 Python 3.8.5 (default, Sep 4 2020, 07:30:14) [GCC 7.3.0] :: Anaconda, Inc. on linux torch 1.11.0

it worked on my case.

Guanbin-Huang avatar May 24 '23 15:05 Guanbin-Huang

changing the diffusers version to diffusers==0.12.1 and reinstall works. Looks like the solution is just to specify the version diffusers==0.12.1 in environments.yaml.

xunsheng avatar Jun 25 '23 10:06 xunsheng

Try this answer: https://www.reddit.com/r/StableDiffusion/comments/115fmc9/cannot_import_name_safe_weights_name_from/

Edit environments.yaml, "diffusers" --> "diffusers==0.12.1"

it gives CondaEnvException: Pip failed error...

berk-efe avatar Jul 05 '23 08:07 berk-efe

Im encountering this same error but I am struggling to find a "tutorial" of what to do. For those of us that are not as technical, where are you typing the "pip install diffusers==0.12.1" because when I try to in my command, it just closes after 3 presses.

fulcrumrebel avatar Jul 23 '23 02:07 fulcrumrebel

pip install -U accelerate

LT1st avatar Oct 20 '23 03:10 LT1st