QWEN-IMAGE Model |nf4|+Abliterated Qwen2.5VL-7b
This repo contains a variant of QWEN's
QWEN-IMAGE, the state-of-the-art generative model with extensive and (image/)text-to-image &/or instruction/control-editing capabilities.
To make these cutting edge capabilities more accessible to those constrained to low-end consumer-grade hardware, we've quantized the DiT (Diffusion Transformer) component of Qwen-Image to the 4-bit NF4 format using the Bits&Bytes toolkit.
This optimization was derived by us directly from the BF16 base model weights released on 08/04/2025, with no other mix-ins or modifications to the DiT component.
NOTE: Install bitsandbytes prior to inference.
QWEN-IMAGE is an open-weights customization-friendly frontier model released under the highly permissive Apache 2.0 license, welcoming unrestricted (within legal limits) commercial, experimental, artistic, academic, and other uses &/or modifications.
To help highlight horizons of possibility broadened by the
QWEN-IMAGE release, our quantization is bundled with an "Abliterated" (aka de-censored) finetune of
Qwen2.5-VL 7B Instruct, QWEN-IMAGE model's sole conditioning encoder (of prompts, instructions, input images, controls, etc), as well as a powerful Vision-Language-Model in its own right.
As such, our repo saddles a lean & prim NF4 DiT over the
Qwen2.5-VL-7B-Abliterated-Caption-it by
Prithiv Sakthi (aka
prithivMLmods).
NOTICE:
Do not be alarmed by the file warning from the ClamAV automated checker.
It is a clear false positive. In assessing one of the typical Diffusers-adapted Safetensors shards (model weights), the checker reads:
The following viruses have been found: Pickle.Malware.SysAccess.sys.STACK_GLOBAL.UNOFFICIAL
However, a Safetensors by its sheer design can not contain suchlike inserts. You may confirm for yourself thru HF's built-in weight/index viewer.
So, to be sure, this repo does not contain any pickle checkpoints, or any other pickled data.
TEXT-TO-IMAGE PIPELINE EXAMPLE:
This repo is formatted for usage with Diffusers (0.35.0.dev0+) & Transformers libraries, vis-a-vis associated pipelines & model component classes, such as the defaults listed in
model_index.json (in this repo's root folder).
Sourced/adapted from the original base model repo by QWEN.
EDIT:
We've confronted some issues with using the below pipeline. Will update once reliable adjustments are confirmed.
1from diffusers import DiffusionPipeline
2import torch
3import bitsandbytes
4model_name = "AlekseyCalvin/QwenImage_nf4"
5# Load the pipeline
6if torch.cuda.is_available():
7 torch_dtype = torch.bfloat16
8 device = "cuda"
9else:
10 torch_dtype = torch.float32
11 device = "cpu"
12pipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)
13pipe = pipe.to(device)
14positive_magic = [
15 "en": "Ultra HD, 4K, cinematic composition." # for english prompt,
16 "zh": "超清,4K,电影级构图" # for chinese prompt,
17]
18# Generate image
19prompt = '''A coffee shop entrance features a chalkboard sign reading "Qwen Coffee 😊 $2 per cup," with a neon light beside it displaying "通义千问". Next to it hangs a poster showing a beautiful Chinese woman, and beneath the poster is written "π≈3.1415926-53589793-23846264-33832795-02384197". Ultra HD, 4K, cinematic composition'''
20negative_prompt = " "
21# Generate with different aspect ratios
22aspect_ratios = {
23 "1:1": (1328, 1328),
24 "16:9": (1664, 928),
25 "9:16": (928, 1664),
26 "4:3": (1472, 1140),
27 "3:4": (1140, 1472)
28}
29width, height = aspect_ratios["16:9"]
30image = pipe(
31 prompt=prompt + positive_magic["en"],
32 negative_prompt=negative_prompt,
33 width=width,
34 height=height,
35 num_inference_steps=50,
36 true_cfg_scale=4.0,
37 generator=torch.Generator(device="cuda").manual_seed(42)
38).images[0]
39image.save("example.png")
SHOWCASES FROM THE QWEN TEAM:
MORE INFO:
- Check out the Technical Report for QWEN-IMAGE, released by the Qwen team!
- Find source base model weights here at huggingface and at Modelscope.
QWEN LINKS:
QWEN-IMAGE TECHNICAL REPORT CITATION:
1@article{qwen-image,
2 title={Qwen-Image Technical Report},
3 author={Qwen Team},
4 journal={arXiv preprint},
5 year={2025}
6}