此部分为mask-rcnn中clip_boxes_graph()函数的使用。首先利用代码解决基本函数的使用,然后运行代码,其细节如下:
代码如下:
import tensorflow as tf
import numpy as np
import random
sess=tf.Session()
window=[0.0,0.0,1.0,1.0] box_rand=np.array([round(random.random( ),1) for i in range(32)]).reshape((8,4)) # 随机生成[0,1]之间的数去模拟box坐标
box_rand=box_rand.astype(np.float32)
print('show box_rand=',box_rand) # 显示模拟的box wind_split=tf.split(window, 4)
wind_sp=sess.run(wind_split)
print('wind_split=',wind_sp) # 查看split的分割情况
print(np.array(wind_split).shape) # 打印维度
y1, x1, y2, x2 = tf.split(box_rand, 4, axis=1) # 表示延第二个维度分割成4个张量
y=sess.run(y1) # 显示第一个分割内容,其它语气类似
print('show value y1=',y) def clip_boxes_graph(boxes, window):
"""
boxes: [N, (y1, x1, y2, x2)]
window: [4] in the form y1, x1, y2, x2
"""
# Split
wy1, wx1, wy2, wx2 = tf.split(window, 4)
y1, x1, y2, x2 = tf.split(boxes, 4, axis=1)
# Clip
# 以y1为例,要求wy1 < y1 < wy2,其余类似,相当与x1/y1/x2/y2取值范围为[0,1]闭区间
y1 = tf.maximum(tf.minimum(y1, wy2), wy1)
x1 = tf.maximum(tf.minimum(x1, wx2), wx1)
y2 = tf.maximum(tf.minimum(y2, wy2), wy1)
x2 = tf.maximum(tf.minimum(x2, wx2), wx1)
clipped = tf.concat([y1, x1, y2, x2], axis=1, name="clipped_boxes")
clipped.set_shape((clipped.shape[0], 4))
return clipped clip=clip_boxes_graph(box_rand,window)
clip=sess.run(clip)
print('show function value clipped=',clip)
print('show function value shape clipped=',clip.shape) 结果如下:

show box_rand= [[0. 0.5 0.1 0.7]
[0.3 0.5 0.6 0.2]
[0.1 0.6 0.6 0.6]
[0.8 0.8 0.9 0.6]
[0.5 0.1 0.8 0.3]
[0.2 0.2 0.1 0.7]
[1. 0.3 1. 0.2]
[0.1 0.8 0. 0.1]]
wind_split= [array([0.], dtype=float32), array([0.], dtype=float32), array([1.], dtype=float32), array([1.], dtype=float32)]
(4,)
show value y1= [[0. ]
[0.3]
[0.1]
[0.8]
[0.5]
[0.2]
[1. ]
[0.1]]
show function value clipped= [[0. 0.5 0.1 0.7]
[0.3 0.5 0.6 0.2]
[0.1 0.6 0.6 0.6]
[0.8 0.8 0.9 0.6]
[0.5 0.1 0.8 0.3]
[0.2 0.2 0.1 0.7]
[1. 0.3 1. 0.2]
[0.1 0.8 0. 0.1]]
show function value shape clipped= (8, 4)


