tensorflow - 如何在tensorflow对象检测api中为不同检测类可视化具有不同min_thres值的框和标签?
问题描述
我有一个训练有素的模型,有 3 个不同的类。在运行推理时,我想通过以下方法可视化我的检测:
def visualize_boxes_and_labels_on_image_array(
image,
boxes,
classes,
scores,
category_index,
instance_masks=None,
instance_boundaries=None,
keypoints=None,
keypoint_scores=None,
keypoint_edges=None,
track_ids=None,
use_normalized_coordinates=False,
max_boxes_to_draw=20,
min_score_thresh=.5,
agnostic_mode=False,
line_thickness=4,
mask_alpha=.4,
groundtruth_box_visualization_color='black',
skip_boxes=False,
skip_scores=False,
skip_labels=False,
skip_track_ids=False):
但是,每个检测类都以相同的 min_score_thresh 显示,但我想显示具有 min_score_thresh=0.9 的 1 类对象、具有 min_score_thresh=0.6 的 class2-objects 和具有 mimin_score_thresh=0.2 的 class3-objects。你有什么想法吗?
太感谢了。
解决方案
使用示例代码可视化边界框。
plt.rcParams['figure.figsize'] = [42, 21]
label_id_offset = 1
image_np_with_detections = image_np.copy()
viz_utils.visualize_boxes_and_labels_on_image_array(
image_np_with_detections,
detections['detection_boxes'][0].numpy(),
detections['detection_classes'][0].numpy().astype(np.int32),
detections['detection_scores'][0].numpy(),
category_index,
use_normalized_coordinates=True,
max_boxes_to_draw=200,
min_score_thresh=.40,
agnostic_mode=False)
plt.subplot(2, 1, i+1)
plt.imshow(image_np_with_detections)
在此处查看 Tensorflow 对象检测 API 演示
推荐阅读
- sql - 如何使用纬度和经度找到两点之间的距离
- c# - 无法在不同项目之间共享 ResourceDictionary
- c# - 使用 C# 的当前应用程序的活动时间
- javascript - 如何创建自定义钩子,其工作方式类似于 React with Typescript 中的类组件中的 setState
- matlab - 说话人识别系统中的欧几里得距离
- reactjs - 如何将选项卡导航器标题减少到状态栏?
- php - PHP - 从 XML 标记中删除前导和尾随空格
- html - 如果我们的文件名不是 index.html,为什么找不到浪涌显示页面?
- python - 我正在尝试使用 python 的 webbrowser 模块在 chrome 中打开 DINO Game
- openssl - 以 SagePay 网关形式将 mcrypt 升级为 OpenSSL 加密