feat(datasets): 添加新的训练数据标签
- 在 datasets/train/labels 目录下新增了多个标签文件 - 文件命名格式为:视频ID-帧序号.jpg.rf.哈希值.txt -标签内容包括物体类别和位置信息,用于训练目标检测模型
This commit is contained in:
parent
20b660c943
commit
b4468c7808
29
test.py
29
test.py
@ -1,4 +1,29 @@
|
||||
from ultralytics import YOLO
|
||||
import os
|
||||
|
||||
model = YOLO("yolov12s.yaml")
|
||||
print("Model loaded successfully!")
|
||||
|
||||
def main():
|
||||
# 加载训练后的模型
|
||||
model = YOLO("runs/detect/final_model3/weights/best.pt")
|
||||
|
||||
# 在验证集上评估模型性能(添加 workers=0 参数)
|
||||
results2 = model.val(data="data.yaml", workers=0)
|
||||
|
||||
# 推理指定图像或目录(添加 workers=0 参数)
|
||||
results = model.predict(
|
||||
source="datasets/test/images/3383011008094_mp4-19_jpg.rf.377dffeb92226013b2abf60eb66473a7.jpg",
|
||||
imgsz=640,
|
||||
conf=0.25,
|
||||
save=True,
|
||||
#device=0,
|
||||
workers=0 # 关键参数
|
||||
)
|
||||
|
||||
# 遍历并打印预测结果
|
||||
for result in results:
|
||||
print(result.names)
|
||||
print(result.boxes)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main() # Windows必须的入口保护
|
||||
|
Loading…
Reference in New Issue
Block a user