in sample-apps/custom-model/code/application.py [0:0]
def process_results(self, batch_set, output_media):
"""Processes output tensors from a computer vision model and annotates a video frame."""
# Model outputs (classes, probabilities, bounding boxes) are collected in
# the BatchSet returned by model.get_result
# Each output is a Batch of arrays, one for each input in the batch
classes = batch_set.get(0)
# Each batch only has one image; save results for that image
classes.get(0, self.class_array)
for ix, prob in enumerate(self.class_array[0]):
if prob >= self.threshold:
logger.info('Detected: class {} ({}%)'.format(ix,int(prob*100)))
output_media.add_label('Class {} ({}%)'.format(ix,int(prob*100)), 0.02, 0.9)
# Filter out results beneath confidence threshold
# prob_person_indices = [i for i in person_indices if self.prob_array[0][i] >= self.threshold]
return output_media