Add object detection, tracking, mobile notifications, and search to any security camera.
add tracking to test
rorycleare9fa29cc22c1
diff --git a/detection/yolov9.py b/detection/yolov9.pyindex a5e6533..e960f75 100644--- a/detection/yolov9.py+++ b/detection/yolov9.py@@ -477,9 +477,9 @@ def draw_bounding_boxes(orig_img_path, predictions, class_labels):box_thickness = int((height + width) / 400)font_scale = (height + width) / 2500object_count = defaultdict(int)-+for pred in predictions:- x1, y1, x2, y2, conf, class_id = pred+ x1, y1, x2, y2, conf, class_id, _ = predif conf == 0:continuediff --git a/test/test_outputs.py b/test/test_mot.pysimilarity index 81%rename from test/test_outputs.pyrename to test/test_mot.pyindex 590dab7..6b2c253 100644--- a/test/test_outputs.py+++ b/test/test_mot.py@@ -35,6 +35,14 @@ def letterbox(im, new_shape=(1280, 1280), color=(114, 114, 114), auto=True, scalreturn im, ratio, (dw, dh)if __name__ == "__main__":+ from yolox.tracker.byte_tracker import BYTETracker+ class Args:+ def __init__(self):+ self.track_buffer = 60 # frames, was 30+ self.mot20 = False+ self.match_thresh = 0.9+ tracker = BYTETracker(Args())+size = "t"model = YOLOv9(*SIZES[size]) if size in SIZES else YOLOv9()state_dict = safe_load(fetch(f'https://huggingface.co/roryclear/yolov9/resolve/main/yolov9-{size}.safetensors'))@@ -56,9 +64,13 @@ if __name__ == "__main__":if len(im.shape) == 3:im = im[None]pred = do_inf(im, model).numpy()[0]- pred = pred[pred[:, 4] >= 0.25]+ online_targets = tracker.update(pred, [960,960], [960,960], 0.25)+ preds = []+ for x in online_targets:+ preds.append(np.array([x.tlwh[0],x.tlwh[1],(x.tlwh[0]+x.tlwh[2]),(x.tlwh[1]+x.tlwh[3]),x.score,x.class_id,x.track_id]))+ #pred = pred[pred[:, 4] >= 0.25]_, buffer = cv2.imencode(".jpg", im0)- out.write(draw_bounding_boxes(buffer, pred, class_labels))+ out.write(draw_bounding_boxes(buffer, preds, class_labels))i+=1print("frame",i)cap.release()