Spaces:
Running
Running
File size: 1,432 Bytes
acad9f5 |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import gradio as gr
from utils import (
sobel_edge_detection,
canny_edge_detection,
hough_lines,
laplacian_edge_detection,
contours_detection,
prewitt_edge_detection,
gradient_magnitude,
corner_detection,
)
def predict_image( input_image,algorithm):
algorithm_functions = {
"Sobel Edge Detection": sobel_edge_detection,
"Canny Edge Detection": canny_edge_detection,
"Hough Lines": hough_lines,
"Laplacian Edge Detection": laplacian_edge_detection,
"Contours Detection": contours_detection,
"Prewitt Edge Detection": prewitt_edge_detection,
"Gradient Magnitude": gradient_magnitude,
"Corner Detection": corner_detection,
}
# Apply the selected image processing algorithm
if algorithm in algorithm_functions:
processed_image = algorithm_functions[algorithm](input_image)
else:
processed_image = input_image # Default to original image if algorithm not found
return processed_image
GrImage = gr.Image()
GrDropdown = gr.Dropdown(
[
"Sobel Edge Detection",
"Canny Edge Detection",
"Hough Lines",
"Laplacian Edge Detection",
"Contours Detection",
"Prewitt Edge Detection",
"Gradient Magnitude",
"Corner Detection",
]
)
iface = gr.Interface(fn=predict_image, inputs=[GrImage, GrDropdown], outputs="image")
iface.launch()
|