Abs6187's picture
Update app.py
8762d1f verified
raw
history blame
647 Bytes
import gradio as gr
from ultralytics import YOLO
# Load YOLO model
model = YOLO("Suspicious_Activities_nano.pt")
# Define a function to predict and return the result
def predict_suspicious_activity(image):
results = model.predict(source=image, show=True, conf=0.6)
return results.pandas().xywh[0].to_dict() # Adjust as per your model output structure
# Create Gradio interface
interface = gr.Interface(
fn=predict_suspicious_activity,
inputs=gr.inputs.Image(type="pil"), # Input type for uploading images
outputs="json" # Output type (you can adjust this based on your needs)
)
# Launch the interface
interface.launch()