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
25.09k stars 5.18k forks source link

'BitDiffusion' object has no attribute 'scheduler' #9111

Open BioGeek opened 1 month ago

BioGeek commented 1 month ago

Describe the bug

Running the Bit Diffusion example code from the Community Pipeline Examples fails

Reproduction

from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained("google/ddpm-cifar10-32", custom_pipeline="bit_diffusion")
image = pipe().images[0]

Logs

AttributeError                            Traceback (most recent call last)
<ipython-input-2-3d32a9d66392> in <cell line: 2>()
      1 from diffusers import DiffusionPipeline
----> 2 pipe = DiffusionPipeline.from_pretrained("google/ddpm-cifar10-32", custom_pipeline="bit_diffusion")
      3 image = pipe().images[0]

/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py in _inner_fn(*args, **kwargs)
    112             kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
    113 
--> 114         return fn(*args, **kwargs)
    115 
    116     return _inner_fn  # type: ignore

/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/pipeline_utils.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    964 
    965         # 10. Instantiate the pipeline
--> 966         model = pipeline_class(**init_kwargs)
    967 
    968         # 11. Save where the model was instantiated from

~/.cache/huggingface/modules/diffusers_modules/git/bit_diffusion.py in __init__(self, unet, scheduler, bit_scale)
    220         super().__init__()
    221         self.bit_scale = bit_scale
--> 222         self.scheduler.step = (
    223             ddim_bit_scheduler_step if isinstance(scheduler, DDIMScheduler) else ddpm_bit_scheduler_step
    224         )

/usr/local/lib/python3.10/dist-packages/diffusers/configuration_utils.py in __getattr__(self, name)
    141             return self._internal_dict[name]
    142 
--> 143         raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
    144 
    145     def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool = False, **kwargs):

AttributeError: 'BitDiffusion' object has no attribute 'scheduler'

System Info

Who can help?

@patrickvonplaten (https://github.com/huggingface/diffusers/commit/78a6eed2d7b082d8116c23061b57621cf909320f) @kingstut (https://github.com/huggingface/diffusers/pull/971)

a-r-r-o-w commented 1 month ago

I believe this pipeline may have been incorrectly written and isn't well tested because community pipelines are maintained by the community members and don't necessarily see any high priority involvement from us.

I think the fix here would be to move the call to self.register_modules above self.scheduler.step = ..., but not sure and don't have the bandwidth to test and fix. If this helps or if you know of a way fix this, feel free to PR :)

https://github.com/huggingface/diffusers/blob/8e3affc6690d30a3adbb3bbe0869171ea863ccef/examples/community/bit_diffusion.py#L226