danielsapit commited on
Commit
fb4f2b9
1 Parent(s): 3ae9a61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -8,6 +8,7 @@ from PIL import Image, ImageOps
8
  import utils_image as util
9
  from network_fbcnn import FBCNN as net
10
  import requests
 
11
 
12
  for model_path in ['fbcnn_gray.pth','fbcnn_color.pth']:
13
  if os.path.exists(model_path):
@@ -19,8 +20,16 @@ for model_path in ['fbcnn_gray.pth','fbcnn_color.pth']:
19
  open(model_path, 'wb').write(r.content)
20
 
21
  def inference(input_img, is_gray, input_quality, zoom, x_shift, y_shift):
22
-
23
- print("img size:",Image.fromarray(input_img).size)
 
 
 
 
 
 
 
 
24
 
25
  if is_gray:
26
  n_channels = 1 # set 1 for grayscale image, set 3 for color image
 
8
  import utils_image as util
9
  from network_fbcnn import FBCNN as net
10
  import requests
11
+ import datetime
12
 
13
  for model_path in ['fbcnn_gray.pth','fbcnn_color.pth']:
14
  if os.path.exists(model_path):
 
20
  open(model_path, 'wb').write(r.content)
21
 
22
  def inference(input_img, is_gray, input_quality, zoom, x_shift, y_shift):
23
+
24
+ print("datetime:",datetime.datetime.utcnow())
25
+ input_img_width, input_img_height = Image.fromarray(input_img).size
26
+ print("img size:",(input_img_width,input_img_height))
27
+
28
+ if (input_img_width > 1080) or (input_img_height > 1080):
29
+ resize_ratio = min(1080/input_img_width, 1080/input_img_height)
30
+ resized_input = Image.fromarray(input_img).resize((int(input_img_width*resize_ratio),int(input_img_height*resize_ratio)),resample=Image.BICUBIC)
31
+ input_img = np.array(resized_input)
32
+ print("input image resized to:", resized_input.size)
33
 
34
  if is_gray:
35
  n_channels = 1 # set 1 for grayscale image, set 3 for color image