Spaces:
Runtime error
Runtime error
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() | |