Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,9 @@ import cv2
|
|
6 |
import random
|
7 |
|
8 |
|
9 |
-
os.system("mkdir _input")
|
10 |
-
os.system("mkdir _output")
|
11 |
-
os.system("mkdir _outputf")
|
12 |
os.system("ls")
|
13 |
col1, col2 = st.columns(2)
|
14 |
|
@@ -25,9 +25,9 @@ if uploaded_file is not None:
|
|
25 |
# To read file as bytes:
|
26 |
bytes_data = uploaded_file.getvalue()
|
27 |
st.video(bytes_data)
|
28 |
-
with open("inputvideo", "wb") as binary_file:
|
29 |
binary_file.write(bytes_data)
|
30 |
-
vcap = cv2.VideoCapture('inputvideo') # 0=camera
|
31 |
width=0
|
32 |
height=0
|
33 |
if vcap.isOpened():
|
@@ -48,7 +48,7 @@ def chamada():
|
|
48 |
#exec=True
|
49 |
# st.write("ffmpeg separando imagens")
|
50 |
#if not os.path.isfile("./_input/imagem-0001.png"):
|
51 |
-
vcap = cv2.VideoCapture('inputvideo') # 0=camera
|
52 |
width=0
|
53 |
height=0
|
54 |
if vcap.isOpened():
|
@@ -57,49 +57,49 @@ def chamada():
|
|
57 |
height = vcap.get(4) # float `height`
|
58 |
fps = vcap.get(5)
|
59 |
-vn -acodec copy output-audio.aac
|
60 |
-
os.system("ffmpeg -i inputvideo -vn -acodec copy output-audio.aac
|
61 |
-
os.system("ffmpeg -i inputvideo -compression_level 10 -pred mixed -pix_fmt rgb24 -sws_flags +accurate_rnd+full_chroma_int -s 720x1280 -r 30
|
62 |
percent_complete= percent_complete+ 30
|
63 |
with col1:
|
64 |
my_bar.progress(percent_complete )
|
65 |
# st.write("testando imagem")
|
66 |
-
input_img = cv2.imread("./_input/imagem-0002.png" , cv2.IMREAD_COLOR)
|
67 |
input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB)
|
68 |
with col1:
|
69 |
st.image(input_img)
|
70 |
|
71 |
-
os.system("ls
|
72 |
if 'myVar' not in globals():
|
73 |
myVar=""
|
74 |
# st.write("melhorando faces")
|
75 |
with col2:
|
76 |
with st.spinner('Wait for it...'):
|
77 |
# os.system("pip install git+https://github.com/TencentARC/GFPGAN.git")
|
78 |
-
os.system("python3 inference_gfpgan.py -i _input -o _output -v 1.3 -s 2")
|
79 |
with col1:
|
80 |
percent_complete= percent_complete+ 30
|
81 |
my_bar.progress(percent_complete )
|
82 |
|
83 |
-
os.system("ls
|
84 |
os.system("echo ----")
|
85 |
-
os.system("ls
|
86 |
os.system("echo ----")
|
87 |
-
os.system("ls
|
88 |
os.system("echo ----")
|
89 |
# s 1480x2560
|
90 |
# with col1:
|
91 |
# st.write("recompilando video")
|
92 |
#ffmpeg -r 60 -f image2 -s 1920x1080 -i _output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p ./videoSaida/output.mp4
|
93 |
-
os.system("ffmpeg -y -r 30 -f image2 -i _output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p
|
94 |
-
os.system("ffmpeg -i
|
95 |
-
os.system("ls
|
96 |
#st.video("./videoSaida/output.mp4" )
|
97 |
with col1:
|
98 |
# st.write("preparando para download do video")
|
99 |
percent_complete= percent_complete+ 30
|
100 |
my_bar.progress(percent_complete )
|
101 |
with col2:
|
102 |
-
with open("
|
103 |
st.video(file)
|
104 |
|
105 |
btn = st.download_button(
|
@@ -119,7 +119,7 @@ def chamada():
|
|
119 |
#input_img = cv2.imread("./_output/cmp/imagem-0001_0000.png" , cv2.IMREAD_COLOR)
|
120 |
with col2:
|
121 |
# st.write("demonstrando imagem restaurada")
|
122 |
-
input_img = cv2.imread("
|
123 |
input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB)
|
124 |
|
125 |
st.image(input_img)
|
|
|
6 |
import random
|
7 |
|
8 |
|
9 |
+
os.system("mkdir /tmp/_input")
|
10 |
+
os.system("mkdir /tmp/_output")
|
11 |
+
os.system("mkdir /tmp/_outputf")
|
12 |
os.system("ls")
|
13 |
col1, col2 = st.columns(2)
|
14 |
|
|
|
25 |
# To read file as bytes:
|
26 |
bytes_data = uploaded_file.getvalue()
|
27 |
st.video(bytes_data)
|
28 |
+
with open("/tmp/inputvideo", "wb") as binary_file:
|
29 |
binary_file.write(bytes_data)
|
30 |
+
vcap = cv2.VideoCapture('/tmp/inputvideo') # 0=camera
|
31 |
width=0
|
32 |
height=0
|
33 |
if vcap.isOpened():
|
|
|
48 |
#exec=True
|
49 |
# st.write("ffmpeg separando imagens")
|
50 |
#if not os.path.isfile("./_input/imagem-0001.png"):
|
51 |
+
vcap = cv2.VideoCapture('/tmp/inputvideo') # 0=camera
|
52 |
width=0
|
53 |
height=0
|
54 |
if vcap.isOpened():
|
|
|
57 |
height = vcap.get(4) # float `height`
|
58 |
fps = vcap.get(5)
|
59 |
-vn -acodec copy output-audio.aac
|
60 |
+
os.system("ffmpeg -i /tmp/inputvideo -vn -acodec copy output-audio.aac /tmp/inputvideo.acc")
|
61 |
+
os.system("ffmpeg -i /tmp/inputvideo -compression_level 10 -pred mixed -pix_fmt rgb24 -sws_flags +accurate_rnd+full_chroma_int -s 720x1280 -r 30 /tmp/_input/imagem-%4d.png")
|
62 |
percent_complete= percent_complete+ 30
|
63 |
with col1:
|
64 |
my_bar.progress(percent_complete )
|
65 |
# st.write("testando imagem")
|
66 |
+
input_img = cv2.imread("./tmp/_input/imagem-0002.png" , cv2.IMREAD_COLOR)
|
67 |
input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB)
|
68 |
with col1:
|
69 |
st.image(input_img)
|
70 |
|
71 |
+
os.system("ls /tmp/_input")
|
72 |
if 'myVar' not in globals():
|
73 |
myVar=""
|
74 |
# st.write("melhorando faces")
|
75 |
with col2:
|
76 |
with st.spinner('Wait for it...'):
|
77 |
# os.system("pip install git+https://github.com/TencentARC/GFPGAN.git")
|
78 |
+
os.system("python3 inference_gfpgan.py -i /tmp/_input -o /tmp/_output -v 1.3 -s 2")
|
79 |
with col1:
|
80 |
percent_complete= percent_complete+ 30
|
81 |
my_bar.progress(percent_complete )
|
82 |
|
83 |
+
os.system("ls /tmp/_output")
|
84 |
os.system("echo ----")
|
85 |
+
os.system("ls /tmp/_output/cmp")
|
86 |
os.system("echo ----")
|
87 |
+
os.system("ls /tmp/./_output/restored_imgs")
|
88 |
os.system("echo ----")
|
89 |
# s 1480x2560
|
90 |
# with col1:
|
91 |
# st.write("recompilando video")
|
92 |
#ffmpeg -r 60 -f image2 -s 1920x1080 -i _output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p ./videoSaida/output.mp4
|
93 |
+
os.system("ffmpeg -y -r 30 -f image2 -i /tmp/_output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p /tmp/videoSaida/outputp1.mp4")
|
94 |
+
os.system("ffmpeg -i /tmp/videoSaida/outputp1.mp4 -i /tmp/inputvideo.acc -c:v copy -c:a aac /tmp/output.mp4")
|
95 |
+
os.system("ls /tmp/videoSaida")
|
96 |
#st.video("./videoSaida/output.mp4" )
|
97 |
with col1:
|
98 |
# st.write("preparando para download do video")
|
99 |
percent_complete= percent_complete+ 30
|
100 |
my_bar.progress(percent_complete )
|
101 |
with col2:
|
102 |
+
with open("/tmp/videoSaida/output.mp4", "rb") as file:
|
103 |
st.video(file)
|
104 |
|
105 |
btn = st.download_button(
|
|
|
119 |
#input_img = cv2.imread("./_output/cmp/imagem-0001_0000.png" , cv2.IMREAD_COLOR)
|
120 |
with col2:
|
121 |
# st.write("demonstrando imagem restaurada")
|
122 |
+
input_img = cv2.imread("/tmp/_output/restored_imgs/imagem-0002.png" , cv2.IMREAD_COLOR)
|
123 |
input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB)
|
124 |
|
125 |
st.image(input_img)
|