morbiwalaq commited on
Commit
ac409c4
·
verified ·
1 Parent(s): 777cca9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -9
app.py CHANGED
@@ -5,17 +5,36 @@ from modelscope.utils.constant import Tasks
5
  # Load ModelScope's Text-to-Video Model
6
  video_model = pipeline(Tasks.text_to_video_synthesis, model='damo/text-to-video-synthesis')
7
 
8
- def generate_video(prompt):
9
- result = video_model({'text': prompt})
 
 
 
 
 
 
 
 
 
 
10
  return result["output_video"]
11
 
12
  # Gradio UI
13
- iface = gr.Interface(
14
- fn=generate_video,
15
- inputs=gr.Textbox(label="Enter text prompt"),
16
- outputs=gr.Video(label="Generated Video"),
17
- title="AI Text-to-Video Generator",
18
- description="Type a prompt, and AI will create a video for you!",
19
- )
 
 
 
 
 
 
 
 
 
20
 
21
  iface.launch()
 
5
  # Load ModelScope's Text-to-Video Model
6
  video_model = pipeline(Tasks.text_to_video_synthesis, model='damo/text-to-video-synthesis')
7
 
8
+ def generate_video(prompt, style, duration, image):
9
+ # Modify prompt with style
10
+ prompt = f"{prompt}, in {style} style"
11
+
12
+ # Prepare inputs
13
+ inputs = {'text': prompt, 'duration': duration}
14
+
15
+ if image:
16
+ inputs['image'] = image # Use uploaded image if provided
17
+
18
+ # Generate video
19
+ result = video_model(inputs)
20
  return result["output_video"]
21
 
22
  # Gradio UI
23
+ with gr.Blocks() as iface:
24
+ gr.Markdown("# 🎥 AI Text-to-Video Generator")
25
+ gr.Markdown("Enter a prompt, choose a style, and generate a video!")
26
+
27
+ with gr.Row():
28
+ prompt = gr.Textbox(label="Enter text prompt", placeholder="A futuristic city with flying cars")
29
+ style = gr.Dropdown(["Realistic", "Cartoon", "Anime"], label="Select Video Style", value="Realistic")
30
+
31
+ duration = gr.Slider(1, 10, step=1, label="Video Duration (Seconds)", value=5)
32
+ image = gr.Image(label="Upload an Image (Optional)", type="filepath")
33
+
34
+ generate_btn = gr.Button("Generate Video")
35
+
36
+ output_video = gr.Video(label="Generated Video")
37
+
38
+ generate_btn.click(generate_video, inputs=[prompt, style, duration, image], outputs=output_video)
39
 
40
  iface.launch()