File size: 1,946 Bytes
96fe8c7
 
 
 
e402479
96fe8c7
 
 
 
 
 
 
 
 
e402479
 
 
 
96fe8c7
 
 
 
 
 
 
 
e402479
 
 
 
 
96fe8c7
e402479
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96fe8c7
 
 
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
import streamlit as st
from colab import AIDancePartner
import tempfile
import os
import time

def main():
    st.title("AI Dance Partner")
    st.write("Upload your dance video and get an AI dance partner!")
    
    # Video upload
    uploaded_file = st.file_uploader("Choose a video file", type=['mp4', 'avi', 'mov'])
    
    if uploaded_file is not None:
        # Create a temporary file
        with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as tfile:
            tfile.write(uploaded_file.read())
            temp_input_path = tfile.name
        
        # Dance style selection
        style = st.selectbox(
            "Choose dance partner style",
            ["Sync Partner", "Creative Partner"]
        )
        
        if st.button("Generate Dance Partner"):
            try:
                with st.spinner("Processing your dance video..."):
                    # Process video
                    dance_partner = AIDancePartner()
                    output_path = dance_partner.process_video(temp_input_path, mode=style)
                    
                    # Display result
                    st.video(output_path)
                    
                    # Download button
                    with open(output_path, 'rb') as file:
                        st.download_button(
                            label="Download video",
                            data=file,
                            file_name="ai_dance_partner.mp4",
                            mime="video/mp4"
                        )
                    
                    # Cleanup temporary files
                    os.unlink(temp_input_path)
                    os.unlink(output_path)
                    
            except Exception as e:
                st.error(f"An error occurred: {str(e)}")
                if os.path.exists(temp_input_path):
                    os.unlink(temp_input_path)

if __name__ == "__main__":
    main()