File size: 826 Bytes
553770f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from diffusers import DiffusionPipeline

# Load the CogVideoX diffusion pipeline (image-to-video model)
pipe = DiffusionPipeline.from_pretrained("THUDM/CogVideoX-5b-I2V")

def generate_image(prompt):
    # Generate the first frame of the video from the prompt
    result = pipe(prompt)
    image = result.images[0]  # Extract the first frame from the generated video
    return image

# Create a Gradio interface
iface = gr.Interface(
    fn=generate_image,
    inputs=gr.Textbox(label="Enter your prompt", placeholder="e.g. Astronaut in a jungle"),
    outputs=gr.Image(label="Generated Image (First Frame)"),
    title="CogVideoX Image-to-Video Generator",
    description="Generate the first frame of a video using CogVideoX based on your text prompts."
)

if __name__ == "__main__":
    iface.launch()