studio-v2.6 / app.py
Ahmed766's picture
Upload app.py with huggingface_hub
bbbde74 verified
# app.py
"""
The Studio v2.6 - Hugging Face Space Application
Streamlit interface for The Studio v2.6
"""
import streamlit as st
import asyncio
import os
import json
from pathlib import Path
from huggingface_deployment import StudioHFOrchestrator
# Streamlit configuration
st.set_page_config(
page_title="The Studio v2.6 - AI Film Generator",
page_icon="🎬",
layout="wide",
initial_sidebar_state="expanded"
)
def main():
st.title("🎬 The Studio v2.6 - Autonomous Film Generator")
st.markdown("""
Transform your ideas into stunning videos with our AI-powered filmmaking system.
Powered by Hugging Face models and advanced consistency protocols.
""")
# Sidebar configuration
with st.sidebar:
st.header("βš™οΈ Configuration")
hf_token = st.text_input("Hugging Face Token", type="password",
help="Get your token from https://huggingface.co/settings/tokens")
if hf_token:
os.environ["HF_API_TOKEN"] = hf_token
st.success("Token set successfully!")
st.divider()
st.header("🎯 Sample Prompts")
sample_prompts = [
"A futuristic cityscape at sunset with flying cars and holographic advertisements",
"A chef preparing gourmet food in a professional kitchen with dynamic camera movements",
"Athletes competing in extreme sports with slow-motion action sequences",
"Luxury travel vlog showing exotic locations and cultural experiences",
"Fashion runway show with models showcasing designer clothing"
]
selected_prompt = st.selectbox("Choose a sample prompt:", sample_prompts)
if st.button("Use Selected Prompt"):
st.session_state.prompt = selected_prompt
# Main content area
col1, col2 = st.columns([2, 1])
with col1:
st.header("πŸ“ Enter Your Video Prompt")
if 'prompt' not in st.session_state:
st.session_state.prompt = ""
prompt = st.text_area(
"Describe the video you want to create:",
value=st.session_state.prompt,
height=200,
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..."
)
title = st.text_input("Video Title:", "My AI Generated Video")
if st.button("🎬 Generate Video", type="primary", disabled=not prompt or not hf_token):
if not hf_token:
st.error("Please enter your Hugging Face token in the sidebar!")
return
with st.spinner("🎨 Creating your video masterpiece... This may take a few minutes..."):
try:
# Initialize orchestrator
orchestrator = StudioHFOrchestrator(hf_token)
# Generate video
result = asyncio.run(
orchestrator.generate_video_from_prompt(prompt, title)
)
if result['status'] == 'completed':
st.success("πŸŽ‰ Video generation completed successfully!")
# Display the generated video
video_file = open(result['video_path'], 'rb')
video_bytes = video_file.read()
st.video(video_bytes)
# Show metadata
with st.expander("πŸ“‹ Generation Details"):
st.json(result)
else:
st.error(f"❌ Video generation failed: {result.get('error', 'Unknown error')}")
except Exception as e:
st.error(f"❌ An error occurred: {str(e)}")
with col2:
st.header("πŸ“ˆ Generation Stats")
# Create some mock stats
st.metric("Videos Generated", "247", "12+ today")
st.metric("Success Rate", "94%", "+3% from last week")
st.metric("Avg. Generation Time", "3.2 min", "-0.4 min from last week")
st.divider()
st.header("πŸ’‘ Tips for Best Results")
st.caption("β€’ Be specific about visual elements and camera movements")
st.caption("β€’ Mention lighting, mood, and atmosphere")
st.caption("β€’ Include character descriptions if people are involved")
st.caption("β€’ Specify duration or number of scenes if needed")
st.divider()
st.header("πŸ”§ Advanced Options")
duration = st.slider("Estimated Duration (seconds)", 10, 60, 30)
style = st.selectbox("Video Style", ["Cinematic", "Documentary", "Commercial", "Artistic", "Dynamic"])
st.divider()
if st.button("πŸ’Ύ Download Project"):
# Create a project bundle
project_data = {
"title": title,
"prompt": prompt,
"style": style,
"duration": duration,
"generated_at": str(Path.home())
}
st.download_button(
label="Download Project JSON",
data=json.dumps(project_data, indent=2),
file_name=f"{title.replace(' ', '_')}_project.json",
mime="application/json"
)
if __name__ == "__main__":
main()