TensorFlow2 Object Detection Api(一)

环境准备

    • Anaconda 安装
    • 新建虚拟环境
    • 进入新建的虚拟环境
    • 安装TensorFlow2
    • 安装Jupyter notebook(非必要)
    • 检测安装结果
    • 下载TensorFlow Model Garden
    • 自带教程运行

Anaconda 安装

前往Anaconda官网进行下载。具体安装过程不做详细描述。
官网地址:https://www.anaconda.com/products/individual#Downloads

新建虚拟环境

conda create -n tensorflow pip python=3.8

在windows下如果显示’conda’ 不是内部或外部命令,检查环境配置问题,或者直接打开Anaconda Prompt输入上面的命令。

进入新建的虚拟环境

conda activate tensorflow

安装TensorFlow2

pip install --ignore-installed --upgrade tensorflow==2.4.1

国内下载速度太慢可以切换镜像
清华镜像:https://pypi.tuna.tsinghua.edu.cn/simple some-package

安装Jupyter notebook(非必要)

conda install jupyter

检测安装结果

python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
2021-02-02 14:10:59.821079: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-02-02 14:10:59.846798: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2021-02-02 14:11:02.208266: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-02-02 14:11:02.209552: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2021-02-02 14:11:02.209830: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
2021-02-02 14:11:02.215073: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-HSHJA7U
2021-02-02 14:11:02.215310: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-HSHJA7U
2021-02-02 14:11:02.216268: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-02-02 14:11:02.216604: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
tf.Tensor(263.02908, shape=(), dtype=float32)

Gpu加速部分后面更新

下载TensorFlow Model Garden

地址:https://github.com/tensorflow/models

自带教程运行

  1. 启动jupyter notebok
  2. 打开models/research/object_detection/colab_tutorials/object_detection_tutorial.ipynb文件

至此基本环境配置完成,但是有个小问题,在object_detection_tutorial.ipynb中他会重新下载一个新的model文件夹放在object_detection中,但这个文件夹和上面提到的ModelGarden是相同的文件。所以我们也可以将object_detection_tutorial.ipynb中的配置命令自己配置一遍。后面将继续介绍如何使用自己的数据。

你可能感兴趣的:(TensoFlow,tensorflow,深度学习,人工智能)