yashzambre commited on
Commit
2430c5c
·
1 Parent(s): 2a99ae8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -1,13 +1,18 @@
1
  import gradio as gr
2
-
3
  import cv2
4
  import numpy as np
5
- def process_images(files,blending_weight=0.5):
 
6
  # Process the uploaded image files here
7
  # You can access the uploaded files in the 'files' parameter as a list
8
  # For example, you can loop through the files and perform operations on them
9
  images = [np.array(img) for img in files]
10
 
 
 
 
 
 
11
  # Perform the image operation (e.g., blending)
12
  result_image = images[0].copy()
13
  for img in images[1:]:
@@ -19,9 +24,8 @@ def process_images(files,blending_weight=0.5):
19
 
20
  iface = gr.Interface(
21
  fn=process_images,
22
- inputs=gr.components.File(label="Upload Multiple Images", type="file", file_count='multiple'),
23
- outputs=gr.components.Image(type="pil", label="Blended Image")
24
  )
25
 
26
-
27
  iface.launch()
 
1
  import gradio as gr
 
2
  import cv2
3
  import numpy as np
4
+
5
+ def process_images(files, blending_weight=0.5):
6
  # Process the uploaded image files here
7
  # You can access the uploaded files in the 'files' parameter as a list
8
  # For example, you can loop through the files and perform operations on them
9
  images = [np.array(img) for img in files]
10
 
11
+ # Ensure all images have the same data type (CV_8U)
12
+ for i in range(len(images)):
13
+ if images[i].dtype != np.uint8:
14
+ images[i] = images[i].astype(np.uint8)
15
+
16
  # Perform the image operation (e.g., blending)
17
  result_image = images[0].copy()
18
  for img in images[1:]:
 
24
 
25
  iface = gr.Interface(
26
  fn=process_images,
27
+ inputs=gr.inputs.Image(type="pil", label="Upload Multiple Images", multiple=True),
28
+ outputs=gr.outputs.Image(type="pil", label="Blended Image")
29
  )
30
 
 
31
  iface.launch()