From 365dcc94e549c614e1b87364d28fe2381a08871c Mon Sep 17 00:00:00 2001 From: zqc <835569504@qq.com> Date: Mon, 9 Mar 2026 13:28:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- biz/checkpoint/checkpoint_biz.py | 15 ++++++++++----- common/constants.py | 2 ++ config.yaml | 5 +++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/biz/checkpoint/checkpoint_biz.py b/biz/checkpoint/checkpoint_biz.py index dbd4224..2536bd3 100644 --- a/biz/checkpoint/checkpoint_biz.py +++ b/biz/checkpoint/checkpoint_biz.py @@ -13,13 +13,10 @@ from algorithm.common.npu_yolo_pose_onnx import YOLOv8_Pose_ONNX from yolox.tracker.byte_tracker import BYTETracker from utils.logger import get_logger +from common.constants import MODEL_ROOT_PATH logger = get_logger(__name__) -# ========================= 配置区 ========================= -# Kadian 模型路径与ROI(可根据实际情况修改) DETECT_MODEL_PATH = 'YOLO_Weight/Kadian.onnx' -#DETECT_MODEL_PATH = r'D:\Python_Save\PoliceProject\TestForLiveStream\AIMonitor_KaDian_0304\YOLO_Weight\Kadian.onnx' -#POSE_MODEL_PATH = 'YOLO_Weight/yolov8l-pose.onnx' # 默认相对ROI(与原文件一致) #ROI_RELATIVE = np.array([ @@ -63,9 +60,17 @@ class KadianDetector: # 摄像头额外参数 self.params = params if params is not None else {} + # 模型路径:从 params 读取,未配置则使用默认值 DETECT_MODEL_PATH + model_path = self.params.get('model_path') + if model_path: + full_model_path = f"{MODEL_ROOT_PATH}/{model_path}" + else: + full_model_path = DETECT_MODEL_PATH + logger.info(f"Loading model from: {full_model_path}") + # 模型加载 self.detector = YOLOv8_ONNX( - DETECT_MODEL_PATH, + full_model_path, conf_threshold=0.6, iou_threshold=0.65, input_size=PERSON_CAR_INPUT_SIZE diff --git a/common/constants.py b/common/constants.py index d75a3bf..1292867 100644 --- a/common/constants.py +++ b/common/constants.py @@ -4,6 +4,8 @@ from utils.logger import get_logger logger = get_logger(__name__) +MODEL_ROOT_PATH = 'YOLO_Weight' + ALERT_PUSH_URL = "" HLS_ROOT_PATH = "" diff --git a/config.yaml b/config.yaml index d565ed0..be1300d 100644 --- a/config.yaml +++ b/config.yaml @@ -49,15 +49,16 @@ video_clip_default_segment_duration: 2 # 默认分片 service_groups: - name: "kadian_group" # 服务组名称 - video_source_type: "hls" + video_source_type: "rtsp" ws_host: "0.0.0.0" # WebSocket 服务地址 ws_port: 8765 # WebSocket 服务端口 - algorithm: "checkpoint" # 算法类型 + algorithm: "corridor" # 算法类型 cameras: # 该组下的摄像头列表 - id: 8 index: "12345" name: Entrance params: + model_path: "Kadian.onnx" roi_points: - [0.15, 0.001] - [0.5, 0.001]