1. 安装环境:
Windows10 64bit
2. 软件包:
看到这么多软件不要慌,下面将详细讲解安装步骤。
新手上路为了避免Tensorflow安装后无法运行,建议已安装过Anaconda软件和Python的同学,将电脑上的Anaconda和Python卸载干净后重新下载安装。所谓置之死地而后生,本人曾经安装了多次都没有成功,各种依赖包版本问题,最终选择了卸载。
python
print("Hello,Anaconda")
为避免官方下载速度较慢,请打开Anaconda Prompt,按照如下代码更新国内的软件源。
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
其他源地址和配置方法,请参考该链接.
配置Anaconda里Tensorflow的虚拟环境,如图所示:
conda activate tf_gpu
conda install tensorflow-gpu=1.13.1
注意:一定要用“=1.13.1”,否则conda将安装最新版本的Tensorflow。之后conda会进行一系列的检查和配置,列出安装软件包列表,输入“y”后按,继续安装,静静等待下载和安装。
python
import tensorflow as tf
print(tf.__version__)
4.3 打印出版本号即认为Tensorflow安装成功,请特别注意版本号是否为1.13.1。若之前曾安装过Tensorflow其他版本,没有卸载或者删除干净可能会显示之前的版本。
git clone -b r1.13.0 https://github.com/tensorflow/models.git
pip install matplotlib pillow lxml contextlib2 cython opencv-python
pip install matplotlib pillow lxml contextlib2 cython opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
在此链接下载并安装。
在tf_gpu里新建“addons”文件夹,在该文件夹下右键,点击“Git Bash Here”,输入如下命令:
git clone https://github.com/philferriere/cocoapi.git
windows 任务栏搜索:Prompt,找到Anaconda Promot,右键管理员运行。
输入命令激活环境:
conda activate tf_gpu
进入PythonAPI文件夹:
d:
cd xxx\tf_train\addons\cocoapi\PythonAPI
输入命令进行安装:
python setup.py install
激活环境后,进入python后导入包,导入成功说明安装完成。
conda activate tf_gpu
python
import pycocotools
由于Tensorflow Object Detection API框架使用protobuf工具配置和训练参数。使用conda命令安装tensorflow时已经安装过,可以使用conda list 查看是否安装。
conda activate tf_gpu
for /f %i in ('dir /b object_detection\protos\*.proto') do protoc object_detection\protos\%i --python_out=.
conda activate tf_gpu
python object_detection_example_1.py
conda activate tf_gpu
pip install labelimg