From d0f54cbc666c1134b452bf54f2cc416876a8dc5d Mon Sep 17 00:00:00 2001 From: Egbert Nierop Date: Fri, 1 Dec 2023 11:30:47 +0100 Subject: [PATCH] fix webcam_addr 2 folder --- yolov6/core/inferer.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yolov6/core/inferer.py b/yolov6/core/inferer.py index cea6586d..d0454686 100644 --- a/yolov6/core/inferer.py +++ b/yolov6/core/inferer.py @@ -19,6 +19,7 @@ from yolov6.data.datasets import LoadData from yolov6.utils.nms import non_max_suppression from yolov6.utils.torch_utils import get_model_info +from urllib.parse import urlparse class Inferer: def __init__(self, source, webcam, webcam_addr, weights, device, yaml, img_size, half): @@ -83,8 +84,12 @@ def infer(self, conf_thres, iou_thres, classes, agnostic_nms, max_det, save_dir, t2 = time.time() if self.webcam: - save_path = osp.join(save_dir, self.webcam_addr) - txt_path = osp.join(save_dir, self.webcam_addr) + parsed_url = urlparse(self.webcam_addr) + #filter : and / and query parameters that we don't want in the folder + webcamfolder = f"{parsed_url.netloc.replace(':', '-')}" + save_path = osp.join(save_dir, webcamfolder) + txt_path = osp.join(save_dir,'labels', webcamfolder ) + os.makedirs(txt_path, exist_ok=True) else: # Create output files in nested dirs that mirrors the structure of the images' dirs rel_path = osp.relpath(osp.dirname(img_path), osp.dirname(self.source))