SweetSitara/Project
0
1import gradio as gr2from ultralytics import YOLO3from PIL import Image4import numpy as np5import cv26 7# Load the YOLO model8model = YOLO("best.pt") # Replace with "yolov8n.pt" or "yolov11.pt" if needed9 10def detect(image):11 # Save the uploaded image temporarily12 image.save("temp.jpg")13 14 # Perform object detection15 results = model("temp.jpg")16 17 # Get annotated result (BGR NumPy array)18 annotated_bgr = results[0].plot()19 20 # Convert BGR to RGB for correct color display21 annotated_rgb = cv2.cvtColor(annotated_bgr, cv2.COLOR_BGR2RGB)22 23 # Return as PIL image24 return Image.fromarray(annotated_rgb)25 26# Create Gradio interface27interface = gr.Interface(28 fn=detect,29 inputs=gr.Image(type="pil"),30 outputs=gr.Image(type="pil"),31 title="Indian Sign Language Recognition"32)33 34# Launch app35interface.launch()36 