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

Diffusers 0.26.3 #25

Closed
elismasilva opened this issue Feb 27, 2024 · 5 comments
Closed

Diffusers 0.26.3 #25

elismasilva opened this issue Feb 27, 2024 · 5 comments

Comments

@elismasilva
Copy link

Hi you need update pipeline XL to work with last version of Diffusers...

@horseee
Copy link
Owner

horseee commented Feb 27, 2024

Hi @elismasilva,

I tested DeepCache under diffusers==0.26.3 and it works well. Can you give me the code snippet that can reproduce the bug/error?

@elismasilva
Copy link
Author

elismasilva commented Feb 27, 2024

When i try import pipeline:

from DeepCache.sdxl.pipeline_stable_diffusion_xl import StableDiffusionXLPipeline as DeepCacheStableDiffusionXLPipeline

i got error:

Exception has occurred: ImportError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
cannot import name 'PositionNet' from 'diffusers.models.embeddings' (f:\Projetos\Fast\optimum\venv2\lib\site-packages\diffusers\models\embeddings.py)
  File "F:\Projetos\Fast\optimum\venv2\Lib\site-packages\DeepCache\sdxl\unet_2d_condition.py", line 32, in <module>
    from diffusers.models.embeddings import (
  File "F:\Projetos\Fast\optimum\venv2\Lib\site-packages\DeepCache\sdxl\pipeline_stable_diffusion_xl.py", line 48, in <module>
    from .unet_2d_condition import UNet2DConditionModel
  File "F:\Projetos\Fast\optimum\text-deep-cache.py", line 3, in <module>
    from DeepCache.sdxl.pipeline_stable_diffusion_xl import StableDiffusionXLPipeline as DeepCacheStableDiffusionXLPipeline
  File "C:\Users\pelol\.pyenv\pyenv-win\versions\3.10.11\Lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\pelol\.pyenv\pyenv-win\versions\3.10.11\Lib\runpy.py", line 196, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
ImportError: cannot import name 'PositionNet' from 'diffusers.models.embeddings' (f:\Projetos\Fast\optimum\venv2\lib\site-packages\diffusers\models\embeddings.py)

I tried to fix this by looking at the original pipeline, I managed to fix the PositionNet one but then more and more errors started appearing so I found that your pipeline is very different from the original, for example it is not prepared for batch process if I don't use the textencoder it It's a problem too. I managed to make it work just with DeepCacheSDHelper using the pipeline. By the way, does this class have the same result as the implemented pipeline?:

This is my code, the line that causes the problem is commented out:

import torch
from diffusers import StableDiffusionXLPipeline
#from DeepCache.sdxl.pipeline_stable_diffusion_xl import StableDiffusionXLPipeline as DeepCacheStableDiffusionXLPipeline
queue = []

queue.extend([{
  'prompt': '3/4 shot, candid photograph of a beautiful 30 year old redhead woman with messy dark hair, peacefully sleeping in her bed, night, dark, light from window, dark shadows, masterpiece, uhd, moody',
  'seed': 877866765,
}])

pipe = StableDiffusionXLPipeline.from_pretrained(
  'stabilityai/stable-diffusion-xl-base-1.0',
  use_safetensors=True,
  torch_dtype=torch.float16,
  variant='fp16',
).to('cuda')

generator = torch.Generator(device='cuda')

for i, generation in enumerate(queue, start=1):
  generator.manual_seed(generation['seed'])

  image = pipe(
    prompt=generation['prompt'],
    generator=generator    
  ).images[0]

  image.save(f'image_{i}.png')

@elismasilva
Copy link
Author

#23 Looking now at the history I suppose this is related, this pipeline is for 0.24 diffusers right?

@horseee
Copy link
Owner

horseee commented Feb 27, 2024

#23 Looking now at the history I suppose this is related, this pipeline is for 0.24 diffusers right?

Yes. If you want to use the code in DeepCache.sdxl.pipeline_stable_diffusion_xl, than Diffusers needs to be downgraded to 0.24(test passed under 0.21.3<diffusers<0.25.0).

And another way is to install the package DeepCache and follow the instruction to run the pipeline (or use DeepCache.extension.deepcache, the same). This implementation can support the latest versions of diffusers so far.

@elismasilva
Copy link
Author

Ok thank you! i hope you can fix cpu offload bug soon, but for while for 1 batch its ok.

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

2 participants