P4s:模型审计 —— 移出零引用模型,修掉代码里三处悬空 best.pt
先回答"这些模型到底有没有人用",用全仓库引用扫描判定,不靠猜: 在用 yolo/detect_best_0.onnx + .engine ← paths.yolo_weights 在用 hole_insert/detect_best_1.onnx ← hole_detect.weights / workpiece_weights 零引用 detect_hc90(pt/onnx/engine) ← 只剩注释里的历史说明 零引用 detect_yolo26_gongjian.pt 零引用 detect_best(onnx/engine) ← 仅代码兜底候选,而那个候选是 .pt,不存在 所以 detect_hc90 不需要修复,是不用的东西:连同另两个一起移出仓库。 注意**二进制权重被 gitignore**,删掉就找不回来了,因此是移出到 ~/ros2-models-unused-20260923/ 而非 rm。搬回 models/ 即可被 list 重新发现。 顺手挖出并修掉三处悬空引用(和之前 site.yaml 里那个 best.pt 同一类问题): - hole_detector.weights_from_site:兜底路径写死 models/hole_insert/best.pt(不存在) - hole_detector._default_model_path:三个候选路径**全都不存在**,函数却 `return candidates[0]`,于是永远返回不存在的 best.pt;报错路径看着很合理, 极易被误判成"文件被误删"。现改为以 site.yaml 为准,再退到规范模型。 - config/hole_insert.yaml 顶部注释同样写的是 best.pt 新增 test_hole_detector.py(8 项)锁住这个回归。测试刻意**不断言文件存在** ——二进制不进 git,新克隆的仓库里 models/ 是空的——只断言解析结果指向规范模型名。 体检从 4 处问题降到 0:bash scripts/weights.sh doctor --check-engines → "没有发现问题" 测试 233 项通过;18 个包构建通过。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -109,13 +109,12 @@ paths:
|
||||
# 2) 这一行改成那个绝对路径(写 .onnx 即可;TensorRT 会找同名 .engine)
|
||||
# 3) backend=tensorrt 时必须先导出引擎(只需做一次):
|
||||
# bash ~/ros2/scripts/export_yolo_trt.sh /home/USER/ros2/models/yolo/detect_best_0.onnx 640
|
||||
# 4) yolo.imgsz 必须等于 ONNX 输入边长(本文件 640;旧 hc90 才是 416)
|
||||
# 4) yolo.imgsz 必须等于 ONNX 输入边长(当前 640)
|
||||
# 5) 改权重/imgsz 后重启:bash ~/ros2/scripts/run_visual_servo_rt.sh [--control]
|
||||
# 当前:detect_best_0.onnx(2026-09-04 从 ~/下载 移入,640 输入)
|
||||
yolo_weights: "/home/USER/ros2/models/yolo/detect_best_0.onnx"
|
||||
# yolo_weights: "/home/USER/ros2/models/yolo/detect_best.onnx"
|
||||
# yolo_weights: "/home/USER/ros2/models/yolo/detect_hc90.pt"
|
||||
# yolo_weights: "/home/USER/ros2/models/yolo/detect_yolo26_gongjian.pt"
|
||||
# 备选模型:直接换成 models/yolo/ 下的其他 .onnx / .pt 绝对路径即可。
|
||||
# 换完建议确认标签没丢:bash ~/ros2/scripts/weights.sh doctor --check-engines
|
||||
# 入孔 YOLO(backend=yolo 时把孔当框)。two_stage 用上面的工件权重。
|
||||
hole_weights: "/home/USER/ros2/models/hole_insert/detect_best_1.onnx"
|
||||
# 下面是缺省(未匹配到 robots[] 时)。真机以 robots[].paths 为准:89 / 91 各一份。
|
||||
@@ -202,7 +201,7 @@ cameras:
|
||||
yolo:
|
||||
conf: 0.10 # 检测器门槛:略低于 min_conf,让运动模糊框也能进跟踪
|
||||
iou: 0.45
|
||||
imgsz: 640 # detect_best.onnx 固定 640;hc90.engine 才是 416
|
||||
imgsz: 640 # 必须等于所用 ONNX 的输入边长(当前 detect_best_0 = 640)
|
||||
device: "0"
|
||||
half_precision: true
|
||||
backend: "tensorrt" # 强制 .engine;没有则启动失败。导出:bash ~/ros2/scripts/export_yolo_trt.sh
|
||||
|
||||
Reference in New Issue
Block a user