mask-rcnn解读(一):clip_boxes_graph的更多相关文章

  1. 目标检测论文解读11——Mask R-CNN

    目的 让Faster R-CNN能做实例分割的任务. 方法 模型的结构图如下. 与Faster R-CNN相比,主要有两点变化. (1) 用RoI Align替代RoI Pool. 首先回顾一下RoI ...

  2. [Network Architecture]Mask R-CNN论文解析(转)

    前言 最近有一个idea需要去验证,比较忙,看完Mask R-CNN论文了,最近会去研究Mask R-CNN的代码,论文解析转载网上的两篇博客 技术挖掘者 remanented 文章1 论文题目:Ma ...

  3. mask rcnn和roi-align

    faster-rcnn的github源码中是round四舍五入 但kaiming he的ppt是直接取整 1.讲roi-align和roi-pooling区别并且详细阐述roi-align过程的博客: ...

  4. 论文笔记:Mask R-CNN

    之前在一次组会上,师弟诉苦说他用 UNet 处理一个病灶分割的任务,但效果极差,我看了他的数据后发现,那些病灶区域比起整张图而言非常的小,而 UNet 采用的损失函数通常是逐像素的分类损失,如此一来, ...

  5. mask rcnn

    Mask RCNN Mask RCNN 中主要改进是在faster rcnn中box regression 的branch 上加入mask prediction branch,能够得到点到点的预测. ...

  6. 论文阅读笔记三十六:Mask R-CNN(CVPR2017)

    论文源址:https://arxiv.org/pdf/1703.06870.pdf 开源代码:https://github.com/matterport/Mask_RCNN 摘要 Mask R-CNN ...

  7. Mask RCNN 源码阅读(update)

    之前看了Google官网的object_dectect 的源码,感觉Google大神写的还不错.最近想玩下Mask RCNN,就看了下源码,这里刚好当做总结和梳理.链接如下: Google官网的obj ...

  8. 目标检测网络之 Mask R-CNN

    Mask R-CNN 论文Mask R-CNN(ICCV 2017, Kaiming He,Georgia Gkioxari,Piotr Dollár,Ross Girshick, arXiv:170 ...

  9. Mask RCNN 学习笔记

    下面会介绍基于ResNet50的Mask RCNN网络,其中会涉及到RPN.FPN.ROIAlign以及分类.回归使用的损失函数等 介绍时所采用的MaskRCNN源码(python版本)来源于GitH ...

  10. [Object Tracking] **Mask R-CNN

    From: 如何评价 Kaiming He 最新的 Mask R-CNN? 如何跟进这些人,是个能力,要慢慢掌握. https://github.com/CharlesShang/FastMaskRC ...

随机推荐

  1. 《SQL Server 2008 R2》 收缩数据库日志文件

    USE [master] GO /****** Object: StoredProcedure [dbo].[pro_Shrink_Log] Script Date: 2019/8/16 16:56: ...

  2. 08配置基础路径 同时导出一个函数和一个变量 封装微信请求Api

    地址===>https://www.bilibili.com/video/av58993009/?p=46 1==>配置基础路径同时导出一个函数和一个变量 var mynetwork= f ...

  3. linux (08) nginx入门详解

    一. nginx 入门 nginx 入门学习 web服务器软件 windows IIS服务器 linux nginx apache 收费​lighthttp 公司的技术栈 收费版技术栈 apache ...

  4. 201871010112-梁丽珍《面向对象程序设计(java)》第十一周学习总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...

  5. 201871010121-王方-《面向对象(java)程序设计对象》第十周学习总结

    王方第九周Java实验总结 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.co ...

  6. 09-tensorflow-tf.split()

    # 'value' is a tensor with shape [5, 30] # Split 'value' into 3 tensors with sizes [4, 15, 11] along ...

  7. linux下安装编译为安装的php扩展

    1.进入php源码包中,找到需要安装的扩展模块目录.cd /root/php-5.6.26/ext/mbstring 2.在扩展模块目录,运行phpize程序,(作用是检测 php 的内核版本,并为扩 ...

  8. JAVA并发-CountDownLatch

    源码: 内部类Sync private static final class Sync extends AbstractQueuedSynchronizer { private static fina ...

  9. 为什么说要搞定微服务架构,先搞定RPC框架

    今天开始聊一些微服务的实践,第一块,RPC框架的原理及实践,为什么说要搞定微服务架构,先搞定RPC框架呢? 一.需求缘起 服务化的一个好处就是,不限定服务的提供方使用什么技术选型,能够实现大公司跨团队 ...

  10. UrlRouting原理笔记

    UrlRouting路由流程: 添加路由:可以通过调用MapRoute().MapPageRoute(),它们内部都是创建Route对象,最终添加到RouteCollection中. 还可以使用[Ro ...