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 boxesclass_ids: [N] int class IDsscores: [N] float probability scores for the class IDsmasks: [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("Processing {} images".format(len(images)))for image in images:log("image", image)# Mold inputs to format expected by the neural networkmolded_images, image_metas, windows = self.mold_inputs(images)# Validate image sizes# All images in a batch MUST be of the same sizeimage_shape = molded_images[0].shapefor g in molded_images[1:]:assert g.shape == image_shape,\"After resizing, all images must have the same size. Check IMAGE_RESIZE_MODE and image sizes."

二,调用self.get_anchors,生成anchors。调用 self.keras_model.predict()进行推论,得到detections与masks。再调用 self.unmold_detections()把detections与masks还原到原图上,因为每张原图大小不同,要by image处理。

# Anchors
anchors = self.get_anchors(image_shape)
# Duplicate across the batch dimension because Keras requires it
# TODO: can this be optimized to avoid duplicating the anchors?
anchors = np.broadcast_to(anchors, (self.config.BATCH_SIZE,) + anchors.shape)if verbose:log("molded_images", molded_images)log("image_metas", image_metas)log("anchors", anchors)
# Run object detection
detections, _, _, mrcnn_mask, _, _, _ =\self.keras_model.predict([molded_images, image_metas, anchors], verbose=0)
# Process detections
results = []
for i, image in enumerate(images):final_rois, final_class_ids, final_scores, final_masks =\self.unmold_detections(detections[i], mrcnn_mask[i],image.shape, molded_images[i].shape,windows[i])results.append({"rois": final_rois,"class_ids": final_class_ids,"scores": final_scores,"masks": final_masks,})
return results

keras Mask Rcnn代码走读(九)-detect方法介绍相关推荐

  1. Mask rcnn代码实现_pytorch版_适用30系列显卡

    Mask rcnn代码实现_pytorch版 由于科研需求,要做一个图像分割的项目,于是开始着手跑一下 mask rcnn.本以为很简单的事情,网上代码比较多,结果尝试了一下,遇到了各种问题. 主要是 ...

  2. 噬血代码进不了游戏_噬血代码联机不了怎么办 噬血代码联机失败解决方法介绍-游侠网...

    噬血代码联机不了怎么办?今天我们给大家带来了噬血代码联机失败解决方法介绍,相信大家看完后,就能和小伙伴一起愉快联机了,还不知道解决方法的玩家赶紧来看看吧. 推荐阅读 联机失败解决方法介绍 多人连线不稳 ...

  3. Mask rcnn 代码复现

    首先去github上下载mask-rcnn源码 GitHub - matterport/Mask_RCNN: Mask R-CNN for object detection and instance ...

  4. Mask Rcnn代码与原理相结合解析

    1:前言 文章目录 1:前言 2:图片的预处理 3:整体流程概述 4:搭建特征提取网络 4:anchors的形成 5:RPN网络的搭建 6:Proposal Layer 7:创建标签 8:ROIAli ...

  5. Mask RCNN代码

    matterport/Mask rcnn model.py是网络主要构建的文件 utils.py中的anchor产生函数部分,主要是涉及函数: RPN部分 scales:(32, 64, 128, 2 ...

  6. [detectron2 ] Mask R-CNN代码笔记

    主要代码文件路径: 总架构文件: detectron2/detectron2/modeling/meta_arch/rcnn.py 默认配置:detectron2/detectron2/config/ ...

  7. mask rcnn 超详细代码解读(一)

    mask r-cnn 代码解读(一) 文章目录 1 代码架构 2 model.py 的结构 3 train过程代码解析 3.1 Resnet Graph 3.2 Region Proposal Net ...

  8. Mask R-CNN Keras 对象检测 对象分割 像素掩码

    原文链接 Mask R-CNN Keras 对象检测 对象分割 像素掩码 在 2019年7月16日 上张贴 由 hotdog发表回复 Mask R-CNN Keras 在本教程中,您将学习如何使用 K ...

  9. 目标分割:Mask RCNN

    日萌社 人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新) 目标分割:Mask RCNN 目标分割:Mask RCNN 气 ...

最新文章

  1. dfmea文件_PFMEA执行之步骤七:结果文件化 vs 高层管理者的承诺
  2. ECMAScript6变量的解构赋值
  3. python基础教程书-7本Python必读的入门书籍
  4. ajax post forbidden,POST方法总是返回403 Forbidden
  5. Pytorch CookBook
  6. [BZOJ1007](HNOI2008)水平可见直线(半平面交习题)
  7. LVS nat 负载均衡实验
  8. OpenKG 祝大家元宵节快乐!
  9. Java发送GET/POST请求
  10. Java 源码 —— List
  11. 怎么能更好地利用好大数据分析
  12. 新手入门概览(一):机器学习
  13. underscore 系列之内部函数 restArgs
  14. 将byte[]转为各种进制的字符串
  15. 打印显示服务器存储空间不足,服务器存储空间不足,无法处理此命令。 ID 2019 或 2020...
  16. 《数学之美》阅读笔记(持续更新……)
  17. 【JS】网页自动连点器,选取网页元素连续点击
  18. Projecting Your View Attentively: Monocular Road Scene Layout Estimation via Cross-view Transformati
  19. 读河南干旱帖有感而发的一天(20191006)
  20. vue校验输入框不能有中文

热门文章

  1. PowerShell隐藏不显示窗口的多种方法
  2. 华为设备配置策略路由命令
  3. vue输入框禁止输入表情的实现方法
  4. javascript getElementByID,getElementsByName,getElementsByTagName的区别
  5. 汇编常用寄存器以及寻址方式
  6. 教你如何爬小说(含全代码)
  7. 实战派来了!聊聊百度智能运维的“前世今生” | 技术沙龙
  8. Django cms 教程六:集成博客/新闻模块
  9. Servlet设置欢迎页面!
  10. 微信开发者工具未绑定企业号开发者