jc-builds/ERNIE-Image-Turbo-iOS
ERNIE-Image-Turbo — iOS bundle
<p align="center"> <a href="https://github.com/haplollc/Mirage"><img alt="Mirage" src="https://img.shields.io/badge/Runs%20on-Mirage-orange" /></a> <a href="https://huggingface.co/baidu/ERNIE-Image"><img alt="Upstream" src="https://img.shields.io/badge/Upstream-baidu%2FERNIE--Image-blue" /></a> <img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-lightgrey" /> <img alt="Params" src="https://img.shields.io/badge/params-8B-purple" /> <img alt="Distill" src="https://img.shields.io/badge/distill-Turbo-green" /> </p>
A mobile-friendly bundle of ERNIE-Image-Turbo — Baidu's 8B single-stream DiT, distilled for fast inference, with state-of-the-art text rendering quality among open-weight models. Bundled with Ministral 3B text encoder + ERNIE's own 32-channel AutoencoderKLFlux2 VAE for on-device inference via **Mirage**.
ERNIE-Image-Turbo is particularly strong at:
- Photorealism at 1024×1024
- Accurate text rendering inside images — best-in-class among open models
- Speed — distilled to few-step sampling
What's inside
Total bundle: ~5.7 GB. Total GPU residency: ~7 GB. iPhone 16 Pro / 17 Pro / Mac territory.
Safety / SFW-by-default
This bundle is intended for shipping in consumer apps and ships with a recommended default negative prompt at `safety_negative_prompt.txt`. Consumers building on top of this bundle SHOULD load the file and prepend its contents to any user-supplied negative prompt by default, with an explicit user-facing opt-out for adult/artistic contexts.
The blocklist covers:
- Child safety — explicit terms blocking sexualised content involving minors or apparent minors (loaded first / highest weight in SD-style negative prompts)
- Adult / explicit —
nsfw,nude,explicit,sexual, anatomical detail - Gore + graphic violence —
gore,blood,mutilation, etc. - Hate symbols —
swastika,nazi,extremist
Diffusion models steer away from negative-prompt concepts; they don't binary-reject them. A sufficiently determined prompt can still produce undesirable output, so apps shipping this bundle to general audiences should pair the negative-prompt filter with output-side classification (e.g. a CSAM/NSFW classifier on the generated CGImage) before display.
Quick start (Mirage)
import Mirage
let docs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let engine = try Engine(models: ModelFiles(
diffusionModel: docs.appendingPathComponent("ernie-image-turbo-Q3_K_M.gguf"),
vae: docs.appendingPathComponent("ae.safetensors"),
textEncoder: docs.appendingPathComponent("Ministral-3-3B-Instruct-2512-Q4_K_M.gguf")
))
let image = try await engine.generate(.init(
prompt: "a vintage diner sign that reads \"OPEN 24/7\" in red neon, dusk lighting, photorealistic",
width: 1024, height: 1024,
steps: 8, // Turbo distillation
cfgScale: 1.0 // CFG is baked in
))Prompting guide
ERNIE-Image-Turbo conditions on a Mistral3-3B text encoder. The upstream Baidu README shows two prompt styles working well: short, dense, comma-separated phrases ("Astronaut in a jungle, cold color palette, muted colors, detailed, 8k") and long photograph-style narration ("This is a photograph depicting an urban street scene. Shot at eye level..."). Long prompts win when the scene has multiple subjects, structured layout, or rendered text.
ERNIE's particular strength: text inside the image. Put the exact text you want rendered in quotes in the prompt and the model will reproduce it on a sign, poster, label, or UI mock with very high fidelity for an open-weight model.
The icon-attractor problem
When your prompt fuses two well-known concepts (Statue of Liberty + dog, American Gothic + corgis, Tony Soprano + golden retriever), the diffusion transformer's cross-attention often collapses toward whichever concept it has seen photographed thousands of times — and ignores the other. Encoder-side, Mistral3 reads your prompt correctly; the failure happens at the DiT's denoising stage, where strong "icon attractors" overwhelm the creative twist at the locked turbo CFG of 1.0.
If you write "a bronze statue of a golden retriever ... on Liberty Island ... with the New York harbor" the model usually paints just the Statue of Liberty. The dog token loses the attention competition.
Four mitigations that actually work:
- Strip the icon's name from the prompt. Don't say "Statue of Liberty", "American Gothic", "Tony Soprano", "Picard". Describe only the visual properties (pose, costume, setting). The icon attractor is summoned by the proper noun more than by visual descriptors.
- Lead with the underdog concept. First tokens get more attention weight. Start with "A golden retriever..." not "A statue of...".
- Reinforce anatomy / species multiple times. Every mention of "floppy ears", "snout", "paw", "fur" adds weight to the underdog attractor. The icon's anatomy (face, robe, crown) only gets named once or zero times.
- Use a negative prompt to subtract the icon. With CFG locked at 1.0 you can't crank prompt adherence directly, but the negative prompt still subtracts attractors. Listing "human face, human person, woman, robe, gown" pushes the model away from the Statue-of-Liberty attractor explicitly.
Some prompts are genuinely hard and may need multiple seeds. When all else fails, image-to-image (start from a photo of the underdog subject, apply the prompt at moderate strength) is the industry workaround — not yet exposed by Mirage's public API.
Examples — viral scroll-video set
Heuristics that work well on ERNIE-Image-Turbo
- Quote any text you want rendered.
the sign reads "BREW & CO."performs much better thana sign saying brew and co. ERNIE's text-in-image fidelity is a real superpower; the viral set above leans on it where it adds composition payoff (ICE COLD,NEXT STOP: 14 ST,WAFFLE HOUSE,LISA,FINDING CRUMBS). - Open with the medium.
"This is a photograph of...","A movie poster showing...","An infographic about..."anchors composition early — ERNIE is particularly good at structured layouts. - Short prompts work too, in a tag-style register.
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"is from the upstream Baidu examples. Use this style when you want atmosphere without committing to a specific scene. - For dual-attractor fusion concepts: strip the icon's name, lead with the underdog subject, reinforce its anatomy, and use a negative prompt to subtract the icon's attractor. See the four mitigations above.
- Mistral3 is instruction-tuned — prompts written as natural-language descriptions of a scene generally outperform pure keyword salad.
Why ERNIE-Image-Turbo
If you need text inside images that actually renders correctly (signs, labels, captions, UI mocks), this is currently the strongest open-weight option. Mid-2025 evaluations showed ERNIE-Image meeting or beating GPT-Image-1 on text rendering despite being 1/10th the size.
