|
|
|
|
|
import streamlit as st |
|
import tempfile |
|
import os |
|
import numpy as np |
|
import cv2 |
|
import moviepy.editor as mp |
|
from model import AnimationGenerator |
|
|
|
|
|
st.set_page_config(page_title="AI Stick Animation", layout="wide") |
|
st.title("π Ultra-Advanced AI Stick Animation") |
|
|
|
class AnimationApp: |
|
def __init__(self): |
|
self.animator = AnimationGenerator() |
|
self.setup_ui() |
|
|
|
def setup_ui(self): |
|
col1, col2 = st.columns([2, 1]) |
|
with col1: |
|
self.story = st.text_area("π Story Script:", |
|
"John walks cautiously through the dark forest...", height=200) |
|
self.character = st.text_input("π Main Character:", "John") |
|
|
|
with col2: |
|
self.background = st.selectbox("π Background", |
|
["None", "Dark Forest", "Haunted House", "City"]) |
|
self.camera_effect = st.selectbox("π½οΈ Camera Effect", |
|
["None", "Dynamic Shake", "Cinematic Zoom", "Slow Motion"]) |
|
self.soundtrack = st.selectbox("πΆ Soundtrack", |
|
["None", "Epic", "Suspense", "Upbeat"]) |
|
|
|
if st.button("π Generate Animation"): |
|
self.process_animation() |
|
|
|
def process_animation(self): |
|
with st.spinner("π§ AI is crafting your masterpiece..."): |
|
with tempfile.TemporaryDirectory() as tmp_dir: |
|
|
|
video_path = self.animator.create_animation( |
|
self.story, |
|
self.character, |
|
self.background, |
|
self.camera_effect, |
|
self.soundtrack, |
|
tmp_dir |
|
) |
|
|
|
|
|
st.success("β
Animation Complete!") |
|
st.video(video_path) |
|
st.download_button("πΎ Download", open(video_path, "rb"), |
|
file_name="ai_animation.mp4") |
|
|
|
if __name__ == "__main__": |
|
AnimationApp() |