shaaravpawar commited on
Commit
f70a81f
1 Parent(s): 65325dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -1,15 +1,20 @@
1
- from diffusers import DiffusionPipeline
2
- import torch
3
 
4
- device = "cuda"if torch.cuda.is _available() else :"cpu"
 
5
 
6
- pipeline=DiffusionPipeline.from_pretrained("stabilityai/stable-video-diffusion-img2vid-xt")
7
- pipeline = pipeline.to(device)
 
8
 
9
- prompt = "A beautiful sunset over the ocean"
10
- video = pipeline(prompt,num_interface_steps=50).videos
 
 
 
 
 
11
 
12
- video path = "generated_video.mp4"with open(video_path, "wb") as f:
13
- f.write(video[0])
14
-
15
- print(f"video generated and saved as {video_path}")
 
1
+ import gradio as gr
2
+ from transformers import DiffusionPipeline
3
 
4
+ # Load the pre-trained Diffusion model from Hugging Face
5
+ pipeline = DiffusionPipeline.from_pretrained("THUDM/CogVideoX-5b-I2V")
6
 
7
+ def generate_image(prompt):
8
+ image = pipeline(prompt)["sample"][0]
9
+ return image
10
 
11
+ iface = gr.Interface(
12
+ fn=generate_image,
13
+ inputs=gr.Textbox(label="Enter your prompt"),
14
+ outputs=gr.Image(type="pil"),
15
+ title="Diffusion Model Image Generator",
16
+ description="Enter a prompt to generate an image using the DiffusionPipeline from Hugging Face."
17
+ )
18
 
19
+ if __name__ == "__main__":
20
+ iface.launch()