【tensorflow2】object detection API 环境搭建

前面刚写完tensorflow1.15+ssd_mobilenet_v2的环境搭建,发现tensorflow2.0+早已经支持Tensorflow object detection API,因此肯定要与时俱进,下面就开始tensorflow2.0的环境搭建吧。
首先申明,以下搭建步骤采纳同门师弟博客,文末附上原文链接,但因人而异,还是些许步骤不同,在此做个人的环境搭建总结。

1.环境创建

conda create -n tf2 pip python=3.8
conda activate tf2   # 激活

2.安装Tensorflow2.2

pip install --ignore-installed --upgrade tensorflow-gpu==2.2.0 -i https://pypi.douban.com/simple/
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

3.安装CUDA和CuDnn

conda install cudatoolkit=10.1 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
conda install cudnn=7.6.5 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/

4.Tensorflow object detection API

4.1 下载源码文件

git clone https://github.com/tensorflow/models.git

或者:到上述网址下载并解压,笔者就是采用这种方式,因为git clone一直下载不下来。

4.2Protobuf的安装配置

在激活的环境中运行命令行

conda install -c anaconda protobuf

或者下最新的压缩包,笔者这里下的是:protoc-3.13.0-linux-x86_64,进行解压
进入models/research/目录下

/home/lianlirong/models-master/protoc-3.13.0-linux-x86_64/bin/protoc object_detection/protos/*.proto --python_out=.

运行结束后可查看protos文件内,是否新生成很多.python文件

4.3 配置PYTHONPATH路径

export PYTHONPATH=$PYTHON:./models-master/research/slim

5.COCO API的安装

方法一:

pip install cpython pip install 
git+https:// github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI

方法二:笔者的方法

git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make
make install
python setup.py install
cp -r ./cocoapi/PythonAPI/pycocotools ./models-master/research/  # 复制pycocotools到models-master/research/

6.Object detection api

cp object_detection/packages/tf2/setup.py .

python -m pip --default-timeout=200 install .   # --default-timeout=200延长网络的反应的时间,避免下载中断

若出现:
在这里插入图片描述
某一依赖项一直下载不下来,则可以先中断,单独下载这一部分:

pip install tensorflow==2.3.1 -i https://pypi.douban.com/simple  # 利用豆瓣源下载速度更快。

.

7.验证配置结果

cd ./models-master/research  
python object_detection/builders/model_builder_tf2_test.py

若出现如下结果则配置成功
在这里插入图片描述
就此环境搭建就好了!!!!
参考链接:
https://blog.csdn.net/l13022736018/article/details/108737082

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值