|
import streamlit as st |
|
import tempfile |
|
import os |
|
import numpy as np |
|
import cv2 |
|
import moviepy.editor as mp |
|
from model import generate_stick_animation, add_camera_effects, add_background, add_sound |
|
|
|
|
|
st.set_page_config(page_title="AI Stick Animation", layout="wide") |
|
st.title("π AI Stick Animation Generator") |
|
|
|
|
|
story = st.text_area("π Enter Your Story:", "John is walking in a dark forest...") |
|
character_name = st.text_input("π Enter Main Character Name:", "John") |
|
|
|
|
|
background_choice = st.selectbox("π Choose Background", ["None", "Dark Forest", "Haunted House", "Battlefield"]) |
|
camera_effect = st.selectbox("π½οΈ Choose Camera Effect", ["None", "Shake", "Zoom", "Slow Motion"]) |
|
sound_effect = st.selectbox("πΆ Choose Background Music", ["None", "Horror", "Action", "Comedy"]) |
|
|
|
|
|
if st.button("π Generate Animation"): |
|
with st.spinner("AI is generating animation..."): |
|
output_frames = generate_stick_animation(story, character_name) |
|
|
|
|
|
output_frames = add_camera_effects(output_frames, camera_effect) |
|
output_frames = add_background(output_frames, background_choice) |
|
|
|
|
|
temp_dir = tempfile.mkdtemp() |
|
output_path = os.path.join(temp_dir, "animation.mp4") |
|
clip = mp.ImageSequenceClip(output_frames, fps=24) |
|
clip.write_videofile(output_path, codec="libx264", fps=24) |
|
|
|
|
|
final_video = add_sound(output_path, sound_effect) |
|
|
|
|
|
st.video(final_video) |
|
st.download_button("π₯ Download Animation", open(final_video, "rb"), file_name="stick_animation.mp4") |