Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def detect(self, img_path, min_prob=0.6):
image = read_image_bgr(img_path)
image = preprocess_image(image)
image, scale = resize_image(image)
boxes, scores, labels = Detector.detection_model.predict_on_batch(np.expand_dims(image, axis=0))
boxes /= scale
processed_boxes = []
for box, score, label in zip(boxes[0], scores[0], labels[0]):
if score < min_prob:
continue
box = box.astype(int).tolist()
label = Detector.classes[label]
processed_boxes.append({'box': box, 'score': score, 'label': label})
return processed_boxes