Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,58 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
import cv2
|
4 |
import streamlit as st
|
5 |
import tempfile
|
6 |
import os
|
7 |
import numpy as np
|
8 |
import cv2
|
9 |
import moviepy.editor as mp
|
10 |
-
from model import
|
11 |
|
12 |
-
#
|
13 |
st.set_page_config(page_title="AI Stick Animation", layout="wide")
|
14 |
-
st.title("π AI Stick Animation
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# πΉ app.py (Optimized with Path Handling & Real-time Previews)
|
2 |
+
|
|
|
3 |
import streamlit as st
|
4 |
import tempfile
|
5 |
import os
|
6 |
import numpy as np
|
7 |
import cv2
|
8 |
import moviepy.editor as mp
|
9 |
+
from model import AnimationGenerator
|
10 |
|
11 |
+
# Initialize core system
|
12 |
st.set_page_config(page_title="AI Stick Animation", layout="wide")
|
13 |
+
st.title("π Ultra-Advanced AI Stick Animation")
|
14 |
+
|
15 |
+
class AnimationApp:
|
16 |
+
def __init__(self):
|
17 |
+
self.animator = AnimationGenerator()
|
18 |
+
self.setup_ui()
|
19 |
+
|
20 |
+
def setup_ui(self):
|
21 |
+
col1, col2 = st.columns([2, 1])
|
22 |
+
with col1:
|
23 |
+
self.story = st.text_area("π Story Script:",
|
24 |
+
"John walks cautiously through the dark forest...", height=200)
|
25 |
+
self.character = st.text_input("π Main Character:", "John")
|
26 |
+
|
27 |
+
with col2:
|
28 |
+
self.background = st.selectbox("π Background",
|
29 |
+
["None", "Dark Forest", "Haunted House", "City"])
|
30 |
+
self.camera_effect = st.selectbox("π½οΈ Camera Effect",
|
31 |
+
["None", "Dynamic Shake", "Cinematic Zoom", "Slow Motion"])
|
32 |
+
self.soundtrack = st.selectbox("πΆ Soundtrack",
|
33 |
+
["None", "Epic", "Suspense", "Upbeat"])
|
34 |
+
|
35 |
+
if st.button("π Generate Animation"):
|
36 |
+
self.process_animation()
|
37 |
+
|
38 |
+
def process_animation(self):
|
39 |
+
with st.spinner("π§ AI is crafting your masterpiece..."):
|
40 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
41 |
+
# Generate core animation
|
42 |
+
video_path = self.animator.create_animation(
|
43 |
+
self.story,
|
44 |
+
self.character,
|
45 |
+
self.background,
|
46 |
+
self.camera_effect,
|
47 |
+
self.soundtrack,
|
48 |
+
tmp_dir
|
49 |
+
)
|
50 |
+
|
51 |
+
# Display results
|
52 |
+
st.success("β
Animation Complete!")
|
53 |
+
st.video(video_path)
|
54 |
+
st.download_button("πΎ Download", open(video_path, "rb"),
|
55 |
+
file_name="ai_animation.mp4")
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
AnimationApp()
|