如何使用带有Azureml服务的张量流对象检测api构建ml模型

Tensor Flow Object Detection API is the framework for creating a deep learning network that solves object detection problems.

Tensor Flow对象检测API是用于创建解决对象检测问题的深度学习网络的框架。

There are pre-trained models in TF framework known as Model Zoo , which are trained with various architectures such as Resnet-50, Resnet -101 and Inception. These models trained on various datasets such as COCO, KITTI and Open Images. These models can be directly consumed for prediction to detect categories available in those datasets.

在TF框架中有称为Model Zoo的预训练模型,它们使用各种架构(例如Resnet-50,Resnet -101和Inception)进行训练。 这些模型在各种数据集(例如COCO,KITTI和Open Images)上进行了训练。 这些模型可以直接用于预测,以检测那些数据集中可用的类别。

To develop model with custom data, we can leverage the existing pre-trained models and their configuration in TF Object Detection API, all we have to do is select the algorithm from the model zoo -> transform the input data to required TF format-> train & evaluate model.

要使用自定义数据开发模型,我们可以利用现有的预训练模型及其在TF Object Detection API中的配置,我们要做的就是从模型Zoo中选择算法->将输入数据转换为所需的TF格式->训练和评估模型。

Once the model is built, operationalization is also equally important. We will see how to orchestrate the model into Azure MLS.

建立模型后,可操作性也同样重要。 我们将看到如何将模型编排到Azure MLS中。

什么是Azure MLS? (What is Azure MLS?)

Azure Machine Learning service (AMLS) helps to automate the model build, train, and tracking in an Azure Machine Learning Workspace. It helps to keep a track of various model experiments and metrics in one place.

Azure机器学习服务(AMLS)可帮助在Azure机器学习工作区中自动化模型的构建,训练和跟踪。 它有助于在一处跟踪各种模型实验和度量。

Once the baseline model is built in VM / local computer, next step is to automate the model training process ,below are the steps to get started with AMLS:

在VM /本地计算机中构建了基准模型后,下一步是使模型训练过程自动化,以下是开始使用AMLS的步骤:

  1. Copy the input data (images and its annotations file) into Azure Blob

    将输入数据(图像及其注释文件)复制到Azure Blob中
  2. Create Azure ML pipelines: An Azure Machine Learning pipeline can be as simple as one that calls a Python script, which reads the input from source, processes and writes output results. we need to prepare Azure ML pipeline for data preparation, model training and deployment.

    创建Azure ML管道:Azure机器学习管道可以像调用Python脚本一样简单,该Python脚本从源中读取输入,进行处理并写入输出结果。 我们需要准备Azure ML管道以进行数据准备,模型训练和部署。
  3. To start building pipeline, we can use the local computer with Jupyter notebook, the prerequisites is to install azure ml libraries.

    要开始构建管道,我们可以将本地计算机与Jupyter Notebook一起使用,前提条件是要安装Azure ml库。
Image for post
Basic flow of Azure ML pipeline creation from local computer
从本地计算机创建Azure ML管道的基本流程

4. The data in Azure blob can be accessed from Azure ML pipeline using Data store mounts.

4.可以使用数据存储装载从Azure ML管道访问Azure blob中的数据。

5.Sample explanation of the Azure ML Pipeline step creation is placed below.

5.Azure ML Pipeline步骤创建的示例说明如下。

Image for post

如何在Azure MLS中编排TF OD API模型 (How to Orchestrate TF OD API model in Azure MLS)

Now, lets see how we can automate the model training using Tensor Flow Object Detection API in Azure MLS. We will see the process of Orchestrating TensorFlow Object Detection API model in Azure Machine Learning Service (AMLS).

现在,让我们看看如何在Azure MLS中使用Tensor Flow Object Detection API自动化模型训练。 我们将在Azure机器学习服务(AMLS)中看到编排TensorFlow对象检测API模型的过程。

Lets break the process into 3 parts.

让我们将过程分为三个部分。

1. Setup TensorFlow Object Detection API with custom data in AMLS

1.在AMLS中使用自定义数据设置TensorFlow对象检测API

2. Orchestration of TF OD API model in the AMLS

2. AMLS中的TF OD API模型的编排

3. Logging TensorBoard Graphs in AMLS Experiment

3.在AMLS实验中记录TensorBoard图

使用AMLS中的自定义数据设置TensorFlow对象检测API:(Setup TensorFlow Object Detection API with custom data in AMLS:)

TensorFlow object detection API can be installed using the tutorial link here. Then follow the below steps to configure with custom data.

可以使用此处的教程链接安装TensorFlow对象检测API。 然后按照以下步骤配置自定义数据。

