mask rcnn测试(demo)中选取指定目标代码

如果想识别哪个class_name,替换掉实列代码中的person即可!

r = results[0]
if class_names.index('person') in r['class_ids']:
    k = list(np.where(r['class_ids'] == class_names.index('person'))[0])
    r['scores'] = np.array([r['scores'][i]for i in k])
    r['rois'] = np.array([r['rois'][i]for i in k])
    r['masks'] = np.transpose(r['masks'])
    r['masks'] = np.array([r['masks'][i]for i in k])
    r['masks'] = np.transpose(r['masks'])
    r['class_ids'] = np.array([r['class_ids'][i]for i in k])
visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'],
                            class_names, r['scores'])

你可能感兴趣的:(机器学习,目标检测,python)