def fomo_post_process(model, inputs, outputs):
ob, oh, ow, oc = model.output_shape[0]
x_scale = inputs[0].roi[2] /oh
y_scale = inputs[0].roi[3] /ow
scale = min(x_scale, y_scale)
x_offset = ((inputs[0].roi[2] - (ow*scale))/ 2) + inputs[0].roi[0]
y_offset = ((inputs[0].roi[3] - ( ow*scale))/ 2) + inputs[0].roi[1]
l = [[] for i in range(oc)]
for i in range(oc):
img = image.Image(outputs[0][0, :, :, i] * 255)
blobs = img.find_blobs(
threshold_list, x_stride=1, y_stride=1, area_threshold=1, pixels_threshold=1
)
for b in blobs:
rect = b.rect()
x, y, w, h = rect
score = (
img.get_statistics(thresholds=threshold_list, roi=rect).l_mean() / 255.0
)
x = int((x * scale) + x_offset)
y = int((y * scale) + y_offset)
w = int(w * scale)
h = int(h * scale)
l[i].append((x, y, w, h, score))
return lFOMO模型只能获得中心位置,尺寸是不准的。