comrender commited on
Commit
c2d1871
·
verified ·
1 Parent(s): 9047ade

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -189,7 +189,7 @@ def esrgan_upscale(image, model, device='cuda', upscale_factor=4):
189
  if low_res_w < 1 or low_res_h < 1:
190
  raise ValueError("Upscale factor too small for image size")
191
 
192
- low_res_image = image.resize((low_res_w, low_res_h), Image.LANCZOS)
193
 
194
  # Prepare image
195
  img_np = np.array(low_res_image).astype(np.float32) / 255.
@@ -210,7 +210,7 @@ def esrgan_upscale(image, model, device='cuda', upscale_factor=4):
210
  target_w = int(orig_w * upscale_factor)
211
  target_h = int(orig_h * upscale_factor)
212
  if upscaled.size != (target_w, target_h):
213
- upscaled = upscaled.resize((target_w, target_h), Image.LANCZOS)
214
 
215
  return upscaled
216
 
@@ -346,7 +346,7 @@ with gr.Blocks(css=css) as demo:
346
  maximum=4,
347
  step=1,
348
  value=4,
349
- info="Choose upscale factor (2x, 3x, 4x)"
350
  )
351
 
352
  num_inference_steps = gr.Slider(
 
189
  if low_res_w < 1 or low_res_h < 1:
190
  raise ValueError("Upscale factor too small for image size")
191
 
192
+ low_res_image = image.resize((low_res_w, low_res_h), Image.BICUBIC) # Changed to BICUBIC for better match to training degradation
193
 
194
  # Prepare image
195
  img_np = np.array(low_res_image).astype(np.float32) / 255.
 
210
  target_w = int(orig_w * upscale_factor)
211
  target_h = int(orig_h * upscale_factor)
212
  if upscaled.size != (target_w, target_h):
213
+ upscaled = upscaled.resize((target_w, target_h), Image.BICUBIC) # Changed to BICUBIC
214
 
215
  return upscaled
216
 
 
346
  maximum=4,
347
  step=1,
348
  value=4,
349
+ info="Choose upscale factor (2x, 3x, 4x). Use 4x for best results; lower may cause color artifacts."
350
  )
351
 
352
  num_inference_steps = gr.Slider(