StableCascade icon indicating copy to clipboard operation
StableCascade copied to clipboard

In text_to_image.ipynb: 'NoneType' object has no attribute 'items'

Open throttlekitty opened this issue 1 year ago • 3 comments

Win11 in jupyter notebook, I'm using the python packages as installed from requirements.txt I have no errors in the prior cells, but get this in the Load Extras & Models cell.

AttributeError                            Traceback (most recent call last)
Cell In[4], line 3
      1 # SETUP MODELS & DATA
      2 extras = core.setup_extras_pre()
----> 3 models = core.setup_models(extras)
      4 models.generator.eval().requires_grad_(False)
      5 print("STAGE C READY")

File h:\ai\stablecascade\train\train_c.py:163, in WurstCore.setup_models(self, extras)
    161         generator.load_state_dict(load_or_fail(self.config.generator_checkpoint_path))
    162     else:
--> 163         for param_name, param in load_or_fail(self.config.generator_checkpoint_path).items():
    164             set_module_tensor_to_device(generator, param_name, "cpu", value=param)
    165 generator = generator.to(dtype).to(self.device)

AttributeError: 'NoneType' object has no attribute 'items'

throttlekitty avatar Feb 13 '24 20:02 throttlekitty

The notebook uses configs/stage_c_3b.yaml, which wants to use the bf16 version of the model, same for the Stage B config. I had already manually downloaded the full versions, so it was trying to load a nonexistent stage_c_bf16.safetensors.

I modified both configs to point to stage_b.safetensors and stage_c.safetensors, and setting their dtype to float32. But now the notebook file is trying to download a 9.99gb "pytorch_model-00001-of-00002.bin" instead. So I downloaded the bf16 safetensors files, restored the configs, using StableCascade/models and still get the same behavior where it wants to download some extras.

Should the model files be placed somewhere else?

throttlekitty avatar Feb 13 '24 21:02 throttlekitty

Your first error comes from not having the model paths set in the config file. And the downloading behavior in the second comment is not any of our models. Its the CLIP models that are downloaded. So thats all fine

dome272 avatar Feb 13 '24 21:02 dome272

The config file in stage_c_3b.yaml is already set to generator_checkpoint_path: models/stage_c_bf16.safetensors This is where I have the models located. H:\ai\StableCascade\models\

Good to know about the CLIP models, thanks. I did let it download using the default config for the bf16 models and configs for both B and C, but I have a new error now:

Cell In[3], line 12
      8 models_b = core_b.setup_models(extras_b, skip_clip=True)
      9 models_b = WurstCoreB.Models(
     10    **{**models_b.to_dict(), 'tokenizer': models.tokenizer, 'text_model': models.text_model}
     11 )
---> 12 models_b.generator.float32().eval().requires_grad_(False)
     13 print("STAGE B READY")

File H:\AI\genv\lib\site-packages\torch\nn\modules\module.py:1695, in Module.__getattr__(self, name)
   1693     if name in modules:
   1694         return modules[name]
-> 1695 raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")

AttributeError: 'StageB' object has no attribute 'float32'

edit: user error. I forgot to revert the notebook change to bfloat16. All is well now for running bf16 models, but I would like to know how to properly load the full models as well.

throttlekitty avatar Feb 13 '24 21:02 throttlekitty

where modified the clip model to local path?

zengjie617789 avatar Feb 21 '24 02:02 zengjie617789