DOTA数据集 | retinanet 实验记录(COCO数据格式)

retinanet 实验记录

  • 源码链接
  • 运行环境
  • 需要下载文件
  • 训练步骤
  • 实验输出(以下贴出部分map)
    • 预测各个类别的map

源码链接

https://github.com/fizyr/keras-retinanet

运行环境

  • Ubuntu16.04
  • python3.6.5
  • CUDA 10.2 ( NVIDIA-SMI 440.33.01 Driver Version: 440.33.01 )

需要下载文件

  • 预训练模型: https://github.com/fizyr/keras-retinanet/releases

训练步骤

  1. 下载该仓库: https://github.com/fizyr/keras-retinanet.git
  2. 数据格式是coco,按照标准的coco格式放置数据即可。在这里插入图片描述
    训练命令:
# Running directly from the repository:
keras_retinanet/bin/train.py coco /path/to/MS/COCO# Using the installed script:
retinanet-train coco /path/to/MS/COCO
python train.py coco /home/xxx/DOTA/DOTA_clip_coco_600/DOTA_clip_coco_600

/path/to/MS/COCO:输入你的coco数据存放的位置。下面的命令没有试过,有需要的朋友可以自己实践一下。

PS:得到训练模型,想要用模型来评估就需要把模型转换一下。

转换模型:

python convert_model.py ./snapshots/resnet50_coco_06.h5 ./models/resnet50_coco_06.h5

评估命令:

python evaluate.py --image-min-side=600 --image-max-side=600 coco /home/xxx/DOTA/DOTA_clip_coco_600/DOTA_clip_coco_600/ ./models/resnet50_coco_06.h5

运行作者给出的预训练模型命令:
首先把从release下载模型,把模型放在snapshots里,运行下面的代码就🆗了。

python train.py --weights ~/keras-retinanet/snapshots/resnet50_coco_best_v2.0.1.h5 coco /home/xxx/DOTA/DOTA_clip_coco_600/DOTA_clip_coco_600

实验输出(以下贴出部分map)

在这里插入图片描述
在这里插入图片描述

预测各个类别的map

在./keras_retinanet/callbacks/coco.py 中加入下面这个函数即可。参考博客

def _print_detection_eval_metrics(self, coco_eval):IoU_lo_thresh = 0.5IoU_hi_thresh = 0.95def _get_thr_ind(coco_eval, thr):ind = np.where((coco_eval.params.iouThrs > thr - 1e-5) &(coco_eval.params.iouThrs < thr + 1e-5))[0][0]iou_thr = coco_eval.params.iouThrs[ind]assert np.isclose(iou_thr, thr)return indind_lo = _get_thr_ind(coco_eval, IoU_lo_thresh)ind_hi = _get_thr_ind(coco_eval, IoU_hi_thresh)# precision has dims (iou, recall, cls, area range, max dets)# area range index 0: all area ranges# max dets index 2: 100 per imageprecision = \coco_eval.eval['precision'][ind_lo:(ind_hi + 1), :, :, 0, 2]ap_default = np.mean(precision[precision > -1])print(('~~~~ Mean and per-category AP @ IoU=[{:.2f},{:.2f}] ''~~~~').format(IoU_lo_thresh, IoU_hi_thresh))# print("")print('MAP:{:.1f}'.format(100 * ap_default))for cls_ind, cls in enumerate(self._classes):if cls == '__background__':continue# minus 1 because of __background__# cat_name  = db.class_name(cls_ind)# print(cat_name)cat_name  = self.class_name(cls)# print(cat_name+":")precision = coco_eval.eval['precision'][ind_lo:(ind_hi + 1), :, cls_ind, 0, 2]ap = np.mean(precision[precision > -1])print(cat_name+':{:.1f}'.format(100 * ap))

并在./keras-retinanet/keras_retinanet/utils/coco_eval.py中coco_eval.accumulate()下面加入:

coco_eval._print_detection_eval_metrics(coco_eval)


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部