Tensorflow 对象检测 API 框坐标

我使用了Tensorflow对象检测API来检测自定义对象。模型运行得很完美,但现在我想知道这些框的坐标。有没有办法知道每个检测到的对象的框坐标?


回答:

请查看教程的IPython笔记本,里面有他们用于检测的代码(链接到GitHub):

with detection_graph.as_default():  with tf.Session(graph=detection_graph) as sess:    # 定义检测图的输入和输出张量    image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')    # 每个框代表图像中检测到特定对象的部分。    detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0')    # 每个分数表示对每个对象的置信度。    # 分数显示在结果图像上,并与类别标签一起显示。    detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')    detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')    num_detections = detection_graph.get_tensor_by_name('num_detections:0')    for image_path in TEST_IMAGE_PATHS:      image = Image.open(image_path)      # 图像的数组表示将在后面用于准备带有框和标签的结果图像。      image_np = load_image_into_numpy_array(image)      # 扩展维度,因为模型期望图像的形状为:[1, None, None, 3]      image_np_expanded = np.expand_dims(image_np, axis=0)      # 实际检测。      (boxes, scores, classes, num) = sess.run(          [detection_boxes, detection_scores, detection_classes, num_detections],          feed_dict={image_tensor: image_np_expanded})

他们将坐标存储在boxes变量中。

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注