NickKolok commited on
Commit
eda498a
·
verified ·
1 Parent(s): 3923e8c
Files changed (1) hide show
  1. app.py +7 -13
app.py CHANGED
@@ -13,8 +13,6 @@ import psutil
13
 
14
 
15
 
16
-
17
- torch.hub.download_url_to_file('http://people.csail.mit.edu/billf/project%20pages/sresCode/Markov%20Random%20Fields%20for%20Super-Resolution_files/100075_lowres.jpg', 'bear.jpg')
18
 
19
 
20
  def run_cmd(command):
@@ -24,11 +22,13 @@ def run_cmd(command):
24
  except KeyboardInterrupt:
25
  print("Process interrupted")
26
  sys.exit(1)
 
27
  run_cmd("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P .")
 
 
28
  run_cmd("pip install basicsr")
29
  run_cmd("pip freeze")
30
 
31
- os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P .")
32
 
33
 
34
  def inference(img,mode):
@@ -39,10 +39,7 @@ def inference(img,mode):
39
  run_cmd("rm -rf " + OUTPUT_DIR)
40
  run_cmd("mkdir -p " + INPUT_DIR)
41
  run_cmd("mkdir -p " + OUTPUT_DIR)
42
- basewidth = 256
43
- wpercent = (basewidth/float(img.size[0]))
44
- hsize = int((float(img.size[1])*float(wpercent)))
45
- #img = img.resize((basewidth,hsize), Image.LANCZOS)
46
  img.save(INPUT_DIR + "1.png", "PNG")
47
  if mode == "base":
48
  run_cmd("python inference_realesrgan.py -n RealESRGAN_x4plus -i "+ INPUT_DIR + " -o " + OUTPUT_DIR)
@@ -59,12 +56,9 @@ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2107.108
59
 
60
  gr.Interface(
61
  inference,
62
- [gr.inputs.Image(type="pil", label="Input"),gr.inputs.Radio(["base","anime"], type="value", default="base", label="model type")],
63
  gr.outputs.Image(type="file", label="Output"),
64
  title=title,
65
  description=description,
66
- article=article,
67
- examples=[
68
- #['bear.jpg','base'],
69
- #['anime.png','anime']
70
- ]).launch()
 
13
 
14
 
15
 
 
 
16
 
17
 
18
  def run_cmd(command):
 
22
  except KeyboardInterrupt:
23
  print("Process interrupted")
24
  sys.exit(1)
25
+
26
  run_cmd("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P .")
27
+ run_cmd("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P .")
28
+
29
  run_cmd("pip install basicsr")
30
  run_cmd("pip freeze")
31
 
 
32
 
33
 
34
  def inference(img,mode):
 
39
  run_cmd("rm -rf " + OUTPUT_DIR)
40
  run_cmd("mkdir -p " + INPUT_DIR)
41
  run_cmd("mkdir -p " + OUTPUT_DIR)
42
+
 
 
 
43
  img.save(INPUT_DIR + "1.png", "PNG")
44
  if mode == "base":
45
  run_cmd("python inference_realesrgan.py -n RealESRGAN_x4plus -i "+ INPUT_DIR + " -o " + OUTPUT_DIR)
 
56
 
57
  gr.Interface(
58
  inference,
59
+ [gr.inputs.Image(type="pil", label="Input"),gr.inputs.Radio(["base","anime"], type="value", default="anime", label="model type")],
60
  gr.outputs.Image(type="file", label="Output"),
61
  title=title,
62
  description=description,
63
+ article=article
64
+ ).launch()