def infer_object_detections_on_loaded_image( self, image_np: np.array, ): orig_img_height, orig_img_width = image_np.shape[:2] img_np = resize_and_letter_box(image_np / 255., target_width=self.model_image_width, target_height=self.model_image_height) img_np = np.expand_dims(img_np, 0) start = time.time() detected_boxes, detected_classes, detected_scores = infer_objects_in_image( image=img_np, session=self.session, orig_image_height=orig_img_height, orig_image_width=orig_img_width, out_tensors=self.out_tensors, input_tensor=self.input_tensors[0], orig_image_width_placeholder_tensor=self.input_tensors[1], orig_image_height_placeholder_tensor=self.input_tensors[2]) end = time.time() time_in_s = end - start if self.verbose: print(f'Took {time_in_s} seconds to run prediction in tf session.') return detected_boxes, detected_classes, detected_scores
def infer_object_detections_on_loaded_image( self, image_np: np.array, ): orig_img_height, orig_img_width = image_np.shape[:2] img_np = resize_and_letter_box(image_np / 255., target_width=608, target_height=608) img_np = np.expand_dims(img_np, 0) detected_boxes, detected_classes, detected_scores = infer_objects_in_image( image=img_np * 255., model=self.model, orig_image_height=orig_img_height, orig_image_width=orig_img_width, detection_prob_treshold=self.detection_prob_treshold) return detected_boxes, detected_classes, detected_scores
def infer_object_detections_on_loaded_image( self, image_np: np.array, ): """ Infers object detection on the loaded numpy array representing pixels of the image (row-major order). :param image_np np.array containing pixels of the image (row-major ordering) :return (detected_boxes, detected_classes, detected_scores) - detected_boxes array of (left, top, bottom, right) - detected_classes array of ints representing class indices - detected_scores array of floats representing probability for each box and class """ orig_img_height, orig_img_width = image_np.shape[:2] img_np = resize_and_letter_box( image_np / 255., target_width=self.model_image_width, target_height=self.model_image_height, interpolation=self.interpolation_strategy) img_np = np.expand_dims(img_np, 0) start = time.time() detected_boxes, detected_classes, detected_scores = infer_objects_in_image( image=img_np, session=self.session, orig_image_height=orig_img_height, orig_image_width=orig_img_width, out_tensors=self.out_tensors, input_tensor=self.input_tensors[0], orig_image_width_placeholder_tensor=self.input_tensors[1], orig_image_height_placeholder_tensor=self.input_tensors[2]) end = time.time() time_in_s = end - start if self.verbose: print(f'Took {time_in_s} seconds to run prediction in tf session.') return detected_boxes, detected_classes, detected_scores
def infer_object_detections_on_loaded_image( self, image_np: np.array, ): orig_img_height, orig_img_width = image_np.shape[:2] img_np = resize_and_letter_box(image_np / 255., target_width=self.model_image_width, target_height=self.model_image_height) img_np = np.expand_dims(img_np, 0) detected_boxes, detected_classes, detected_scores = infer_objects_in_image( image=img_np, restored_model=self.model, session=self.session, orig_image_height=orig_img_height, orig_image_width=orig_img_width, detection_prob_treshold=self.detection_threshold, model_image_height=self.model_image_height, model_image_width=self.model_image_width, anchors=self.anchors, verbose=self.verbose) return detected_boxes, detected_classes, detected_scores