yashzambre commited on
Commit
ee05941
·
1 Parent(s): 405a302

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -3,9 +3,9 @@ import cv2
3
  import numpy as np
4
 
5
  # Define a function that performs the image operation with adjustable blending weight
6
- def perform_image_operation(image1, image2, image3, image4, image5, image6, image7, image8, blending_weight=0.5):
7
  # Convert the Gradio input images to NumPy arrays
8
- images = [image1, image2, image3, image4, image5, image6, image7, image8]
9
 
10
  # Perform the image operation (e.g., blending)
11
  result_image = images[0].copy()
@@ -16,11 +16,19 @@ def perform_image_operation(image1, image2, image3, image4, image5, image6, imag
16
  result_pil_image = cv2.cvtColor(result_image, cv2.COLOR_BGR2RGB)
17
  return result_pil_image
18
 
19
- # Define the Gradio interface with an adjustable blending weight slider
20
  iface = gr.Interface(
21
  fn=perform_image_operation,
22
  inputs=[
23
- gr.File(file_count='multiple')
 
 
 
 
 
 
 
 
24
  ],
25
  outputs=gr.outputs.Image(type="pil", label="Blended Image")
26
  )
 
3
  import numpy as np
4
 
5
  # Define a function that performs the image operation with adjustable blending weight
6
+ def perform_image_operation(images, blending_weight=0.5):
7
  # Convert the Gradio input images to NumPy arrays
8
+ images = [np.array(img) for img in images]
9
 
10
  # Perform the image operation (e.g., blending)
11
  result_image = images[0].copy()
 
16
  result_pil_image = cv2.cvtColor(result_image, cv2.COLOR_BGR2RGB)
17
  return result_pil_image
18
 
19
+ # Define the Gradio interface with multiple file uploads and an adjustable blending weight slider
20
  iface = gr.Interface(
21
  fn=perform_image_operation,
22
  inputs=[
23
+ gr.File(type="image", label="Image 1", multiple=True),
24
+ gr.File(type="image", label="Image 2", multiple=True),
25
+ gr.File(type="image", label="Image 3", multiple=True),
26
+ gr.File(type="image", label="Image 4", multiple=True),
27
+ gr.File(type="image", label="Image 5", multiple=True),
28
+ gr.File(type="image", label="Image 6", multiple=True),
29
+ gr.File(type="image", label="Image 7", multiple=True),
30
+ gr.File(type="image", label="Image 8", multiple=True),
31
+ gr.Slider(minimum=0, maximum=1, default=0.5, label="Blending Weight"),
32
  ],
33
  outputs=gr.outputs.Image(type="pil", label="Blended Image")
34
  )