--- language: en library_name: mlx base_model_relation: quantized pipeline_tag: text-generation tags: - mlx - text-generation-inference - qwen3_5 - mlx-vlm - prompt-rewriter - prompt enhancer - apple-silicon - 4-bit - 8-bit license: other license_name: qwen-research license_link: https://huggingface.co/Qwen/Qwen-Image-2.1-PE-I2I/blob/main/LICENSE base_model: - Qwen/Qwen-Image-2.1-PE-T2I --- # **Qwen-Image-2.1-PE-T2I-MLX** > **Qwen-Image-2.1-PE-T2I** is the text-to-image prompt-rewriting model for Qwen-Image-2.1, a fine-tuned Qwen3.5-VL-9B that turns a brief image request in any language into a detailed, expanded English prompt paired with a recommended aspect ratio, acting as the bridge between casual multilingual user requests (e.g., a short Chinese phrase describing a corgi playing guitar in the rain) and the precise, richly-detailed instructions the downstream 7B-parameter DiT-based Qwen-Image-2.1 generator needs for best results. After a `` reasoning block, it outputs a structured JSON object containing the `rewritten_prompt` and a `wh_ratio` value (e.g., `16:9`), which maps directly to standard render resolutions when passed into the Diffusers `QwenImage21Pipeline`. It's usable via standard Hugging Face `AutoModelForCausalLM` loading, is intended purely as a preprocessing step ahead of image generation rather than a general-purpose chat model, and is released under the Qwen Research License Agreement. > [!NOTE] System Prompt — https://huggingface.co/Qwen/Qwen-Image-2.1-PE-T2I/blob/main/system_prompt.txt ```text prithivMLmods/Qwen-Image-2.1-PE-T2I-MLX (main) [~32.82 GB Total] ├── 4bit/ [~5.58 GB] │ ├── model shards: 2 safetensors (~5.56 GB) │ └── metadata & configs (~19.1 MB) │ ├── 8bit/ [~9.72 GB] │ ├── model shards: 2 safetensors (~9.70 GB) │ └── metadata & configs (~19.1 MB) │ └── [BF16 Base Files] [~17.52 GB] ├── model shards: 4 safetensors (~17.50 GB) └── metadata & configs (~19.1 MB) ``` ## Use with mlx Install the required library: ```bash pip install -U mlx-vlm ``` > **Task Note:** `Qwen-Image-2.1-PE-T2I` is a Text-to-Image prompt enhancer/rewriter (based on Qwen VL). It takes a short, simple user prompt (e.g., *"A cybernetic tiger in Tokyo"*) and outputs an expanded, high-detail English diffusion prompt along with the optimal aspect ratio (`wh_ratio`). ### BF16 Variant (Base Weights) The BF16 weights reside directly in the root repository path: #### CLI (Terminal) ```bash python -m mlx_vlm generate \ --model prithivMLmods/Qwen-Image-2.1-PE-T2I-MLX \ --max-tokens 512 \ --temperature 0.2 \ --prompt "A neon cybernetic samurai standing under rainy Tokyo streets, cinematic lighting" ``` #### Python API ```python from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config model_path = "prithivMLmods/Qwen-Image-2.1-PE-T2I-MLX" model, processor = load(model_path) config = load_config(model_path) prompt = "A neon cybernetic samurai standing under rainy Tokyo streets, cinematic lighting" formatted_prompt = apply_chat_template(processor, config, prompt) output = generate(model, processor, formatted_prompt, max_tokens=512, temperature=0.2) print(output.text) ``` ### 8-bit Variant Target the `8bit` subfolder: #### CLI (Terminal) ```bash python -m mlx_vlm generate \ --model prithivMLmods/Qwen-Image-2.1-PE-T2I-MLX/8bit \ --max-tokens 512 \ --temperature 0.2 \ --prompt "A neon cybernetic samurai standing under rainy Tokyo streets, cinematic lighting" ``` #### Python API ```python from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config model_path = "prithivMLmods/Qwen-Image-2.1-PE-T2I-MLX" model, processor = load(model_path, subfolder="8bit") config = load_config(model_path, subfolder="8bit") prompt = "A neon cybernetic samurai standing under rainy Tokyo streets, cinematic lighting" formatted_prompt = apply_chat_template(processor, config, prompt) output = generate(model, processor, formatted_prompt, max_tokens=512, temperature=0.2) print(output.text) ``` ### 4-bit Variant Target the `4bit` subfolder: #### CLI (Terminal) ```bash python -m mlx_vlm generate \ --model prithivMLmods/Qwen-Image-2.1-PE-T2I-MLX/4bit \ --max-tokens 512 \ --temperature 0.2 \ --prompt "A neon cybernetic samurai standing under rainy Tokyo streets, cinematic lighting" ``` #### Python API ```python from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config model_path = "prithivMLmods/Qwen-Image-2.1-PE-T2I-MLX" model, processor = load(model_path, subfolder="4bit") config = load_config(model_path, subfolder="4bit") prompt = "A neon cybernetic samurai standing under rainy Tokyo streets, cinematic lighting" formatted_prompt = apply_chat_template(processor, config, prompt) output = generate(model, processor, formatted_prompt, max_tokens=512, temperature=0.2) print(output.text) ``` ## License and Attribution * **Base Model:** [Qwen/Qwen-Image-2.1-PE-T2I](https://huggingface.co/Qwen/Qwen-Image-2.1-PE-T2I) * **License:** [Qwen Research License](https://huggingface.co/Qwen/Qwen-Image-2.1-PE-T2I/blob/main/LICENSE) * **MLX-VLM:** [Blaizzy/mlx-vlm](https://github.com/Blaizzy/mlx-vlm) * **MLX:** [ml-explore/mlx](https://github.com/ml-explore/mlx)