Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,39 +2,43 @@ import gradio as gr
|
|
2 |
from modelscope.pipelines import pipeline
|
3 |
from modelscope.utils.constant import Tasks
|
4 |
|
5 |
-
# Load
|
6 |
-
|
7 |
-
|
8 |
-
|
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("# 🎥 PokeVidGen
|
25 |
-
gr.Markdown("Enter a prompt,
|
26 |
|
27 |
with gr.Row():
|
28 |
-
prompt = gr.Textbox(label="Enter Pokémon Scene", placeholder="
|
29 |
-
style = gr.Dropdown(["Anime
|
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 Pokémon Video")
|
35 |
-
|
36 |
-
output_video = gr.Video(label="Generated Pokémon 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 the Pokémon-specific text-to-video model.
|
6 |
+
# NOTE: Replace 'pokemon/pokemon-anime-text-to-video' with your actual model ID.
|
7 |
+
video_model = pipeline(Tasks.text_to_video_synthesis, model='pokemon/pokemon-anime-text-to-video')
|
8 |
+
|
9 |
+
def generate_pokemon_anime_video(prompt, style, duration, image):
|
10 |
+
"""
|
11 |
+
Generate a Pokémon anime–themed video.
|
12 |
+
The prompt is enriched with style and context, ensuring the model understands
|
13 |
+
references to Ash, Pikachu, and other trainers.
|
14 |
+
"""
|
15 |
+
full_prompt = (f"{prompt}, in {style} style. "
|
16 |
+
"Ensure the scene reflects the world of Pokémon, featuring Ash, "
|
17 |
+
"Pikachu, and recognizable elements from the Pokémon series.")
|
18 |
|
19 |
+
# Prepare inputs for the model
|
20 |
+
inputs = {'text': full_prompt, 'duration': duration}
|
21 |
if image:
|
22 |
+
inputs['image'] = image
|
23 |
|
|
|
24 |
result = video_model(inputs)
|
25 |
return result["output_video"]
|
26 |
|
27 |
+
# Build the Gradio UI
|
28 |
with gr.Blocks() as iface:
|
29 |
+
gr.Markdown("# 🎥 PokeVidGen AI")
|
30 |
+
gr.Markdown("Generate Pokémon anime shorts! Enter a scene prompt, select an animation style, set the video duration, and optionally upload an image.")
|
31 |
|
32 |
with gr.Row():
|
33 |
+
prompt = gr.Textbox(label="Enter Pokémon Scene", placeholder="Ash battles with Team Rocket with Pikachu's Thunderbolt")
|
34 |
+
style = gr.Dropdown(["Anime Classic", "Modern 3D", "Cartoon"], label="Animation Style", value="Anime Classic")
|
35 |
+
|
36 |
duration = gr.Slider(1, 10, step=1, label="Video Duration (Seconds)", value=5)
|
37 |
image = gr.Image(label="Upload an Image (Optional)", type="filepath")
|
38 |
|
39 |
+
generate_btn = gr.Button("Generate Pokémon Anime Video")
|
40 |
+
output_video = gr.Video(label="Generated Video")
|
|
|
41 |
|
42 |
+
generate_btn.click(generate_pokemon_anime_video, inputs=[prompt, style, duration, image], outputs=output_video)
|
43 |
|
44 |
iface.launch()
|