torchyolo / app.py
kadirnar's picture
Update app.py
15bbe04
raw
history blame
2.07 kB
from torchyolo import YoloHub
import gradio as gr
"""
Paper Implementation
#"kadirnar/OcSort"
#"kadirnar/SORT"
"""
def object_tracker(
source: str,
model_type: str,
model_path: str,
tracker_type: str,
tracker_config_path: str,
):
model = YoloHub(
config_path="default_config.yaml",
model_type=model_type,
model_path=model_path,
)
model.predict(
source=source,
tracker_type=tracker_type,
tracker_config_path=tracker_config_path,
)
return 'output.mp4'
inputs = [
gr.Video(),
gr.inputs.Dropdown(
label="Model Type",
choices=["yolov5", "yolov6", "yolov8"],
default="yolov5",
),
gr.inputs.Dropdown(
label="Model Path",
choices=[
"kadirnar/yolov5s6-v6.0",
"kadirnar/yolov6m-v3.0",
"kadirnar/yolov8n-v8.0",
],
default="kadirnar/yolov5s6-v6.",
),
gr.inputs.Dropdown(
label="Tracker Type",
choices=["NORFAIR", "STRONGSORT", "OCSORT", "BYTETRACK", "SORT"],
default="NORFAIR",
),
gr.inputs.Dropdown(
label="Tracker Config Path",
choices=[
"tracker/norfair_track.yaml",
"tracker/strong_sort.yaml",
"tracker/oc_sort.yaml",
"tracker/byte_track.yaml",
"tracker/sort_track.yaml",
],
default="tracker/norfair_track.yaml",
),
]
examples = [
[
"test.mp4",
"yolov5",
"kadirnar/yolov5s6-v6.0",
"SORT",
"tracker/sort_track.yaml",
],
[
"testv2.mp4",
"yolov6",
"kadirnar/yolov6m-v3.0",
"OCSORT",
"tracker/oc_sort.yaml"
]
]
outputs = gr.Video()
title = "TorchYolo: YOLO Series Object Detection and Track Algorithm Library"
demo_app = gr.Interface(
fn=object_tracker,
inputs=inputs,
examples=examples,
outputs=outputs,
title=title,
cache_examples=False,
theme='huggingface',
)
demo_app.launch(debug=True, enable_queue=True)