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

Inference not working #45

Open
peter-ch opened this issue Feb 15, 2024 · 3 comments
Open

Inference not working #45

peter-ch opened this issue Feb 15, 2024 · 3 comments

Comments

@peter-ch
Copy link

I installed the diffusers package as specified on the HF page, and I use this code for simple inference:

import os
import sys
import torch
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline

torch.cuda.device_count()
device = 'cpu'
num_images_per_prompt = 2

prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16).to(device)
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade",  torch_dtype=torch.float16).to(device)

It's the same exact code as in the HF page. It breaks with this error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[5], [line 4](vscode-notebook-cell:?execution_count=5&line=4)
      [1](vscode-notebook-cell:?execution_count=5&line=1) prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16, 
      [2](vscode-notebook-cell:?execution_count=5&line=2)                                                    low_cpu_mem_usage=False, ignore_mismatched_sizes=True
      [3](vscode-notebook-cell:?execution_count=5&line=3)                                                    ).to(device)
----> [4](vscode-notebook-cell:?execution_count=5&line=4) decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade",  torch_dtype=torch.float16, 
      [5](vscode-notebook-cell:?execution_count=5&line=5)                                                        low_cpu_mem_usage=False, ignore_mismatched_sizes=True
      [6](vscode-notebook-cell:?execution_count=5&line=6)                                                        ).to(device)

File [c:\Python310\lib\site-packages\huggingface_hub\utils\_validators.py:118](file:///C:/Python310/lib/site-packages/huggingface_hub/utils/_validators.py:118), in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
    [115](file:///C:/Python310/lib/site-packages/huggingface_hub/utils/_validators.py:115) if check_use_auth_token:
    [116](file:///C:/Python310/lib/site-packages/huggingface_hub/utils/_validators.py:116)     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> [118](file:///C:/Python310/lib/site-packages/huggingface_hub/utils/_validators.py:118) return fn(*args, **kwargs)

File [c:\Python310\lib\site-packages\diffusers\pipelines\pipeline_utils.py:1263](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1263), in DiffusionPipeline.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
   [1260](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1260)     loaded_sub_model = passed_class_obj[name]
   [1261](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1261) else:
   [1262](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1262)     # load sub model
-> [1263](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1263)     loaded_sub_model = load_sub_model(
   [1264](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1264)         library_name=library_name,
   [1265](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1265)         class_name=class_name,
   [1266](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1266)         importable_classes=importable_classes,
   [1267](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1267)         pipelines=pipelines,
   [1268](file:///C:/Python310/lib/site-packages/diffusers/pipelines/pipeline_utils.py:1268)         is_pipeline_module=is_pipeline_module,
...
    [846](file:///C:/Python310/lib/site-packages/diffusers/models/modeling_utils.py:846)     )

RuntimeError: Error(s) in loading state_dict for StableCascadeUnet:
	size mismatch for embedding.1.weight: copying a param with shape torch.Size([320, 16, 1, 1]) from checkpoint, the shape in current model is torch.Size([320, 64, 1, 1]).
	You may consider adding `ignore_mismatched_sizes=True` in the model `from_pretrained` method.

Nothing helps including the suggestions in the error message.

@pabloppp
Copy link
Contributor

The diffusers branch is currently broken, will be fixed very soon, meanwhile you can install it from an older commit:

pip3 install git+https://github.com/kashif/diffusers.git@a3dc21385b7386beb3dab3a9845962ede6765887

@hos3inoo
Copy link

wait

@FurkanGozukara
Copy link

ye it is hard to make it work

here our developed app check this out : #125

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

4 participants