什么纸头都可以用来做打印机卡纸怎么处理打印吗?

Faster&R-CNN安装笔记,只用CPU
R-CNN是我科大师弟任少卿在微软研究院实习时完成的,现在用深度学习做图像分割和目标检测最快的算法。
下载代码和数据
git clone --recursive&
下载demo模型数据
[root@localhost py-faster-rcnn]#
./data/scripts/fetch_faster_rcnn_models.sh
Downloading Faster R-CNN demo models (695M)...
Unzipping...
faster_rcnn_models/
faster_rcnn_models/ZF_faster_rcnn_final.caffemodel
faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel
编译cython
进入lib目录,修改setup.py,注释掉GPU相关代码,如下
locate_cuda()
#&&&&&&&&&&&
self.set_executable('compiler_so',
CUDA['nvcc'])
Extension('nms.gpu_nms',
['nms/nms_kernel.cu', 'nms/gpu_nms.pyx'],
library_dirs=[CUDA['lib64']],
libraries=['cudart'],
language='c++',
runtime_library_dirs=[CUDA['lib64']],
# this syntax is specific to this build system
# we're only going to use certain compiler args with nvcc and not
# gcc the implementation of this trick is in customize_compiler()
extra_compile_args={'gcc':
["-Wno-unused-function"],
#&&&&&&&&&&&&&&&&&&&&&&&&&&&
'nvcc': ['-arch=sm_35',
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
'--ptxas-options=-v',
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
'--compiler-options',
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
"'-fPIC'"]},
include_dirs = [numpy_include, CUDA['include']]
[root@localhost lib]# make
安装caffe(自带的,不是通用的)
进入caffe-fast-rcnn目录,大部分跟前面caffe安装记录一文一样,修改Makefile.config为
## Refer to
http://caffe.berkeleyvision.org/installation.html
# Contributions
simplifying and improving our build system are
# cuDNN acceleration
switch (uncomment to build with cuDNN).
# USE_CUDNN :=
# CPU-only switch
(uncomment to build without GPU support).
CPU_ONLY :=
# uncomment to disable
IO dependencies and corresponding data layers
# USE_OPENCV :=
# USE_LEVELDB :=
# USE_LMDB :=
# uncomment to allow
MDB_NOLOCK when reading LMDB files (only if necessary)
& You should not set this flag if you will be
reading LMDBs with any
& possibility of simultaneous read and
# ALLOW_LMDB_NOLOCK :=
# Uncomment if you're
using OpenCV 3
# OPENCV_VERSION :=
# To customize your
choice of compiler, uncomment and set the following.
# N.B. the default for
Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX :=
# CUDA directory
contains bin/ and lib/ directories that we need.
# CUDA_DIR :=
/usr/local/cuda
# On Ubuntu 14.04, if
cuda tools are installed via
# "sudo apt-get install
nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR :=
# CUDA architecture
setting: going with all of them.
# For CUDA & 6.0,
comment the *_50 lines for compatibility.
#CUDA_ARCH := -gencode
arch=compute_20,code=sm_20 \
& & & -gencode
arch=compute_20,code=sm_21 \
& & & -gencode
arch=compute_30,code=sm_30 \
& & & -gencode
arch=compute_35,code=sm_35 \
& & & -gencode
arch=compute_50,code=sm_50 \
& & & -gencode
arch=compute_50,code=compute_50
# atlas for ATLAS
# open for
(MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to
accept the defaults for your choice of BLAS
# (which should
BLAS_INCLUDE :=
/usr/include/atlas-x86_64-base
BLAS_LIB :=
/usr/lib64/atlas
# Homebrew puts
openblas in a directory that is not on the standard search
# BLAS_INCLUDE :=
$(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell
brew --prefix openblas)/lib
# This is required only
if you will compile the matlab interface.
# MATLAB directory
should contain the mex binary in /bin.
# MATLAB_DIR :=
/usr/local
# MATLAB_DIR :=
/Applications/MATLAB_R2012b.app
# NOTE: this is
required only if you will compile the python
interface.
# We need to be able to
find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE :=
/usr/include/python2.7 \
/usr/lib64/python2.7/site-packages/numpy/core/include
# Anaconda Python
distribution is quite popular. Include path:
# Verify anaconda
location, sometimes it's in root.
# ANACONDA_HOME :=
$(HOME)/anaconda
# PYTHON_INCLUDE :=
$(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python2.7 \
$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
# Uncomment to use
Python 3 (default is Python 2)
# PYTHON_LIBRARIES :=
boost_python3 python3.5m
# PYTHON_INCLUDE :=
/usr/include/python3.5m \
&/usr/lib/python3.5/dist-packages/numpy/core/include
# We need to be able to
find libpythonX.X.so or .dylib.
PYTHON_LIB :=
/usr/lib64
# PYTHON_LIB :=
$(ANACONDA_HOME)/lib
# Homebrew installs
numpy in a non standard path (keg only)
# PYTHON_INCLUDE +=
$(dir $(shell python -c 'import numpy.
print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell
brew --prefix numpy)/lib
# Uncomment to support
layers written in Python (will link against Python
WITH_PYTHON_LAYER :=
# Whatever else you
find you need goes here.
INCLUDE_DIRS :=
$(PYTHON_INCLUDE) /usr/include
LIBRARY_DIRS :=
$(PYTHON_LIB) /usr/lib64
# If Homebrew is
installed at a non standard location (for example your home
directory) and you use it for general dependencies
# INCLUDE_DIRS +=
$(shell brew --prefix)/include
# LIBRARY_DIRS +=
$(shell brew --prefix)/lib
# Uncomment to use
`pkg-config` to specify OpenCV library paths.
# (Usually not
necessary -- OpenCV libraries are normally installed in one of the
above $LIBRARY_DIRS.)
# USE_PKG_CONFIG :=
BUILD_DIR :=
DISTRIBUTE_DIR :=
distribute
# Uncomment for
debugging. Does not work on OSX due to
/BVLC/caffe/issues/171
# DEBUG :=
# The ID of the GPU
that 'make runtest' will use to run unit tests.
# TEST_GPUID :=
# enable pretty build
(comment to see full commands)
修改Makefile
LIBRARIES += satlas tatlas #新版atlas已经不用这两个lib了:cblas
编译caffe和pycaffe
&[root@localhost caffe-fast-rcnn]# make -j8
&& make pycaffe
[root@localhost py-faster-rcnn]# ./tools/demo.py
Traceback (most recent call last):
File "./tools/demo.py", line 17, in
&from fast_rcnn.config import cfg
"/root/zhanxiang/work/py-faster-rcnn/tools/../lib/fast_rcnn/config.py",
line 23, in
from easydict import EasyDict as edict
ImportError: No module named easydict
缺少Python库easydict,所以安装 pip install easydict
[root@localhost py-faster-rcnn]# ./tools/demo.py
Traceback (most recent call last):
& File "./tools/demo.py", line 18, in
& & from fast_rcnn.test
import im_detect
"/root/zhanxiang/work/py-faster-rcnn/tools/../lib/fast_rcnn/test.py",
line 15, in
& & import cv2
ImportError: No module named cv2
缺少Python库cv2,这个是openCV里面的。那就来装openCV python库
yum install opencv-python.x86_64
[root@localhost py-faster-rcnn]# python tools/demo.py
Traceback (most recent call last):
& File "tools/demo.py", line 21, in
& & import
matplotlib.pyplot as plt
"/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 26,
& & from matplotlib.figure
import Figure, figaspect
"/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 36,
& & from matplotlib.axes
import Axes, SubplotBase, subplot_class_factory
"/usr/lib64/python2.7/site-packages/matplotlib/axes/__init__.py",
line 4, in
& & from ._subplots import
"/usr/lib64/python2.7/site-packages/matplotlib/axes/_subplots.py",
line 10, in
matplotlib.axes._axes import Axes
"/usr/lib64/python2.7/site-packages/matplotlib/axes/_axes.py", line
& & from matplotlib import
unpack_labeled_data
ImportError: cannot import name
unpack_labeled_data
看起来跟matplotlib库有关,pip
install的版本太旧,直接下载源码安装。
按照官网指示,
[root@localhost work]# git clone
git:///matplotlib/matplotlib.git
[root@localhost work]# cd matplotlib/
安装依赖包
[root@localhost matplotlib]# yum-builddep
python-matplotlib
[root@localhost matplotlib]# python setup.py install
[root@localhost py-faster-rcnn]# python tools/demo.py
Traceback (most recent call last):
& File "tools/demo.py", line 19, in
fast_rcnn.nms_wrapper import nms
"/root/zhanxiang/work/py-faster-rcnn/tools/../lib/fast_rcnn/nms_wrapper.py",
line 9, in
& & from nms.gpu_nms import
ImportError: No module named gpu_nms
修改nms_wrapper.py,改force_cpu
[root@localhost py-faster-rcnn]# vi
lib/fast_rcnn/nms_wrapper.py
nms (dets, thresh, force_cpu
[root@localhost py-faster-rcnn]# python
tools/demo.py --cpu
就能看到结果了
<img STYLE="height:"
ALT="Faster&R-CNN安装笔记,只用CPU"
TITLE="Faster&R-CNN安装笔记,只用CPU" />
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。您还可以使用以下方式登录
当前位置:&>&&>&&>& > py-faster-rcnn训练自己数据集需要修改的参数
py-faster-rcnn训练自己数据集需要修改的参数
faster rcnn默认有三种网络模型ZF(小)、VGG_CNN_M_1024(中)、VGG16 (大)&训练图片大小为500*500,类别数1。修改VGG_CNN_M_1024模型配置文件1)train.protxt文件input-data层的num_class数值由21改为2;roi-data层的num_class数值由21改为2;cls_score层的num_output数值由21改为2(1+1);bbox_pred层的num_output数值由84改为8(2*4);2)test.prototxt文件cls_score层的num_output数值由21改为2(1+1);bbox_pred层的num_output数值由84改为8(2*4);3)lib/datasets/pascal_voc.py文件修改self._classes = (&#39;__background__&#39;, &#39;训练的数据类别&#39;)&&测试模型时需要改的文件faster_rcnn_test.ptcls_score层的num_output数值由21改为2;bbox_pred层的num_output数值由84改为8;&&cache问题在重新训练新的数据之前将cache删除1)py-faster-rcnn/output2)py-faster-rcnn/data/cache&超参数py-faster-rcnn/models/pascal_voc/VGG16/faster_rcnn_alt_opt/stage_fast_rcnn_solver*.ptbase_lr: 0.001lr_policy: &#39;step&#39;step_size: 30000display: 20....迭代次数在文件py-faster-rcnn/tools/train_faster_rcnn_alt_opt.py中进行修改max_iters = [8, 8]分别对应rpn第1阶段,fast rcnn第1阶段,rpn第2阶段,fast rcnn第2阶段的迭代次数。&开始训练:cd py-faster-rcnn./experiments/scripts/faster_rcnn_alt_opt.sh 0 VGG16 pascal_voc 参数表明使用第一块GPU(0);模型是VGG16;训练数据是pascal_voc(voc2007)。就爱阅读网友整理上传,为您提供最全的知识大全,期待您的分享,转载请注明出处。
欢迎转载:
推荐:    Ubuntu16下配置Faster_rcnn训练自己的数据
Ubuntu16下配置Faster_rcnn训练自己的数据。之前用Fast_rcnn 的例子训练自己的数据集,但是由于Fast_rcnn 例子中用的是预先处理好的图片文件(就是吧图片先用selective-search 把图片预先处理成matlab的.mat文件)。所以再用Fast_rcnn 训练自己的数据图图片时,也要把自己的图片先预处理。终于把数据弄的一致了。但是网络又不收敛。所以改用Faster_rcnn。 相比Fast_rcnn 好用的多。
一 首先下载Faster_rcnn 项目
1)项目地址  在你想放置的文件夹下面执行:
git clone --recursive /rbgirshick/py-faster-rcnn.git
 一定要有--recursive 否则不会下载caffe 部分
2)进入Faster_rcnn 根目录下
  cd $FRCN_ROOT/lib
编译的过程有可能有gcc版本的错误。我在之前编译别的软件的时候将gcc版本降低了,编译不通过。把gcc和 g++ 版本调高后编译顺利通过。
3)编译Caffe and pyCaffe。 这里的caffe并不是正常的caffe,也不需要自己下载。需要安装caffe 的依赖环境 ,具体参考 caffe 官方文档,在编译之前需要修改Makefile文件。
  cd $FRCN_ROOT/caffe-fast-rcnn
