Skip to content

Bug in pipeline_utils.py with different Python versions #10763

Description

@rebel-kblee

Describe the bug

In Python versions less than 3.10, the default python typing package does not have the name attribute for formats like List and Tuple. As a result, an issue occurs in diffusers versions (>=0.32.2).

One way to solve this issue like #10762

Reproduction

from diffusers import ControlNetModel, StableDiffusionControlNetPipeline
controlnet = ControlNetModel.from_pretrained("hf-internal-testing/tiny-controlnet")
pipe = StableDiffusionControlNetPipeline.from_pretrained("hf-internal-testing/tiny-stable-diffusion-torch", controlnet=controlnet)
pipe.save_pretrained("sd_controlnet")
pipe = StableDiffusionControlNetPipeline.from_pretrained("sd_controlnet", controlnet=controlnet)

Logs

.venv/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py:114: in _inner_fn
return fn(*args, **kwargs)
.venv/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:850: in from_pretrained
_expected_class_types.append(expected_type.__name__)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = typing.List[diffusers.models.controlnets.controlnet.ControlNetModel]
attr = '__name__'
def __getattr__(self, attr):
# We are careful for copy and pickle.# Also for simplicity we don't relay any dunder namesif'__origin__'in self.__dict__ and not _is_dunder(attr):
return getattr(self.__origin__, attr)
> raise AttributeError(attr)
E AttributeError: __name__

System Info

diffusers (0.32.2)
python (<3.10)

Who can help?

@sayakpaul@DN6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions