YOLOv5 in tesnorflow2.x-keras
()
- mAP@0.5/mAP@0.5:0.95/精度/召回率
train epoch 284/299: 100%|██████████████████████████| 146/146 [01:29<00:00, 1.63it/s, loss=0.88708]
training dataset val: 100%|███████████████████████████████████████| 146/146 [00:38<00:00, 3.77it/s]
class mAP@0.5 mAP@0.5:0.95 precision recall
0 cat 0.886272 0.544572 0.376286 0.922149
1 dog 0.920848 0.522949 0.481021 0.944245
2 total 0.903560 0.533760 0.428654 0.933197
val dataset val: 100%|██████████████████████████████████████████████| 38/38 [00:06<00:00, 5.94it/s]
class mAP@0.5 mAP@0.5:0.95 precision recall
0 cat 0.905156 0.584378 0.682848 0.886555
1 dog 0.940633 0.513005 0.724036 0.934866
2 total 0.922895 0.548692 0.703442 0.910710
save ./logs/yolov5s-best.h5 best weight with 0.548691646029708 mAP.
save ./logs/yolov5s-last.h5 last weights at epoch 284.
pip3 install -r requirements.txt
- 下载数据集
https://www.kaggle.com/datasets/andrewmvd/dog-and-cat-detection/download
解压数据将images目录修改为JPEGImages, 放到 ./data/cat_dog_face_data下
- 训练
- tensorboard
tensorboard --host 0.0.0.0 --logdir ./logs/ --port 8053 --samples_per_plugin=images=40
- 查看
- 测试, 修改
detect.py
里面input_image
和model_path
- 评估验证
- labelme打标自己的数据
- 打开
data/labelme2coco.py
脚本, 修改如下地方
input_dir = '这里写labelme打标时保存json标记文件的目录'
output_dir = '这里写要转CoCo格式的目录,建议建一个空目录'
labels = "这里是你打标时所有的类别名, txt文本即可, 每行一个类, 类名无需加引号"
- 执行
data/labelme2coco.py
脚本会在output_dir
生成对应的json文件和图片
- 修改
train.py
文件中train_coco_json
, val_coco_json
, num_class
, classes
- 开始训练,
python3 train.py