谁有ws sizeboxx的模型能发给我 谢谢

box-sizing 与 盒模型 - 简书
box-sizing 与 盒模型
box-sizing 属性用于改变元素相对于其“盒模型”的大小的方式。
我们首先再次将这个盒模型的图搬了上来。
标准盒模型
通常,当设置元素的大小时,width 和 height 属性确定元素的内容框的宽度和高度。添加到元素上任意的 padding 都将增加元素的总计算宽度和(或)高度 —— 这是默认的盒模型在调整元素大小时的工作原理。
因为这是盒子模型尺寸在 CSS 中的工作原理。如果你不知道这一点,你可能不会总是得到你最终想要的尺寸。
.element {
width: 100
height: 100
如果我们再添加一个 padding 属性:
.element {
width: 100
height: 100
padding: 20
因为 padding 区域的宽度将被添加到内容区域的宽度,因此总宽度(和高度)将增加。
原本的 100 x 100 像素的元素将变为一个 120 x 120 像素的元素。
你以为到这里就结束了?接着往下看:
我们一般会为我们的元素添加边框的。因此,我们再来添加一个 border 属性好了:
.element {
width: 100
height: 100
padding: 20
border: 5px solid #000;
此时,我们又添加了一个 border 属性,那么此时的盒模型大小再次发生了改变。
原本的 120 x 120 像素的元素将变为 130 x 130 像素的元素。
当然,你还可以再给其添加 margin 属性,我这里就不演示了,相信大家都理解并在这里复习了一遍。
box-sizing
我在前面为什么要使用盒模型作为铺垫内容呢?就是为了是大家更好地理解 box-sizing
这个属性的工作原理是什么。
box-sizing 属性允许你控制元素尺寸的大小如何工作。
使用 box-sizing 属性,你可以告诉浏览器在元素的宽度中包括 padding 的宽度和(或) border 宽度,而不是增加该宽度。
因此,在上面的示例中,你可以更改默认框大小从 content-box(记住:height 和 width 指定内容区域的高度和宽度)改为 padding-box ; 通过将其更改为 padding-box,你的元素将宽度为 110px,高度为 110px,内部宽度为 20px,因此只有 border 宽度添加到 width 和 height 属性的值。
当您创建流体(flow)和网格(grid)布局时,例如,你需要计算列的宽度时,这是特别有用的。而不必担心额外的 padding 和 border 宽度会破坏布局,使创建布局更容易。
接下来我们来看看它的参数:content-box(默认) | padding-box | border-box | inherit
content-box:默认行为。指定的宽度高度(以及相应的 min-width,min-height 和 max-width,max-height 属性)分别适用于元素的内容框的宽度和高度。元素的 padding 和 border 被布置并绘制在指定的宽度和高度之外。元素的指定宽度和高度不包括 padding 和 border。
padding-box:此元素上的指定宽度和高度(以及相应的 min-width,min-height 和 max-width,max-height 属性)确定元素的填充框。也就是说,在元素上指定的任何 padding 都会布局并在此指定的宽度和高度内绘制。通过从指定的 width 和 height 属性中减去各边的 padding 宽度来计算内容宽度和高度。由于内容宽度和高度不能为负,因此该计算的值为 0。也就是说,如果 padding 对于指定的宽度和高度太大,则内容区域的大小可能为零。**元素的宽度和高度包括 padding,但不包括 border **。
border-box:此元素上指定的宽度和高度(以及相应的 min-width,min-height 和 max-width,max-height 属性)确定元素的边框。也就是说,元素上指定的任何 padding 或 border 都会在此指定的宽度和高度内进行布局和绘制。通过从指定的 width 和 height 属性中减去各边的 padding 宽度来计算内容宽度和高度。由于内容宽度和高度不能为负,因此该计算的值为 0。也就是说,如果 padding 对于指定的宽度和高度太大,则内容区域的大小可能为零。指定的宽度和高度包括 padding 和 border。
我知道你们现在内心中有一种“太长不看”的心态,但是请耐着性子将上面那段话再重复地看一遍。其实很简单,只要理解到位了,中心思想就是:到底要不要包括 padding 和 border 在盒模型内部。
我们来看一个例子:
所有以下容器都使用 width 和 height 属性都被设置为相同的宽度和高度。第一个具有默认的框大小调整值,第二个框具有设置为 padding-box 的框大小,第三个框具有设置为border-box 的框大小。让我们一起来看看它们的区别:
box-sizing
以上所有三个框都有一个 200px 的宽度和高度,30px 的 padding(四边)和一个 10px的 border 。
如果你的浏览器不支持 padding-box 值,第二个框可能会与第一个框相同。
请记住,下面这句话很重要!
padding-box 已从规范中移除。
因此,我们使用的时候只有 border-box 和 inherit 两个值可以使用(由于 content-box 为默认值我就省略了)。
以下是我使用的 webstorm IDE 的截图显示:
目前这个属性的兼容性已经很好了,因此可以放心的使用(旧版本 IE 不支持)。
本节我们介绍了 box-sizing 的相关知识,并且还将盒模型再次复习了一遍,不知道你有没有学习到新东西呢?
热爱一切新奇事物的可爱蓝孩纸~o( =oωo= )m
问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补丁和内补丁不同问题症状:随便写几个标签,不加样式控制的情况下,各自的margin 和padding差异较大。碰到频率:100%解决方案:CSS里 {margin...
H5移动端知识点总结 阅读目录 移动开发基本知识点 calc基本用法 box-sizing的理解及使用 理解display:box的布局 理解flex布局 Flex布局兼容知识点总结 回到顶部 移动开发基本知识点 一. 使用rem作为单位 html { font-size:...
移动开发基本知识点 一.使用rem作为单位 html { font-size: 100 } @media(min-width: 320px) { html { font-size: 100 } } @media(min-width: 360px) { html ...
选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,list-style 优先 计算方法 a-===行内样式 b-id选择器的数量 c=类,伪类和属性选择器的数量 d=标签选择器和微元素选择器的数量 value=a*...
选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,list-style 优先 计算方法 a-===行内样式 b-id选择器的数量 c=类,伪类和属性选择器的数量 d=标签选择器和微元素选择器的数量 value=a*...
竺校长抗战西迁日记(连载第1293天) 日(六)贵阳~遵义,晨阴,下午晴,傍晚29°。 晨五点起。七点至冠生园吃早点。遇刘廷蔚及其夫人与吴主席夫人(刘之丈母娘)。
八点至护国路146 号,晤刘俊杰,告知明日不能参加浙大同学会的茶聚。八点半至社会服...
半夜从梦中醒来,准确的说应该是做了个梦,惊醒的,梦见了前男友结婚了。梦里刚刚开始是跟在跟父母吃饭,经常不下厨的我爸做了个香菜拌金针菇,醒来时香菜那浓烈而有独特的味道,还充斥在的脑海中,久久挥之不去,然后我爸讲了个笑话,我特别想发朋友圈,朋友圈还没发完,闺蜜递给我她...
在js的懒汉式单例模式中,其实也用到了另一种设计模式,即模块模式。在传统软件工程中,模块模式被定义为给类提供私有和公共封装的一种方法,也就是我们常说的“模块化”。在Java里面Class就是一种模块,解决了属性、方法的封装问题,它的模块模式直接就融合到语言特性里面了,因此也...
一个人时候总是听着音乐,思绪顺着回忆的夹缝去寻求故事的渊源。那些人,那些事,它们在哪里?她们在干什么?他们过得好不好? 【一】南阳科子 很奇怪的名字,可是这个名字这几天来一直在我脑海里盘旋、挥之不去...... 南阳科子、南阳科子、南阳科子、南阳科子… … 第一次见到他,安...大学作业急需整套的咖啡厅设计,CAD设计图,和3D效果图,3D源文件模型,谁能发给我?谢谢!!!_百度知道
大学作业急需整套的咖啡厅设计,CAD设计图,和3D效果图,3D源文件模型,谁能发给我?谢谢!!!
我有更好的答案
咖啡厅的设计风格现在比较流行的就是LOFT工业风,把硬朗的水泥管道和工业元素造型融合在空间中,也能给你一俩套loft咖啡厅的CAD和3D模型效果图对照参考吧
为您推荐:
其他类似问题
咖啡厅设计的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。转载请注明出处,楼燚(yì)航的blog,
这是我在github上修改的几个文件的链接,求星星啊,求星星啊(原谅我那么不要脸~~)
在之前两篇文章中我介绍了怎么编译Fast RCNN,和怎么修改Fast RCNN的读取数据接口,接下来我来说明一下怎么来训练网络和之后的检测过程
先给看一下极好的检测效果
1.预训练模型介绍
首先在data目录下,有两个目录就是之前在1中解压好
fast_rcnn_models/
imagenet_models/
fast_rcnn_model文件夹下面是作者用fast rcnn训练好的三个网络,分别对应着小、中、大型网络,大家可以试用一下这几个网络,看一些检测效果,他们训练都迭代了40000次,数据集都是pascal_voc的数据集。
caffenet_fast_rcnn_iter_40000.caffemodel
vgg_cnn_m_1024_fast_rcnn_iter_40000.caffemodel
vgg16_fast_rcnn_iter_40000.caffemodel
imagenet_model文件夹下面是在Imagenet上训练好的通用模型,在这里用来初始化网络的参数
CaffeNet.v2.caffemodel
VGG_CNN_M_1024.v2.caffemodel
VGG16.v2.caffemodel
在这里我比较推荐先用中型网络训练,中型网络训练和检测的速度都比较快,效果也都比较理想,大型网络的话训练速度比较慢,我当时是5000多个标注信息,网络配置默认,中型网络训练大概两三个小时,大型网络的话用十几个小时,需要注意的是网络训练最好用GPU,CPU的话太慢了,我当时用的实验室的服务器,有16块Tesla K80,用起来真的是灰常爽!
2. 修改模型文件配置
模型文件在models下面对应的网络文件夹下,在这里我用中型网络的配置文件修改为例子
比如:我的检测目标物是car ,那么我的类别就有两个类别即 background 和 car
因此,首先打开网络的模型文件夹,打开train.prototxt
修改的地方重要有三个
分别是个地方
首先在data层把num_classes 从原来的21类 20类+背景 ,改成 2类 车+背景
接在在cls_score层把num_output 从原来的21 改成 2
在bbox_pred层把num_output 从原来的84 改成8, 为检测类别个数乘以4,比如这里是2类那就是2*4=8
OK,如果你要进一步修改网络训练中的学习速率,步长,gamma值,以及输出模型的名字,需要在同目录下的solver.prototxt中修改。
train_net: &models/VGG_CNN_M_1024/train.prototxt&
base_lr: 0.001
lr_policy: &step&
gamma: 0.1
stepsize: 30000
display: 20
average_loss: 100
momentum: 0.9
weight_decay: 0.0005
# We disable standard caffe solver snapshotting and implement our own snapshot
# function
snapshot: 0
# We still use the snapshot prefix, though
snapshot_prefix: &vgg_cnn_m_1024_fast_rcnn&
#debug_info: true
3.启动Fast RCNN网络训练
启动训练:
./tools/train_net.py --gpu 11 --solver models/VGG_CNN_M_1024_LOUYIHANG/solver.prototxt --weights data/imagenet_models/VGG_CNN_M_1024.v2.caffemodel --imdb KakouTrain
参数讲解:
这里的--是两个-,markdown写的,大家不要输错
train_net.py是网络的训练文件,之后的参数都是附带的输入参数
--gpu 代表机器上的GPU编号,如果是nvidia系列的tesla显卡,可以在终端中输入nvidia-smi来查看当前的显卡负荷,选择合适的显卡
--solver 代表模型的配置文件,train.prototxt的文件路径已经包含在这个文件之中
--weights 代表初始化的权重文件,这里用的是Imagenet上预训练好的模型,中型的网络我们选择用VGG_CNN_M_1024.v2.caffemodel
--imdb 这里给出的训练的数据库名字需要在factory.py的__sets中,我在文件里面有__sets['KakouTrain'],train_net.py这个文件会调用factory.py再生成kakou这个类,来读取数据
4.启动Fast RCNN网络检测
我修改了tools下面的demo.py这个文件,用来做检测,并且将检测的坐标结果输出到相应的txt文件中
可以看到原始的demo.py 是用网络测试了两张图像,并做可视化输出,有具体的检测效果,但是我是在Linux服务器的终端下,没有display device,因此部分代码要少做修改
下面是原始的demo.py:
#!/usr/bin/env python
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
Demo script showing detections in sample images.
See README.md for installation instructions before running.
import _init_paths
from fast_rcnn.config import cfg
from fast_rcnn.test import im_detect
from utils.cython_nms import nms
from utils.timer import Timer
import matplotlib.pyplot as plt
import numpy as np
import scipy.io as sio
import caffe, os, sys, cv2
import argparse
CLASSES = ('__background__',
'aeroplane', 'bicycle', 'bird', 'boat',
'bottle', 'bus', 'car', 'cat', 'chair',
'cow', 'diningtable', 'dog', 'horse',
'motorbike', 'person', 'pottedplant',
'sheep', 'sofa', 'train', 'tvmonitor')
NETS = {'vgg16': ('VGG16',
'vgg16_fast_rcnn_iter_40000.caffemodel'),
'vgg_cnn_m_1024': ('VGG_CNN_M_1024',
'vgg_cnn_m_1024_fast_rcnn_iter_40000.caffemodel'),
'caffenet': ('CaffeNet',
'caffenet_fast_rcnn_iter_40000.caffemodel')}
def vis_detections(im, class_name, dets, thresh=0.5):
&&&Draw detected bounding boxes.&&&
inds = np.where(dets[:, -1] &= thresh)[0]
if len(inds) == 0:
im = im[:, :, (2, 1, 0)]
fig, ax = plt.subplots(figsize=(12, 12))
ax.imshow(im, aspect='equal')
for i in inds:
bbox = dets[i, :4]
score = dets[i, -1]
ax.add_patch(
plt.Rectangle((bbox[0], bbox[1]),
bbox[2] - bbox[0],
bbox[3] - bbox[1], fill=False,
edgecolor='red', linewidth=3.5)
ax.text(bbox[0], bbox[1] - 2,
'{:s} {:.3f}'.format(class_name, score),
bbox=dict(facecolor='blue', alpha=0.5),
fontsize=14, color='white')
ax.set_title(('{} detections with '
'p({} | box) &= {:.1f}').format(class_name, class_name,
fontsize=14)
plt.axis('off')
plt.tight_layout()
plt.draw()
def demo(net, image_name, classes):
&&&Detect object classes in an image using pre-computed object proposals.&&&
# Load pre-computed Selected Search object proposals
box_file = os.path.join(cfg.ROOT_DIR, 'data', 'demo',
image_name + '_boxes.mat')
obj_proposals = sio.loadmat(box_file)['boxes']
# Load the demo image
im_file = os.path.join(cfg.ROOT_DIR, 'data', 'demo', image_name + '.jpg')
im = cv2.imread(im_file)
# Detect all object classes and regress object bounds
timer = Timer()
timer.tic()
scores, boxes = im_detect(net, im, obj_proposals)
timer.toc()
print ('Detection took {:.3f}s for '
'{:d} object proposals').format(timer.total_time, boxes.shape[0])
# Visualize detections for each class
CONF_THRESH = 0.8
NMS_THRESH = 0.3
for cls in classes:
cls_ind = CLASSES.index(cls)
cls_boxes = boxes[:, 4*cls_ind:4*(cls_ind + 1)]
cls_scores = scores[:, cls_ind]
dets = np.hstack((cls_boxes,
cls_scores[:, np.newaxis])).astype(np.float32)
keep = nms(dets, NMS_THRESH)
dets = dets[keep, :]
print 'All {} detections with p({} | box) &= {:.1f}'.format(cls, cls,
CONF_THRESH)
vis_detections(im, cls, dets, thresh=CONF_THRESH)
def parse_args():
&&&Parse input arguments.&&&
parser = argparse.ArgumentParser(description='Train a Fast R-CNN network')
parser.add_argument('--gpu', dest='gpu_id', help='GPU device id to use [0]',
default=0, type=int)
parser.add_argument('--cpu', dest='cpu_mode',
help='Use CPU mode (overrides --gpu)',
action='store_true')
parser.add_argument('--net', dest='demo_net', help='Network to use [vgg16]',
choices=NETS.keys(), default='vgg16')
args = parser.parse_args()
return args
if __name__ == '__main__':
args = parse_args()
prototxt = os.path.join(cfg.ROOT_DIR, 'models', NETS[args.demo_net][0],
'test.prototxt')
caffemodel = os.path.join(cfg.ROOT_DIR, 'data', 'fast_rcnn_models',
NETS[args.demo_net][1])
if not os.path.isfile(caffemodel):
raise IOError(('{:s} not found.\nDid you run ./data/script/'
'fetch_fast_rcnn_models.sh?').format(caffemodel))
if args.cpu_mode:
caffe.set_mode_cpu()
caffe.set_mode_gpu()
caffe.set_device(args.gpu_id)
net = caffe.Net(prototxt, caffemodel, caffe.TEST)
print '\n\nLoaded network {:s}'.format(caffemodel)
print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
print 'Demo for data/demo/000004.jpg'
demo(net, ';, ('car',))
print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
print 'Demo for data/demo/001551.jpg'
demo(net, ';, ('sofa', 'tvmonitor'))
plt.show()
复制这个demo.py 修改成CarFaceTest.py,下面是修改后的文件
修改后的文件主要是添加了outputDetectionResult和runDetection两个函数, 添加了部分注释
#!/usr/bin/env python
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
Demo script showing detections in sample images.
See README.md for installation instructions before running.
import _init_paths
from fast_rcnn.config import cfg
from fast_rcnn.test import im_detect
from utils.cython_nms import nms
from utils.timer import Timer
import matplotlib.pyplot as plt
import numpy as np
import scipy.io as sio
import caffe, os, sys, cv2
import argparse
#CLASSES = ('__background__','aeroplane','bicycle','bird','boat',
'bottle','bus','car','cat','chair','cow','diningtable','dog','horse'
'motorbike','person','pottedplant','sheep','sofa','train','tvmonitor')
CLASSES = ('__background__','car') #需要跟自己训练的数据集中的类别一致,原来是21类的voc数据集,自己的数据集就是car和background
NETS = {'vgg16': ('VGG16',
'vgg16_fast_rcnn_iter_40000.caffemodel'),
'vgg_cnn_m_1024': ('VGG_CNN_M_1024',
'vgg_cnn_m_1024_fast_rcnn_iter_40000.caffemodel'),
'vgg_cnn_m_1024_louyihang': ('VGG_CNN_M_1024_LOUYIHANG',
'vgg_cnn_m_1024_fast_rcnn_louyihang_iter_40000.caffemodel'),
'caffenet': ('CaffeNet',
'caffenet_fast_rcnn_iter_40000.caffemodel'),
'caffenet_louyihang':('CaffeNet_LOUYIHANG',
'caffenet_fast_rcnn_louyihang_iter_40000.caffemodel'),
'vgg16_louyihang':('VGG16_LOUYIHANG',
'vgg16_fast_rcnn_louyihang_iter_40000.caffemodel')}#映射到对应的模型文件
def outputDetectionResult(im, class_name, dets, thresh=0.5): #打开相应的输出文件
outputFile = open('CarDetectionResult.txt')
inds = np.where(dets[:,-1] &= thresh)[0]
if len(inds) == 0:
def runDetection (net, basePath, testFileName,classes):#这个函数是自己后加的,取代了demo函数,给定测试数据列表
ftest = open(testFileName,'r')
imageFileName = basePath+'/' + ftest.readline().strip()
outputFile = open('CarDetectionResult.txt','w')
while imageFileName:
print imageFileName
print 'now is ', num
imageFileBaseName = os.path.basename(imageFileName)
imageFileDir = os.path.dirname(imageFileName)
boxFileName = imageFileDir +'/'+imageFileBaseName.replace('.jpg','_boxes.mat')
print boxFileName
obj_proposals = sio.loadmat(boxFileName)['boxes']
#obj_proposals[:,2] = obj_proposals[:, 2] + obj_proposals[:, 0]#这里也需要注意,OP里面的坐标数据是否为x1y1x2y2还是x1y1wh
#obj_proposals[:,3] = obj_proposals[:, 3] + obj_proposals[:, 1]
im = cv2.imread(imageFileName)
timer = Timer()
timer.tic()
scores, boxes = im_detect(net, im, obj_proposals)#检测函数
timer.toc()
print ('Detection took {:.3f} for '
'{:d} object proposals').format(timer.total_time, boxes.shape[0])
CONF_THRESH = 0.8
NMS_THRESH = 0.3#NMS参数用来控制非极大值抑制
for cls in classes:
cls_ind = CLASSES.index(cls)
cls_boxes = boxes[:, 4*cls_ind:4*(cls_ind + 1)]
cls_scores = scores[:, cls_ind]
dets = np.hstack((cls_boxes,
cls_scores[:, np.newaxis])).astype(np.float32)
keep = nms(dets, NMS_THRESH)
dets = dets[keep, :]
print 'All {} detections with p({} | box) &= {:.1f}'.format(cls, cls,
CONF_THRESH)
inds = np.where(dets[:, -1] &= CONF_THRESH)[0]
print 'inds.size', inds.size
if len(inds) != 0:
outputFile.write(imageFileName+' ')
outputFile.write(str(inds.size)+' ')将检测的结果写出相应的文件里
for i in inds:
bbox = dets[i, :4]
outputFile.write(str(int(bbox[0]))+' '+ str(int(bbox[1]))+' '+ str(int(bbox[2]))+' '+ str(int(bbox[3]))+' ')
outputFile.write('\n')
outputFile.write(imageFileName +' 0' '\n')
temp = ftest.readline().strip()
imageFileName = basePath+'/' + temp
def vis_detections(im, class_name, dets, thresh=0.5):#这个函数需要加以说明,这个函数虽然没有用,但是我的服务器上没有输出设备
&&&Draw detected bounding boxes.&&&#因此要将部分用到显示的函数给注释掉,否则运行会报错
inds = np.where(dets[:, -1] &= thresh)[0]
print 'inds.shape', inds.shape
print inds
print 'inds.size', inds.size
if len(inds) == 0:
#im = im[:, :, (2, 1, 0)]
#fig, ax = plt.subplots(figsize=(12, 12))
#ax.imshow(im, aspect='equal')
#for i in inds:
bbox = dets[i, :4]
score = dets[i, -1]
ax.add_patch(
plt.Rectangle((bbox[0], bbox[1]),
bbox[2] - bbox[0],
bbox[3] - bbox[1], fill=False,
edgecolor='red', linewidth=3.5)
ax.text(bbox[0], bbox[1] - 2,
'{:s} {:.3f}'.format(class_name, score),
bbox=dict(facecolor='blue', alpha=0.5),
fontsize=14, color='white')
#ax.set_title(('{} detections with '
'p({} | box) &= {:.1f}').format(class_name, class_name,
fontsize=14)
#plt.axis('off')
#plt.tight_layout()
#plt.draw()
def demo(net, image_name, classes):#原来的demo函数,没有修改
&&&Detect object classes in an image using pre-computed object proposals.&&&
# Load pre-computed Selected Search object proposals
#box_file = os.path.join(cfg.ROOT_DIR, 'data', 'demo',image_name + '_boxes.mat')
basePath='/home/chenjie/DataSet/500CarTestDataSet2'
box_file = os.path.join(basePath,image_name + '_boxes.mat')
obj_proposals = sio.loadmat(box_file)['boxes']
# Load the demo image
#im_file = os.path.join(cfg.ROOT_DIR, 'data', 'demo', image_name + '.jpg')
im_file = os.path.join(basePath, image_name + '.jpg')
im = cv2.imread(im_file)
# Detect all object classes and regress object bounds
timer = Timer()
timer.tic()
scores, boxes = im_detect(net, im, obj_proposals)
timer.toc()
print ('Detection took {:.3f}s for '
'{:d} object proposals').format(timer.total_time, boxes.shape[0])
# Visualize detections for each class
CONF_THRESH = 0.8
NMS_THRESH = 0.3
for cls in classes:
cls_ind = CLASSES.index(cls)
cls_boxes = boxes[:, 4*cls_ind:4*(cls_ind + 1)]
cls_scores = scores[:, cls_ind]
dets = np.hstack((cls_boxes,
cls_scores[:, np.newaxis])).astype(np.float32)
keep = nms(dets, NMS_THRESH)
dets = dets[keep, :]
print 'All {} detections with p({} | box) &= {:.1f}'.format(cls, cls,
CONF_THRESH)
vis_detections(im, cls, dets, thresh=CONF_THRESH)
def parse_args():
&&&Parse input arguments.&&&
parser = argparse.ArgumentParser(description='Train a Fast R-CNN network')
parser.add_argument('--gpu', dest='gpu_id', help='GPU device id to use [0]',
default=0, type=int)
parser.add_argument('--cpu', dest='cpu_mode',
help='Use CPU mode (overrides --gpu)',
action='store_true')
parser.add_argument('--net', dest='demo_net', help='Network to use [vgg16]',
choices=NETS.keys(), default='vgg16')
args = parser.parse_args()
return args
if __name__ == '__main__':
args = parse_args()
prototxt = os.path.join(cfg.ROOT_DIR, 'models', NETS[args.demo_net][0],
'test.prototxt')
#caffemodel = os.path.join(cfg.ROOT_DIR, 'data', 'fast_rcnn_models',
NETS[args.demo_net][1])
#caffemodel = '/home/chenjie/fast-rcnn/output/default/KakouTrain/vgg16_fast_rcnn_louyihang_iter_40000.caffemodel'
#caffemodel = '/home/chenjie/louyihang/fast-rcnn/output/default/KakouTrain/caffenet_fast_rcnn_louyihang_iter_40000.caffemodel'
caffemodel = '/home/chenjie/fast-rcnn/output/default/KakouTrain/vgg_cnn_m_1024_fast_rcnn_louyihang_iter_40000.caffemodel'#我在这里直接指定了训练好的模型文件,训练好的模型文件是在工程根目录下的,output/default/对应的数据库名字下面
if not os.path.isfile(caffemodel):
raise IOError(('{:s} not found.\nDid you run ./data/script/'
'fetch_fast_rcnn_models.sh?').format(caffemodel))
if args.cpu_mode:
caffe.set_mode_cpu()
caffe.set_mode_gpu()
caffe.set_device(args.gpu_id)
net = caffe.Net(prototxt, caffemodel, caffe.TEST)
print '\n\nLoaded network {:s}'.format(caffemodel)
#demo(net, 'Target0/;, ('car',))
#输入对应的测试图像列表,需要在同级目录下摆放同名的_boxes.mat文件,它会自动的替换后缀名!
#runDetection(net, '/home/chenjie/DataSet/temptest','/home/chenjie/DataSet/temptest/Imagelist.txt',('car',))
runDetection(net, '/home/chenjie/DataSet/500CarTestDataSet2','/home/chenjie/DataSet/500CarTestDataSet2/Imagelist.txt',('car',))
#runDetection(net, '/home/chenjie/DataSet/Kakou_Test_Scale0.25/','/home/chenjie/DataSet/Kakou_Test_Scale0.25/imagelist.txt',('car',))
#runDetection(net, '/home/chenjie/DataSet/Images_Version1_Test_Boxes','/home/chenjie/DataSet/Images_Version1_Test_Boxes/ImageList_Version1_List.txt',('car',))
#plt.show()
5.检测结果
训练数据集
首先给出我的训练数据集,其实我的训练数据集并不是太复杂的
测试数据集
输出检测结果到txt文件中,
**在复杂场景下的测试效果非常好,速度也非常快,中型网络监测平均每张在K80显卡下时0.1~0.2S左右,图像的尺寸是480*640,6000张测试数据集下达到的准确率是98%!!!**
阅读(...) 评论()

我要回帖

更多关于 boxsize 的文章

 

随机推荐