File size: 888 Bytes
9608bfe
 
27c6e3c
9608bfe
27c6e3c
 
 
 
 
9608bfe
27c6e3c
 
 
9608bfe
27c6e3c
 
 
9608bfe
27c6e3c
9608bfe
27c6e3c
9608bfe
27c6e3c
 
 
 
 
 
9608bfe
 
27c6e3c
9608bfe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
import cv2
import numpy as np

# Define a function that performs the image operation
def perform_image_operation(input_image1, input_image2):
    # Load the images using OpenCV
    image1 = cv2.imread(input_image1.name)
    image2 = cv2.imread(input_image2.name)

    # Perform the image operation (e.g., blending)
    alpha = 0.5  # Adjust alpha for blending
    blended_image = cv2.addWeighted(image1, alpha, image2, 1 - alpha, 0)

    # Save the result to a temporary file
    result_path = "result.png"
    cv2.imwrite(result_path, blended_image)

    return result_path

# Define the Gradio interface
iface = gr.Interface(
    fn=perform_image_operation,
    inputs=[
        gr.inputs.Image(label="Input Image 1"),
        gr.inputs.Image(label="Input Image 2")
    ],
    outputs=gr.outputs.Image(label="Blended Image")
)

# Start the Gradio app
iface.launch()