此部分为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. MNIST数据集上卷积神经网络的简单实现(使用PyTorch)

    设计的CNN模型包括一个输入层,输入的是MNIST数据集中28*28*1的灰度图 两个卷积层, 第一层卷积层使用6个3*3的kernel进行filter,步长为1,填充1.这样得到的尺寸是(28+1* ...

  2. 解决Error: ENOENT: no such file or directory, scandir 'xxx\node-sass\vendor'

      解决方案是执行以下方法: npm rebuild node-sass

  3. git stash 命令

    摘自: http://blog.csdn.net/longxiaowu/article/details/26815433 关于git stash命令的使用方法网上一大把,我想记录的是我在使用过程中觉得 ...

  4. 201871010134-周英杰《面向对象程序设计(java)》第八周学习总结

    201871010134-周英杰<面向对象程序设计(java)>八周学习总结 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个 ...

  5. 快速安装Rainbond——开源企业级Paas平台

    快速安装Rainbond--开源企业级Paas平台 参考:https://www.rainbond.com/docs/user-operations/install/online_install/ R ...

  6. USACO Building Roads

    洛谷 P2872 [USACO07DEC]道路建设Building Roads 洛谷传送门 JDOJ 2546: USACO 2007 Dec Silver 2.Building Roads JDOJ ...

  7. thymeleaf:在一个页面中引入其它的页面

    这个在jsp中很容易实现,但是springBoot不推荐使用jsp,建议使用thymeleaf,下面是在thymeleaf中引入界面的方法 1.修改配置文件 spring: mvc: static-p ...

  8. Django2.2 Vue 前后端分离 无法访问Cookie

    个人验证后可用配置如下: 环境: - Django 2.2 - djangorestframework 3.9 - django-cors-headers 2.5.3 INSTALLED_APPS = ...

  9. [LeetCode] 344. Reverse String 翻转字符串

    Write a function that reverses a string. The input string is given as an array of characters char[]. ...

  10. [LeetCode] 187. Repeated DNA Sequences 求重复的DNA序列

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...