MCPcopy
hub / github.com/matterport/Mask_RCNN / detect

Method detect

model.py:2346–2386  ·  view source on GitHub ↗

Runs the detection pipeline. images: List of images, potentially of different sizes. Returns a list of dicts, one dict per image. The dict contains: rois: [N, (y1, x1, y2, x2)] detection bounding boxes class_ids: [N] int class IDs scores: [N] float probabili

(self, images, verbose=0)

Source from the content-addressed store, hash-verified

2344 return boxes, class_ids, scores, full_masks
2345
2346 def detect(self, images, verbose=0):
2347 """Runs the detection pipeline.
2348
2349 images: List of images, potentially of different sizes.
2350
2351 Returns a list of dicts, one dict per image. The dict contains:
2352 rois: [N, (y1, x1, y2, x2)] detection bounding boxes
2353 class_ids: [N] int class IDs
2354 scores: [N] float probability scores for the class IDs
2355 masks: [H, W, N] instance binary masks
2356 """
2357 assert self.mode == "inference", "Create model in inference mode."
2358 assert len(
2359 images) == self.config.BATCH_SIZE, "len(images) must be equal to BATCH_SIZE"
2360
2361 if verbose:
2362 log("Processing {} images".format(len(images)))
2363 for image in images:
2364 log("image", image)
2365 # Mold inputs to format expected by the neural network
2366 molded_images, image_metas, windows = self.mold_inputs(images)
2367 if verbose:
2368 log("molded_images", molded_images)
2369 log("image_metas", image_metas)
2370 # Run object detection
2371 detections, mrcnn_class, mrcnn_bbox, mrcnn_mask, \
2372 rois, rpn_class, rpn_bbox =\
2373 self.keras_model.predict([molded_images, image_metas], verbose=0)
2374 # Process detections
2375 results = []
2376 for i, image in enumerate(images):
2377 final_rois, final_class_ids, final_scores, final_masks =\
2378 self.unmold_detections(detections[i], mrcnn_mask[i],
2379 image.shape, windows[i])
2380 results.append({
2381 "rois": final_rois,
2382 "class_ids": final_class_ids,
2383 "scores": final_scores,
2384 "masks": final_masks,
2385 })
2386 return results
2387
2388 def ancestor(self, tensor, name, checked=None):
2389 """Finds the ancestor of a TF tensor in the computation graph.

Callers 2

evaluate_cocoFunction · 0.80
detect_and_color_splashFunction · 0.80

Calls 3

mold_inputsMethod · 0.95
unmold_detectionsMethod · 0.95
logFunction · 0.85

Tested by

no test coverage detected