Xintao commited on
Commit
eef4068
1 Parent(s): c21c011

robust to scale input

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -64,10 +64,13 @@ def inference(img, version, scale):
64
  else:
65
 
66
  extension = 'png'
67
- if scale != 2:
68
- interpolation = cv2.INTER_AREA if scale < 2 else cv2.INTER_LANCZOS4
69
- h, w = img.shape[0:2]
70
- output = cv2.resize(output, (int(w * scale /2), int(h * scale/2)), interpolation=interpolation)
 
 
 
71
  if img_mode == 'RGBA': # RGBA images should be saved in png format
72
  extension = 'png'
73
  else:
 
64
  else:
65
 
66
  extension = 'png'
67
+ try:
68
+ if scale != 2:
69
+ interpolation = cv2.INTER_AREA if scale < 2 else cv2.INTER_LANCZOS4
70
+ h, w = img.shape[0:2]
71
+ output = cv2.resize(output, (int(w * scale /2), int(h * scale/2)), interpolation=interpolation)
72
+ except:
73
+ print('wrong scale input')
74
  if img_mode == 'RGBA': # RGBA images should be saved in png format
75
  extension = 'png'
76
  else: