This is a int8-wo pre-quantized version of Qwen-Image-Edit.
It needs at least 24GB VRAM GPU to run efficiently.
How to use
Install the latest version of diffusers, transformers, torchvision, torchao and accelerate:
pip install -U diffusers transformers torchvision torchao accelerate
The following contains a code snippet illustrating how to use the model to generate images based on image and text prompts:
import torch
from diffusers import AutoModel, DiffusionPipeline
from diffusers.utils import load_image
torch_dtype = torch.bfloat16
device = "cuda"
transformer = AutoModel.from_pretrained(
"dimitribarbot/Qwen-Image-Edit-int8wo",
torch_dtype=torch_dtype,
use_safetensors=False
)
pipe = DiffusionPipeline.from_pretrained(
"Qwen/Qwen-Image-Edit",
transformer=transformer,
torch_dtype=torch_dtype
)
pipe.enable_model_cpu_offload()
pipe.enable_vae_tiling()
prompt = "change the dog plushie for a cat preserving the background, the lighting, colors, shadows, also the cat plushie should have the same style of the dog plushie with the same eyes and lines."
generator = torch.Generator(device=device).manual_seed(42)
ref_image = load_image("https://huggingface.co/datasets/OzzyGT/testing-resources/resolve/main/resources/dog_plushie.png").convert("RGB")
image = pipe(
image=ref_image,
prompt=prompt,
num_inference_steps=25,
true_cfg_scale=4.0,
generator=generator
).images[0]
image.save("qwen_image_edit_torchao.png")
Credits
- OzzyGT for the code snippet here: https://huggingface.co/Qwen/Qwen-Image/discussions/27
- The Qwen-Image-Edit team
- The HuggingFace team
- Downloads last month
- 136
Model tree for dimitribarbot/Qwen-Image-Edit-int8wo
Base model
Qwen/Qwen-Image-Edit