Instructions to use Qwen/Qwen-Image-Edit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Qwen/Qwen-Image-Edit with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image-Edit", torch_dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Inference
- Notebooks
- Google Colab
- Kaggle
I installed the latest transformers, but still keep getting this error. What should I do?
Traceback (most recent call last):
File "E:\Qwen-image\pythonProject\run.py", line 9, in
from diffusers import QwenImageEditPipeline
File "", line 1075, in _handle_fromlist
File "E:\Qwen-image\pythonProject.venv\lib\site-packages\diffusers\utils\import_utils.py", line 965, in getattr
value = getattr(module, name)
File "E:\Qwen-image\pythonProject.venv\lib\site-packages\diffusers\utils\import_utils.py", line 965, in getattr
value = getattr(module, name)
File "E:\Qwen-image\pythonProject.venv\lib\site-packages\diffusers\utils\import_utils.py", line 964, in getattr
module = self._get_module(self._class_to_module[name])
File "E:\Qwen-image\pythonProject.venv\lib\site-packages\diffusers\utils\import_utils.py", line 976, in get_module
raise RuntimeError(
RuntimeError: Failed to import diffusers.pipelines.qwenimage.pipeline_qwenimage_edit because of the following error (look up to see its traceback):
cannot import name 'Qwen2_5_VLForConditionalGeneration' from 'transformers' (E:\Qwen-image\pythonProject.venv\lib\site-packages\transformers_init.py)
I installed the latest transformers, but still keep getting this error. What should I do?