manhkhanhUIT commited on
Commit
7785814
1 Parent(s): e686fcd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -22
app.py CHANGED
@@ -1,10 +1,9 @@
1
  import gradio as gr
2
  import os
3
- #import cv2
4
- #import shutil
5
- #import sys
6
- #from subprocess import call
7
- from utils import Restoration
8
 
9
  os.system("pip install dlib")
10
  os.system('bash setup.sh')
@@ -17,25 +16,22 @@ def run_cmd(command):
17
  sys.exit(1)
18
 
19
  def run(image):
20
- # os.makedirs("Temp")
21
- # os.makedirs("Temp/input")
22
- # print(type(image))
23
- # cv2.imwrite("Temp/input/input_img.png", image)
24
 
25
- # command = ("python run.py --input_folder "
26
- # + "Temp/input"
27
- # + " --output_folder "
28
- # + "Temp"
29
- # + " --GPU "
30
- # + "-1"
31
- # + " --with_scratch")
32
- # run_cmd(command)
33
-
34
- # result = cv2.imread("Temp/final_output/input_img.png")
35
- # shutil.rmtree("Temp")
36
-
37
- result = Restoration(image)
38
 
 
 
39
  return result
40
 
41
  iface = gr.Interface(fn=run, inputs="image", outputs="image").launch(debug=True, share=True)
 
1
  import gradio as gr
2
  import os
3
+ import cv2
4
+ import shutil
5
+ import sys
6
+ from subprocess import call
 
7
 
8
  os.system("pip install dlib")
9
  os.system('bash setup.sh')
 
16
  sys.exit(1)
17
 
18
  def run(image):
19
+ os.makedirs("Temp")
20
+ os.makedirs("Temp/input")
21
+ print(type(image))
22
+ cv2.imwrite("Temp/input/input_img.png", image)
23
 
24
+ command = ("python run.py --input_folder "
25
+ + "Temp/input"
26
+ + " --output_folder "
27
+ + "Temp"
28
+ + " --GPU "
29
+ + "-1"
30
+ + " --with_scratch")
31
+ run_cmd(command)
 
 
 
 
 
32
 
33
+ result = cv2.imread("Temp/final_output/input_img.png")
34
+ shutil.rmtree("Temp")
35
  return result
36
 
37
  iface = gr.Interface(fn=run, inputs="image", outputs="image").launch(debug=True, share=True)