File size: 2,112 Bytes
7769943 4bece86 7769943 4bece86 7769943 4bece86 7769943 |
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 57 58 |
# πΉ app.py (Optimized with Path Handling & Real-time Previews)
import streamlit as st
import tempfile
import os
import numpy as np
import cv2
import moviepy.editor as mp
from model import AnimationGenerator
# Initialize core system
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:
# Generate core animation
video_path = self.animator.create_animation(
self.story,
self.character,
self.background,
self.camera_effect,
self.soundtrack,
tmp_dir
)
# Display results
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() |