Faster R-CNN画PR曲线
参考:https://github.com/rbgirshick/py-faster-rcnn/issues/670
原地址https://blog.csdn.net/hongxingabc/article/details/80064574
在pascal_voc.py里添加几行代码即可:
1,文件头部:
import matplotlib.pyplot as plt
import pylab as pl
from sklearn.metrics import precision_recall_curve
from itertools import cycle
2,_do_python_eval函数:
def _do_python_eval(self, output_dir='output'):
annopath = os.path.join(
self._devkit_path,
'VOC' + self._year,
'Annotations',
'{:s}.xml')
imagesetfile = os.path.join(
self._devkit_path,
'VOC' + self._year,
'ImageSets',
'Main',
self._image_set + '.txt')
cachedir = os.path.join(self._devkit_path, 'annotations_cache')
aps = []
# The PASCAL VOC metric changed in 2010
use_07_metric = True if int(self._year) < 2010 else False
print('VOC07 metric? ' + ('Yes' if use_07_metric else 'No'))
if not os.path.isdir(output_dir):
os.mkdir(output_dir)
for i, cls in enumerate(self._classes):
if cls == '__background__':
continue
filename = self._get_voc_results_file_template().format(cls)
rec, prec, ap = voc_eval(
filename, annopath, imagesetfile, cls, cachedir, ovthresh=0.5,
use_07_metric=use_07_metric)
aps += [ap]
pl.plot(rec, prec, lw=2,
label='Precision-recall curve of class {} (area = {:.4f})'
''.format(cls, ap))
print(('AP for {} = {:.4f}'.format(cls, ap)))
with open(os.path.join(output_dir, cls + '_pr.pkl'), 'wb') as f:
pickle.dump({'rec': rec, 'prec': prec, 'ap': ap}, f)
pl.xlabel('Recall')
pl.ylabel('Precision')
plt.grid(True)
pl.ylim([0.0, 1.05])
pl.xlim([0.0, 1.0])
pl.title('Precision-Recall')
pl.legend(loc="upper right")
plt.show()
print(('Mean AP = {:.4f}'.format(np.mean(aps))))
print('~~~~~~~~')
print('Results:')
for ap in aps:
print(('{:.3f}'.format(ap)))
print(('{:.3f}'.format(np.mean(aps))))
print('~~~~~~~~')
print('')
print('--------------------------------------------------------------')
print('Results computed with the **unofficial** Python eval code.')
print('Results should be very close to the official MATLAB eval code.')
print('Recompute with `./tools/reval.py --matlab ...` for your paper.')
print('-- Thanks, The Management')
print('--------------------------------------------------------------')
然后运行test_net.py,就可以得到如下图的PR曲线。如果想比较多条曲线,可以先把rec, prec数据存起来再画图。
Faster R-CNN画PR曲线相关推荐
- python脚本——图片重命名、图片合成视频、faster-rcnn画P-R曲线
调试faster rcnn算法实用的python脚本 目录 调试faster rcnn算法实用的python脚本 一.前言 二.常用python脚本 三.后记 一.前言 最近在做关于目标检测算法的研究 ...
- Faster R CNN
Faster R CNN 3 FASTER R-CNN 我们的Faster R CNN 由两个模块组成,第一个模块是 proposes regions 的全卷积网络,第二个是使用 proposed r ...
- python怎么画出圆润的曲线_Python如何画P-R曲线
Python如何画P-R曲线 Python生成P-R图需要安装第三方库matplotlib.numpy及sklearn. 推荐学习<Python教程>. P-R曲线的生成方法: 根据学习器 ...
- python画pr曲线_python 画函数曲线示例
python 画函数曲线示例 如下所示: import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2 * np.pi ...
- python画pr曲线代码_利用Python中的numpy包实现PR曲线和ROC曲线的计算
闲来无事,边理解PR曲线和ROC曲线,边写了一下计算两个指标的代码.在 python 环境下,sklearn里有现成的函数计算ROC曲线坐标点,这里为了深入理解这两个指标,写代码的时候只用到numpy ...
- python 画pr曲线
roc曲线: python 画roc曲线_jacke121的专栏-CSDN博客 import _pickle as cPickle import matplotlib.pyplot as pltxxx ...
- 机器学习之性能度量指标——决定系数R^2、PR曲线、ROC曲线、AUC值、以及准确率、查全率、召回率、f1_score
一.线性回归的决定系数(也称为判定系数,拟合优度) 相关系数是R哈~~~就是决定系数的开方! 正如题所说决定系数是来衡量回归的好坏,换句话说就是回归拟合的曲线它的拟合优度!也就是得分啦~~ 决定系数它 ...
- yoloV3测试map和画PR曲线
参考1:https://blog.csdn.net/qq_33350808/article/details/83178002 2:https://blog.csdn.net/weixin_437175 ...
- 关于Mask R-CNN 画PR曲线
最近太多人问我如何绘制PR曲线了,我又很少及时看到你们的消息,在这里跟大家道个歉,我直接把代码贴出来,你们看着改参数就好. ################ 导入相关包 ############### ...
最新文章
- linux使用线程实现生产者消费者问题,Linux平台下线程同步,实现“生产者消费者问题”...
- Linux软件安装小结
- Ubuntu 下一个 vim 建立python 周围环境 构造
- iOS之深入解析分类Category的底层原理
- 深入理解Spark 2.1 Core (七):Standalone模式任务执行的原理与源码分析
- jqGrid使用经验分享(一)——jqGrid简单使用、json格式和jsonReader介绍
- new、delelte和malloc、free的关系
- 多线程面试题之原子性、可见性、有序性
- 论文浅尝 - AAAI2020 | 多轮对话系统中的历史自适应知识融合机制
- 计算机程序的思维逻辑 (47) - 堆和PriorityQueue的应用
- Apache Drill学习
- 单行及多行文本溢出以省略号显示的方法总结
- oracle 如何修改字符集 update prop,ORACLE 修改字符集
- linux下监控网络连接,Linux网络监控工具--netstat及网络连接分析
- flex 连接mysql数据库_Flex+blazeds实现与mySQL数据库的连接(已成功实现此文的例子)...
- 《FLUENT 14流场分析自学手册》——2.3 FLUENT14.5软件包的安装以及运行
- c# itextsharp根据模板导出pdf报表
- 2013蓝桥杯 CC++程序设计本科B组 第39级台阶
- 外部多端口映射Https443端口配置
- 如何判断自己外网IP是否为真实公网IP,以及解决方案