快乐学习
前程无忧、中华英才非你莫属!

Tensorflow框架下Faster-RCNN实践(二)-用自己制作的数据训练Faster-RCNN网络(附代码)

修改make.sh
#!/usr/bin/env bash
TF_INC=$(python -c ‘import tensorflow as tf; print(tf.sysconfig.get_include())’)
echo $TF_INC
CUDA_PATH=/usr/local/cuda/
cd roi_pooling_layer
nvcc -std=c++11 -c -o roi_pooling_op.cu.o roi_pooling_op_gpu.cu.cc
-I $TF_INC -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -arch=sm_52
## if you install tf using already-built binary, or gcc version 4.x, uncomment the two lines below#g++ -std=c++11 -shared -D_GLIBCXX_USE_CXX11_ABI=0 -o roi_pooling.so roi_pooling_op.cc # roi_pooling_op.cu.o -I $TF_INC -fPIC -lcudart -L $CUDA_PATH/lib64
# for gcc5-built tf#g++ -std=c++11 -shared -D_GLIBCXX_USE_CXX11_ABI=1 -o roi_pooling.so roi_pooling_op.cc # roi_pooling_op.cu.o -I $TF_INC -fPIC -lcudart -L $CUDA_PATH/lib64
g++ -std=c++11 -shared -o roi_pooling.so roi_pooling_op.cc -D_GLIBCXX_USE_CXX11_ABI=0
roi_pooling_op.cu.o -I $TF_INC -D GOOGLE_CUDA=1 -fPIC $CXXFLAGS
-lcudart -L $CUDA_PATH/lib64
cd ..
# add building psroi_pooling layercd psroi_pooling_layer
nvcc -std=c++11 -c -o psroi_pooling_op.cu.o psroi_pooling_op_gpu.cu.cc
-I $TF_INC -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -arch=sm_52
g++ -std=c++11 -shared -o psroi_pooling.so psroi_pooling_op.cc -D_GLIBCXX_USE_CXX11_ABI=0
psroi_pooling_op.cu.o -I $TF_INC -D GOOGLE_CUDA=1 -fPIC $CXXFLAGS
-lcudart -L $CUDA_PATH/lib64
## if you install tf using already-built binary, or gcc version 4.x, uncomment the two lines below#g++ -std=c++11 -shared -D_GLIBCXX_USE_CXX11_ABI=0 -o psroi_pooling.so psroi_pooling_op.cc # psroi_pooling_op.cu.o -I $TF_INC -fPIC -lcudart -L $CUDA_PATH/lib64
cd ..

–restore -0(位置)

python ./faster_rcnn/train_net.py gpu 0 weights ./data/pretrain_model/VGG_imagenet.npy imdb voc_2007_trainval iters 70000 cfg ./experiments/cfgs/faster_rcnn_end2end.yml network VGGnet_train restore 0 set EXP_DIR exp_dir

1
修改run_profilling.sh
#!/bin/bash
python -m cProfile -o experiments/profiling/profile.out ./faster_rcnn/train_net.py
–gpu 0 –weights data/pretrain_model/VGG_imagenet.npy –imdb voc_2007_trainval
–iters 1000 –cfg experiments/cfgs/faster_rcnn_end2end.yml –network VGGnet_train
# generate an imageif [ ! -f experiments/profiling/gprof2dot.py ]; then
echo “Downloading … “
fi
python experiments/profiling/gprof2dot.py -f pstats experiments/profiling/profile.out | dot -Tpng -o experiments/profiling/profile.png

#!/bin/bash
python -m cProfile -o experiments/profiling/profile.out ./faster_rcnn/train_net.py
–gpu 0 –weights data/pretrain_model/VGG_imagenet.npy –imdb voc_2007_trainval
–iters 1000 –restore 0 –cfg experiments/cfgs/faster_rcnn_end2end.yml –network VGGnet_train
# generate an imageif [ ! -f experiments/profiling/gprof2dot.py ]; then
echo “Downloading … “
fi
python experiments/profiling/gprof2dot.py -f pstats experiments/profiling/profile.out | dot -Tpng -o experiments/profiling/profile.png

替换自己的数据 删除 cache/*.pkl
cfgs NCLASSES 2
EXP_DIR: faster_rcnn_voc_vgg
LOG_DIR: faster_rcnn_voc_vgg
IS_MULTISCALE: False
NET_NAME: VGGnet
ANCHOR_SCALES: [8, 16, 32]
NCLASSES: 2
TRAIN:
OHEM: True
RPN_BATCHSIZE: 2000
BATCH_SIZE: 300
LOG_IMAGE_ITERS: 100
DISPLAY: 100
SNAPSHOT_ITERS: 5000
HAS_RPN: True
LEARNING_RATE: 0.001
MOMENTUM: 0.9
GAMMA: 0.1
STEPSIZE: 60000
IMS_PER_BATCH: 1
BBOX_NORMALIZE_TARGETS_PRECOMPUTED: True
RPN_POSITIVE_OVERLAP: 0.7
RPN_BATCHSIZE: 256
PROPOSAL_METHOD: gt
BG_THRESH_LO: 0.0
PRECLUDE_HARD_SAMPLES: True
BBOX_INSIDE_WEIGHTS: [1, 1, 1, 1]
RPN_BBOX_INSIDE_WEIGHTS: [1, 1, 1, 1]
RPN_POSITIVE_WEIGHT: –1.0
FG_FRACTION: 0.3
WEIGHT_DECAY: 0.0005
TEST:
HAS_RPN: True

对自己的数据扩充pad
sys.path.appent
ckpt.index ckpt.meta ->ckpt
修改train.py (8.9 在一块)
In train.py: +from tensorflow.core.protobuf import saver_pb2
and in function of “def init”:
self.saver = tf.train.Saver(max_to_keep=100,write_version=saver_pb2.SaverDef.V1)

修改plt.show()的位置,并且保存生成的图片 
11.运行test的时候,修改cfgs 默认参数,21->2
作者:ruyiweicas


打赏

未经允许不得转载:同乐学堂 » Tensorflow框架下Faster-RCNN实践(二)-用自己制作的数据训练Faster-RCNN网络(附代码)

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

特别的技术,给特别的你!

联系QQ:1071235258QQ群:226134712
error: Sorry,暂时内容不可复制!