cp Makefile.config.example Makefile.config
  修改如下两处
# In your Makefile.config, make sure to have this line uncommented
  WITH_PYTHON_LAYER := 1
  # Unrelatedly, it&#39;s also recommended that you use CUDNN
  USE_CUDNN := 1
  如果编译时提示找不到hdf5,则需要添加hdf5的路径。我的配如下
  # Whatever else you find you need goes here.
  INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
  LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
  配置好后开始编译:
  make -j8 && make pycaffe
4)编译完成后下载预训练的模型
  cd $FRCN_ROOT
  ./data/scripts/fetch_faster_rcnn_models.sh
  有可能需要翻墙下载。总之把模型下好。跑一下demo
cd $FRCN_ROOT
  ./tools/demo.py
  没错误的话应该看到几张图片的识别实例(要是ssh 登录服务器会提示没有显示设备)
二 训练自己的数据
训练自己的图片数据需要将自己的图片变为VOC格式。可以按照github上的文档,下载pascalVOC数据集,然后将文件都删掉,用自己的数据替换。我这里没这样做,下载太慢了。 因为之前弄过Fast_rcnn,目录结构直接自己建立就行了。先说一下目录组织结构
$FRCN_ROOT--|
|-VOCdevkit2007-|
|-VOC2007-|
|-Annotations- (存放图片的.xml)
|-JPEGImages-(存放图片本身)
|-ImageSets-|
|-Main-(存放 train.txt test.txt trainval.txt val.txt)
1) 将图片中的目标区域提取出来变为xml文件,每张图片一个xml文件。 我用的是-Based-Labeling-Tool-for-PASCAL-VOC-master 这个工具,也可以在github 上有个py-faster-rcnn-data-interface-generator 这个工具或者自己写个小脚本。至于工具怎么用自行百度。
2) Main 文件夹下的四个文件由python 脚本生成createdata.py
#!/usr/bin/env python
import numpy as np
import random
&&& create_imageset.py
Create .txt files containing the names of the imageset for training, validation and testing for the pascal_voc benchmark.
DATASET_PATH = &#39;$Faster_rcnn/data/VOC2007&#39;
train = []
trainval = []
#test_probality = 0.2
#train_probablity = 0.5
test_probability = 0.2
train_probability = 0.8
def save_imagesets(imageset_path):
with open(os.path.join(imageset_path, &test.txt&), &w&) as test_file:
test_file.write(&#39;\n&#39;.join(i for i in test))
with open(os.path.join(imageset_path, &train.txt&), &w&) as train_file:
train_file.write(&#39;\n&#39;.join(i for i in train))
with open(os.path.join(imageset_path, &val.txt&), &w&) as val_file:
val_file.write(&#39;\n&#39;.join(i for i in val))
with open(os.path.join(imageset_path, &trainval.txt&), &w&) as trainval_f:
trainval_f.write(&#39;\n&#39;.join(i for i in trainval))
    f __name__ == &#39;__main__&#39;:
# get all files that have an existing annotation
annotation_path = os.path.join(DATASET_PATH, &#39;Annotations&#39;)
imageset_path = os.path.join(DATASET_PATH, &#39;ImageSets&#39;, &#39;Main&#39;)
files = [f for f in os.listdir(annotation_path)]
files.sort()
for f in files:
# strip extenstion
short_name = os.path.splitext(f)[0]
# decide whether its testing (p=0.5) or trainval(p=0.5)
if random.random() & test_probability :
test.append(short_name)
trainval.append(short_name)
# train (p=0.5) or val (p=0.5)
if random.random() & train_probability:
train.append(short_name)
val.append(short_name)
print(&ImageSets saved&)
save_imagesets(imageset_path)
3) 将自己的图片和文件放到对应的文件夹下面
4) 下载ImageNet数据集下预训练得到的模型参数(用来初始化)
5) 修改网络参数,这里用的是ZF网络,修改/models/faster_rcnn_alt_opt配置文件如何在faster—rcnn上训练自己的数据集(单类和多类)?? - 知乎43被浏览2471分享邀请回答2添加评论分享收藏感谢收起与世界分享知识、经验和见解使用faster rcnn训练imageNet上的部分数据集(1)
最近在做毕业设计,需要用到faster rcnn,训练数据使用的是我自己下载的imageNet里的部分数据,主要用到了其中的bike,motorbike,car,bus,train等交通工具。由于imageNet自带了annotation,只是&#26684;式和pascal voc不一样,所以还需要转化&#26684;式。目前我正在使用imageNet中的ship数据集来进行一个二分类的检测和识别,即background和ship。等这个实验成功之后再进行其他类别的数据转换并进行多类的训练。本文主要记录在进行这个实验时候自己所做的一些工作和查阅资料所获得的帮助,相关参考链接也会在文中贴出来。目前网络还在训练中,结果未知,先将已做的一些工作记录,以供以后自己和大家参考,后续再更新。
我的开发环境是Ubuntu14.04,caffe是必须先要配置好的,这里就不再赘述,网上很多教程。进行该实验之前需要先配置py-faster-rcnn工程,具体参考原作者的github项目(/rbgirshick/py-faster-rcnn),写得很清楚,另外该算法还有一个matlab版本(/ShaoqingRen/faster_rcnn),要想直接看中文可以参考这一篇博客(http://blog.csdn.net/samylee/article/details/)
运行成功demo.py之后,我们还需要做的是下载pascal voc的数据集,对它进行训练。在项目的github网站也给出了训练的方法,这一步个人感觉必须得做,因为我们后续训练自己的imageNet数据的时候也是模仿pascal voc2007的数据集的&#26684;式来的。具体步骤参考原作者的github项目(/rbgirshick/py-faster-rcnn),或者博客(http://blog.csdn.net/samylee/article/details/),个人感觉最好看原作者的比较好,道理很简单,谁做的肯定就是谁最清楚怎么回事。
经过以上的参考,配置好py-faster-rcnn并在pascal voc 2007数据集上训练成功应该不成问题。下面讲述如何利用imageNet的某一类数据进行训练。
=======================================我是华丽丽的分割线=========================分割割割割==========================================
首先要下载imageNet2015数据集,贴出百度云链接(/s/1geEdTeV),总共40G,慢慢下吧,&#20540;得提醒的是千万不要为了下载这个求快而去开通百度云会员,不要问为什么,因为我任性,开通过,并没有什么用处,试用的时候能到1m/s,但开通后就打回原形了,个人很鄙视这种近&#20284;于欺骗消费者的行为。下载完之后你就可以去里面找你想要的数据了。在imageNet\ILSVRC2015 _DET\Data\DET\train\ILSVRC2013_train\这个目录下面可以看到
每个子目录对应一种类别,具体怎么知道对应关系可以查看imageNet\ILSVRC2015_devkit\devkit\data\map_clsloc.txt文件,我按照这个文件找到了ship这一类别,每个类别对应的annotation在imageNet\ILSVRC2015 _DET\Annotations\DET\train\ILSVRC2013_train\目录下找到。现在我们要做的是怎么把ship的图片xml文件转化为pascalvoc的&#26684;式,我这里采用了比较笨的方法,参考这篇http://blog.csdn.net/samylee/article/details/,他是将每个图片的数据写成了一个txt文件,然后用txt转化为xml文件。我模仿这种方法,那么我得先获得txt文件,所以现在的第一步是要将我的imageNet的annotation,即xml文件转化为参考博客所提到的txt文件,如下图所示的&#26684;式,&#20540;得注意的是下
四个坐标的顺序依次为xmin,ymin,xmax,ymax。而pascal voc的&#26684;式是xmin,xmax,ymin,ymax,转化的时候需要注意。先在m文件当前目录下创建名为JPEGImage和labels的文件夹,以及一个JPEGImage1的文件夹。创建这个文件夹的原因是imageNet上的&#26684;式是.JPEG,而pascal的是.jpg,为了和它保持一致,我们先将所有图片转化为.jpg,并存在JPEGImage1文件夹中。首先将所有源图片放入JPEGImage文件夹中。然后贴出将.JPEG转化为.jpg文件的m代码:
path_image='JPEGImages/';
path_image1='JPEGImages1/';
file_all = dir(path_image);
for i = 3:length(file_all)
& & JPEGPath = [path_image,file_all(i).name];
& & fprintf('JPEGPath = %s\n',JPEGPath)
& & img = imread(JPEGPath);
& & jpgPath = [path_image1,file_all(i).name(1:end-5),'.jpg'];
& & fprintf('jpgPath = %s\n',jpgPath)
& & imwrite(img,jpgPath)
然后你可以将原JPEGImage文件删除,并将新生成的JPEGImage1改名为JPEGImage即可。
贴出将imageNet的xml转化为txt的matlab代码,以供参考,代码可能不能直接运行,因为这和你所存图片和xml文件的目录有关系,具体的自己稍微看下应该就能解决。
%createtxt.m
path_image='JPEGImages/';%源图片存放路径
path_label='labels/';%txt文件存放路径
files_all=dir(path_image);
for i = 3:length(files_all)
& & sprintf('i = %d',i)
& & pathSrcXml = ['./n/' files_all(i).name(1:end-4) '.xml'];%这是imageNet某一类别的xml文件的目录
& & sprintf('%s', pathSrcXml)
& & pathtxt = ['./labels/' files_all(i).name(1:end-4) '.txt'];
& & sprintf('%s', pathtxt)
& & str = fileread( pathSrcXml );
& & v = xml_parse( str );
& & xmin = v.object.bndbox.xmin
& & ymin = v.object.bndbox.ymin
& & xmax = v.object.bndbox.xmax
& & ymax = v.object.bndbox.ymax
& & filename = v.filename
& & %filename =&
& & fid = fopen(pathtxt,'wt')
& & fprintf(fid,'%s%s',filename,'.jpg')
& & fprintf(fid,'%c',' ');
& & fprintf(fid,'%s','ship')
& & fprintf(fid,'%c',' ');
& & fprintf(fid,'%c',xmin);
& & fprintf(fid,'%c',' ');
& & fprintf(fid,'%c',ymin);
& & fprintf(fid,'%c',' ');
& & fprintf(fid,'%c',xmax);
& & fprintf(fid,'%c',' ');
& & fprintf(fid,'%c',ymax);
& & fclose(fid);
以上代码有一个xml_parse(str),这是解析xml文件用的,我之前用matlab里面自带的xmlread()函数感觉总是不能达到我想要的效果,即我只要读出一个xml文件到一个对象object中,我就可以用object.字段名.字段名这种方式来访问xml的数据,后来上网找了下资料发现这么个工具箱能够实现我想要的功能,贴出百度云链接/s/1nvaSrn7,我的matlab是2012,运行这个工具箱会有warning,因为这是老版本的工具箱了,但是不影响使用,具体使用方法参考里面的test文件夹就可秒懂。经过以上步骤即可在labels文件夹中生成每个imageNet的xml文件对应的txt文件。如下图所示:
每个txt里面如下图所示:
接下来就可以进行将txt转化为pascal voc&#26684;式的xml文件了,在当前目录下创建一个Annotations的文件夹,代码在百度云链接中:/s/1hrKN1Es,自己稍微琢磨下就能看懂。
小结:经过以上步骤,就能获得一个JPEGImage的文件夹,里面存的是.jpg后缀的源图片,和一个Annotations的文件夹,里面存的是每个源图片对应的pascal voc&#26684;式的xml文件,labels文件夹可以不用了,因为voc数据集本来就没有这个东西,他只是我们用来过度的一个文件夹。我们还差什么?imageSets文件夹,如何生成四个txt文件,贴出代码:
%createimagesets.m
file = dir('Annotations');
len = length(file)-2;
num_trainval=sort(randperm(len, floor(9*len/10)));%trainval集占所有数据的9/10,可以根据需要设置
num_train=sort(num_trainval(randperm(length(num_trainval), floor(5*length(num_trainval)/6))));%train集占trainval集的5/6,可以根据需要设置
num_val=setdiff(num_trainval,num_train);%trainval集剩下的作为val集
num_test=setdiff(1:len,num_trainval);%所有数据中剩下的作为test集
path = 'ImageSets\Main\';
fid=fopen(strcat(path, 'trainval.txt'),'a&#43;');
for i=1:length(num_trainval)
& & s = sprintf('%s',file(num_trainval(i)&#43;2).name);
& & fprintf(fid,[s(1:length(s)-4) '\r\n']);
fclose(fid);
fid=fopen(strcat(path, 'train.txt'),'a&#43;');
for i=1:length(num_train)
& & s = sprintf('%s',file(num_train(i)&#43;2).name);
& & fprintf(fid,[s(1:length(s)-4) '\r\n']);
fclose(fid);
fid=fopen(strcat(path, 'val.txt'),'a&#43;');
for i=1:length(num_val)
& & s = sprintf('%s',file(num_val(i)&#43;2).name);
& & fprintf(fid,[s(1:length(s)-4) '\r\n']);
fclose(fid);
fid=fopen(strcat(path, 'test.txt'),'a&#43;');
for i=1:length(num_test)
& & s = sprintf('%s',file(num_test(i)&#43;2).name);
& & fprintf(fid,[s(1:length(s)-4) '\r\n']);
fclose(fid);
这样所需的文件夹我们都已备齐,将imageSets,Annotations和JPEGiImage文件夹分别放入voc数据集的对应位置,在这之前先将其原来的文件夹删除。
以上是准备自己的数据集部分,后续还涉及到修改配置文件以及训练部分,在下一篇博客更新。
看过本文的人也看了:
我要留言技术领域:
取消收藏确定要取消收藏吗?
删除图谱提示你保存在该图谱下的知识内容也会被删除,建议你先将内容移到其他图谱中。你确定要删除知识图谱及其内容吗?
删除节点提示无法删除该知识节点,因该节点下仍保存有相关知识内容!
删除节点提示你确定要删除该知识节点吗?

我要回帖

更多关于 打印机卡纸是什么原因 的文章

 

随机推荐