Downloads · 30 days
46
19% of all-time downloads
htdu87/z-image-control-turbo-unified-8-steps-v2
z-image-control-turbo-unified-8-steps-v2 is a text-to-image model from htdu87. Use it when you need an image from a text prompt. It is set up for diffusers. The card lists the license as apache-2.0.
[](https://github.com/aigc-apps/VideoX-Fun) [](https://huggingface.co/alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union-2.1)
Downloads · 30 days
46
19% of all-time downloads
All-time downloads
241
Public
Repo size
58.6 GB
Likes
0
Public
Click a slice to open those files.
.safetensors8.2 GB · 51%
From the Hugging Face model README
This repository hosts the Z-Image Turbo Control Unified V2 model. This is a specialized architecture that unifies the powerful Z-Image Turbo base transformer with enhanced ControlNet capabilities into a single, cohesive model. This unified pipeline supports multiple generation modes in one place: Text-to-Image, Image-to-Image, ControlNet, and Inpainting.
Unlike traditional pipelines where ControlNet is an external add-on, this model integrates control layers directly into the transformer structure. This enables Unified GGUF Quantization, allowing the entire merged architecture (Base + Control) to be quantized (e.g., Q4_K_M, Q8_0) and run efficiently on consumer hardware with limited VRAM. This version also introduces significant optimizations, architectural improvements, and bug fixes for features like group_offload.
To set up the environment, simply install the dependencies:
#create virtual env
python -m venv venv
# Activate your venv
#upgrade pip
python.exe -m pip install --upgrade pip
#install requirements
pip install -r requirements.txt
Note: This repository contains a diffusers_local folder with the custom ZImageControlUnifiedPipeline and transformer logic required to run this specific architecture.
This repository provides separate, easy-to-use scripts for each generation task.
infer_t2i.py: For Text-to-Image generation.infer_i2i.py: For Image-to-Image generation.infer_controlnet.py: For ControlNet-guided generation (Pose, Canny, Depth, etc.).infer_inpaint.py: For all inpainting tasks.Use this version if you have limited VRAM (e.g., 6GB - 8GB). It loads the model from a quantized GGUF file. To use it, set use_gguf = True in the desired inference script and provide the path to the .gguf file.
Key Features:
group_offload to fit large models on consumer GPUs.Use this version if you have ample VRAM (e.g., 24GB+). Set use_gguf = False in the script to load the model using the standard from_pretrained directory structure for full BFloat16 precision.
The infer_inpaint.py script leverages a powerful, unified inpainting system with multiple modes controlled by the inpaint_mode parameter.
For best results, especially when removing objects or dealing with complex edges, it's recommended to pre-process your mask. We provide a utility script for this.
prepare_mask.py
This script expands the white areas of your mask and applies a feather (blur) to the edges. This helps to completely cover artifacts from the old image and ensures a smooth, seamless blend with the new generated content.
Usage:
python prepare_mask.py <input_mask_path> <output_mask_path> --expand 15 --feather 10
--expand: Expands the mask to cover "ghosting".--feather: Creates a soft gradient for seamless blending.infer_inpaint.pyYou can choose the inpainting method by setting the inpaint_mode variable in the script:
inpaint_mode = "default"
inpaint_mode = "diff"
inpaint_mode = "diff+inpaint"
diff mode for background preservation while also feeding the inpainting context to the ControlNet layers. This can be useful for complex scenes where both structural guidance and texture preservation are needed.controlnet_conditioning_scale for stronger control. For better stability, we highly recommend using a detailed prompt. The optimal range for controlnet_conditioning_scale is from 0.65 to 0.90.
This optmized V2 model introduces several new features and parameters for enhanced control and flexibility:
controlnet_refiner_conditioning_scale): It provides fine-grained control over the influence of the initial refining layers, allowing for isolated adjustments without the influence of the controlnet's conditioning force.add_control_noise_refiner=False): You can now disable the control noise refiner layers when loading the model to save memory or for different stylistic results.mask_blur_radius): A parameter to soften the edges of the inpainting mask for smoother transitions.group_offload works correctly with use_stream=True, enabling efficient memory management without errors.The new controlnet_refiner_conditioning_scale parameter allows for fine-tuning the control signal. Here is a comparison showing its effect while keeping the main control scale fixed.
Prompt: "Photorealistic portrait of a beautiful young East Asian woman with long, vibrant purple hair and a black bow. She is wearing a flowing white summer dress, standing on a sunny beach with a sparkling ocean and clear blue sky in the background. Bright natural sunlight, sharp focus, ultra-detailed." Control Image: Pose.
controlnet_conditioning_scale=0.75, num_steps=25 | Refiner: Off | Refiner Scale: 0.75 | Refiner Scale: 1.0 | Refiner Scale: 1.5 | Refiner Scale: 2.0 |
|---|---|---|---|---|---|
| Output | ![]() | ![]() | ![]() | ![]() | ![]() |
The table below shows the generation results under different combinations of Diffusion steps and Control Scale strength from the original model:
| Diffusion Steps | Scale 0.65 | Scale 0.70 | Scale 0.75 | Scale 0.8 | Scale 0.9 | Scale 1.0 |
|---|---|---|---|---|---|---|
| 9 | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 10 | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 20 | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 30 | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 40 | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
./transformer/: Directory for model weights (GGUF or standard).infer_controlnet.py: Script for ControlNet inference.infer_inpaint.py: Script for inpainting inference.infer_t2i.py: Script for Text-to-Image inference.infer_i2i.py: Script for Image-to-Image inference.prepare_mask.py: Utility script to process masks for inpainting.diffusers_local/: Custom pipeline code.requirements.txt: Python dependencies.