File size: 2,154 Bytes
474e88e
1c04df8
 
474e88e
77e44b8
 
a1e0acd
605a78f
77e44b8
605a78f
77e44b8
 
 
605a78f
77e44b8
 
 
 
ac409c4
77e44b8
 
605a78f
ac409c4
77e44b8
ac409c4
 
1c04df8
474e88e
77e44b8
ac409c4
77e44b8
 
 
 
 
ac409c4
77e44b8
 
 
 
 
 
 
 
 
ac409c4
 
77e44b8
 
ac409c4
77e44b8
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
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/CogVideoX-5b')

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()