File size: 881 Bytes
b488bef 47ee765 7f292e1 428e3e7 8762d1f 2863de0 7f292e1 cc8344a 7f292e1 cc8344a c000958 428e3e7 58e9978 8762d1f 7f292e1 cc8344a 7f292e1 cc8344a 428e3e7 47ee765 c000958 |
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 |
import gradio as gr
from ultralytics import YOLO
from PIL import Image
# Load YOLO model
model = YOLO("Suspicious_Activities_nano.pt")
# Define the prediction function
def predict_suspicious_activity(image):
results = model.predict(source=image, show=False, conf=0.6)
results_img = results[0].plot() # Get the image with bounding boxes/annotations
return Image.fromarray(results_img) # Get class names
# Create Gradio interface
interface = gr.Interface(
fn=predict_suspicious_activity, # Function to run on input
inputs=gr.Image(type="pil"), # Input type is image (PIL)
outputs=gr.Image(type="pil"), # Output type is image (PIL)
title="Suspicious Activity Detection with YOLO", # Interface title
description="Upload an image to detect suspicious activities.", # Description
)
# Launch the interface
interface.launch(share=True) |