jon-pascal commited on
Commit
2d27e8d
1 Parent(s): c161754

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -344,9 +344,11 @@ def restore_on_gpu(
344
  torch.cuda.set_device(SUPIR_device)
345
 
346
  with torch.no_grad():
347
- input_image = Image.open(input_image_path)
 
 
348
  input_image = upscale_image(input_image, upscale, unit_resolution=32, min_size=min_size)
349
- LQ = np.array(input_image) / 255.0
350
  LQ = np.power(LQ, gamma_correction)
351
  LQ *= 255.0
352
  LQ = LQ.round().clip(0, 255).astype(np.uint8)
@@ -367,8 +369,8 @@ def restore_on_gpu(
367
  results = [x_samples[i] for i in range(num_samples)]
368
  torch.cuda.empty_cache()
369
 
370
- input_height, input_width, input_channel = np.array(input_image).shape
371
- result_height, result_width, result_channel = np.array(results[0]).shape
372
 
373
  print('Restoration completed.')
374
  end = time.time()
 
344
  torch.cuda.set_device(SUPIR_device)
345
 
346
  with torch.no_grad():
347
+ # Convert input image to NumPy array and ensure it has 3 channels
348
+ input_image = HWC3(np.array(Image.open(input_image_path)))
349
+
350
  input_image = upscale_image(input_image, upscale, unit_resolution=32, min_size=min_size)
351
+ LQ = input_image / 255.0
352
  LQ = np.power(LQ, gamma_correction)
353
  LQ *= 255.0
354
  LQ = LQ.round().clip(0, 255).astype(np.uint8)
 
369
  results = [x_samples[i] for i in range(num_samples)]
370
  torch.cuda.empty_cache()
371
 
372
+ input_height, input_width, input_channel = input_image.shape
373
+ result_height, result_width, result_channel = results[0].shape
374
 
375
  print('Restoration completed.')
376
  end = time.time()