TensorFlow2 Object Detection API框架的安装,相对之前,变得简单的容易了,只需要安装setup.py文件
"""Setup script for object_detection with TF2.0."""
import os
from setuptools import find_packages
from setuptools import setup
# Note: adding apache-beam to required packages causes conflict with
# tf-models-offical requirements. These packages request for incompatible
# oauth2client package.
REQUIRED_PACKAGES = [
# Required for apache-beam with PY3
'avro-python3',
'apache-beam',
'pillow',
'lxml',
'matplotlib',
'Cython',
'contextlib2',
'tf-slim',
'six',
'pycocotools',
'lvis',
'scipy',
'pandas',
'tf-models-official'
]
setup(
name='object_detection',
version='0.1',
install_requires=REQUIRED_PACKAGES,
include_package_data=True,
packages=(
[p for p in find_packages() if p.startswith('object_detection')] +
find_packages(where=os.path.join('.', 'slim'))),
package_dir={
'datasets': os.path.join('slim', 'datasets'),
'nets': os.path.join('slim', 'nets'),
'preprocessing': os.path.join('slim', 'preprocessing'),
'deployment': os.path.join('slim', 'deployment'),
'scripts': os.path.join('slim', 'scripts'),
},
description='Tensorflow Object Detection Library',
python_requires='>3.6',
)
第一步,将\models\research\object_detection\packages\tf2 中的setup.py文件拷贝到\models\research文件夹
第二步,在\models\research路径运行命令
python -m pip install .
常见导致安装不成功的原因: 使用pip默认的安装源,由于网速太慢,导致诸多python包安装失败,解决方式是,设定pip安装源为Baidupip源,具体做法是:
第一步:运行命令升级 pip 到最新的版本
pip install -i https://mirror.baidu.com/pypi/simple pip -U
第二步,运行命令配置pip镜像源
pip config set global.index-url https://mirror.baidu.com/pypi/simple
这时,会自动生成一个配置文件,Baidu源配置成功