Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,8 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
-
print(os.listdir("/home/user/app/"))
|
| 4 |
-
print(os.path.exists(temp_path)) # Harus return True
|
| 5 |
import subprocess
|
| 6 |
import tempfile
|
| 7 |
-
import
|
| 8 |
-
deepmosaic.main("--input /tmp/tmp92go9ezb.mp4 --output output_video.mp4")
|
| 9 |
|
| 10 |
def remove_mosaic(video_file):
|
| 11 |
output_path = "output_video.mp4"
|
|
@@ -15,22 +12,33 @@ def remove_mosaic(video_file):
|
|
| 15 |
temp_file.write(video_file.read())
|
| 16 |
temp_path = temp_file.name
|
| 17 |
|
| 18 |
-
# Jalankan deepmosaic.py untuk
|
| 19 |
-
command = "python3 deepmosaic.py --input {} --output {}"
|
| 20 |
-
subprocess.run(
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
st.title("🎥 DeepMosaics - Remove Mosaic from Videos")
|
| 25 |
-
uploaded_file = st.file_uploader("Upload Video with Mosaic", type=["mp4", "
|
| 26 |
|
| 27 |
if uploaded_file is not None:
|
| 28 |
st.video(uploaded_file)
|
| 29 |
|
| 30 |
if st.button("Remove Mosaic"):
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
|
|
|
|
|
|
| 3 |
import subprocess
|
| 4 |
import tempfile
|
| 5 |
+
import time
|
|
|
|
| 6 |
|
| 7 |
def remove_mosaic(video_file):
|
| 8 |
output_path = "output_video.mp4"
|
|
|
|
| 12 |
temp_file.write(video_file.read())
|
| 13 |
temp_path = temp_file.name
|
| 14 |
|
| 15 |
+
# Jalankan deepmosaic.py untuk menghapus mosaik
|
| 16 |
+
command = f"python3 deepmosaic.py --mode clean --input {temp_path} --output {output_path}"
|
| 17 |
+
process = subprocess.run(command, shell=True)
|
| 18 |
|
| 19 |
+
# Tunggu sebentar untuk memastikan file selesai dibuat
|
| 20 |
+
time.sleep(2)
|
| 21 |
+
|
| 22 |
+
if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
|
| 23 |
+
return output_path
|
| 24 |
+
else:
|
| 25 |
+
return None
|
| 26 |
|
| 27 |
st.title("🎥 DeepMosaics - Remove Mosaic from Videos")
|
| 28 |
+
uploaded_file = st.file_uploader("Upload Video with Mosaic", type=["mp4", "avi", "mov"])
|
| 29 |
|
| 30 |
if uploaded_file is not None:
|
| 31 |
st.video(uploaded_file)
|
| 32 |
|
| 33 |
if st.button("Remove Mosaic"):
|
| 34 |
+
with st.spinner("Processing video, please wait..."):
|
| 35 |
+
result_path = remove_mosaic(uploaded_file)
|
| 36 |
+
|
| 37 |
+
if result_path:
|
| 38 |
+
st.success("Processing complete!")
|
| 39 |
+
st.video(result_path)
|
| 40 |
+
|
| 41 |
+
with open(result_path, "rb") as file:
|
| 42 |
+
st.download_button("Download Processed Video", file, "output_video.mp4")
|
| 43 |
+
else:
|
| 44 |
+
st.error("Failed to process video. Please try again.")
|