Ahmed766 commited on
Commit
bbbde74
Β·
verified Β·
1 Parent(s): d83c6f6

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +148 -0
app.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ """
3
+ The Studio v2.6 - Hugging Face Space Application
4
+ Streamlit interface for The Studio v2.6
5
+ """
6
+
7
+ import streamlit as st
8
+ import asyncio
9
+ import os
10
+ import json
11
+ from pathlib import Path
12
+ from huggingface_deployment import StudioHFOrchestrator
13
+
14
+ # Streamlit configuration
15
+ st.set_page_config(
16
+ page_title="The Studio v2.6 - AI Film Generator",
17
+ page_icon="🎬",
18
+ layout="wide",
19
+ initial_sidebar_state="expanded"
20
+ )
21
+
22
+ def main():
23
+ st.title("🎬 The Studio v2.6 - Autonomous Film Generator")
24
+ st.markdown("""
25
+ Transform your ideas into stunning videos with our AI-powered filmmaking system.
26
+ Powered by Hugging Face models and advanced consistency protocols.
27
+ """)
28
+
29
+ # Sidebar configuration
30
+ with st.sidebar:
31
+ st.header("βš™οΈ Configuration")
32
+ hf_token = st.text_input("Hugging Face Token", type="password",
33
+ help="Get your token from https://huggingface.co/settings/tokens")
34
+
35
+ if hf_token:
36
+ os.environ["HF_API_TOKEN"] = hf_token
37
+ st.success("Token set successfully!")
38
+
39
+ st.divider()
40
+
41
+ st.header("🎯 Sample Prompts")
42
+ sample_prompts = [
43
+ "A futuristic cityscape at sunset with flying cars and holographic advertisements",
44
+ "A chef preparing gourmet food in a professional kitchen with dynamic camera movements",
45
+ "Athletes competing in extreme sports with slow-motion action sequences",
46
+ "Luxury travel vlog showing exotic locations and cultural experiences",
47
+ "Fashion runway show with models showcasing designer clothing"
48
+ ]
49
+
50
+ selected_prompt = st.selectbox("Choose a sample prompt:", sample_prompts)
51
+
52
+ if st.button("Use Selected Prompt"):
53
+ st.session_state.prompt = selected_prompt
54
+
55
+ # Main content area
56
+ col1, col2 = st.columns([2, 1])
57
+
58
+ with col1:
59
+ st.header("πŸ“ Enter Your Video Prompt")
60
+
61
+ if 'prompt' not in st.session_state:
62
+ st.session_state.prompt = ""
63
+
64
+ prompt = st.text_area(
65
+ "Describe the video you want to create:",
66
+ value=st.session_state.prompt,
67
+ height=200,
68
+ placeholder="Example: A futuristic tech conference with holographic displays, showing the latest AI innovations, people interacting with virtual interfaces, dynamic camera movements capturing the excitement..."
69
+ )
70
+
71
+ title = st.text_input("Video Title:", "My AI Generated Video")
72
+
73
+ if st.button("🎬 Generate Video", type="primary", disabled=not prompt or not hf_token):
74
+ if not hf_token:
75
+ st.error("Please enter your Hugging Face token in the sidebar!")
76
+ return
77
+
78
+ with st.spinner("🎨 Creating your video masterpiece... This may take a few minutes..."):
79
+ try:
80
+ # Initialize orchestrator
81
+ orchestrator = StudioHFOrchestrator(hf_token)
82
+
83
+ # Generate video
84
+ result = asyncio.run(
85
+ orchestrator.generate_video_from_prompt(prompt, title)
86
+ )
87
+
88
+ if result['status'] == 'completed':
89
+ st.success("πŸŽ‰ Video generation completed successfully!")
90
+
91
+ # Display the generated video
92
+ video_file = open(result['video_path'], 'rb')
93
+ video_bytes = video_file.read()
94
+ st.video(video_bytes)
95
+
96
+ # Show metadata
97
+ with st.expander("πŸ“‹ Generation Details"):
98
+ st.json(result)
99
+
100
+ else:
101
+ st.error(f"❌ Video generation failed: {result.get('error', 'Unknown error')}")
102
+
103
+ except Exception as e:
104
+ st.error(f"❌ An error occurred: {str(e)}")
105
+
106
+ with col2:
107
+ st.header("πŸ“ˆ Generation Stats")
108
+
109
+ # Create some mock stats
110
+ st.metric("Videos Generated", "247", "12+ today")
111
+ st.metric("Success Rate", "94%", "+3% from last week")
112
+ st.metric("Avg. Generation Time", "3.2 min", "-0.4 min from last week")
113
+
114
+ st.divider()
115
+
116
+ st.header("πŸ’‘ Tips for Best Results")
117
+ st.caption("β€’ Be specific about visual elements and camera movements")
118
+ st.caption("β€’ Mention lighting, mood, and atmosphere")
119
+ st.caption("β€’ Include character descriptions if people are involved")
120
+ st.caption("β€’ Specify duration or number of scenes if needed")
121
+
122
+ st.divider()
123
+
124
+ st.header("πŸ”§ Advanced Options")
125
+ duration = st.slider("Estimated Duration (seconds)", 10, 60, 30)
126
+ style = st.selectbox("Video Style", ["Cinematic", "Documentary", "Commercial", "Artistic", "Dynamic"])
127
+
128
+ st.divider()
129
+
130
+ if st.button("πŸ’Ύ Download Project"):
131
+ # Create a project bundle
132
+ project_data = {
133
+ "title": title,
134
+ "prompt": prompt,
135
+ "style": style,
136
+ "duration": duration,
137
+ "generated_at": str(Path.home())
138
+ }
139
+
140
+ st.download_button(
141
+ label="Download Project JSON",
142
+ data=json.dumps(project_data, indent=2),
143
+ file_name=f"{title.replace(' ', '_')}_project.json",
144
+ mime="application/json"
145
+ )
146
+
147
+ if __name__ == "__main__":
148
+ main()