Riz0030 commited on
Commit
7ba4b43
·
verified ·
1 Parent(s): eddf134

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -15
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 deepmosaic
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 memproses video
19
- command = "python3 deepmosaic.py --input {} --output {}".format(temp_path, output_path)
20
- subprocess.run("python3 deepmosaic.py --help", shell=True)
21
 
22
- return output_path
 
 
 
 
 
 
23
 
24
  st.title("🎥 DeepMosaics - Remove Mosaic from Videos")
25
- uploaded_file = st.file_uploader("Upload Video with Mosaic", type=["mp4", "MKV"])
26
 
27
  if uploaded_file is not None:
28
  st.video(uploaded_file)
29
 
30
  if st.button("Remove Mosaic"):
31
- result_path = remove_mosaic(uploaded_file)
32
- st.success("Processing complete!")
33
- st.video(result_path)
34
-
35
- with open(result_path, "rb") as file:
36
- st.download_button("Download Processed Video", file, "output_video.mp4")
 
 
 
 
 
 
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.")