Spaces:
Running
Running
| 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.") | |