Spaces:
Runtime error
Runtime error
Commit
·
bec2695
1
Parent(s):
765e4f7
Update app.py
Browse files
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 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
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="
|
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 |
|