Faster RCNN pytorch 复现

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zw__chen/article/details/82706019

本文参考的复现代码为Faster RCNN with PyTorch

1.Install the requirements

pip install pyyaml sympy h5py cython numpy scipy menpo

·install opencv3
1.1 Update packages

sudo apt-get update
sudo apt-get upgrade

1.2 Install OS libraries

Remove any previous installations of x264</h3>
sudo apt-get remove x264 libx264-dev
 
We will Install dependencies now
 
sudo apt-get install build-essential checkinstall cmake pkg-config yasm
sudo apt-get install git gfortran
sudo apt-get install libjpeg8-dev libjasper-dev libpng12-dev
 
# If you are using Ubuntu 14.04
sudo apt-get install libtiff4-dev
# If you are using Ubuntu 16.04
sudo apt-get install libtiff5-dev
 
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev
sudo apt-get install libxine2-dev libv4l-dev
sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
sudo apt-get install qt5-default libgtk2.0-dev libtbb-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libfaac-dev libmp3lame-dev libtheora-dev
sudo apt-get install libvorbis-dev libxvidcore-dev
sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev
sudo apt-get install x264 v4l-utils
 
# Optional dependencies
sudo apt-get install libprotobuf-dev protobuf-compiler
sudo apt-get install libgoogle-glog-dev libgflags-dev
sudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

1.3 Download OpenCV and OpenCV_contrib
1.3.1 Download opencv from Github

git clone https://github.com/opencv/opencv.git
cd opencv 
git checkout 3.3.1 
cd ..

1.3.2 Download opencv_contrib from Github

git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout 3.3.1
cd ..

1.4 Compile and install OpenCV with contrib modules
1.4.1 Create a build directory

cd opencv
mkdir build
cd build

1.4.2 Run CMake

cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D INSTALL_C_EXAMPLES=ON \
      -D INSTALL_PYTHON_EXAMPLES=ON \
      -D WITH_TBB=ON \
      -D WITH_V4L=ON \
      -D WITH_QT=ON \
      -D WITH_OPENGL=ON \
      -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
      -D BUILD_EXAMPLES=ON ..

1.4.3 Compile and Install

# find out number of CPU cores in your machine
nproc
# substitute 4 by output of nproc
make -j4
sudo make install
sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

2.Clone the Faster R-CNN repository

git clone https://github.com/longcw/faster_rcnn_pytorch.git

3.Build the Cython modules for nms and the roi_pooling layer

cd faster_rcnn_pytorch/faster_rcnn
./make.sh

4.Download the trained model VGGnet_fast_rcnn_iter_70000.h5 and set the model path in demo.py在这里插入图片描述

5.set image in the “demo” : 0.00545.jpg
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

6.python demo.py
在这里插入图片描述

在这里插入图片描述

如有不当,请指教;如有疑问,欢迎留言交流~

猜你喜欢

转载自blog.csdn.net/zw__chen/article/details/82706019