Text-to-Image
Diffusers
Safetensors
QwenImagePipeline
nvidia
ModelOpt
Qwen-Image
quantized
FP4
fp4
8-bit precision
Instructions to use nvidia/Qwen-Image-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use nvidia/Qwen-Image-NVFP4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("nvidia/Qwen-Image-NVFP4", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Download serving/generate_sample.py from nvidia/Qwen-Image-NVFP4: direct link, hf CLI and curl.
- Browser
- Download file 777 Bytes
-
https://huggingface.co/nvidia/Qwen-Image-NVFP4/resolve/main/serving/generate_sample.py
- Command line
-
hf download hf://nvidia/Qwen-Image-NVFP4/serving/generate_sample.py
-
curl -L -o generate_sample.py https://huggingface.co/nvidia/Qwen-Image-NVFP4/resolve/main/serving/generate_sample.py
777 Bytes
| import base64, json, urllib.request | |
| payload = { | |
| "model": "/model", | |
| "prompt": "A realistic photograph of a red ceramic teapot on a wooden table beside a window, soft morning light, detailed wood grain.", | |
| "negative_prompt": " ", "size": "512x512", | |
| "num_inference_steps": 50, "guidance_scale": 4.0, "seed": 42, | |
| "response_format": "b64_json", "format": "png", | |
| } | |
| request = urllib.request.Request( | |
| "http://127.0.0.1:8000/v1/images/generations", | |
| data=json.dumps(payload).encode(), headers={"Content-Type": "application/json"}) | |
| with urllib.request.urlopen(request, timeout=600) as response: | |
| result = json.load(response) | |
| with open("sample.png", "wb") as output: | |
| output.write(base64.b64decode(result["data"][0]["b64_json"])) | |
| print("Saved sample.png") | |