umairrrkhan's picture
Update app.py
831fb22 verified
raw
history blame contribute delete
761 Bytes
import gradio as gr
import cv2
import numpy as np
# Function to process uploaded images
def process_image(image):
# Convert image to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Apply Canny edge detection
edges = cv2.Canny(gray, 100, 200)
# Convert edges back to 3-channel image for display
edges_bgr = cv2.cvtColor(edges, cv2.COLOR_GRAY2BGR)
return edges_bgr
# Gradio Interface
interface = gr.Interface(
fn=process_image,
inputs=gr.Image(type="numpy", label="Upload an Image"),
outputs=gr.Image(type="numpy", label="Edges Detected"),
title="Real-Time Edge Detection",
description="Upload an image to detect edges using Canny Edge Detection."
)
# Launch the app
interface.launch()