英特尔 ncs2

    科技2022-08-01  142

    英特尔 ncs2

    Introduction

    介绍

    What we’ll cover in this story:

    我们将在这个故事中介绍:

    Installing OpenVINO toolkit for Ubuntu.

    为Ubuntu安装OpenVINO工具包。 Data preprocessing and model training with Google Colab.

    使用Google Colab进行数据预处理和模型培训。 Saving a TensorFlow model to protocol buffer (pb) format.

    将TensorFlow模型保存为协议缓冲区(pb)格式。 Converting a TensorFlow model to intermediate representation.

    将TensorFlow模型转换为中间表示。 Running a trained model and prediction obtaining with NCS2 device.

    使用NCS2设备运行训练有素的模型并获得预测。

    In the past few years, there has been an active introduction of machine learning for industrial tasks solvings. Machine learning allows you to solve problems that humans cannot cope with. This can be work in hard-to-reach places, in hazardous chemical production, in conditions of increased radiation, etc. Machine learning is applicable in areas where human intelligence can also be applied, but is ineffective: predicting critical failures, preventing sudden equipment failures, condition-based maintenance, predicting the remaining life of equipment.

    在过去的几年中,已经积极引入了机器学习来解决工业任务。 机器学习使您能够解决人类无法应对的问题。 这可以在难以到达的地方,危险的化学产品生产中,在辐射增加的条件下使用。机器学习适用于也可以应用人类智能的领域,但效果不佳:预测关键故障,防止突然出现的设备故障,基于状态的维护,预测设备的剩余寿命。

    Often, in industrial enterprises there is no opportunity to use workstations for data analysis and processing. Therefore, special devices that can be easily connected to existing equipment (most often an industrial microcomputer) are in demand. The computational module NCS2 is one of such devices.

    在工业企业中,通常没有机会使用工作站进行数据分析和处理。 因此,需要可以容易地连接到现有设备(通常是工业微型计算机)的特殊设备。 计算模块NCS2是这样的设备之一。

    Our company AI Labs periodically receives requests for solving some industrial problems related to machine learning. Not so long ago, we had the opportunity to take advantage of the opportunities provided by NCS2. As a result, I developed a pipeline for image classification using NCS2. I would like to share the results of this work with the readers.

    我们公司的AI实验室会定期收到解决与机器学习相关的一些工业问题的请求。 不久前,我们有机会利用NCS2提供的机会。 结果,我开发了使用NCS2进行图像分类的管道。 我想与读者分享这项工作的结果。

    Installing OpenVINO toolkit for Ubuntu

    为Ubuntu安装OpenVINO工具包

    First of all, you need to download and install the current version of OpenVINO. You can get OpenVINO from here. You can find a detailed installation guide here. Quick installation guide:

    首先,您需要下载并安装当前版本的OpenVINO 。 您可以从这里获取OpenVINO。 您可以在此处找到详细的安装指南。 快速安装指南:

    Go to the folder (for example, Downloads) with the downloaded archive:

    转到包含已下载存档的文件夹(例如, Downloads ):

    cd ~/Downloads/

    2. Unpack the .tgz file (where <version> is the version of the downloaded archive, you will see it in the file name):

    2.解压缩.tgz文件(其中<version>是下载的存档的版本,您将在文件名中看到它):

    tar -xvzf l_openvino_toolkit_p_<version>.tgz

    3. Go to the l_openvino_toolkit_p_<version> directory:

    3.转到l_openvino_toolkit_p_ <version>目录:

    cd l_openvino_toolkit_p_<version>

    4. Run the installation script as root:

    4.以超级用户身份运行安装脚本:

    sudo ./install.sh

    5. Follow the instructions on your screen.

    5.按照屏幕上的说明进行操作。

    6. Set environment variables by editing the .bashrc file. Go to the user directory and open .bashrc file for editing (for example, with nano):

    6.通过编辑.bashrc文件来设置环境变量。 转到用户目录并打开.bashrc文件进行编辑(例如,使用nano ):

    cd ~nano .bashrc

    Add the following line to the end of the .bashrc file, save it and reload:

    将以下行添加到.bashrc文件的末尾,保存并重新加载:

    source /opt/intel/openvino/bin/setupvars.shsource .bashrc

    That’s all. All the necessary functionality for local work with NCS2 has been prepared. You can perform data preprocessing and model training.

    就这样。 已经准备好使用NCS2进行本地工作的所有必要功能。 您可以执行数据预处理和模型训练。

    Data preprocessing and model training with Google Colab

    使用Google Colab进行数据预处理和模型培训

    Animals-10 dataset was used to solve the classification problem. To simplify the problem, 5 classes (species of animals) were selected from Animals-10: cat, dog, chicken, horse, sheep. Images related to each of the classes are grouped into corresponding folders (‘cat’, ‘dog’, ‘chicken’, ‘horse’, ‘sheep’). The model was trained in Google Colab. Let’s take a closer look.

    Animals-10数据集用于解决分类问题。 为简化此问题,从Animals-10中选择了5类(动物种类):猫,狗,鸡,马,绵羊。 与每个类别相关的图像都被分组到相应的文件夹(“猫”,“狗”,“鸡”,“马”,“羊”)中。 该模型在Google Colab中进行了训练。 让我们仔细看看。

    First of all, you need to install a version of TensorFlow suitable for working with NCS2:

    首先,您需要安装适用于NCS2的TensorFlow版本:

    !pip install tensorflow==1.15.2

    Import libraries:

    导入库:

    import tensorflow.compat.v1 as tfimport tensorflow_hub as hubimport matplotlib.pylab as pltimport numpy as np

    Mount the Google Drive (with dataset) to Google Colab:

    将Google云端硬盘(带有数据集)安装到Google Colab:

    from google.colab import drivedrive.mount(‘/content/drive’)

    Go to the directory where the data was uploaded (‘animals’):

    转到上传数据的目录(“动物”):

    转载请注明原文地址:https://blackberry.8miu.com/read-12387.html
    最新回复(0)