Downloads · 30 days
16
5% of all-time downloads
Xiejiehang/ERNIE-Image-Turbo-MLX-Q4
ERNIE-Image-Turbo-MLX-Q4 is a text-to-image model from Xiejiehang. 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.
ERNIE-Image-Turbo-MLX-Q4 is a local inference distribution of ERNIE-Image-Turbo optimized for Apple Silicon. This directory contains ready-to-run MLX inference assets and minimal inference scripts, aiming to help deve…
Downloads · 30 days
16
5% of all-time downloads
All-time downloads
291
Public
Parameters
1.3B
8.5 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors8.5 GB · 99%
How the weights are stored.
U321B · 80%
From the Hugging Face model README
ERNIE-Image-Turbo-MLX-Q4 is a local inference distribution of ERNIE-Image-Turbo optimized for Apple Silicon. This directory contains ready-to-run MLX inference assets and minimal inference scripts, aiming to help developers perform high-quality text-to-image verification, prototyping, and engineering integration on macOS with lower VRAM consumption.
Compared to the original BF16 weights, this version quantizes the most memory-intensive modules—Transformer, Text Encoder, and Prompt Enhancement—to 4-bit, while keeping the VAE decoder at high precision to achieve a stable balance between deployment efficiency and generation quality.
<p align="center"> <img src="https://ai-studio-static-online.cdn.bcebos.com/c089f215fd764a10a38084dc416bba16ba177272cc364f38a089bc966eb1b3b0" /> </p>MLX, specifically optimized for the Unified Memory Architecture of Apple M-series chips.ERNIE-Image-Turbo, including complex instruction following, long-form text rendering, and structured image generation.demo.py, a local scripts/ inference implementation, and all necessary configuration files. Developers can verify the model immediately.This distribution includes the following core components:
| Component | Precision | Description |
|---|---|---|
transformer/ | Q4 | Diffusion backbone (DiT), the primary compute and memory bottleneck. |
text_encoder/ | Q4 | Text encoder responsible for prompt semantic modeling. |
pe/ | Q4 | Prompt Enhancement module. |
vae/ | BF16 | Image decoder, kept at high precision for high-fidelity output. |
tokenizer/, pe_tokenizer/, scheduler/ | Original | Necessary assets for the inference pipeline. |
ERNIE-Image-Turbo's local inference capabilities on Apple Silicon.3.11+Install dependencies:
pip install -r requirements.txt
The requirements.txt includes core dependencies for local execution:
mlxmlx-lmtransformersPillownumpysafetensorsExecute the following command in the current directory:
python demo.py
By default, this will:
"A cinematic poster of a futuristic city at sunrise, ultra detailed, realistic lighting".5 denoising steps.output.png.To integrate this model into your own scripts, you can directly use the provided scripts.pipeline:
from pathlib import Path
from scripts.pipeline import generate, load_pipeline
# Load the pipeline from the current directory
model_dir = Path(".")
pipeline = load_pipeline(model_dir)
# Generate an image
image = generate(
pipeline,
prompt="A cinematic poster of a futuristic city at sunrise, ultra detailed, realistic lighting",
steps=5,
seed=42,
height=1024,
width=1024,
)
image.save("output.png")
print("Saved to output.png")
For the best balance between quality and speed, we recommend:
1024x10248For portrait or landscape orientations, you can explore:
848x1264 / 1264x848768x1376 / 1376x768896x1200 / 1200x896| Path | Description |
|---|---|
demo.py | Minimal runnable example. |
scripts/pipeline.py | End-to-end loading and generation entry point. |
scripts/dit.py | MLX implementation of the DiT backbone. |
scripts/vae.py | VAE Decoder implementation. |
transformer/ | Quantized DiT weights and configuration. |
text_encoder/ | Quantized Text Encoder. |
pe/ | Quantized Prompt Enhancement module. |
vae/ | High-precision VAE decoder. |
We conducted local inference verification on an Apple M3 device. The core results are as follows:
| Metric | Value |
|---|---|
| Model Load Time | 4.62 s |
| Peak Memory Usage | 14.70 GB |
| Text Encoding Time | 1.05 s |
| Denoising Time | 221.19 s |
| VAE Decoding Time | 9.28 s |
| Total Generation Time | 231.51 s |
Notes:
24 GB Unified Memory.1024x1024 resolution, 5 denoising steps.The base model, ERNIE-Image-Turbo, was released by the Baidu ERNIE-Image team and excels in:
This MLX Q4 version is intended as a lightweight deployment option for developers rather than a redefinition of the model's capabilities.
This project references and builds upon the following open-source works:
ERNIE-Image and ERNIE-Image-Turbo models and methods.