123LETSPLAY commited on
Commit
553770f
1 Parent(s): 8c789dc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import DiffusionPipeline
3
+
4
+ # Load the CogVideoX diffusion pipeline (image-to-video model)
5
+ pipe = DiffusionPipeline.from_pretrained("THUDM/CogVideoX-5b-I2V")
6
+
7
+ def generate_image(prompt):
8
+ # Generate the first frame of the video from the prompt
9
+ result = pipe(prompt)
10
+ image = result.images[0] # Extract the first frame from the generated video
11
+ return image
12
+
13
+ # Create a Gradio interface
14
+ iface = gr.Interface(
15
+ fn=generate_image,
16
+ inputs=gr.Textbox(label="Enter your prompt", placeholder="e.g. Astronaut in a jungle"),
17
+ outputs=gr.Image(label="Generated Image (First Frame)"),
18
+ title="CogVideoX Image-to-Video Generator",
19
+ description="Generate the first frame of a video using CogVideoX based on your text prompts."
20
+ )
21
+
22
+ if __name__ == "__main__":
23
+ iface.launch()