示例#1
0
image, image_meta, gt_class_id, gt_bbox, gt_mask =\
    modellib.load_image_gt(dataset, config, image_id, use_mini_mask=False)
info = dataset.image_info[image_id]


print("---------------------------------------------------------------------------")
print("image ID: {}.{} ({}) {}".format(info["source"], info["id"], image_id,
                                       dataset.image_reference(image_id)))
print("---------------------------------------------------------------------------")
results = model.detect([image], verbose=1)

r = results[0]

AP, precisions, recalls, overlaps = utils.compute_ap(gt_bbox, gt_class_id, gt_mask, r['rois'], r['class_ids'], r['scores'], r['masks'])

visualize.plot_precision_recall(AP, precisions, recalls)
plt.show()


# Display results
print("---------------------------------------------------------------------------")
ax = get_ax(1)
r = results[0]
visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'],
                            dataset.class_names, r['scores'], ax=ax,
                            title="Predictions")
log("gt_class_id", gt_class_id)
log("gt_bbox", gt_bbox)
log("gt_mask", gt_mask)
print("---------------------------------------------------------------------------")
示例#2
0
                                               tr[idx][0]['masks'])

        APs.append(AP)
        precision_vals.append(prec)
        recall_vals.append(recall)
        overlaps.append(overlap)

    return APs, precision_vals, recall_vals, overlaps


fish_eval = eval_model()

APs, Precisions, Recalls, Overlaps = fish_eval[0], fish_eval[1], fish_eval[
    2], fish_eval[3]

import matplotlib.pyplot as plt
from mrcnn.visualize import plot_precision_recall, plot_overlaps

im_ = np.random.choice(range(len(APs)))
plot_precision_recall(APs[im_], Precisions[im_], Recalls[im_])

avPr_vals = []
avRec_vals = []
for im_idx in range(len(APs)):
    avPr = np.mean(Precisions[im_idx] / len(Precisions[im_idx]))
    avRec = np.mean(Recalls[im_idx] / len(Recalls[im_idx]))
    avPr_vals.append(avPr)
    avRec_vals.append(avRec)

plot_precision_recall(np.mean(APs), avPr_vals, avRec_vals)