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

Bug in pipeline_utils.py with different Python versions #10763

Closed
rebel-kblee opened this issue Feb 11, 2025 · 4 comments
Closed

Bug in pipeline_utils.py with different Python versions #10763

rebel-kblee opened this issue Feb 11, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@rebel-kblee
Copy link
Contributor

rebel-kblee commented Feb 11, 2025

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 names
        if '__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

@rebel-kblee
Copy link
Contributor Author

rebel-kblee commented Feb 11, 2025

I think it's a wrong reproduce example, so I'll check again and reopen issue

@rebel-kblee
Copy link
Contributor Author

I fix the reproduce example, so i'll reopen this issue

@hlky
Copy link
Collaborator

hlky commented Feb 12, 2025

Thanks @rebel-kblee. This wasn't caught as it's an unusual case, we don't typically save a pipeline with a controlnet then want to use a different controlnet, we'd just the same pipeline with from_pretrained and pass a different controlnet. The fix may be duplicate of work done in #10758 can you test that?

@rebel-kblee
Copy link
Contributor Author

Thanks @rebel-kblee. This wasn't caught as it's an unusual case, we don't typically save a pipeline with a controlnet then want to use a different controlnet, we'd just the same pipeline with from_pretrained and pass a different controlnet. The fix may be duplicate of work done in #10758 can you test that?

Good. It works well. Thanks. @hlky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants