Stability-AI / StableCascade

Official Code for Stable Cascade
MIT License
6.44k stars 518 forks source link

RuntimeError during Model State Dictionary Loading in text to image.ipynb #44

Open jlmaoju opened 4 months ago

jlmaoju commented 4 months ago

I encountered a RuntimeError while trying to run the code within text to image.ipynb, indicating an issue with loading the model's state dictionary. The error reports missing keys and also mentions the presence of unexpected keys.

Upon attempting to load the model's state dictionary, a RuntimeError is thrown, indicating several missing keys as well as unexpected keys in the state dictionary. The error message is as follows:

RuntimeError: Error(s) in loading state_dict for StageA: Missing key(s) in state_dict: ... Unexpected key(s) in state_dict: ...

I am seeking assistance to resolve the RuntimeError encountered while loading the model's state dictionary. Any suggestions on how to address the missing keys and handle the unexpected keys would be greatly appreciated.

Below is the full content in the powershell

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'] Loading checkpoint shards: 0%| | 0/2 [00:00<?, ?it/s]C:\Users\YQBen\anaconda3\envs\SC\lib\site-packages\torch\_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() return self.fget.__get__(instance, owner)() Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:01<00:00, 1.49it/s] ['tokenizer', 'text_model', 'generator', 'effnet', 'previewer'] STAGE C READY ['transforms', 'clip_preprocess', 'gdf', 'sampling_configs', 'effnet_preprocess'] Traceback (most recent call last): File "g:\rise\ai\StableCascade\StableCascade\test.py", line 38, in <module> models_b = core_b.setup_models(extras_b, skip_clip=True) File "g:\rise\ai\StableCascade\StableCascade\train\train_b.py", line 150, in setup_models stage_a.load_state_dict(stage_a_checkpoint if 'state_dict' not in stage_a_checkpoint else stage_a_checkpoint['state_dict']) File "C:\Users\YQBen\anaconda3\envs\SC\lib\site-packages\torch\nn\modules\module.py", line 2152, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for StageA: Missing key(s) in state_dict: "in_block.1.weight", "in_block.1.bias", "down_blocks.0.gammas", "down_blocks.0.depthwise.1.weight", "down_blocks.0.depthwise.1.bias", "down_blocks.0.channelwise.0.weight", "down_blocks.0.channelwise.0.bias", "down_blocks.0.channelwise.2.weight", "down_blocks.0.channelwise.2.bias", "down_blocks.1.weight", "down_blocks.1.bias", "down_blocks.2.gammas", "down_blocks.2.depthwise.1.weight", "down_blocks.2.depthwise.1.bias", "down_blocks.2.channelwise.0.weight", "down_blocks.2.channelwise.0.bias", "down_blocks.2.channelwise.2.weight", "down_blocks.2.channelwise.2.bias", "down_blocks.3.0.weight", "down_blocks.3.1.weight", "down_blocks.3.1.bias", "down_blocks.3.1.running_mean", "down_blocks.3.1.running_var", "vquantizer.codebook.weight", "up_blocks.0.0.weight", "up_blocks.0.0.bias", "up_blocks.1.gammas", "up_blocks.1.depthwise.1.weight", "up_blocks.1.depthwise.1.bias", "up_blocks.1.channelwise.0.weight", "up_blocks.1.channelwise.0.bias", "up_blocks.1.channelwise.2.weight", "up_blocks.1.channelwise.2.bias", "up_blocks.2.gammas", "up_blocks.2.depthwise.1.weight", "up_blocks.2.depthwise.1.bias", "up_blocks.2.channelwise.0.weight", "up_blocks.2.channelwise.0.bias", "up_blocks.2.channelwise.2.weight", "up_blocks.2.channelwise.2.bias", "up_blocks.3.gammas", "up_blocks.3.depthwise.1.weight", "up_blocks.3.depthwise.1.bias", "up_blocks.3.channelwise.0.weight", "up_blocks.3.channelwise.0.bias", "up_blocks.3.channelwise.2.weight", "up_blocks.3.channelwise.2.bias", "up_blocks.4.gammas", "up_blocks.4.depthwise.1.weight", "up_blocks.4.depthwise.1.bias", "up_blocks.4.channelwise.0.weight", "up_blocks.4.channelwise.0.bias", "up_blocks.4.channelwise.2.weight", "up_blocks.4.channelwise.2.bias", "up_blocks.5.gammas", "up_blocks.5.depthwise.1.weight", "up_blocks.5.depthwise.1.bias", "up_blocks.5.channelwise.0.weight", "up_blocks.5.channelwise.0.bias", "up_blocks.5.channelwise.2.weight", "up_blocks.5.channelwise.2.bias", "up_blocks.6.gammas", "up_blocks.6.depthwise.1.weight", "up_blocks.6.depthwise.1.bias", "up_blocks.6.channelwise.0.weight", "up_blocks.6.channelwise.0.bias", "up_blocks.6.channelwise.2.weight", "up_blocks.6.channelwise.2.bias", "up_blocks.7.gammas", "up_blocks.7.depthwise.1.weight", "up_blocks.7.depthwise.1.bias", "up_blocks.7.channelwise.0.weight", "up_blocks.7.channelwise.0.bias", "up_blocks.7.channelwise.2.weight", "up_blocks.7.channelwise.2.bias", "up_blocks.8.gammas", "up_blocks.8.depthwise.1.weight", "up_blocks.8.depthwise.1.bias", "up_blocks.8.channelwise.0.weight", "up_blocks.8.channelwise.0.bias", "up_blocks.8.channelwise.2.weight", "up_blocks.8.channelwise.2.bias", "up_blocks.9.gammas", "up_blocks.9.depthwise.1.weight", "up_blocks.9.depthwise.1.bias", "up_blocks.9.channelwise.0.weight", "up_blocks.9.channelwise.0.bias", "up_blocks.9.channelwise.2.weight", "up_blocks.9.channelwise.2.bias", "up_blocks.10.gammas", "up_blocks.10.depthwise.1.weight", "up_blocks.10.depthwise.1.bias", "up_blocks.10.channelwise.0.weight", "up_blocks.10.channelwise.0.bias", "up_blocks.10.channelwise.2.weight", "up_blocks.10.channelwise.2.bias", "up_blocks.11.gammas", "up_blocks.11.depthwise.1.weight", "up_blocks.11.depthwise.1.bias", "up_blocks.11.channelwise.0.weight", "up_blocks.11.channelwise.0.bias", "up_blocks.11.channelwise.2.weight", "up_blocks.11.channelwise.2.bias", "up_blocks.12.gammas", "up_blocks.12.depthwise.1.weight", "up_blocks.12.depthwise.1.bias", "up_blocks.12.channelwise.0.weight", "up_blocks.12.channelwise.0.bias", "up_blocks.12.channelwise.2.weight", "up_blocks.12.channelwise.2.bias", "up_blocks.13.weight", "up_blocks.13.bias", "up_blocks.14.gammas", "up_blocks.14.depthwise.1.weight", "up_blocks.14.depthwise.1.bias", "up_blocks.14.channelwise.0.weight", "up_blocks.14.channelwise.0.bias", "up_blocks.14.channelwise.2.weight", "up_blocks.14.channelwise.2.bias", "out_block.0.weight", "out_block.0.bias". Unexpected key(s) in state_dict: "blocks.0.bias", "blocks.0.weight", "blocks.11.bias", "blocks.11.num_batches_tracked", "blocks.11.running_mean", "blocks.11.running_var", "blocks.11.weight", "blocks.12.bias", "blocks.12.weight", "blocks.14.bias", "blocks.14.num_batches_tracked", "blocks.14.running_mean", "blocks.14.running_var", "blocks.14.weight", "blocks.15.bias", "blocks.15.weight", "blocks.17.bias", "blocks.17.num_batches_tracked", "blocks.17.running_mean", "blocks.17.running_var", "blocks.17.weight", "blocks.18.bias", "blocks.18.weight", "blocks.2.bias", "blocks.2.num_batches_tracked", "blocks.2.running_mean", "blocks.2.running_var", "blocks.2.weight", "blocks.20.bias", "blocks.20.num_batches_tracked", "blocks.20.running_mean", "blocks.20.running_var", "blocks.20.weight", "blocks.21.bias", "blocks.21.weight", "blocks.23.bias", "blocks.23.num_batches_tracked", "blocks.23.running_mean", "blocks.23.running_var", "blocks.23.weight", "blocks.24.bias", "blocks.24.weight", "blocks.3.bias", "blocks.3.weight", "blocks.5.bias", "blocks.5.num_batches_tracked", "blocks.5.running_mean", "blocks.5.running_var", "blocks.5.weight", "blocks.6.bias", "blocks.6.weight", "blocks.8.bias", "blocks.8.num_batches_tracked", "blocks.8.running_mean", "blocks.8.running_var", "blocks.8.weight", "blocks.9.bias", "blocks.9.weight".