Step 1: Training Dateset Preparation:

步骤1:训练日期集准备:

TensorFlow Object Detection API reads data using the ‘TFRecord’(TensorFlow record) format. For training the object detection API, model needs the following information.

TensorFlow对象检测API使用'TFRecord'(TensorFlow记录)格式读取数据。 为了训练对象检测API,模型需要以下信息。

a) Data

a)数据

Input Images: Images to be trained

输入图像:要训练的图像

Labels: Object location co-ordinates for locating it in the image.

标签:用于在图像中定位对象的位置坐标。

For Labeling there are few tools which helps to perform the labeling.

对于标签,很少有工具可以帮助执行标签。

b) Number of classes/objects to be detected. Create a label file, which specifies the label ID and name. Labels are number of objects to be trained. Below is the sample.

b)要检测的类/对象的数量。 创建一个标签文件,该文件指定标签ID和名称。 标签是要训练的对象数。 下面是示例。

item {
id: 1
name: ‘Class_1’
}

项目{ 编号:1 名称:“ Class_1” }

item {
id: 2
name: ‘Class_2’
}

项目{ id:2 名称:“ Class_2” }

c) Based on the use case, choose the relevant pre-trained model from the model zoo as TensorFlow Object Detection API uses Transfer Learning.

c)根据用例,从TensorFlow对象检测API使用转移学习的模型动物园中选择相关的预训练模型。

d) Model Configuration file for training. (this is used for tuning the model).

d)用于训练的模型配置文件。 (这用于调整模型)。

For each image, object co-ordinates need to be passed along with input image. object coordinates are known as Annotations.

对于每个图像,需要将对象坐标与输入图像一起传递。 对象坐标称为注释。

Image annotations should be in csv format. Placed the sample data below:

图片注释应为csv格式。 将示例数据放在下面:

Image for post
sample input data (image name + annotations + label [classid is label id])
输入数据样本(图像名称+注释+标签[classid是标签ID])

Step 2: Model Training:

步骤2:模型训练:

Image for post
TF OD API Model Training Flow (image source is from web)
TF OD API模型培训流程(图像来源来自网络)

a. Split the Input data set (Images + Annotations) to train,test and validation sets.

一种。 拆分输入数据集(图像+注释)以训练,测试和验证集。

b. Convert the input data to TFRecord for each train and test datasets.

b。 将每个训练和测试数据集的输入数据转换为TFRecord。

d. Run the model training on train data set with modified config file on multi GPU for better performance.

d。 在多GPU上使用修改后的配置文件对训练数据集运行模型训练,以获得更好的性能。

e. Evaluate the model on test set.

e。 在测试集上评估模型。

After configuring Tensor Flow Object Detection API, following python files are needed to train, evaluate, and to save model.

配置Tensor Flow Object Detection API后,需要以下python文件来训练,评估和保存模型。

Image for post

Azure MLS中的TF OD API模型的编排 (Orchestration of TF OD API model in the Azure MLS)

After preparing the model with custom data using TF OD API, the next step is to operationalize the process in AMLS for better tracking of the model results/experiments.

使用TF OD API使用自定义数据准备模型后,下一步是在AMLS中操作该流程,以便更好地跟踪模型结果/实验。

Image for post
3- step process
三步法

The code for creating training pipeline is available in the Github repository here.

创建培训管道的代码是在Github上库中找到这里

Image for post
Azure ML Training Pipeline Flow
Azure ML培训管道流程

Once the model is automated in Azure MLS, we can view and track the model evaluation in the Azure MLS experiments.

在Azure MLS中自动完成模型后,我们可以在Azure MLS实验中查看和跟踪模型评估。

Logging TensorBoard Graphs in AMLS Experiment

在AMLS实验中记录TensorBoard图

TensorBoard is used to view the model graphs such as loss in runtime to monitor the model performance. Along with the model evaluation metrics, we can read the TensorBoard graphs by reading values from .tfevents file and log in the Azure experiments for better tracking of model results and performance.

TensorBoard用于查看模型图(例如运行时损失)以监视模型性能。 连同模型评估指标,我们可以通过读取.tfevents文件中的值来读取TensorBoard图,并登录Azure实验以更好地跟踪模型结果和性能。

Below image shows the Azure experiment with model evaluation metrics and TensorBoard graphs.

下图显示了带有模型评估指标和TensorBoard图的Azure实验。

Image for post
AMLS Experiment — Model Eval results & TensorBoard Graphs
AMLS实验—模型评估结果和TensorBoard图

翻译自: https://medium.com/swlh/how-to-build-ml-model-using-tensor-flow-object-detection-api-with-azureml-service-d19cd74598b4

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值