File size: 534 Bytes
85006c3
3ef32da
6ca3b52
85006c3
6ca3b52
 
8fe8be0
718657d
3ef32da
 
 
718657d
ac9eb6d
718657d
 
a9d8847
8fe8be0
de8582c
718657d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
import cv2
from ultralytics import YOLO

def run(source):
    global model
    res = model(source, conf=.5, iou=.5)
    res_plotted = res[0].plot()
    # converting BGR to RGB
    result = cv2.cvtColor(res_plotted, cv2.COLOR_BGR2RGB)
    return result
    
model = YOLO("yolov8n-nckh2023.pt") # Select YOLO model

gr.Interface(
    run,
    inputs=gr.Image(label="Upload image", type="filepath"),
    outputs=gr.Image(label="Your result"),
    title="Motorcyclist, helmet, and license plate detection",
).launch()