TypeError: argument of type 'NoneType' is not iterable
Same error as https://github.com/Stability-AI/StableCascade/issues/6 but different code location.
I setup a new environment as per requirements.txt, downloaded all the models into models (11 files 38.6 GB). Ran a local script using the same code as in text_to_image.ipynb. Gives this error.
cuda:0
['model_version', 'effnet_checkpoint_path', 'previewer_checkpoint_path']
['model_version', 'stage_a_checkpoint_path', 'effnet_checkpoint_path']
['transforms', 'clip_preprocess', 'gdf', 'sampling_configs', 'effnet_preprocess']
Traceback (most recent call last):
File "D:\Tests\StableCascade\stablecascade.py", line 38, in <module>
models = core.setup_models(extras)
File "D:\Tests\StableCascade\train\train_c.py", line 128, in setup_models
effnet.load_state_dict(effnet_checkpoint if 'state_dict' not in effnet_checkpoint else effnet_checkpoint['state_dict'])
TypeError: argument of type 'NoneType' is not iterable
Any ideas? Thanks.
I can run the more basic script/code from https://huggingface.co/stabilityai/stable-cascade but not the code from the text_to_image.ipynb
OK, I worked this one out. (I am running this under Windows if that matters.)
It seems as if the paths to the models in the config file must be a full path and not a relative path.
This fails effnet_checkpoint_path: models/effnet_encoder.safetensors
This works effnet_checkpoint_path: D:\Tests\StableCascade\models/effnet_encoder.safetensors
Maybe that can help other Windows users.
A quick edit to this. It WILL use relative paths. The problem I had was due to there being os.chdir('..') near the start of the code that threw everything out. If you use the code from the notebook, get rid of that and the rest is fine.
OK, I worked this one out. (I am running this under Windows if that matters.)
It seems as if the paths to the models in the config file must be a full path and not a relative path. This fails
effnet_checkpoint_path: models/effnet_encoder.safetensorsThis workseffnet_checkpoint_path: D:\Tests\StableCascade\models/effnet_encoder.safetensorsMaybe that can help other Windows users.
A quick edit to this. It WILL use relative paths. The problem I had was due to there being
os.chdir('..')near the start of the code that threw everything out. If you use the code from the notebook, get rid of that and the rest is fine.
so, where is the config file? thank you!
so, where is the config file? thank you!
Under configs\inference by default. The path is specified in the example notebook.
But, as long as you remove the os.chgdir call in the script you do not need to edit the configs.
so, where is the config file? thank you!
Under
configs\inferenceby default. The path is specified in the example notebook. But, as long as you remove theos.chgdircall in the script you do not need to edit the configs.
OK, I'll try it again, thank you very much!
For anyone else who runs into this error, i found that the actual fix was to download the models using the script in models/ here: https://github.com/Stability-AI/StableCascade/tree/master/models
After doing this, the example script worked fine
For anyone else who runs into this error, i found that the actual fix was to download the models using the script in
models/here: https://github.com/Stability-AI/StableCascade/tree/master/modelsAfter doing this, the example script worked fine
Downloading the models is not the "actual fix". I had downloaded the models. The os.chgdir in the notebook code was the problem as it went "up" a directory level so when it went to find the models (that did exist) it was in the wrong directory. But yes, you do neeed to download the models first if you have not.
I also have this issue, I got the models via the script, but it doesn't seem to be working in the notebook, the pwd returns the root dir. Running on an EC2.
Fixing the working directory did not fix the issue for me (on Windows). I had to run model download script in models (I used WSL as it's a bash script).
The os.chdir('..') attempts to put the notebook kernel into the root of the project, but if you run the cell multiple times then it will keep going up the directory tree. You can replace that line with this:
if 'notebook_path' not in locals():
notebook_path = os.path.abspath("")
os.chdir(f'{notebook_path}/..')
This will get the current working directory just the first time the notebook is run, and reuse that directory if it is rerun.