py-faster-rcnn使用注意点记录

本文详细介绍如何从源码搭建Faster R-CNN环境,包括使用Caffe和TensorFlow两种方式,涵盖了git clone命令的区别、Makefile.config配置、依赖库设置、编译步骤、模型下载及存放等关键信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

caffe

  • 注意点
    1.git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git和直接网页下载区别,其中caffe-fast-rcnn @ 0dcd397是caffe源码
    2 拷贝caffe源码里的Makefile.config.example,修改为Makefile.config,如果使用CPU计算,将CPU_ONLY := 1,WITH_PYTHON_LAYER := 1注释去掉,如果WITH_PYTHON_LAYER := 1注释,会报roi_pooling_param不能解析错误,另外caffe需要hdf5的支持,系统如果安装hdf5,但未配置头文件和库文件路径,可以在Makefile.config中添加如下:
    (1)INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
    (2)LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/
    3.进入源码目录 make -j8 && make pycaffe
    4.进入py-fasrter-rcnn目录下的lib目录,执行python setup.py build_ext --inplace
    5.下载训练好的模型,根据说明存放数据文件
    6.需要protobuf3.0.0以下版本,否则draw_net.py运行出错.
    7 .cmake . -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" -DUSE_CUDNN=OFF

tf-faster-rcnn

1.make.sh 需要tensorflow-gpu版本

#!/usr/bin/env bash
TF_LIB=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')
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

#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 -L $TF_LIB -ltensorflow_framework -D GOOGLE_CUDA=1 \
#-fPIC $CXXFLAGS -lcudart -L $CUDA_PATH/lib64

nvcc -std=c++11 -c -o roi_pooling_op.cu.o roi_pooling_op_gpu.cu.cc -D_GLIBCXX_USE_CXX11_ABI=0\
	-I $TF_INC -L $TF_LIB -ltensorflow_framework -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 -L $TF_LIB -ltensorflow_framework -fPIC -lcudart -L $CUDA_PATH/lib64

# for gcc5-built tf
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 -L $TF_LIB -ltensorflow_framework -fPIC -lcudart -L $CUDA_PATH/lib64
cd ..

# add building psroi_pooling layer
cd psroi_pooling_layer
nvcc -std=c++11 -c -o psroi_pooling_op.cu.o psroi_pooling_op_gpu.cu.cc\
	-I $TF_INC -L $TF_LIB -ltensorflow_framework -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 -L $TF_LIB -ltensorflow_framework -fPIC -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 -L $TF_LIB -ltensorflow_framework -fPIC -lcudart -L $CUDA_PATH/lib64

cd ..
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值