def _infer_on_img(self, img, ann): res_detections = detect(self.net, len(self.train_names), img.encode('utf-8'), thresh=self.score_thresh) res_figures = yolo_preds_to_sly_rects(res_detections, ann.image_size_wh, self.train_names) return res_figures
def inference(self, img): h, w = img.shape[:2] cv2.imwrite(self.image_path, img[:, :, ::-1]) # ok for sequential calls res_detections = detect(self.net, len(self.train_names), self.image_path.encode('utf-8'), thresh=self.score_thresh) res_figures = yolo_preds_to_sly_rects(res_detections, (w, h), self.train_names) res_ann = sly.Annotation.new_with_objects((w, h), res_figures) return res_ann
def _raw_detections_to_ann(self, detections_raw, img_size): labels = common.yolo_preds_to_sly_rects( detections_raw, self.out_class_mapping, self.confidence_tag_meta) return sly.Annotation(img_size, labels=labels)