File size: 2,132 Bytes
df7bbea 7bec948 df7bbea 06b6bf9 df7bbea 7bec948 06b6bf9 df7bbea 06b6bf9 df7bbea |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
import os
os.system("pip3 install cython_bbox gdown 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'")
from torchyolo import YoloHub
import gradio as gr
from utils import attempt_download_from_hub
def object_tracker(
source: str,
model_type: str,
model_path: str,
tracker_type: str,
tracker_config_path: str,
StrongSort_OsNet_Path: str = None,
):
model = YoloHub(
config_path="default_config.yaml",
model_type=model_type,
model_path=model_path,
)
if tracker_type == "STRONGSORT":
StrongSort_OsNet_Path = attempt_download_from_hub(StrongSort_OsNet_Path)
model.predict(
source=source,
tracker_type=tracker_type,
tracker_weight_path=StrongSort_OsNet_Path,
tracker_config_path=tracker_config_path,
)
return 'output.mp4'
inputs = [
gr.Video(),
gr.inputs.Dropdown(
label="Model Type",
choices=["yolov5"],
default="yolov5",
),
gr.inputs.Dropdown(
label="Model Path",
choices=[
"aijack/v5s" ],
default="aijack/v5s",
),
gr.inputs.Dropdown(
label="Tracker Type",
choices=["OCSORT"],
default="OCSORT",
),
gr.inputs.Dropdown(
label="Tracker Config Path",
choices=[
"tracker/oc_sort.yaml",
],
default="tracker/oc_sort.yaml",
),
gr.inputs.Dropdown(
label="Tracker Weight Path",
choices=[
"aijack/osnet"
],
default="aijack/osnet",
),
]
examples = [
[
"01.mp4",
"yolov5",
"aijack/v5s",
"OCSORT",
"tracker/oc_sort.yaml",
]
]
outputs = gr.Video()
title = "YOLOV5 Object Detection and Track Algorithm Library"
article = "<p style='text-align: center'><a href='http://claireye.com.tw'>Claireye</a> | 2023</p>"
demo_app = gr.Interface(
fn=object_tracker,
inputs=inputs,
examples=examples,
outputs=outputs,
title=title,
article = article,
cache_examples=False
)
demo_app.launch(debug=True, enable_queue=True) |