SimianLuo/LCM_Dreamshaper_v7 compiled on an AWS Inf2 instance.
INF2/TRN1 ONLY
1from optimum.neuron import NeuronLatentConsistencyModelPipeline
2
3pipe = NeuronLatentConsistencyModelPipeline.from_pretrained("Jingya/LCM_Dreamshaper_v7_neuronx")
4
5num_images_per_prompt = 2
6prompt = ["Self-portrait oil painting, a beautiful cyborg with golden hair, 8k"] * num_images_per_prompt
7
8images = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=8.0).images
If you are using a later neuron compiler version, you can compile the checkpoint yourself with the following lines via
🤗 optimum-neuron (the compilation takes approximately 40 min):
1from optimum.neuron import NeuronLatentConsistencyModelPipeline
2
3model_id = "SimianLuo/LCM_Dreamshaper_v7"
4num_images_per_prompt = 1
5input_shapes = {"batch_size": 1, "height": 768, "width": 768, "num_images_per_prompt": num_images_per_prompt}
6compiler_args = {"auto_cast": "matmul", "auto_cast_type": "bf16"}
7
8stable_diffusion = NeuronLatentConsistencyModelPipeline.from_pretrained(
9 model_id, export=True, **compiler_args, **input_shapes
10)
11save_directory = "lcm_sd_neuron/"
12stable_diffusion.save_pretrained(save_directory)
13
14# Push to hub
15stable_diffusion.push_to_hub(save_directory, repository_id="Jingya/LCM_Dreamshaper_v7_neuronx", use_auth_token=True)