KenjieDec commited on
Commit
c5c5bb4
·
verified ·
1 Parent(s): ef2a093

Faulty variable removed

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -11,7 +11,6 @@ import requests
11
  import datetime
12
  from gradio_imageslider import ImageSlider
13
 
14
- current_output = None
15
  for model_path in ['fbcnn_gray.pth','fbcnn_color.pth']:
16
  if os.path.exists(model_path):
17
  print(f'{model_path} exists.')
@@ -118,8 +117,6 @@ def inference(input_img, is_gray, res_percentage, input_quality, zoom, x_shift,
118
  if img_E.ndim == 3:
119
  img_E = img_E[:, :, [2, 1, 0]]
120
 
121
- global current_output
122
- current_output = img_E.copy()
123
  print("--inference finished")
124
 
125
  (in_img, out_img) = zoom_image(zoom, x_shift, y_shift, input_img, img_E)
@@ -128,11 +125,8 @@ def inference(input_img, is_gray, res_percentage, input_quality, zoom, x_shift,
128
  return img_E, (in_img, out_img)
129
 
130
  def zoom_image(zoom, x_shift, y_shift, input_img, output_img = None):
131
- global current_output
132
  if output_img is None:
133
- if current_output is None:
134
- return None
135
- output_img = current_output
136
 
137
  img = Image.fromarray(input_img)
138
  out_img = Image.fromarray(output_img)
@@ -187,9 +181,9 @@ with gr.Blocks() as demo:
187
  ["text.jpg", True, 100, 70, 50, 11, 29]
188
  ], inputs=[input_img, is_gray, max_res, input_quality, zoom, x_shift, y_shift])
189
 
190
- zoom.release(zoom_image, inputs=[zoom, x_shift, y_shift, input_img], outputs=[before_after])
191
- x_shift.release(zoom_image, inputs=[zoom, x_shift, y_shift, input_img], outputs=[before_after])
192
- y_shift.release(zoom_image, inputs=[zoom, x_shift, y_shift, input_img], outputs=[before_after])
193
 
194
  gr.Markdown("""
195
  JPEG Artifacts are noticeable distortions of images caused by JPEG lossy compression.
 
11
  import datetime
12
  from gradio_imageslider import ImageSlider
13
 
 
14
  for model_path in ['fbcnn_gray.pth','fbcnn_color.pth']:
15
  if os.path.exists(model_path):
16
  print(f'{model_path} exists.')
 
117
  if img_E.ndim == 3:
118
  img_E = img_E[:, :, [2, 1, 0]]
119
 
 
 
120
  print("--inference finished")
121
 
122
  (in_img, out_img) = zoom_image(zoom, x_shift, y_shift, input_img, img_E)
 
125
  return img_E, (in_img, out_img)
126
 
127
  def zoom_image(zoom, x_shift, y_shift, input_img, output_img = None):
 
128
  if output_img is None:
129
+ return None
 
 
130
 
131
  img = Image.fromarray(input_img)
132
  out_img = Image.fromarray(output_img)
 
181
  ["text.jpg", True, 100, 70, 50, 11, 29]
182
  ], inputs=[input_img, is_gray, max_res, input_quality, zoom, x_shift, y_shift])
183
 
184
+ zoom.release(zoom_image, inputs=[zoom, x_shift, y_shift, input_img, output_img], outputs=[before_after])
185
+ x_shift.release(zoom_image, inputs=[zoom, x_shift, y_shift, input_img, output_img], outputs=[before_after])
186
+ y_shift.release(zoom_image, inputs=[zoom, x_shift, y_shift, input_img, output_img], outputs=[before_after])
187
 
188
  gr.Markdown("""
189
  JPEG Artifacts are noticeable distortions of images caused by JPEG lossy compression.