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()