tomaseo2022 commited on
Commit
3a7fb02
1 Parent(s): 005fee0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -13,17 +13,17 @@ import numpy as np
13
  os.system('wget https://github.com/JingyunLiang/SwinIR/releases/download/v0.0/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth -P experiments/pretrained_models')
14
 
15
  def inference(img):
 
 
 
16
  try:
17
- if isinstance(img, Image.Image):
18
- basewidth = 256
19
- wpercent = basewidth / float(img.width)
20
- hsize = int(float(img.height) * float(wpercent))
21
- img_resized = img.resize((basewidth, hsize))
22
- img_resized.save("test/1.jpg", "JPEG")
23
- os.system('python main_test_swinir.py --task real_sr --model_path experiments/pretrained_models/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth --folder_lq test --scale 4')
24
- return 'results/swinir_real_sr_x4/1_SwinIR.png'
25
- else:
26
- return "Error: La entrada no es una imagen válida."
27
  except Exception as e:
28
  return f"Error: {str(e)}"
29
 
 
13
  os.system('wget https://github.com/JingyunLiang/SwinIR/releases/download/v0.0/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth -P experiments/pretrained_models')
14
 
15
  def inference(img):
16
+ if not isinstance(img, Image.Image):
17
+ return "Error: La entrada no es una imagen válida."
18
+
19
  try:
20
+ basewidth = 256
21
+ wpercent = basewidth / float(img.width)
22
+ hsize = int(float(img.height) * float(wpercent))
23
+ img_resized = img.resize((basewidth, hsize))
24
+ img_resized.save("test/1.jpg", "JPEG")
25
+ os.system('python main_test_swinir.py --task real_sr --model_path experiments/pretrained_models/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth --folder_lq test --scale 4')
26
+ return 'results/swinir_real_sr_x4/1_SwinIR.png'
 
 
 
27
  except Exception as e:
28
  return f"Error: {str(e)}"
29