评估
概述
测试
CLI
Command Line
1luxonis_train test --config configs/detection_light_model.yaml \
2 --view val \
3 --weights path/to/checkpoint.ckptPython API
Python
1from luxonis_train import LuxonisModel
2
3model = LuxonisModel("configs/detection_light_model.yaml")
4model.test(weights="path/to/checkpoint.ckpt")注意: 通过使用 TestOnTrainEnd 回调,可以在训练结束时自动启动测试过程。
推理
CLI
在数据集视图上进行推理
Command Line
1luxonis_train infer --config configs/detection_light_model.yaml \
2 --view val \
3 --weights path/to/checkpoint.ckpt在视频文件上进行推理
Command Line
1luxonis_train infer --config configs/detection_light_model.yaml \
2 --weights path/to/checkpoint.ckpt \
3 --source-path path/to/video.mp4在图像目录上进行推理
Command Line
1luxonis_train infer --config configs/detection_light_model.yaml \
2 --weights path/to/checkpoint.ckpt \
3 --source-path path/to/images在单张图像上进行推理
Command Line
1luxonis_train infer --config configs/detection_light_model.yaml \
2 --weights path/to/checkpoint.ckpt \
3 --source-path path/to/image.jpgPython API
Python
1from luxonis_train import LuxonisModel
2
3model = LuxonisModel("configs/detection_light_model.yaml")
4
5# 在数据集视图上进行推理
6model.infer(weights="path/to/checkpoint.ckpt", view="val")
7
8# 在视频文件上进行推理
9model.infer(weights="path/to/checkpoint.ckpt", source_path="path/to/video.mp4")
10
11# 在图像目录上进行推理并保存结果
12model.infer(
13 weights="path/to/checkpoint.ckpt",
14 source_path="path/to/images",
15 save_dir="path/to/save_directory",
16)标注
CLI
Command Line
1luxonis_train annotate --config configs/detection_light_model.yaml \
2 --weights path/to/checkpoint.ckpt \
3 --source-path path/to/imagesPython API
Python
1from luxonis_train import LuxonisModel
2
3model = LuxonisModel("configs/detection_light_model.yaml")
4dataset = model.annotate(
5 dir_path="path/to/images",
6 dataset_name="annotated_dataset",
7 weights="path/to/checkpoint.ckpt",
8)LuxonisDataset 对象返回,因此可以直接检查、导出或在后续训练运行中重复使用。通过同时使用测试和推理,您可以全面了解模型性能,并进行必要的调整以提高其准确性和可靠性。