Archive of AI

Source Snapshot / 2026-04-15-baidu-ernie-image-open-weights-3

ERNIE-Image 官方推理代码

Linked event: 2026-04-15 · Baidu ERNIE Open-Sources ERNIE-Image and Turbo Text-to-Image Models

Publisher
百度/GitHub
Archived
2026-11-23
Capture Method
Direct page capture
HTTP / SHA-256
200 / c8e14ff8ff8c14f8
Original URL
Open source ↗
Wayback Backup
Wayback archive ↗
This page preserves a plain-text static snapshot against link rot. When citing figures, tables, or full legal terms, verify against the original URL and Wayback Machine archive.

Skip to content

Navigation Menu

Appearance settings

You signed in with another tab or window. Reload to refresh your session.

You signed out in another tab or window. Reload to refresh your session.

You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

Repository navigation

NotificationsYou must be signed in to change notification settings

Star520 (520)You must be signed in to star a repository

ERNIE-Image is an open text-to-image generation model developed by the ERNIE-Image team at Baidu. It is built on a single-stream Diffusion Transformer (DiT), with only 8B DiT parameters, it reaches state-of-the-art performance among open-weight text-to-image models.

Apache-2.0 license

Custom properties

Report repository

BranchesTags

Open more actions menu

Latest commit

Folders and files

Last commit message

Last commit date

View all files

Repository files navigation

🤗 ERNIE-Image  |

🤗 ERNIE-Image-Turbo  |

🖥️ Huggingface Demo  |

🖥️ AI Studio Demo  |

🖼️ Art Gallery

💬 WeChat(微信)  |

🫨 Discord  |

ERNIE-Image is an open text-to-image generation model developed by the ERNIE-Image team at Baidu. It is built on a single-stream Diffusion Transformer (DiT) and paired with a lightweight Prompt Enhancer that expands brief user inputs into richer structured descriptions. With only 8B DiT parameters, it reaches state-of-the-art performance among open-weight text-to-image models.

Compact but strong: Despite its compact 8B DiT scale, ERNIE-Image remains highly competitive with substantially larger open-weight models across a range of benchmarks.

Text rendering: Performs particularly well on dense, long-form, and layout-sensitive text, making it a strong choice for posters, infographics, UI-like images, and other text-heavy visual content.

Instruction following: Able to follow complex prompts involving multiple objects, detailed relationships, and knowledge-intensive descriptions with strong reliability.

Structured generation: Especially effective for structured visual tasks such as posters, comics, storyboards, and multi-panel compositions.

Style coverage: Supports realistic photography, design-oriented imagery, and distinctive stylized aesthetics.

Practical deployment: Can run on consumer GPUs with 24G VRAM.

Released Versions

Inference Steps

SFT model with stronger general-purpose capability and instruction fidelity

ERNIE-Image-Turbo

Turbo model optimized by DMD and RL for faster speed and higher aesthetics

Single Object

Attribute Binding

ERNIE-Image (w/o PE)

ERNIE-Image (w/ PE)

ERNIE-Image-Turbo (w/o PE)

ERNIE-Image-Turbo (w/ PE)

FLUX.2-klein-9B

Z-Image-Turbo

Nano Banana 2.0

Seedream 4.5

Seedream 4.0

Qwen-Image-2512

LongTextBench

LongText-Bench-EN

LongText-Bench-ZH

Install the latest version of diffusers:

pip install git+https://github.com/huggingface/diffusers

cd diffusers

pip install -e .

import torch

from diffusers import ErnieImagePipeline

# Use ERNIE-Image (50 steps)

pipe = ErnieImagePipeline.from_pretrained(

"baidu/ERNIE-Image",

torch_dtype=torch.bfloat16,

).to("cuda")

