HiDream-I1 is supported by the diffusers library. It is recommended to install diffusers from source for optimal compatibility.
To use the pipeline, you must provide a tokenizer_4 and a text_encoder_4 initialized from the meta-llama/Meta-Llama-3.1-8B-Instruct model.
Parameter Notes:
guidance_scale: Use 5.0 for the full model. For dev and fast models, use 0.0.num_inference_steps: Use 50 for full, 28 for dev, and 16 for fast.
import torch
from transformers import PreTrainedTokenizerFast, LlamaForCausalLM
from diffusers import HiDreamImagePipeline
tokenizer_4 = PreTrainedTokenizerFast.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct")
text_encoder_4 = LlamaForCausalLM.from_pretrained(
"meta-llama/Meta-Llama-3.1-8B-Instruct",
output_hidden_states=True,
output_attentions=True,
torch_dtype=torch.bfloat16,
)
pipe = HiDreamImagePipeline.from_pretrained(
"HiDream-ai/HiDream-I1-Full", # "HiDream-ai/HiDream-I1-Dev" | "HiDream-ai/HiDream-I1-Fast"
tokenizer_4=tokenizer_4,
text_encoder_4=text_encoder_4,
torch_dtype=torch.bfloat16,
)
pipe = pipe.to('cuda')
image = pipe(
'A cat holding a sign that says "HiDream.ai".',
height=1024,
width=1024,
guidance_scale=5.0, # 0.0 for Dev&Fast
num_inference_steps=50, # 28 for Dev and 16 for Fast
generator=torch.Generator("cuda").manual_seed(0),
).images[0]
image.save("output.png")