Views
No views yet
a photo of sks dog to trigger the image generation.1 >>> import torch
2 >>> from transformers import PreTrainedTokenizerFast, LlamaForCausalLM
3 >>> from diffusers import UniPCMultistepScheduler, HiDreamImagePipeline
4
5 >>> scheduler = UniPCMultistepScheduler(
6 ... flow_shift=3.0, prediction_type="flow_prediction", use_flow_sigmas=True
7 ... )
8
9 >>> tokenizer_4 = PreTrainedTokenizerFast.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct")
10 >>> text_encoder_4 = LlamaForCausalLM.from_pretrained(
11 ... "meta-llama/Meta-Llama-3.1-8B-Instruct",
12 ... output_hidden_states=True,
13 ... output_attentions=True,
14 ... torch_dtype=torch.bfloat16,
15 ... )
16
17 >>> pipe = HiDreamImagePipeline.from_pretrained(
18 ... "HiDream-ai/HiDream-I1-Full",
19 ... scheduler=scheduler,
20 ... tokenizer_4=tokenizer_4,
21 ... text_encoder_4=text_encoder_4,
22 ... torch_dtype=torch.bfloat16,
23 ... )
24 >>> pipe.enable_model_cpu_offload()
25 >>> pipe.load_lora_weights(f"linoyts/dog-hidream-lora")
26 >>> image = pipe(f"a photo of sks dog").images[0]
27
28# TODO: add an example code snippet for running this diffusion pipeline