| 10 | |
| 11 | |
| 12 | def makeplot(rs, ps, outDir, class_name, iou_type): |
| 13 | cs = np.vstack([ |
| 14 | np.ones((2, 3)), |
| 15 | np.array([.31, .51, .74]), |
| 16 | np.array([.75, .31, .30]), |
| 17 | np.array([.36, .90, .38]), |
| 18 | np.array([.50, .39, .64]), |
| 19 | np.array([1, .6, 0]) |
| 20 | ]) |
| 21 | areaNames = ['allarea', 'small', 'medium', 'large'] |
| 22 | types = ['C75', 'C50', 'Loc', 'Sim', 'Oth', 'BG', 'FN'] |
| 23 | for i in range(len(areaNames)): |
| 24 | area_ps = ps[..., i, 0] |
| 25 | figure_tile = iou_type + '-' + class_name + '-' + areaNames[i] |
| 26 | aps = [ps_.mean() for ps_ in area_ps] |
| 27 | ps_curve = [ |
| 28 | ps_.mean(axis=1) if ps_.ndim > 1 else ps_ for ps_ in area_ps |
| 29 | ] |
| 30 | ps_curve.insert(0, np.zeros(ps_curve[0].shape)) |
| 31 | fig = plt.figure() |
| 32 | ax = plt.subplot(111) |
| 33 | for k in range(len(types)): |
| 34 | ax.plot(rs, ps_curve[k + 1], color=[0, 0, 0], linewidth=0.5) |
| 35 | ax.fill_between( |
| 36 | rs, |
| 37 | ps_curve[k], |
| 38 | ps_curve[k + 1], |
| 39 | color=cs[k], |
| 40 | label=str('[{:.3f}'.format(aps[k]) + ']' + types[k])) |
| 41 | plt.xlabel('recall') |
| 42 | plt.ylabel('precision') |
| 43 | plt.xlim(0, 1.) |
| 44 | plt.ylim(0, 1.) |
| 45 | plt.title(figure_tile) |
| 46 | plt.legend() |
| 47 | # plt.show() |
| 48 | fig.savefig(outDir + '/{}.png'.format(figure_tile)) |
| 49 | plt.close(fig) |
| 50 | |
| 51 | |
| 52 | def analyze_individual_category(k, cocoDt, cocoGt, catId, iou_type): |