Spaces:
Runtime error
Runtime error
import gradio as gr | |
from modelscope.pipelines import pipeline | |
from modelscope.utils.constant import Tasks | |
# Use CogVideo, a publicly available text-to-video model on Hugging Face. | |
# (Replace 'THUDM/CogVideo-5M' with the correct ID if needed.) | |
video_model = pipeline(Tasks.text_to_video_synthesis, model='THUDM/CogVideo-5M') | |
def generate_pokemon_anime_video(prompt, style, duration, image): | |
""" | |
Generate a Pokémon anime–themed video. | |
The prompt is enriched with style and context so that the model "imagines" | |
iconic Pokémon scenes (e.g., Ash, Pikachu, Team Rocket). | |
""" | |
full_prompt = ( | |
f"{prompt}, in {style} style. " | |
"Include iconic Pokémon elements like Ash, Pikachu, and Team Rocket." | |
) | |
# Prepare inputs for the model. | |
# (If the model doesn't support image conditioning, the 'image' key may be ignored.) | |
inputs = {'text': full_prompt, 'duration': duration} | |
if image: | |
inputs['image'] = image | |
result = video_model(inputs) | |
return result["output_video"] | |
# Build the Gradio UI with dropdown, slider, and file upload. | |
with gr.Blocks() as iface: | |
gr.Markdown("# 🎥 PokeVidGen AI") | |
gr.Markdown( | |
"Generate Pokémon anime shorts with AI! " | |
"Enter a scene prompt, select an animation style, set the video duration, and optionally upload an image." | |
) | |
with gr.Row(): | |
prompt = gr.Textbox( | |
label="Enter Pokémon Scene", | |
placeholder="Ash battles Team Rocket with Pikachu's Thunderbolt" | |
) | |
style = gr.Dropdown( | |
["Anime Classic", "Modern 3D", "Cartoon"], | |
label="Animation Style", | |
value="Anime Classic" | |
) | |
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 Anime Video") | |
output_video = gr.Video(label="Generated Video") | |
generate_btn.click(generate_pokemon_anime_video, | |
inputs=[prompt, style, duration, image], | |
outputs=output_video) | |
iface.launch() | |