Ahsen Khaliq commited on
Commit
f1d72e1
1 Parent(s): 5eda779

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -24,10 +24,10 @@ run_cmd("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/Re
24
  run_cmd("pip install basicsr")
25
  run_cmd("pip freeze")
26
 
27
- #run_cmd("python setup.py develop")
28
 
29
 
30
- def inference(img):
31
  _id = randint(1, 10000)
32
  INPUT_DIR = "/tmp/input_image" + str(_id) + "/"
33
  OUTPUT_DIR = "/tmp/output_image" + str(_id) + "/"
@@ -40,7 +40,10 @@ def inference(img):
40
  hsize = int((float(img.size[1])*float(wpercent)))
41
  img = img.resize((basewidth,hsize), Image.ANTIALIAS)
42
  img.save(INPUT_DIR + "1.jpg", "JPEG")
43
- run_cmd("python inference_realesrgan.py --model_path RealESRGAN_x4plus.pth --input "+ INPUT_DIR + " --output " + OUTPUT_DIR + " --netscale 4 --outscale 4")
 
 
 
44
  return os.path.join(OUTPUT_DIR, "1_out.jpg")
45
 
46
 
@@ -52,7 +55,7 @@ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2107.108
52
 
53
  gr.Interface(
54
  inference,
55
- [gr.inputs.Image(type="pil", label="Input")],
56
  gr.outputs.Image(type="file", label="Output"),
57
  title=title,
58
  description=description,
 
24
  run_cmd("pip install basicsr")
25
  run_cmd("pip freeze")
26
 
27
+ os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P .")
28
 
29
 
30
+ def inference(img,mode):
31
  _id = randint(1, 10000)
32
  INPUT_DIR = "/tmp/input_image" + str(_id) + "/"
33
  OUTPUT_DIR = "/tmp/output_image" + str(_id) + "/"
 
40
  hsize = int((float(img.size[1])*float(wpercent)))
41
  img = img.resize((basewidth,hsize), Image.ANTIALIAS)
42
  img.save(INPUT_DIR + "1.jpg", "JPEG")
43
+ if mode == "base":
44
+ run_cmd("python inference_realesrgan.py --model_path RealESRGAN_x4plus.pth --input "+ INPUT_DIR + " --output " + OUTPUT_DIR + " --netscale 4 --outscale 4")
45
+ else:
46
+ os.system("python inference_realesrgan.py -n RealESRGAN_x4plus_anime_6B -i "+ INPUT_DIR + " --output " + OUTPUT_DIR)
47
  return os.path.join(OUTPUT_DIR, "1_out.jpg")
48
 
49
 
 
55
 
56
  gr.Interface(
57
  inference,
58
+ [gr.inputs.Image(type="pil", label="Input"),gradio.inputs.Radio(["base","anime"], type="value", default="base", label="model type")],
59
  gr.outputs.Image(type="file", label="Output"),
60
  title=title,
61
  description=description,