参考:link1 link2 link3
Tensorflow对象检测API安装与测试
1.安装opencv4版本
下载opencv安装配置方法参考4版开发包:opencv学习-第一节:环境配置与建设
2.安装opencv-python
cmd中输入:
pip install opencv-python
检查,cmd输入:
python
3.安装tensorflow
cmd中输入: 默认为CPU版本
pip install tensorflow
pip install tensorflow-GPU
检查安装是否成功: cmd输入:
python import tensorflow as tf
若无输出,则表示安装成功,如下图所示。
测试opencv安装成功与否 cmd输入:
import cv2 as cv cv.imread (“D:/images/hand.jpg”)
4.安装和基本使用pycharm
安装参考博客:最新版本超详细pycharm小白能理解安装教程
注意:在cmd可作为在中间pycharm第三方依赖于导入和使用。
然后安装opencv-python和TensorFlow导入到pycharm中。 最后输入以下代码测试
import cv2 as cv import tensorflow as tf tf.compat.v1.disable_eager_execution() a = tf.constant(3.0) b = tf.constant(4.0) c = tf.add(a, b) sess = tf.compat.v1.Session(); print(sess. run(c)) src = cv. imread("D:/images/hand.jpg") cv. imshow("image", src) cv. waitKey(0) cv. destroyAllWindows()
5.安装TensorFlow第三方依赖包
cmd依此输入:
pip install Cython pip install contextlib2 pip install pillow pip install lxml pip install jupyter pip install matplotlib
6.安装TensorFlow的models
1.先安装git 然后将models文件下载到D盘中。 打开git然后输入:
git clone https://github.com/tensorflow/models.git D:tensorflow/models
2.再安装protobuf https://github.com/protocolbuffers/protobuf/releases/tag/v3.4.0 解压到D盘中。 然后cmd中输入:
D:\tensorflow\models\research>D:\protoc-3.4.0-win32\bin\protoc object_detection/protos/*.proto --python_out=.
就会将proto文件生成python,如下图所示: 测试是否安装成功,cmd输入:
cd /d D: D:\tensorflow\models\research>python object_detection/builders/model_builder_test.py
报错: 解决方法:打开cmd并输入以下命令:
pip install absl
报错:
解决办法,cmd输入:
python -m pip install --upgrade pip -i https://pypi.douban.com/simple
新建一个pth文件,写入下面的路径:
D:\tensorflow\models\research
D:\tensorflow\models\research\slim
D:\tensorflow\models\research\object_detection
存放在C:\Users\Administrator\AppData\Local\Programs\Python\Python36\Lib\site-packages下
解决办法,cmd输入:
pip install tf-models-official
可是结果依然报错,有大佬看到了还望指教!!!
cmd中输入: cd /d D:/tensorflow/models/research python object_detection/dataset_tools/create_pascal_tf_record.py --label_map_path=D:/tensorflow/pedestrian_train/data/label_map.pbtxt --data_dir=D:/pedestrian_data --year=VOC2012 --set=train --output_path=D:/1/pascal_train.record
cd /d D:/tensorflow/models/research object_detection/model_main.py --pipeline_config_path=D:/tensorflow/pedestrian_train/models/ssd_mobilenet_v2_coco.config --model_dir=D:/tensorflow/pedestrian_train/models/train --num_train_stps=1000 --sample_1_of_n_eval_examples=1 --alsologstderr
如何切换opython参考: 如何切换Python版本–基于window10系统
参考:Tensorflow Object Detection API配置(window10 + CPU) Notepad++下载与安装步骤(图文详解) Could not find a version that satisfies the requirement (from versions: ) No matching distribution ModuleNotFoundError: No module named ‘google’