yashzambre commited on
Commit
bec2695
·
1 Parent(s): 765e4f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -4,19 +4,21 @@ def process_images(files):
4
  # Process the uploaded image files here
5
  # You can access the uploaded files in the 'files' parameter as a list
6
  # For example, you can loop through the files and perform operations on them
7
- processed_images = []
8
 
9
- for file in files:
10
- # Here, you can perform some image processing on 'file' (e.g., display it, analyze it, etc.)
11
- # In this example, we'll just return the filenames of the uploaded images.
12
- processed_images.append(file.name)
13
-
14
- return processed_images
 
 
15
 
16
  iface = gr.Interface(
17
  fn=process_images,
18
  inputs=gr.inputs.File(label="Upload Multiple Images", type="file", file_count='multiple'),
19
- outputs="text",
20
  live=True,
21
  )
22
 
 
4
  # Process the uploaded image files here
5
  # You can access the uploaded files in the 'files' parameter as a list
6
  # For example, you can loop through the files and perform operations on them
7
+ images = [np.array(img) for img in files]
8
 
9
+ # Perform the image operation (e.g., blending)
10
+ result_image = images[0].copy()
11
+ for img in images[1:]:
12
+ result_image = cv2.addWeighted(result_image, 1 - blending_weight, img, blending_weight, 0)
13
+
14
+ # Convert the result image to PIL format for Gradio display
15
+ result_pil_image = cv2.cvtColor(result_image, cv2.COLOR_BGR2RGB)
16
+ return result_pil_image
17
 
18
  iface = gr.Interface(
19
  fn=process_images,
20
  inputs=gr.inputs.File(label="Upload Multiple Images", type="file", file_count='multiple'),
21
+ outputs=gr.outputs.Image(type="pil", label="Blended Image")
22
  live=True,
23
  )
24