123LETSPLAY commited on
Commit
882777b
1 Parent(s): b8d0d96

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import DiffusionPipeline
3
+ import gradio as gr
4
+
5
+ # Load the diffusion pipeline for CogVideoX model
6
+ pipe = DiffusionPipeline.from_pretrained("THUDM/CogVideoX-5b-I2V", torch_dtype=torch.float16)
7
+
8
+ def generate_image(prompt):
9
+ image = pipe(prompt).images[0]
10
+ return image
11
+
12
+ # Set up Gradio interface
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("# Image Generation using CogVideoX Diffusers")
15
+
16
+ # Input prompt
17
+ prompt_input = gr.Textbox(label="Prompt", value="Astronaut in a jungle, cold color palette, muted colors, detailed, 8k")
18
+
19
+ # Output image
20
+ output_image = gr.Image(label="Generated Image")
21
+
22
+ # Button to trigger image generation
23
+ generate_button = gr.Button("Generate Image")
24
+
25
+ # Bind button to function
26
+ generate_button.click(fn=generate_image, inputs=prompt_input, outputs=output_image)
27
+
28
+ # Launch Gradio app
29
+ demo.launch()