huggingface / diffusers

🤗 Diffusers: State-of-the-art diffusion models for image and audio generation in PyTorch and FLAX.
https://huggingface.co/docs/diffusers
Apache License 2.0
26.12k stars 5.38k forks source link

WuerstchenCombinedPipeline Import error in version 0.21.0 #5023

Closed rupeshs closed 1 year ago

rupeshs commented 1 year ago

Describe the bug

Failed to import import WuerstchenCombinedPipeline from diffusers.pipelines.wuerstchen, Tested on Google Colab

Reproduction

import torch from diffusers import AutoPipelineForText2Image

Logs

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/diffusers/utils/import_utils.py in _get_module(self, module_name)
    683         try:
--> 684             return importlib.import_module("." + module_name, self.__name__)
    685         except Exception as e:

12 frames
ImportError: cannot import name 'WuerstchenCombinedPipeline' from 'diffusers.pipelines.wuerstchen' (/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/wuerstchen/__init__.py)

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/diffusers/utils/import_utils.py in _get_module(self, module_name)
    684             return importlib.import_module("." + module_name, self.__name__)
    685         except Exception as e:
--> 686             raise RuntimeError(
    687                 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
    688                 f" traceback):\n{e}"

RuntimeError: Failed to import diffusers.pipelines.auto_pipeline because of the following error (look up to see its traceback):
cannot import name 'WuerstchenCombinedPipeline' from 'diffusers.pipelines.wuerstchen' (/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/wuerstchen/__init__.py)

System Info

Diffuser : v0.21.0 only Environment: Google Colab, Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] pytorch : 2.0.1+cu118

Who can help?

No response

jwooldridge234 commented 1 year ago

I'm also seeing this issue on my local machine (MPS).

DN6 commented 1 year ago

@rupeshs Thanks for flagging. Looks like an issue with AutoPipeline when transformers is not installed. Could you try pip install transformers in your notebook and then run your code again?

patrickvonplaten commented 1 year ago

This should be fixed here: #5036

@DN6 we cannot assume that transformers is installed (it's on optional dependency). If it's not installed we should raise a nice error message

rubensmau commented 1 year ago

The same problem happens to me, even after installing transformers

DN6 commented 1 year ago

@rubensmau we just did a patch release that should address the issue. Could you please upgrade your diffusers version and try running your code again?

rupeshs commented 1 year ago

Hi @patrickvonplaten @DN6 Thanks for the swift response! I just tried the latest patch version 0.21.1 The previous error is gone and now getting cannot import name 'DEFAULT_STAGE_C_TIMESTEPS' from 'diffusers.pipelines.wuerstchen' pip install transformers still required to resolve this error.

DN6 commented 1 year ago

@rupeshs Could you please share a code snippet causing the error? I'm running the following snippet and not seeing the error.

import torch
from diffusers import AutoPipelineForText2Image
zba commented 1 year ago

transformer

edit to "transformers" please. you will keep another 5mins who pass through this error

rupeshs commented 1 year ago

@DN6 Please check this colab https://colab.research.google.com/drive/1Brinkt40qpPn6RTrwSNxmU4yvni8tJsf?usp=sharing

DN6 commented 1 year ago

Hi @rupeshs for that specific example that you shared, you will need to install transformers. It is a required dependency for the Wuerstchen pipeline and it won't run without it.

As for this part

from diffusers.pipelines.wuerstchen import DEFAULT_STAGE_C_TIMESTEPS

I'll look into how we might be able to better enable accessing constants defined in pipelines with lazy import enabled.

rupeshs commented 1 year ago

Hi @DN6 , BTW I have integrated diffuser Würstchen workflow to DiffusionMagic https://github.com/rupeshs/diffusionmagic

zba commented 1 year ago

I solved by use diffusers from github, because embed was not fixed in 0.21.2

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.