keras Mask Rcnn代码走读(八)-detect方法介绍,主要用于图片实体分割的推断时调用的。
一,首先对图像进行处理,调用self.mold_inputs()函数,把原图等比例resize成102410243的图像,不够的地方用0填充,同时减去图像平均值。并记录原图的位置及大小信息在image_metas里, molded_images处理后的图像。windows为原图在处理后图片的对角像素坐标。
def detect(self, images, verbose=0):
"""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 probability scores for the class IDs
masks: [H, W, N] instance binary masks
"""
assert self.mode == "inference", "Create model in inference mode."
assert len(
images) == self.config.BATCH_SIZE, "len(images) must be equal to BATCH_SIZE"
if verbose:
log("Proce