abiabidali commited on
Commit
53cd4b7
·
verified ·
1 Parent(s): 44a27e2

Update app.py

Browse files

Using gr.Files for file inputs

Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -60,11 +60,12 @@ def resize_image(input_image, width, height):
60
  temp_file.close()
61
  return Image.open(temp_file.name)
62
 
63
- def process_images(input_images, enhance, scale, adjust_dpi, dpi, resize, width, height):
64
  processed_images = []
65
  file_paths = []
66
 
67
- for input_image in input_images:
 
68
  original_image = Image.fromarray(input_image.astype('uint8'), 'RGB')
69
 
70
  if enhance:
@@ -86,7 +87,7 @@ def process_images(input_images, enhance, scale, adjust_dpi, dpi, resize, width,
86
  iface = gr.Interface(
87
  fn=process_images,
88
  inputs=[
89
- gr.Images(label="Upload Images"), # Use gr.Images for multi-image upload
90
  gr.Checkbox(label="Enhance Images (ESRGAN)"),
91
  gr.Radio(['2x', '4x', '8x'], type="value", value='2x', label='Resolution model'),
92
  gr.Checkbox(label="Adjust DPI"),
 
60
  temp_file.close()
61
  return Image.open(temp_file.name)
62
 
63
+ def process_images(image_files, enhance, scale, adjust_dpi, dpi, resize, width, height):
64
  processed_images = []
65
  file_paths = []
66
 
67
+ for image_file in image_files:
68
+ input_image = np.array(Image.open(image_file).convert('RGB'))
69
  original_image = Image.fromarray(input_image.astype('uint8'), 'RGB')
70
 
71
  if enhance:
 
87
  iface = gr.Interface(
88
  fn=process_images,
89
  inputs=[
90
+ gr.Files(label="Upload Image Files"), # Use gr.Files for multiple file uploads
91
  gr.Checkbox(label="Enhance Images (ESRGAN)"),
92
  gr.Radio(['2x', '4x', '8x'], type="value", value='2x', label='Resolution model'),
93
  gr.Checkbox(label="Adjust DPI"),