yashzambre commited on
Commit
83fd970
·
1 Parent(s): 8e6237a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -2,22 +2,33 @@ import gradio as gr
2
  import cv2
3
  import numpy as np
4
 
5
- # Define a function that performs the image operation
6
- def perform_image_operation(image1, image2):
 
 
 
7
  # Perform the image operation (e.g., blending)
8
- alpha = 0.5 # Adjust alpha for blending
9
- blended_image = cv2.addWeighted(image1, alpha, image2, 1 - alpha, 0)
 
10
 
11
  # Convert the result image to PIL format for Gradio display
12
- result_pil_image = cv2.cvtColor(blended_image, cv2.COLOR_BGR2RGB)
13
  return result_pil_image
14
 
15
- # Define the Gradio interface
16
  iface = gr.Interface(
17
  fn=perform_image_operation,
18
  inputs=[
19
  gr.inputs.Image(label="Input Image 1"),
20
- gr.inputs.Image(label="Input Image 2")
 
 
 
 
 
 
 
21
  ],
22
  outputs=gr.outputs.Image(type="pil", label="Blended Image")
23
  )
 
2
  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()
12
+ for img in images[1:]:
13
+ result_image = cv2.addWeighted(result_image, 1 - blending_weight, img, blending_weight, 0)
14
 
15
  # Convert the result image to PIL format for Gradio display
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.inputs.Image(label="Input Image 1"),
24
+ gr.inputs.Image(label="Input Image 2"),
25
+ gr.inputs.Image(label="Input Image 3"),
26
+ gr.inputs.Image(label="Input Image 4"),
27
+ gr.inputs.Image(label="Input Image 5"),
28
+ gr.inputs.Image(label="Input Image 6"),
29
+ gr.inputs.Image(label="Input Image 7"),
30
+ gr.inputs.Image(label="Input Image 8"),
31
+ gr.inputs.Slider(label="Blending Weight", minimum=0.0, maximum=1.0, default=0.5, step=0.01)
32
  ],
33
  outputs=gr.outputs.Image(type="pil", label="Blended Image")
34
  )