【问题标题】:Tensorflow combined non max suppression for candidate regions of an imageTensorFlow 对图像候选区域的组合非最大抑制
【发布时间】:2020-08-03 18:47:59
【问题描述】:

我想在一组中运行组合的非最大抑制 图像的窗口。 我正在使用来自 tensorflow 的 tf.image.combined_non_max_suppression 如下:

import matplotlib.pyplot as plt
import matplotlib.patches as patches
from PIL import Image
import numpy as np
import tensorflow as tf 



boxesX=np.array(([200,100,150,100],[220,120,150,100],[190,110,150,100],[210,112,150,100])).astype('float32')
scoresX=np.array(([0.2,0.7,0.1],[0.1,0.8,0.1],[0.3,0.6,0.1],[0.05,0.9,0.05]))
boxes1=tf.reshape(boxesX,(1,4,1,4))
boxes2=tf.dtypes.cast(boxes1, tf.float32)
scores1=tf.reshape(scoresX,(1,4,3))
scores2=tf.dtypes.cast(scores1, tf.float32)

boxes, scores, classes, valid_detections = tf.image.combined_non_max_suppression(
boxes=boxes2,
scores=scores2,
max_output_size_per_class=10,
max_total_size=10,
iou_threshold=0.5,
score_threshold=0.2)

但输出的“盒子”只是一个零和一的数组:

array([[[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [0., 0., 0., 0.],
    [0., 0., 0., 0.],
    [0., 0., 0., 0.],
    [0., 0., 0., 0.],
    [0., 0., 0., 0.],
    [0., 0., 0., 0.],
    [0., 0., 0., 0.]]], dtype=float32)>

【问题讨论】:

    标签: python tensorflow object-detection


    【解决方案1】:

    框被剪裁在[0,1] 之间。您需要做的就是添加参数clip_boxes=False

    boxes, scores, classes, valid_detections = tf.image.combined_non_max_suppression(
    boxes=boxes2,
    scores=scores2,
    max_output_size_per_class=10,
    max_total_size=10,
    iou_threshold=0.5,
    score_threshold=0.2,
    clip_boxes=False)
    

    【讨论】:

      猜你喜欢
      • 2017-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-19
      • 1970-01-01
      • 2014-07-22
      相关资源
      最近更新 更多