安装TensorFlow Object Detection API
参考PaddleX准备anaconda和cuda
参考安装Tensorflow21
2
3conda create -n tensorflow python=3.10
conda activate tensorflow
pip install tensorflow
pip自动安装最新release版本 2.0之后不再区分cpu和gpu版本
测试安装,在python中引用tensorflow, 对一个随机张量的求和1
2python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
# 结果形如tf.Tensor(-1082.7711, shape=(), dtype=float32)
install the TensorFlow Object Detection API:
下载模型库 新建一个Tensorflow目录并将模型库clone/解压到目录下
TensorFlow/
└─ models/
├─ community/
├─ official/
├─ orbit/
├─ research/
└── …
根据Readme的提示安装official library1
2
3
4# 将model路径添加到PYTHONPATH环境变量
set PYTHONPATH=%PYTHONPATH%;C:\Users\qqqst\Documents\TensorFlow\models
# 安装requirements
pip3 install --user -r models/official/requirements.txt
下载protobuf添加到环境变量path,对于windows下载 protoc---win64.zip并解压,注意protobuf--.zip是source code 添加路径如D:\Software\protoc-25.1-win64\bin到path
使用protoc编译模型的python版本(与.proto一一对应的.py文件)1
2# cmdline in TensorFlow/models/research
for /f %i in ('dir /b object_detection\protos\*.proto') do protoc object_detection\protos\%i --python_out=.
install pycocotools (依赖vc++ 2015)1
2pip install cython
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
看到Object Detection for TensorFlow 2.0的setup script
Install the Object Detection API1
2
3# From within TensorFlow/models/research/
cp object_detection\packages\tf2\setup.py .
python -m pip install .
调用test脚本以测试安装1
2# From within TensorFlow/models/research/
python object_detection/builders/model_builder_tf2_test.py
</del>