def _heatmap(x, y, confidences, activations, threshold=0.2):
channel, height, width = x.shape
heatmaps = []
max_activation = 0
for activation, confidence in six.moves.zip(activations, confidences):
heatmap = np.zeros((height, width))
activation = confidence * cv2.resize(activation, (width, height), interpolation=cv2.INTER_CUBIC)
heatmap = heatmap + activation
heatmaps.append(heatmap)
max_activation = np.max([max_activation, np.max(heatmap)])
for heatmap in heatmaps:
heatmap[np.where(heatmap <= max_activation * threshold)] = 0.0
total_heatmap = np.zeros((height, width))
for heatmap in heatmaps:
total_heatmap = total_heatmap + heatmap
return (x, y, heatmaps, total_heatmap)
评论列表
文章目录