Views
No views yet
1from diffusers import StableDiffusionXLControlNetPipeline, ControlNetModel, EulerDiscreteScheduler
2from PIL import Image
3import torch
4
5# Load the ControlNet model
6controlnet = ControlNetModel.from_pretrained(
7 "YOUR_USERNAME/temporalnet2-sdxl-controlnet",
8 torch_dtype=torch.float16
9)
10
11# Create the pipeline
12pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
13 "stabilityai/stable-diffusion-xl-base-1.0",
14 controlnet=controlnet,
15 torch_dtype=torch.float16
16)
17pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
18pipe.to("cuda")
19
20# Load your conditioning images
21prev_frame = Image.open("previous_frame.jpg")
22optical_flow = Image.open("optical_flow.jpg")
23
24# Concatenate conditioning images (they will be concatenated in the pipeline)
25# Note: You'll need to prepare the 6-channel input by concatenating prev_frame and optical_flow
26prompt = "your prompt describing the scene"
27
28# Generate
29image = pipe(
30 prompt=prompt,
31 image=[prev_frame, optical_flow], # The pipeline will handle concatenation
32 num_inference_steps=20,
33 guidance_scale=7.5
34).images[0]
35
36image.save("output.jpg")