Files
orisys_arm/models/yolo/README.md
T
2026-10-16 17:27:30 +08:00

64 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# YOLO 工件检测权重
> **改这个目录之前先读 [`../README.md`](../README.md)**(权重模块的规则)。
## 放什么
同名的 `.pt` / `.onnx` / `.engine` / `.labels.yaml` 放一起,名字主干必须一致:
```
detect_best_0.onnx ← 写进 config/site.yaml 的那个
detect_best_0.engine ← TensorRT 引擎,backend: tensorrt 时自动使用
detect_best_0.labels.yaml ← 类别标签(进 git,可手改)
```
二进制不进 git;`.labels.yaml` 进 git。
## 加新模型
```bash
cp ~/下载/xxx.pt ~/ros2/models/staging/
bash ~/ros2/scripts/weights.sh convert staging/xxx.pt --name workpiece --group yolo
```
然后改 `config/site.yaml`:
```yaml
paths:
yolo_weights: "/home/USER/ros2/models/yolo/workpiece.onnx"
yolo:
backend: "tensorrt"
imgsz: 640 # 必须等于该模型输入尺寸
```
## 查看 / 修改标签
```bash
bash ~/ros2/scripts/weights.sh labels detect_best_0
bash ~/ros2/scripts/weights.sh labels detect_best_0 --set "工件,通止规"
```
## 工作区里有哪些模型
只保留**真正在用**的两个,避免 `weights.sh list` 被无用模型干扰、也避免误选到废模型:
| 模型 | 用途 |
|---|---|
| `yolo/detect_best_0.onnx` + `.engine` | 工件/跟踪模型,即 `config/site.yaml → paths.yolo_weights` |
| `hole_insert/detect_best_1.onnx` | 孔/工件检测,即 `hole_detect.weights` 与 `workpiece_weights` |
曾经在这里、现已移出仓库的模型(`detect_hc90`、`detect_best`、`detect_yolo26_gongjian`)
是零引用的历史遗留,二进制权重不进 git,所以是**移出到备份目录**而非直接删除;
需要时搬回本目录即可,`weights.sh list` 会自动重新发现。
## 排错
```bash
bash ~/ros2/scripts/weights.sh doctor --check-engines
```
`engine` 和 TensorRT 版本绑死:换过 TensorRT 后旧 engine 会加载失败,重导即可
(`convert <同名>.onnx --name <名字> --to engine --force`)。
**注意 `doctor` 能查出这类静默失效** —— engine 反序列化返回空时不会报错,
只会安静地不退任何检测框,很容易被当成"模型效果差"。