Summary
I am encountering an ImportError
when running StableDiffusionImg2ImgPipeline
in diffusers
. The error states that computed_field
cannot be imported from pydantic
, even though I am using version 2.10.6.
Error Message
ImportError: cannot import name ‘computed_field’ from ‘pydantic’ (/usr/local/lib/python3.11/dist-packages/pydantic/init.cpython-311-x86_64-linux-gnu.so)
Steps I Have Tried
- Checked
pydantic
versionpip show pydantic
returnsVersion: 2.10.6
- Upgraded
pydantic
anddiffusers
pip install --upgrade pydantic diffusers
- Uninstalled and reinstalled
pydantic
pip uninstall pydantic && pip install pydantic
- Restarted runtime (Google Colab)
- Checked Python environment dependencies
pip list | grep pydantic
shows onlypydantic 2.10.6
installed.
Code Example
from diffusers import StableDiffusionImg2ImgPipeline
from pydantic import computed_field # <- This causes ImportError
pipe = StableDiffusionImg2ImgPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
pipe = pipe.to("cuda")
Environment Details
Python: 3.11
Diffusers: latest (installed via pip)
Pydantic: 2.10.6
Running on: Google Colab
Questions
Why does computed_field not exist even though I am using pydantic 2.10.6?
Is there any workaround for this issue?
Is this a known bug in diffusers or pydantic?
Any insights would be greatly appreciated. Thanks in advance!