Abs6187's picture
Update app.py
cc8344a verified
raw
history blame contribute delete
881 Bytes
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)