renatotn7 commited on
Commit
07a6275
·
1 Parent(s): 6a2fa62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -14
app.py CHANGED
@@ -4,30 +4,50 @@ import os.path
4
  import cv2
5
  import random
6
 
7
- os.system("sudo apt-get -y install libx264-dev")
8
  os.system("mkdir _input")
9
  os.system("mkdir _output")
10
  os.system("mkdir _outputf")
11
  os.system("ls")
12
 
13
 
 
 
 
 
 
 
14
  #-s 720x1280
15
- if 'exec' in globals():
16
-
 
 
 
 
 
17
  #exec=True
 
18
  #if not os.path.isfile("./_input/imagem-0001.png"):
19
  os.system("ffmpeg -i vivi.mp4 -compression_level 10 -pred mixed -pix_fmt rgb24 -sws_flags +accurate_rnd+full_chroma_int -s 1480x2560 -r 30 ./_input/imagem-%4d.png")
 
 
 
20
  input_img = cv2.imread("./_input/imagem-0002.png" , cv2.IMREAD_COLOR)
21
  input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB)
22
 
23
  st.image(input_img)
 
24
  os.system("ls ./_input")
25
  if 'myVar' not in globals():
26
  myVar=""
 
 
27
  # os.system("pip install git+https://github.com/TencentARC/GFPGAN.git")
28
- os.system("python3 inference_gfpgan.py -i _input -o _output -v 1.3 -s 2")
29
-
30
 
 
 
 
31
  os.system("ls ./_output")
32
  os.system("echo ----")
33
  os.system("ls ./_output/cmp")
@@ -35,13 +55,16 @@ if 'exec' in globals():
35
  os.system("ls ./_output/restored_imgs")
36
  os.system("echo ----")
37
  # s 1480x2560
 
38
  #ffmpeg -r 60 -f image2 -s 1920x1080 -i _output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p ./videoSaida/output.mp4
39
  os.system("ffmpeg -y -r 30 -f image2 -i _output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p ./videoSaida/output.mp4")
40
  os.system("ls ./videoSaida")
41
  #st.video("./videoSaida/output.mp4" )
42
-
43
  with open("./videoSaida/output.mp4", "rb") as file:
44
-
 
 
45
  btn = st.download_button(
46
 
47
  label="Download video",
@@ -58,7 +81,7 @@ if 'exec' in globals():
58
  #input_img = cv2.imread("./_output/cmp/imagem-0001_0000.png" , cv2.IMREAD_COLOR)
59
  #input_img = cv2.imread("./_output/cmp/imagem-0001_0000.png" , cv2.IMREAD_COLOR)
60
 
61
-
62
  input_img = cv2.imread("./_output/restored_imgs/imagem-0002.png" , cv2.IMREAD_COLOR)
63
  input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB)
64
 
@@ -67,12 +90,6 @@ if 'exec' in globals():
67
  #return Image.fromarray(restored_faces[0][:,:,::-1])
68
 
69
 
70
- title = "Melhoria de imagens"
71
-
72
- os.system("ls")
73
- description = "Sistema para automação。"
74
-
75
- article = "<p style='text-align: center'><a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'>clone from akhaliq@huggingface with little change</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>GFPGAN Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
76
  #st.button('Imagem',on_click=inference)
77
  exec=True
78
 
 
4
  import cv2
5
  import random
6
 
7
+
8
  os.system("mkdir _input")
9
  os.system("mkdir _output")
10
  os.system("mkdir _outputf")
11
  os.system("ls")
12
 
13
 
14
+ title = "Melhoria de imagens"
15
+ st.title(title)
16
+ os.system("ls")
17
+ description = "Sistema para automação。"
18
+ st.header(description)
19
+ article = "<p style='text-align: center'><a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'>clone from akhaliq@huggingface with little change</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>GFPGAN Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
20
  #-s 720x1280
21
+ my_bar = st.progress(0)
22
+ my_bar.progress(percent_complete + 1)=0
23
+
24
+
25
+ if 'exec' not in globals():
26
+ percent_complete= percent_complete+ 10
27
+ my_bar.progress(percent_complete )
28
  #exec=True
29
+ st.write("ffmpeg separando imagens")
30
  #if not os.path.isfile("./_input/imagem-0001.png"):
31
  os.system("ffmpeg -i vivi.mp4 -compression_level 10 -pred mixed -pix_fmt rgb24 -sws_flags +accurate_rnd+full_chroma_int -s 1480x2560 -r 30 ./_input/imagem-%4d.png")
32
+ percent_complete= percent_complete+ 30
33
+ my_bar.progress(percent_complete )
34
+ st.write("testando imagem")
35
  input_img = cv2.imread("./_input/imagem-0002.png" , cv2.IMREAD_COLOR)
36
  input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB)
37
 
38
  st.image(input_img)
39
+
40
  os.system("ls ./_input")
41
  if 'myVar' not in globals():
42
  myVar=""
43
+ st.write("melhorando faces")
44
+ with st.spinner('Wait for it...'):
45
  # os.system("pip install git+https://github.com/TencentARC/GFPGAN.git")
46
+ os.system("python3 inference_gfpgan.py -i _input -o _output -v 1.3 -s 2")
 
47
 
48
+ percent_complete= percent_complete+ 30
49
+ my_bar.progress(percent_complete )
50
+
51
  os.system("ls ./_output")
52
  os.system("echo ----")
53
  os.system("ls ./_output/cmp")
 
55
  os.system("ls ./_output/restored_imgs")
56
  os.system("echo ----")
57
  # s 1480x2560
58
+ st.write("recompilando video")
59
  #ffmpeg -r 60 -f image2 -s 1920x1080 -i _output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p ./videoSaida/output.mp4
60
  os.system("ffmpeg -y -r 30 -f image2 -i _output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p ./videoSaida/output.mp4")
61
  os.system("ls ./videoSaida")
62
  #st.video("./videoSaida/output.mp4" )
63
+ st.write("preparando para download do video")
64
  with open("./videoSaida/output.mp4", "rb") as file:
65
+ percent_complete= percent_complete+ 30
66
+ my_bar.progress(percent_complete )
67
+
68
  btn = st.download_button(
69
 
70
  label="Download video",
 
81
  #input_img = cv2.imread("./_output/cmp/imagem-0001_0000.png" , cv2.IMREAD_COLOR)
82
  #input_img = cv2.imread("./_output/cmp/imagem-0001_0000.png" , cv2.IMREAD_COLOR)
83
 
84
+ st.write("demonstrando imagem restaurada")
85
  input_img = cv2.imread("./_output/restored_imgs/imagem-0002.png" , cv2.IMREAD_COLOR)
86
  input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB)
87
 
 
90
  #return Image.fromarray(restored_faces[0][:,:,::-1])
91
 
92
 
 
 
 
 
 
 
93
  #st.button('Imagem',on_click=inference)
94
  exec=True
95