Diffusers documentation

ERNIE-Image

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Ernie-Image

LoRA

[ERNIE-Image]は、8Bパラメータを持つ、強力かつ高効率な画像生成モデルです。現在リリース予定のモデルは2つのみです:

モデルHugging Face
ERNIE-Imagehttps://huggingface.co/baidu/ERNIE-Image
ERNIE-Image-Turbohttps://huggingface.co/baidu/ERNIE-Image-Turbo

ERNIE-Image

ERNIE-Image は、比較的小規模なアーキテクチャと堅牢な指示追従能力を備え、パラメータ効率を重視して設計されています。8B の DiT バックボーンを基盤としており、パラメータ効率を適度に保ちながら、一部のシナリオではより大規模な(20B 以上)モデルに匹敵するパフォーマンスを発揮します。指示の理解と実行、テキスト生成(例:英語 / 中国語 / 日本語)、および全体としての安定性において、比較的安定したレベルのパフォーマンスを提供します。

ERNIE-Image-Turbo

ERNIE-Image-Turbo は ERNIE-Image の蒸留版であり、NFE(Number of Function Evaluations)はわずか 8 回で済むため、特定のケースではフルモデルとほぼ同等のパフォーマンスを維持しながら、より効率的な代替手段を提供します。

ErnieImagePipeline

ErnieImagePipeline を使用して、テキストプロンプトから画像を生成します。このパイプラインはデフォルトで Prompt Enhancer (PE) をサポートしており、ユーザーの生のプロンプトを強化して出力品質を向上させますが、指示追従の精度が低下する可能性があります。

事前学習済みの3BパラメータのPEモデルを提供していますが、プロンプトの強化にはより大規模な言語モデル(GeminiやChatGPTなど)を使用する方が、より良い結果が得られる場合があります。システムプロンプトのテンプレートは、https://huggingface.co/baidu/ERNIE-Image/blob/main/pe/chat_template.jinja で利用できます。

PEの使用を避ける場合は、use_pe=Falseを設定してください。

import torch
from diffusers import ErnieImagePipeline
from diffusers.utils import load_image

pipe = ErnieImagePipeline.from_pretrained("baidu/ERNIE-Image", dtype=torch.bfloat16)
pipe.to("cuda")  # or "mps", "xpu", "cpu"
# If you are running low on GPU VRAM, you can enable offloading
pipe.enable_model_cpu_offload()

prompt = "一只黑白相间的中华田园犬"
images = pipe(
    prompt=prompt,
    height=1024,
    width=1024,
    num_inference_steps=50,
    guidance_scale=4.0,
    generator=torch.Generator("cuda").manual_seed(42),
    use_pe=True,
).images
images[0].save("ernie-image-output.png")
import torch
from diffusers import ErnieImagePipeline
from diffusers.utils import load_image

pipe = ErnieImagePipeline.from_pretrained("baidu/ERNIE-Image-Turbo", dtype=torch.bfloat16)
pipe.to("cuda")  # or "mps", "xpu", "cpu"
# If you are running low on GPU VRAM, you can enable offloading
pipe.enable_model_cpu_offload()

prompt = "一只黑白相间的中华田园犬"
images = pipe(
    prompt=prompt,
    height=1024,
    width=1024,
    num_inference_steps=8,
    guidance_scale=1.0,
    generator=torch.Generator("cuda").manual_seed(42),
    use_pe=True,
).images
images[0].save("ernie-image-turbo-output.png")
Update on GitHub