File size: 1,471 Bytes
d5f993b
 
 
 
7ba4b43
d5f993b
 
 
 
 
 
 
 
 
7ba4b43
 
 
d5f993b
7ba4b43
 
 
 
 
 
 
d5f993b
 
7ba4b43
d5f993b
 
 
 
 
7ba4b43
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import os
import subprocess
import tempfile
import time

def remove_mosaic(video_file):
    output_path = "output_video.mp4"
    
    # Simpan file sementara
    with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as temp_file:
        temp_file.write(video_file.read())
        temp_path = temp_file.name
    
    # Jalankan deepmosaic.py untuk menghapus mosaik
    command = f"python3 deepmosaic.py --mode clean --input {temp_path} --output {output_path}"
    process = subprocess.run(command, shell=True)
    
    # Tunggu sebentar untuk memastikan file selesai dibuat
    time.sleep(2)
    
    if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
        return output_path
    else:
        return None

st.title("🎥 DeepMosaics - Remove Mosaic from Videos")
uploaded_file = st.file_uploader("Upload Video with Mosaic", type=["mp4", "avi", "mov"])

if uploaded_file is not None:
    st.video(uploaded_file)
    
    if st.button("Remove Mosaic"):
        with st.spinner("Processing video, please wait..."):
            result_path = remove_mosaic(uploaded_file)
            
        if result_path:
            st.success("Processing complete!")
            st.video(result_path)
            
            with open(result_path, "rb") as file:
                st.download_button("Download Processed Video", file, "output_video.mp4")
        else:
            st.error("Failed to process video. Please try again.")