image = pipe(

prompt="一只黑白相间的中华田园犬",

height=1024,

num_inference_steps=50,

guidance_scale=4.0,

image.save("output.png")

For faster generation, use ERNIE-Image-Turbo (8 steps):

"baidu/ERNIE-Image-Turbo",

num_inference_steps=8,

guidance_scale=1.0,

Method 1: Deploy ERNIE-Image with inner Prompt Enhancer (PE)

Install the latest version of sglang:

git clone https://github.com/sgl-project/sglang.git

Start the server:

sglang serve --model-path baidu/ERNIE-Image

Send a generation request:

curl -X POST http://localhost:30000/v1/images/generations \

-H "Content-Type: application/json" \

"prompt": "一只黑白相间的中华田园犬",

"height": 1024,

"width": 1024,

"num_inference_steps": 50,

"guidance_scale": 4.0

--output output.png

Method 2: Deploy ERNIE-Image and the Prompt Enhancer (PE) separately to improve PE inference speed

Install the latest version of sglang and deloy for ERNIE-Image Server.

sglang serve --model-path baidu/ERNIE-Image-Turbo

Install vllm and deploy for ERNIE-Image-PE Server.

pip install uv

uv venv --python=3.12 --seed

uv pip install vllm

uv pip install transformers==5.4.0

mkdir ./ernie_image_pe

# 将baidu/ERNIE-Image-Turbo目录下的pe和pe_tokenizer子目录文件同步到ernie_image_pe目录下

cp -rfnL ~/.cache/huggingface/hub/models--baidu--ERNIE-Image-Turbo/snapshots/*/pe*/* ./ernie_image_pe

vllm serve ./ernie_image_pe --port 8888

Stage1: Get revised prompt:

curl -X POST http://localhost:8888/v1/chat/completions \

"model": "./ernie_image_pe",

"messages": [

{"role": "user", "content": "{\"prompt\": \"一个女孩在海边\", \"width\": 1024, \"height\": 1024}"}

"temperature": 0.6,

"top_p": 0.8,

"max_tokens": 2048,

"stream": false

Stage2: Request the DiT model based on the revised prompt:

"prompt": {revised_propmt},

"num_inference_steps": 8,

"guidance_scale": 1.0,

"use_pe": false # Using this method requires use_pe to be false.

展开提示词一张桌面端浏览器网页界面的截图,宽高比适宜宽屏展示。顶部是标准的浏览器外框区域,左上角的标签页名称显示为 'Introduction to LLMs',旁边带有细小的关闭叉号。地址栏中显示着网址 'https://www.ai-insights.com/intro-to-llms',左侧有深灰色的后退、前进和刷新图标,右上角是常规的最小化、最大化和关闭窗口按钮。网页顶部是一个白底导航栏,左侧有一个包含蓝色节点连线图案的品牌Logo,旁边的文字为 'AI Insights'。导航栏中部水平排列着四个导航链接:'Home'、'Models'、'Research' 和 'About Us'。右侧放置着一个带放大镜图标的浅灰色搜索框,以及一个蓝色的 'Log In' 按钮。网页主体部分采用现代简洁的风格,浅灰白色的背景。视觉中心上方是醒目的黑色加粗大标题 'Understanding Large Language Models (LLMs)',下方紧跟深灰色的副标题 'A brief guide to the AI systems shaping the future of natural language processing.'。页面中下部呈左右两栏布局。左侧为文字说明区,包含一个小标题 'What are LLMs?',下方正文为 'Large Language Models are advanced artificial intelligence systems designed to understand, generate, and interact with human language. They are trained on vast amounts of text data using deep learning techniques, particularly transformer architectures.'。紧接着是第二个小标题 'How do they work?',其正文内容为 'By analyzing billions of parameters, LLMs predict the next word in a sequence, allowing them to perform tasks like translation, summarization, and conversation with remarkable accuracy.'。下方还有一个要点列表,标题为 'Key Capabilities:',包含三个带有圆点符号的项目:'• Text Generation & Completion','• Language Translation','• Sentiment Analysis'。右侧栏是一幅充满科技感的矢量插画,主色调为深蓝和紫色。插画中心是一个由发光线条和节点构成的大脑形状神经网络,周围环绕着代表不同功能的悬浮图标,包括白色的聊天对话气泡、折角的文档图标以及金色的齿轮。网页最右侧边缘显示着一段灰色的垂直滚动条。画面光线明亮,排版整洁,文字清晰可辨。

展开提示词这是一张夜间城市街道的摄影照片,展示了雨后湿滑路面与昏黄灯光交织的街景。画面主体是一条被雨水打湿的柏油马路,路面因积水呈现出强烈的反光效果,倒映着街道两侧的霓虹灯牌和路灯,形成蓝青色与暖黄色交织的光影。一辆深色轿车正亮着刺眼的白色前大灯行驶在画面右侧的街道上,车灯的光芒在湿润的路面上投射出明亮的倒影。\n\n街道左侧排列着数家店铺,最显眼的是一家挂着黄色招牌的居酒屋,招牌上用醒目的红色和黑色字体写着‘居酒屋’、‘生ビール 190円’以及‘SMOOTH PREMIUM BEER’字样,招牌下方悬挂着一个红色的灯笼。在这家店的上方和侧面还有竖向的灯箱招牌,同样写着‘生ビール 190円’。左侧前景处立着一个小型的发光广告牌,上面列有菜单,隐约可见‘100’等数字。街道右侧是一排较高的建筑物,窗户透出零星灯光,路边竖立着交通标志杆。

[...内容已截断,完整版请查看原文或 Wayback 快照]