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