增加了单帧入侵判断及yoloV10
This commit is contained in:
@ -128,6 +128,8 @@ def init_trackers(tracker_yaml = None, bs=1):
|
||||
"""
|
||||
# tracker_yaml = r"./tracking/trackers/cfg/botsort.yaml"
|
||||
|
||||
tracker_yaml = str(tracker_yaml)
|
||||
|
||||
TRACKER_MAP = {'bytetrack': BYTETracker, 'botsort': BOTSORT}
|
||||
|
||||
cfg = IterableSimpleNamespace(**yaml_load(tracker_yaml))
|
||||
@ -149,7 +151,7 @@ def yolov10_resnet_tracker(
|
||||
is_save_img = True,
|
||||
is_save_video = True,
|
||||
|
||||
tracker_yaml = "./tracking/trackers/cfg/botsort.yaml",
|
||||
tracker_yaml = ROOT / "tracking/trackers/cfg/botsort.yaml",
|
||||
line_thickness=3, # bounding box thickness (pixels)
|
||||
hide_labels=False, # hide labels
|
||||
):
|
||||
@ -157,7 +159,7 @@ def yolov10_resnet_tracker(
|
||||
## load a custom model
|
||||
model = YOLOv10(weights)
|
||||
|
||||
custom = {"conf": 0.25, "batch": 1, "save": False, "mode": "predict"}
|
||||
custom = {"conf": 0.1, "batch": 1, "save": False, "mode": "predict"}
|
||||
kwargs = {"save": True, "imgsz": 640, "conf": 0.1}
|
||||
args = {**model.overrides, **custom, **kwargs}
|
||||
predictor = model.task_map[model.task]["predictor"](overrides=args, _callbacks=model.callbacks)
|
||||
@ -294,7 +296,7 @@ def yolo_resnet_tracker(
|
||||
is_save_img = True,
|
||||
is_save_video = True,
|
||||
|
||||
tracker_yaml = "./tracking/trackers/cfg/botsort.yaml",
|
||||
tracker_yaml = ROOT / "tracking/trackers/cfg/botsort.yaml",
|
||||
imgsz=(640, 640), # inference size (height, width)
|
||||
conf_thres=0.25, # confidence threshold
|
||||
iou_thres=0.45, # NMS IOU threshold
|
||||
@ -359,6 +361,7 @@ def yolo_resnet_tracker(
|
||||
# Process predictions
|
||||
for i, det in enumerate(pred): # per image
|
||||
im0 = im0s.copy()
|
||||
|
||||
annotator = Annotator(im0.copy(), line_width=line_thickness, example=str(names))
|
||||
s += '%gx%g ' % im.shape[2:] # print string
|
||||
if len(det):
|
||||
@ -438,7 +441,7 @@ def yolo_resnet_tracker(
|
||||
if dataset.mode == 'image':
|
||||
imgpath = save_path_img + ".png"
|
||||
else:
|
||||
imgpath = save_path_img + f"_{frameId}.png"
|
||||
imgpath = save_path_img + f"_{frameId}.png"
|
||||
cv2.imwrite(Path(imgpath), im0)
|
||||
|
||||
# if dataset.mode == 'video' and is_save_video:
|
||||
@ -461,6 +464,7 @@ def yolo_resnet_tracker(
|
||||
else: # stream
|
||||
fps, w, h = 25, im0.shape[1], im0.shape[0]
|
||||
## for image rotating in dataloader.LoadImages.__next__()
|
||||
|
||||
w, h = im0.shape[1], im0.shape[0]
|
||||
|
||||
vdieo_path = str(Path(vdieo_path).with_suffix('.mp4')) # force *.mp4 suffix on results videos
|
||||
@ -484,7 +488,7 @@ def run(
|
||||
project=ROOT / 'runs/detect', # save results to project/name
|
||||
name='exp', # save results to project/name
|
||||
|
||||
tracker_yaml = "./tracking/trackers/cfg/botsort.yaml",
|
||||
tracker_yaml = ROOT / "tracking/trackers/cfg/botsort.yaml",
|
||||
imgsz=(640, 640), # inference size (height, width)
|
||||
conf_thres=0.25, # confidence threshold
|
||||
iou_thres=0.45, # NMS IOU threshold
|
||||
|
Reference in New Issue
Block a user