Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,39 +2,41 @@ import gradio as gr
|
|
2 |
from modelscope.pipelines import pipeline
|
3 |
from modelscope.utils.constant import Tasks
|
4 |
|
5 |
-
# Load
|
6 |
-
video_model = pipeline(Tasks.text_to_video_synthesis, model='damo-vilab/text-to-video-
|
7 |
-
|
8 |
-
def
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
14 |
|
|
|
|
|
15 |
if image:
|
16 |
-
inputs['image'] = image #
|
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("# 🎥
|
25 |
-
gr.Markdown("Enter a prompt, choose a style, and generate a video!")
|
26 |
|
27 |
with gr.Row():
|
28 |
-
prompt = gr.Textbox(label="Enter
|
29 |
-
style = gr.Dropdown(["
|
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(
|
39 |
|
40 |
iface.launch()
|
|
|
2 |
from modelscope.pipelines import pipeline
|
3 |
from modelscope.utils.constant import Tasks
|
4 |
|
5 |
+
# Load a valid Text-to-Video model from ModelScope
|
6 |
+
video_model = pipeline(Tasks.text_to_video_synthesis, model='damo-vilab/text-to-video-synthesis')
|
7 |
+
|
8 |
+
def generate_pokemon_video(prompt, style, duration, image):
|
9 |
+
"""
|
10 |
+
Generate a Pokémon-themed video.
|
11 |
+
The prompt is augmented with the chosen style.
|
12 |
+
"""
|
13 |
+
# Modify prompt with chosen style
|
14 |
+
full_prompt = f"{prompt}, Pokémon style: {style}"
|
15 |
|
16 |
+
# Prepare the input dictionary
|
17 |
+
inputs = {'text': full_prompt, 'duration': duration}
|
18 |
if image:
|
19 |
+
inputs['image'] = image # Include image if provided
|
20 |
|
21 |
+
# Generate the video using the ModelScope pipeline
|
22 |
result = video_model(inputs)
|
23 |
return result["output_video"]
|
24 |
|
25 |
+
# Build the Gradio UI
|
26 |
with gr.Blocks() as iface:
|
27 |
+
gr.Markdown("# 🎥 PokeVidGen - AI Pokémon Shorts Generator")
|
28 |
+
gr.Markdown("Enter a prompt, choose a Pokémon style, adjust video duration, and (optionally) upload an image to generate a Pokémon-themed video!")
|
29 |
|
30 |
with gr.Row():
|
31 |
+
prompt = gr.Textbox(label="Enter Pokémon Scene", placeholder="Pikachu using Thunderbolt in a forest")
|
32 |
+
style = gr.Dropdown(["Anime", "Classic Pokémon", "Modern 3D"], label="Pokémon Style", value="Anime")
|
33 |
|
34 |
duration = gr.Slider(1, 10, step=1, label="Video Duration (Seconds)", value=5)
|
35 |
image = gr.Image(label="Upload an Image (Optional)", type="filepath")
|
36 |
|
37 |
+
generate_btn = gr.Button("Generate Pokémon Video")
|
38 |
+
output_video = gr.Video(label="Generated Pokémon Video")
|
|
|
39 |
|
40 |
+
generate_btn.click(generate_pokemon_video, inputs=[prompt, style, duration, image], outputs=output_video)
|
41 |
|
42 |
iface.launch()
|