从环境搭建起,Faster-RCNN-TensorFlow-CPU-Ubuntu下运行demo

参考源代码GitHub:https://github.com/endernewton/tf-faster-rcnn

环境:

VirtualBox6.0+Ubuntu16.0

Anaconda3-2018-Linux+Python35+TensorFlow1.8.0

链接:

https://download.virtualbox.org/virtualbox/6.0.16/

http://releases.ubuntu.com/16.04/

https://repo.anaconda.com/archive/

安装步骤:

1. xshell/xftp连接Ubuntu以及设置静态IP,可以参考我的这篇博文:xshell/xftp连接Ubuntu以及设置静态IP

2. 修改Ubuntu的镜像源

根据Ubuntu版本选择镜像源(清华大学),地址:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/,然后复制框内镜像源以替换Ubuntu自带的镜像源。

1)备份自带镜像源文件:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

2)编辑文件:sudo vim /etc/apt/sources.list,替换成刚才复制的镜像源保存并退出;

3)更新:sudo apt-get update。

3. 配置环境

1)将anaconda安装包传到Ubuntu里,打开安装包所在目录,执行命令安装:bash Anaconda3-5.0.1-Linux-x86_64.sh
一路回车,然后yes,记住安装位置以便设置Python环境,激活:source ~/.bashrc 

2)创建Python35的环境,命令行:conda create -n tf python=3.5

激活环境:source activate tf

3)安装TensorFlow

命令行:pip install --upgrade --ignore-installed  --upgrade tensorflow==1.8.0

PS:另一种直接在Ubuntu上安装TensorFlow的方法:

(1)Ubuntu自带Python2和Python3.5的包,首先设置Python3为默认:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
输入python,会出现python3.5

参考博文:https://blog.csdn.net/qq_33392383/article/details/86549971

(2)下载TensorFlow的清华镜像到本地:https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/

然后上传,进入到包所在的目录,输入命令安装:sudo pip3 install xx.whl

 4)安装所需的包

pip install cython

pip install opencv-python

pip install easydict==1.6

pip install pillow(跑demo时发现缺少这个包,所以需要的话可以提前下下来)

4. 修改配置文件

1)从GitHub下载项目和数据(我是下载到Windows上然后传输的)

git clone https://github.com/endernewton/tf-faster-rcnn.git
2)修改配置文件

因为我的电脑没有GPU,所以需要注释掉项目中用到GPU的地方,参考的这篇博文

Faster R-CNN tensorflow版本,cpu下运行demo

主要是lib/model/nms_wrapper.py和lib/setup.py文件。

5. 运行demo

1)到tf-faster-rcnn/lib下编译Cython 模块:

make clean

make

cd ..

 2)安装Python COCO API:

cd data

git clone https://github.com/pdollar/coco.git

cd coco/PythonAPI

make

cd ../../..

3)下载预训练模型

百度网盘链接:链接:https://pan.baidu.com/s/1a9xm9AfPlXrgfou2M4vZ8g 提取码:7z7e 

下载后保存到data目录下,解压:tar xvf voc_0712_80k-110k.tgz

解压得到voc_2007_trainval+voc_2012_trainval文件夹。

4)建立预训练模型的软连接

NET=res101

TRAIN_IMDB=voc_2007_trainval+voc_2012_trainval

mkdir -p output/${NET}/${TRAIN_IMDB}

cd output/${NET}/${TRAIN_IMDB}
ln
 -s ../../../voc_2007_trainval+voc_2012_trainval ./default

cd ../../..

5)运行demo

转到demo目录下../tools/demo

执行命令:python demo.py

得到demo的运行结果:

参考博文:

https://blog.csdn.net/sinat_33486980/article/details/81045315

https://www.jianshu.com/p/448b3b93184b

https://www.jianshu.com/p/dda97b547f95

https://blog.csdn.net/chenzhenyu123456/article/details/81567789

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

折耳猫的橙汁儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值