vitis ai library user guide...• chapter 1 is an introduction to the ai library. this chapter...

201
Vis AI ライブラリ ユーザー ガイド UG1354 (v1.2) 2020 7 21 この資料は表記のバージョンの英語版を翻訳したもので、内容に相違が生じる場合には原文を優先します。資 料によっては英語版の更新に対応していないものがあります。日本語版は参考用としてご使用の上、最新情報 につきましては、必ず最新英語版をご参照ください。

Upload: others

Post on 20-Aug-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

Vitis AI ライブラリ ユーザーガイドUG1354 (v1.2) 2020 年 7 月 21 日

この資料は表記のバージョンの英語版を翻訳したもので、内容に相違が生じる場合には原文を優先します。資料によっては英語版の更新に対応していないものがあります。日本語版は参考用としてご使用の上、最新情報につきましては、必ず最新英語版をご参照ください。

Page 2: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

改訂履歴次の表に、この文書の改訂履歴を示します。

セクション 内容2020 年 7 月 21 日、バージョン 1.2

文書全体 軽微な変更2020 年 7 月 13 日、バージョン 1.2

はじめに 「Vitis AI ライブラリ 1.2 リリース ノート」を追加。ブロック図を更新。

はじめに 「Vitis AI ライブラリ 1.2 リリース ノート」を追加。ブロック図を更新。

インストール 章全体を更新。ライブラリとサンプル 複数の elf モデルの操作方法を追加。

「顔認識」、「プレート検出」、「プレート認識」、「医療画像セグメンテーション」を追加。API のプログラミング 章を更新、すべての API をこの資料の付録に記載。性能 U280 および U50lv の性能データを追加。

U50、ZCU102 および ZCU104 の性能データを更新。2020 年 3 月 23 日、バージョン 1.1

第 1 章: はじめに 「Vitis AI ライブラリ 1.1 リリース ノート」を追加。第 2 章: インストール クラウドの動作に関する内容を追加。

ホストのセットアップ方法を更新。第 7 章: 性能 U50 の性能データを追加。

改訂履歴

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 2

Page 3: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

目次改訂履歴..........................................................................................................................................................................2

第 1 章: はじめに...................................................................................................................................................... 5このユーザー ガイドについて........................................................................................................................................5概要..................................................................................................................................................................................6ブロック図.......................................................................................................................................................................6機能..................................................................................................................................................................................9Vitis AI ライブラリ 1.2 リリース ノート........................................................................................................................9Vitis AI ライブラリ 1.1 リリース ノート..................................................................................................................... 12Vitis AI ライブラリ 1.0 リリース ノート..................................................................................................................... 15

第 2 章: インストール..........................................................................................................................................19Vitis AI ライブラリのダウンロード..............................................................................................................................19ホストのセットアップ..................................................................................................................................................19ターゲットをセットアップする................................................................................................................................... 24Vitis AI サンプルの実行................................................................................................................................................ 28サポート........................................................................................................................................................................ 32

第 3 章: ライブラリとサンプル.................................................................................................................... 33モデル ライブラリ........................................................................................................................................................ 34モデル サンプル............................................................................................................................................................ 48

第 4 章: プログラム例..........................................................................................................................................50Vitis AI API_0 を使用した開発......................................................................................................................................51ユーザー モデルと AI ライブラリ API_2 を使用した開発...........................................................................................53プリプロセスのカスタマイズ.......................................................................................................................................55コンフィギュレーション ファイルの使用................................................................................................................... 56独自のポストプロセス コードを実装.......................................................................................................................... 59AI ライブラリのポストプロセス ライブラリを使用する方法.................................................................................... 60

第 5 章: アプリケーション デモ...................................................................................................................62デモの概要.....................................................................................................................................................................62デモ プラットフォームとセットアップ.......................................................................................................................62デモ 1: マルチタスク セグメンテーションおよび車両検出と車線検出.....................................................................63デモ 2: マルチタスク セグメンテーションおよび車両検出と姿勢検出.....................................................................65

第 6 章: API のプログラミング.....................................................................................................................67

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 3

Page 4: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

第 7 章: 性能............................................................................................................................................................... 68ZCU102 の性能..............................................................................................................................................................68ZCU104 の性能..............................................................................................................................................................70U50/U50lv の性能.........................................................................................................................................................72U280 の性能.................................................................................................................................................................. 77

付録 A: API リファレンス.................................................................................................................................80vitis::ai::Classification..................................................................................................................................................80vitis::ai::DpuTask..........................................................................................................................................................83vitis::ai::FaceDetect..................................................................................................................................................... 88vitis::ai::FaceFeature................................................................................................................................................... 93vitis::ai::FaceLandmark............................................................................................................................................... 99vitis::ai::MedicalSegmentation................................................................................................................................ 102vitis::ai::MedicalSegmentationPostProcess........................................................................................................... 106vitis::ai::MultiTask...................................................................................................................................................... 108vitis::ai::MultiTask8UC1.............................................................................................................................................113vitis::ai::MultiTask8UC3.............................................................................................................................................116vitis::ai::MultiTaskPostProcess.................................................................................................................................119vitis::ai::OpenPose.....................................................................................................................................................120vitis::ai::PlateDetect...................................................................................................................................................125vitis::ai::PlateNum..................................................................................................................................................... 128vitis::ai::PoseDetect...................................................................................................................................................132vitis::ai::RefineDet..................................................................................................................................................... 137vitis::ai::RefineDetPostProcess................................................................................................................................ 142vitis::ai::Reid............................................................................................................................................................... 144vitis::ai::RoadLine...................................................................................................................................................... 147vitis::ai::RoadLinePostProcess................................................................................................................................. 151vitis::ai::Segmentation.............................................................................................................................................. 153vitis::ai::Segmentation8UC1.....................................................................................................................................158vitis::ai::Segmentation8UC3.....................................................................................................................................161vitis::ai::SSD................................................................................................................................................................164vitis::ai::SSDPostProcess...........................................................................................................................................168vitis::ai::TFSSD............................................................................................................................................................169vitis::ai::TFSSDPostProcess.......................................................................................................................................173vitis::ai::YOLOv2......................................................................................................................................................... 175vitis::ai::YOLOv3......................................................................................................................................................... 178データ構造索引........................................................................................................................................................... 182

付録 B: その他のリソースおよび法的通知........................................................................................200ザイリンクス リソース...............................................................................................................................................200Documentation Navigator およびデザイン ハブ.................................................................................................... 200お読みください: 重要な法的通知...............................................................................................................................200

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 4

Page 5: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

第 1 章

はじめにこのユーザー ガイドについて

該当バージョンこのユーザー ガイドの内容は、次に示す AI ライブラリ バージョンに適用されます。表 1: Vitis AI ライブラリ パケットのリスト

番号 パケット名 バージョン1 vitis_ai_library_r1.2.0_video.tar.gz r1.2

2 vitis_ai_library_r1.2.0_image.tar.gz r1.2

3 vitis-ai-runtime-1.2.0.tar.gz r1.2

4 vitis_ai_2020.1-r1.2.0.tar.gz r1.2

5 xilinx_model_zoo_zcu102-1.2.0-1.aarch64.rpm r1.2

6 xilinx_model_zoo_zcu104-1.2.0-1.aarch64.rpm r1.2

7 xilinx_model_zoo_u50_1.2.0_amd64.deb r1.2

8 xilinx_model_zoo_u280_u50lv9e_1.2.0_amd64.deb r1.2

9 xilinx_model_zoo_u50lv10e_1.2.0_amd64.deb r1.2

10 alveo_xclbin-1.2.1.tar.gz r1.2

11 sdk-2020.1.0.0.sh 2020.1

対象者Vitis AI ライブラリの使用は、次のユーザーを対象としています。• ザイリンクス モデルを使用して迅速にアプリケーションを構築したい。• Vitis AI ライブラリ サポート ネットワーク リストを使用して、独自のデータで再学習したカスタム モデルを使用する。

• Vitis AI ライブラリでサポートされているモデルと類似したカスタム モデルを使用し、Vitis AI のポストプロセスライブラリを使用する。

注記: AI ライブラリでサポートされているモデルとはまったく異なるカスタム モデルを使用している場合や、独自のポストプロセス用デバイスを使用している場合でも、参考用としてザイリンクスのサンプル モデルやライブラリを利用できます。この資料の構成このユーザー ガイドでは、AI ライブラリのインストール、活用、および開発方法について説明しています。

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 5

Page 6: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

• 第 1 章では、AI ライブラリの概要を説明しています。AI ライブラリの概要のほか、フレームワーク、サポートされるネットワーク、サポートされるハードウェア プラットフォームなどについて概説しています。

• 第 2 章では、AI ライブラリのインストール方法とサンプル デザインの実行方法について説明しています。ホスト環境やターゲット環境を迅速にセットアップし、AI ライブラリ関連のサンプル デザインをコンパイルして実行する手順を示しています。

• 第 3 章では、AI ライブラリでサポートされる各モデル ライブラリについて詳しく説明しています。AI ライブラリでサポートされるモデル ライブラリ、各ライブラリの目的、画像やビデオを使用してライブラリをテストする方法、およびライブラリの性能を評価する方法について説明しています。

• 第 4 章では、AI ライブラリを使用してアプリケーションを開発する方法を詳しく説明しています。次の内容を理解できます。○ Vitis API を使用する開発○ 独自モデルを使用する開発○ プリプロセスのカスタマイズ○ プリプロセスおよびポストプロセスのパラメーターの取得にコンフィギュレーション ファイルを使用○ AI ライブラリのポストプロセス ライブラリを使用○ 独自のポストプロセス コードを実装

• 第 5 章では、テスト環境をセットアップして、アプリケーション デモを実行する方法を説明しています。Vitis AIライブラリを使用した 2 つのアプリケーション デモがあります。

• 第 6 章では、API のプログラミング方法を説明しています。• 第 7 章では、異なるボード上での Vitis AI ライブラリの性能について詳しく説明しています。

概要Vitis AI ライブラリは、DPU (Deep-Learning Processor Unit) を使用する効率的な AI 推論用に構築された高レベルのライブラリと API を提供します。統合 API を備えた Vitis AI ランタイムをベースに構築されており、XRT 2020.1 を完全にサポートしています。Vitis AI ライブラリは、効率的かつ高品質のニューラル ネットワークをカプセル化することで、統合された使いやすいインターフェイスを提供します。これにより、深層学習や FPGA の知識がないユーザーでも、深層学習ニューラルネットワークを簡単に使用できます。Vitis AI ライブラリを使用することで、基礎となるハードウェアに時間を費やすことなく、アプリケーション開発により重点を置くことができます。AI ライブラリの使用対象者については、このユーザー ガイドについて を参照してください。

ブロック図Vitis™ AI ライブラリは、ベース ライブラリ、モデル ライブラリ、ライブラリ テスト サンプル、およびアプリケーション デモの 4 つで構成されています。

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 6

Page 7: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

ベース ライブラリは、DPU および各モデルのポストプロセス モジュールとの動作インターフェイスを提供します。dpu_task は、DPU 動作用のインターフェイス ライブラリです。xnnpp は各モデルのポストプロセス ライブラリで、最適化や高速化などのビルトイン モジュールを備えています。モデル ライブラリはオープンソースであり、これを利用することで一般的なニューラル ネットワークの運用が可能になります。たとえば、分類、検出、セグメンテーションなどの一般的な種類のニューラル ネットワークなどです。これらのライブラリは、統合インターフェイスを使用した簡単かつ迅速な開発手段を提供し、ザイリンクスのモデルだけでなくカスタム モデルにも適用できます。ライブラリ テスト サンプルは、モデル ライブラリを短時間でテスト/評価するために使用します。アプリケーション デモでは、AI ライブラリを使用してアプリケーションを開発する方法を示します。次の図に、Vitis AI ライブラリのブロック図を示します。

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 7

Page 9: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

機能Vitis AI ライブラリの特長は次のとおりです。• 包括的なフルスタック アプリケーション ソリューション• 最適化されたプリプロセス/ポストプロセスの機能およびライブラリ• オープンソース モデル ライブラリ• DPU とモデルのプリプロセス/ポストプロセス インターフェイスを備えた統合動作インターフェイス• 実用的なアプリケーション ベースのモデル ライブラリ、プリプロセス/ポストプロセス ライブラリ、およびアプリケーション サンプル

Vitis AI ライブラリ 1.2 リリース ノートこのセクションでは、Vitis™ AI ライブラリ 1.2 リリースの主な機能とアップデートに関する情報を提供します。

主な機能および拡張機能この AI ライブラリ リリースの主な機能と拡張機能は次のとおりです。• クラウド ボードの新たなサポート: 今回のリリースでは U50lv および U280 カードが新たにサポートされました。• 新しいモデル ライブラリ: 次の新しいモデル ライブラリがサポートされました。

• face recognition

• plate detection

• plate recognition

• medical segmentation

• Pytorch モデル サポート: 3 つの Pytorch モデルがサポートされました。• 6 つの Caffe モデルの追加。: 6 つの新しい Pytorch モデルがサポートされました。変更点1. エッジ向けターゲットのインストール モードが変更され、rpm 形式のパッケージが使用されるようになりまし

た。2. モデルの meta.json ファイルは廃止されました。

互換性• Vitis AI ライブラリ 1.2 は、次のイメージを使用してテストされています。

○ xilinx-zcu102-dpu-v2020.1-v1.2.0.img.gz

○ xilinx-zcu104-dpu-v2020.1-v1.2.0.img.gz

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 9

Page 10: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

モデル サポートこのバージョンの Vitis AI ライブラリでは、次のモデルがサポートされています。表 2: AI ライブラリでサポートされるモデル

番号 ニューラル ネットワーク ZCU102/ZCU104 U50/U50lv/U280 アプリケーション1 inception_resnet_v2_tf Y Y 画像分類2 inception_v1_tf Y Y

3 inception_v3_tf Y Y

4 inception_v4_2016_09_09_tf Y Y

5 mobilenet_v1_0_25_128_tf Y N/A

6 mobilenet_v1_0_5_160_tf Y N/A

7 mobilenet_v1_1_0_224_tf Y N/A

8 mobilenet_v2_1_0_224_tf Y N/A

9 mobilenet_v2_1_4_224_tf Y N/A

10 resnet_v1_101_tf Y Y

11 resnet_v1_152_tf Y Y

12 resnet_v1_50_tf Y Y

13 vgg_16_tf Y Y

14 vgg_19_tf Y Y

15 ssd_mobilenet_v1_coco_tf Y N/A 物体検出16 ssd_mobilenet_v2_coco_tf Y N/A

17 ssd_resnet_50_fpn_coco_tf Y Y

18 yolov3_voc_tf Y Y

19 mlperf_ssd_resnet34_tf Y N/A

20 resnet50 Y Y 画像分類21 resnet18 Y Y

22 inception_v1 Y Y

23 inception_v2 Y Y

24 inception_v3 Y Y

25 inception_v4 Y Y

26 mobilenet_v2 Y N/A

27 squeezenet Y Y

28 ssd_pedestrain_pruned_0_97 Y Y ADAS 歩行者検出29 ssd_traffic_pruned_0_9 Y Y トラフィック検出30 ssd_adas_pruned_0_95 Y Y ADAS 車両検出31 ssd_mobilenet_v2 Y N/A 物体検出32 refinedet_pruned_0_8 Y Y

33 refinedet_pruned_0_92 Y Y

34 refinedet_pruned_0_96 Y Y

35 vpgnet_pruned_0_99 Y Y ADAS 車線検出

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 10

Page 11: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 2: AI ライブラリでサポートされるモデル (続き)

番号 ニューラル ネットワーク ZCU102/ZCU104 U50/U50lv/U280 アプリケーション36 fpn Y Y ADAS セグメンテーション37 sp_net Y Y 姿勢推定38 openpose_pruned_0_3 Y Y

39 densebox_320_320 Y Y 顔検出40 densebox_640_360 Y Y

41 face_landmark Y Y 顔検出/認識42 reid Y Y 物体追跡43 multi_task Y Y ADAS

44 yolov3_adas_pruned_0_9 Y Y 物体検出45 yolov3_voc Y Y

46 yolov3_bdd Y Y

47 yolov2_voc Y Y

48 yolov2_voc_pruned_0_66 Y Y

49 yolov2_voc_pruned_0_71 Y Y

50 yolov2_voc_pruned_0_77 Y Y

51 facerec_resnet20 Y Y プレート認識52 facerec_resnet64 Y Y

53 plate_detection Y Y プレート認識54 plate_recognition Y Y

55 FPN_Res18_Medical_segmentation Y Y 医療画像セグメンテーション56 refinedet_baseline Y Y 物体検出57 resnet50_pt N/A Y 画像分類58 squeezenet_pt N/A Y

59 inception_v3_pt N/A Y

注記:1. #1 ~ #19 のニューラル ネットワーク モデルは、Tensorflow フレームワークに基づいてトレーニングされます。2. #20 ~ #56 のニューラル ネットワーク モデルは、Caffe フレームワークに基づいてトレーニングされます。3. #57 ~ #59 のニューラル ネットワーク モデルは、Pytorch フレームワークに基づいてトレーニングされます。

デバイス サポート次に示すプラットフォームおよび EVB は、AI ライブラリ 1.2 でサポートされています。表 3: エッジ デバイス サポート

プラットフォーム EVB バージョンZynq UltraScale+ MPSoC ZU9EG ザイリンクス ZCU102 V1.1

Zynq® UltraScale+™ MPSoC ZU7EV ザイリンクス ZCU104 V1.0

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 11

Page 12: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 4: クラウド デバイス サポートアクセラレータ カード

ザイリンクス Alveo U50

ザイリンクス Alveo U50lv

ザイリンクス Alveo U280

制限• mobilenet をバックボーンとした一部のニューラル ネットワークは、U50、U50lv および U280 ではサポートされません。

• エッジ デバイスでは、Pytorch モデルはサポートされていません。• Docker 環境の制限により、クラウド デバイス上ではマルチ タスク デモは DRM モードで実行できません。

Vitis AI ライブラリ 1.1 リリース ノートこのセクションでは、Vitis™ AI ライブラリ 1.1 リリースの主な機能とアップデートに関する情報を提供します。

主な機能および拡張機能この AI ライブラリ リリースの主な機能と拡張機能は次のとおりです。• クラウドをサポート: 今回のリリースでは Alveo U50 カードがサポートされました。• 新しい DPU をサポート: クラウドで使用可能な DPU がサポートされました。• 新規オープンソース ライブラリ: 今回のリリースでは、ニューラル ネットワークのプリプロセスとポストプロセスの方法を示した xnnpp ライブラリがオープンソースとなりました。

• モデル ライブラリをアップデート: 新しいモデル ライブラリは、クラウドとエッジ間のインターフェイスを統合します。

変更点エッジの場合のホストのインストール モードが変更され、従来の Docker インストール モードは廃止されました。

互換性• Vitis AI ライブラリ 1.1 は、次のイメージを使用してテストされています。

○ xilinx-zcu102-dpu-v2019.2-v2.img

○ xilinx-zcu104-dpu-v2019.2-v2.img

モデル サポートこのバージョンの Vitis AI ライブラリでは、次のモデルがサポートされています。

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 12

Page 13: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 5: AI ライブラリでサポートされるモデル

番号 ニューラル ネットワーク ZCU102/ZCU104 U50 アプリケーション1 inception_resnet_v2_tf Y Y 画像分類2 inception_v1_tf Y Y

3 inception_v3_tf Y Y

4 inception_v4_2016_09_09_tf

Y Y

5 mobilenet_v1_0_25_128_tf

Y N/A

6 mobilenet_v1_0_5_160_tf

Y N/A

7 mobilenet_v1_1_0_224_tf

Y N/A

8 mobilenet_v2_1_0_224_tf

Y N/A

9 mobilenet_v2_1_4_224_tf

Y N/A

10 resnet_v1_101_tf Y Y

11 resnet_v1_152_tf Y Y

12 resnet_v1_50_tf Y Y

13 vgg_16_tf Y Y

14 vgg_19_tf Y Y

15 ssd_mobilenet_v1_coco_tf

Y N/A 物体検出

16 ssd_mobilenet_v2_coco_tf

Y N/A

17 ssd_resnet_50_fpn_coco_tf

Y Y

18 yolov3_voc_tf Y Y

19 mlperf_ssd_resnet34_tf Y N/A

20 resnet50 Y Y 画像分類21 resnet18 Y Y

22 inception_v1 Y Y

23 inception_v2 Y Y

24 inception_v3 Y Y

25 inception_v4 Y Y

26 mobilenet_v2 Y N/A

27 squeezenet Y Y

28 ssd_pedestrain_pruned_0_97

Y Y ADAS 歩行者検出

29 ssd_traffic_pruned_0_9 Y Y トラフィック検出30 ssd_adas_pruned_0_95 Y Y ADAS 車両検出

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 13

Page 14: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 5: AI ライブラリでサポートされるモデル (続き)

番号 ニューラル ネットワーク ZCU102/ZCU104 U50 アプリケーション31 ssd_mobilenet_v2 Y N/A 物体検出32 refinedet_pruned_0_8 Y Y

33 refinedet_pruned_0_92 Y Y

34 refinedet_pruned_0_96 Y Y

35 vpgnet_pruned_0_99 Y Y ADAS 車線検出36 fpn Y Y ADAS セグメンテーション37 sp_net Y Y 姿勢推定38 openpose_pruned_0_3 Y Y

39 densebox_320_320 Y Y 顔検出40 densebox_640_360 Y Y

41 face_landmark Y Y 顔検出/認識42 reid Y Y 物体追跡43 multi_task Y Y ADAS

44 yolov3_adas_pruned_0_9

Y Y 物体検出

45 yolov3_voc Y Y

46 yolov3_bdd Y Y

47 yolov2_voc Y Y

48 yolov2_voc_pruned_0_66

Y Y

49 yolov2_voc_pruned_0_71

Y Y

50 yolov2_voc_pruned_0_77

Y Y

注記:1. #1 ~ #19 のニューラル ネットワーク モデルは、Tensorflow フレームワークに基づいてトレーニングされます。2. #20 ~ #50 のニューラル ネットワーク モデルは、Caffe フレームワークに基づいてトレーニングされます。

デバイス サポート次に示すプラットフォームおよび EVB は、AI ライブラリ 1.1 でサポートされています。表 6: エッジ デバイス サポート

プラットフォーム EVB バージョンZynq UltraScale+ MPSoC ZU9EG ザイリンクス ZCU102 V1.1

Zynq® UltraScale+™ MPSoC ZU7EV ザイリンクス ZCU104 V1.0

表 7: クラウド デバイス サポートアクセラレータ カード

ザイリンクス Alveo U50

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 14

Page 15: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

制限mobilenet をバックボーンとした一部のニューラル ネットワークは、U50 ではサポートされません。

Vitis AI ライブラリ 1.0 リリース ノートこのセクションでは、Vitis™ AI ライブラリ 1.0 リリースの主な機能とアップデートに関する情報を提供します。今回のリリースは、前回リリースされたザイリンクス AI SDK v2.0 の後継です。Vitis AI ライブラリは、DPU (Deep Learning Processing Unit) を使用して効率的な AI 推論を実現するために構築された高レベルのライブラリと API です。高効率かつ高品質のニューラル ネットワークを数多くカプセル化しているため、簡単に使用できる統合インターフェイスを提供します。

主な機能および拡張機能この Vitis AI ライブラリ リリースの主な機能と拡張機能は次のとおりです。• 新しい Vitis AI ランタイムをサポート: Vitis AI ライブラリが、統合 API を使用する新しい Vitis AI ランタイムに基づいてアップデートされました。XRT 2019.2 も完全にサポートしています。

• 新しい DPU をサポート: エッジ デバイス用の DPU に加えて、新しい AI ライブラリでは、同じコードを使用して新しいクラウド ベースの DPU IP もサポートする予定です (今回のリリースには、クラウド DPU 向けのランタイムおよびモデルは含まれていない)。

• 新しい Tensorflow モデルをサポート: 公式 Tensorflow リポジトリからの最大 21 個の Tensorflow モデルをサポートしています。エッジ デバイス用のコンパイル済みモデルが含まれています。オリジナル モデルは最新のModel Zoo でリリースされています。

• 新しいライブラリとデモ: 2 つの新しいライブラリ (libdpmultitask、libdptfssd) があり、 公式 TensorFlowリポジトリからのマルチタスク モデルおよび SSD モデルをサポートしています。最新の分類デモでは、Vitis AI ランタイムの統合 API の使用法を説明しています。

• 新規オープンソース ライブラリ: 今回のリリースで、Vitis AI ランタイムの統合 API を使用して高レベルのライブラリを構築する方法を示した libdpbase ライブラリがオープンソースとなりました。

• 新しいインストール方法: ホスト側の環境で Docker イメージのインストールをサポートすることで、インストール プロセスが統合されてフローがシンプルになっています。

互換性• Vitis AI ライブラリ 1.0 は、次のイメージを使用してテストされています。

○ xilinx-zcu102-dpu-v2019.2.img

○ xilinx-zcu104-dpu-v2019.2.img

• ライブラリ インターフェイスはザイリンクス AI SDK v2.0 との整合性が維持されているため、既存のアプリケーションを新しい Vitis AI ライブラリに直接移植できます。

モデル サポートこのバージョンの Vitis AI ライブラリでは、次のモデルがサポートされています。

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 15

Page 16: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 8: AI ライブラリでサポートされるモデル番号 ニューラル ネットワーク アプリケーション

1 inception_resnet_v2_tf 画像分類2 inception_v1_tf

3 inception_v3_tf

4 inception_v4_2016_09_09_tf

5 mobilenet_v1_0_25_128_tf

6 mobilenet_v1_0_5_160_tf

7 mobilenet_v1_1_0_224_tf

8 mobilenet_v2_1_0_224_tf

9 mobilenet_v2_1_4_224_tf

10 resnet_v1_101_tf

11 resnet_v1_152_tf

12 resnet_v1_50_tf

13 vgg_16_tf

14 vgg_19_tf

15 ssd_mobilenet_v1_coco_tf 物体検出16 ssd_mobilenet_v2_coco_tf

17 ssd_resnet_50_fpn_coco_tf

18 yolov3_voc_tf

19 mlperf_ssd_resnet34_tf

20 resnet50 画像分類21 resnet18

22 inception_v1

23 inception_v2

24 inception_v3

25 inception_v4

26 mobilenet_v2

27 squeezenet

28 ssd_pedestrain_pruned_0_97 ADAS 歩行者検出29 ssd_traffic_pruned_0_9 トラフィック検出30 ssd_adas_pruned_0_95 ADAS 車両検出31 ssd_mobilenet_v2 物体検出32 refinedet_pruned_0_8

33 refinedet_pruned_0_92

34 refinedet_pruned_0_96

35 vpgnet_pruned_0_99 ADAS 車線検出36 fpn ADAS セグメンテーション37 sp_net 姿勢推定38 openpose_pruned_0_3

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 16

Page 17: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 8: AI ライブラリでサポートされるモデル (続き)

番号 ニューラル ネットワーク アプリケーション39 densebox_320_320 顔検出40 densebox_640_360

41 face_landmark 顔検出/認識42 reid 物体追跡43 multi_task ADAS

44 yolov3_adas_pruned_0_9 物体検出45 yolov3_voc

46 yolov3_bdd

47 yolov2_voc

48 yolov2_voc_pruned_0_66

49 yolov2_voc_pruned_0_71

50 yolov2_voc_pruned_0_77

注記:1. #1 ~ #19 のニューラル ネットワーク モデルは、Tensorflow フレームワークに基づいてトレーニングされます。2. #20 ~ #50 のニューラル ネットワーク モデルは、Caffe フレームワークに基づいてトレーニングされます。

デバイス サポート次に示すプラットフォームおよび EVB は、AI ライブラリ 1.0 でサポートされています。表 9: デバイス サポート

プラットフォーム EVB バージョンZynq UltraScale+ MPSoC ZU9EG ザイリンクス ZCU102 V1.1

Zynq® UltraScale+™ MPSoC ZU7EV ザイリンクス ZCU104 V1.0

制限公式 Tensorflow リポジトリからのライブラリは SSD モデル用に複雑な構成となっているため、オリジナルlibdpssd ライブラリとは異なる caffe モデル用の新しい libdptfssd ライブラリがあります。これらの 2 つのライブラリは、今後のリリースでマージされる可能性があります。

推奨されない機能次に示す機能は、Vitis AI ライブラリ 1.0 でサポートされていません。• 削除されたデモ

squeezenet と SSD のデモが削除されています。アプリケーションおよびソリューション開発には AI ライブラリの高レベル API を使用することを推奨しているため、今回のリリースでは、分類デモを 1 つだけ提供して Vitis AIランタイムで低レベルの統合 API を使用する方法を示します。

• 削除されたコンパイル済みモデル

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 17

Page 18: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

今回のリリースでは、6 つの Tensorflow モデルが削除されています。前回のザイリンクス AI v2.0 リリースでは最新の Model Zoo との同期を保つためにこれらを提供していました。削除されたモデルは、Tensorflow スリム モデルに由来する最新 Model Zoo の類似モデルで置き換えることができます。これらのモデルを次に示します。• resnet_50_tf

• inception_v1_tf

• resnet_18_tf

• mobilenet_v1_tf

• mobilenet_v2_tf

• ssd_voc_tf

第 1 章: はじめに

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 18

Page 19: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

第 2 章

インストールVitis AI ライブラリのダウンロード

Vitis™ AI ライブラリのパッケージは GitHub で公開しており、https://github.com/Xilinx/Vitis-AI から無償でダウンロードできます。Vitis AI ライブラリの使用に慣れるまでは、Vitis AI ライブラリでサポートされる評価ボードまたは Alveo カードを使用することを推奨します。Vitis AI ライブラリでサポートされる評価ボードの詳細は、https://japan.xilinx.com/products/design-tools/ai-inference/ai-developer-hub.html#edge を参照してください。Alveo カードの詳細は、https://japan.xilinx.com/products/boards-and-kits/alveo.html を参照してください。このリリースでサポートされている評価ボードは次のとおりです。• ザイリンクス ZCU102

• ザイリンクス ZCU104

このリリースでサポートされている Alveo カードは次のとおりです。• ザイリンクス Alveo U50

• ザイリンクス Alveo U50lv

• ザイリンクス Alveo U280

ホストのセットアップエッジの場合次の手順に従って、エッジ デバイス開発用のホストをセットアップします。1. こちら から sdk-2020.1.0.0.sh をダウンロードします。2. クロス コンパイル システム環境をインストールします。

$./sdk-2020.1.0.0.sh

3. プロンプトに従ってインストールします。注記:

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 19

Page 20: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

インストール パスには ~/petalinux_sdk を推奨します。いずれの場合も、インストール パスには読み出し-書き込みパーミッションが必要です。ここでは、~/petalinux_sdk にインストールします。

4. インストールが完了したら、プロンプトに従って次のコマンドを実行します。$source ~/petalinux_sdk/environment-setup-aarch64-xilinx-linux

現在のターミナルを閉じた場合は、次に新規ターミナル インターフェイスを開いたときに上記の手順をもう一度実行する必要があります。

5. こちら から vitis_ai_2020.1-r1.2.x.tar.gz をダウンロードし、PetaLinux システムにインストールします。$tar -xzvf vitis_ai_2020.1-r1.2.x.tar.gz -C ~/petalinux_sdk/sysroots/aarch64-xilinx-linux

6. Vitis AI リポジトリをコピーします。$cd ~$git clone --recurse-submodules https://github.com/Xilinx/Vitis-AI

7. AI ライブラリのデモをクロス コンパイルします。ここでは、yolov3 の例を示します。$cd ~/Vitis-AI/Vitis-AI-Library/overview/demo/yolov3$bash -x build.sh

次のコマンドを実行すると、コンパイル中に情報を出力しないようにできます。$bash build.sh

コンパイル プロセスでエラーが報告されず、実行可能ファイル demo_yolov3 が生成されている場合は、ホスト環境が正しくインストールされています。

8. AI ライブラリのライブラリ サンプルをコンパイルする場合は、次のコマンドを実行します (classificationを例として使用)。$cd ~/Vitis-AI/Vitis-AI-Library/overview/samples/classification$bash -x build.sh

これで実行可能なプログラムが生成されます。9. ライブラリのソース コードを変更する場合は、~/Vitis-AI/Vitis-AI-Library にあるファイルを開いて変更します。AI ライブラリをコンパイルする前に、コンパイル済みファイルの出力パスを確認してください。デフォルトの出力パスは$HOME/build です。デフォルトの出力パスを変更する場合は、cmake.sh 内の build_dir_default を編集してください。たとえば、build_dir_default=$HOME/build/build.${target_info}/${project_name} をbuild_dir_default=/workspace/build/build.${target_info}/${project_name} に変更します。注記:

build_dir_default を編集する場合は、$HOME の部分のみを変更してください。次のコマンドを実行して、ライブラリを一括でビルドします。$cd ~/Vitis-AI/Vitis-AI-Library$./cmake.sh --clean --cmake-options='-DCMAKE_NO_SYSTEM_FROM_IMPORTED=on'

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 20

Page 21: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

コンパイルが完了すると、build_dir_default ディレクトリに AI ライブラリが生成されます。コンパイル規則を変更する場合は、ライブラリのディレクトリにある cmake.sh を確認して変更してください。注記: すべてのソース コード、サンプル、デモ、およびヘッド ファイルは、~/Vitis-AI/Vitis-AI-Libraryにあります。

クラウド (U50/U50lv/U280) の場合Docker イメージを実行して、クラウド上でホストをセットアップします。1. Vitis AI リポジトリをコピーします。

$git clone --recurse-submodules https://github.com/xilinx/vitis-ai$cd Vitis-AI

2. https://github.com/Xilinx/Vitis-AI#installation の Docker インストール ガイドに従って Docker コンテナーを実行します。$./docker_run.sh -X xilinx/vitis-ai-cpu:<x.y.z>

注記: Docker ランタイム システムによって、workspace フォルダーが作成され、Docker ランタイム システムの /workspace に配置されます。

3. 開発するプログラム、データ、およびその他のファイルを workspace フォルダーに入れます。Docker システムが起動すると、これらのファイルは Docker システムの /workspace に格納されます。Docker システムの別のパスに入れると、Docker システムを終了したときに、これらのファイルの場所がわからなくなるため、所定のパス以外は指定しないでください。

4. プラットフォームのモデルを選択します。最新モデルのダウンロード リンクは、https://github.com/Xilinx/Vitis-AI/tree/master/Vitis-AI-Library#quick-start-for-alveo にあります。ここでは、U50 の例を示します。こちら からU50 モデルのパッケージをダウンロードし、インストールします。$sudo dpkg -i xilinx_model_zoo_u50_1.2.0_amd64.deb

Pytorch モデルの場合は、こちら から U50 Pytorch モデル パッケージをダウンロードし、インストールします。$sudo dpkg -i xilinx_model_zoo_u50_pytorch_1.2.0_amd64.deb

5. クラウド xclbin パッケージは、こちら からダウンロードします。これを解凍し、Alveo カードを選択してインストールします。ここでは、U50 の例を示します。$tar -xzvf alveo_xclbin-1.2.1.tar.gz$cd alveo_xclbin-1.2.1/U50/6E300M$sudo cp dpu.xclbin hbm_address_assignment.txt /usr/lib

6. サーバーに複数のカードがインストールされていて、いくつかのカードを指定してプログラムを実行する場合は、XLNX_ENABLE_DEVICES を設定します。次に、XLNX_ENABLE_DEVICES の使用法を示します。• export XLNX_ENABLE_DEVICES=0 --DPU にデバイス 0 のみを使用• export XLNX_ENABLE_DEVICES=0,1,3 --DPU に使用するデバイス 0、デバイス 1 およびデバイス 3 を選択

• この環境変数を設定しない場合、すべてのデバイスがデフォルトで DPU に使用されます。7. AI ライブラリのデモをコンパイルします。ここでは、yolov3 の例を示します。

$cd /workspace/Vitis-AI-Library/overview/demo/yolov3$bash -x build.sh

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 21

Page 22: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

注記: Vitis-AI をダウンロードした場合は、Vitis-AI ディレクトリに移動してから Docker を起動します。Vitis-AI-Library は、Docker システムの /workspace/Vitis_AI_Library/ パスにあります。次のコマンドを実行すると、コンパイル中に情報を出力しないようにできます。$bash build.sh

コンパイル プロセスでエラーが報告されず、実行可能ファイル demo_yolov3 が生成されている場合は、ホスト環境が正しくインストールされています。

8. AI ライブラリのライブラリ サンプルをコンパイルする場合は、次のコマンドを実行します (classificationを例として使用)。$cd /workspace/Vitis-AI-Library/overview/samples/classification$bash -x build.sh

これで実行可能なプログラムが生成されます。9. ライブラリのソース コードを変更する場合は、/workspace/Vitis-AI/Vitis-AI-Library にあるファイル

を開いて変更します。AI ライブラリをコンパイルする前に、コンパイル済みファイルの出力パスを確認してください。デフォルトの出力パスは $HOME/build です。デフォルトの出力パスを変更する場合は、cmake.sh 内の build_dir_default を編集してください。たとえば、build_dir_default=$HOME/build/build.${target_info}/${project_name} をbuild_dir_default=/workspace/build/build.${target_info}/${project_name} に変更します。注記: build_dir_default を編集する場合は、$HOME の部分のみを変更してください。次のコマンドを実行して、ライブラリを一括でビルドします。$cd /workspace/Vitis-AI/Vitis-AI-Library$./cmake.sh --clean --cmake-options='-DCMAKE_NO_SYSTEM_FROM_IMPORTED=on'

コンパイルが完了すると、build_dir_default ディレクトリに AI ライブラリが生成されます。コンパイル規則を変更する場合は、ライブラリのディレクトリにある cmake.sh を確認して変更してください。

10. DPU の周波数を制御 (スケールダウン) する方法を説明します。Alveo カードの消費電力には制限があるため、各カードのすべての CNN モデルを各最大周波数で実行できるわけではありません。周波数のスケールダウンが必要な場合があります。DPU コア クロックは、プラットフォーム Clock_1 (デフォルト値は 100MHz) で駆動される内部 DCM モジュールから生成され、コア クロックは常に Clock_1 に線形的に比例します。たとえば、U50LV-10E275M オーバーレイでは、275MHz のコア クロックは 100MHz のクロック ソースで駆動されます。つまり、このオーバーレイのコア クロックを 220MHz にするには、Clock_1 の周波数を (220/275)*100 = 80MHz に設定する必要があります。VART/ライブラリ サンプルを実行する前に、XRT xbutil ツールを使用して DPU オーバーレイの動作周波数をスケール ダウンできます。周波数のスケール ダウンの前に、まずオーバーレイを FPGA にプログラムしておく必要があります。次のコマンドの例を参照して、FPGA をプログラムし、周波数をスケール ダウンしてください。これらのコマンドは Clock_1 を 80MHz に設定し、ホスト側または Docker で実行できます。/opt/xilinx/xrt/bin/xbutil program -p /usr/lib/dpu.xclbin/opt/xilinx/xrt/bin/xbutil clock -d0 -g 80

d0 は、Alveo カード デバイスの番号です。xbutil ツールの詳細は、XRT の資料を参照してください。

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 22

Page 23: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

クラウド (U200/U250) の場合Docker イメージを実行して、クラウド上でホストをセットアップします1. Vitis AI リポジトリを複製します。

$git clone --recurse-submodules https://github.com/xilinx/vitis-ai$cd Vitis-AI

2. https://github.com/Xilinx/Vitis-AI#installation の Docker インストール ガイドに従って Docker コンテナーを実行します。$./docker_run.sh -X xilinx/vitis-ai-cpu:<x.y.z>

注記: Docker ランタイム システムによって、ワークスペース フォルダーが作成され、Docker ランタイム システムのワークスペースに配置されます。

3. Conda 環境をアクティベートします。$conda activate vitis-ai-caffe

4. ライブラリのソース コードを変更する場合は、/workspace/Vitis-AI-Library にあるファイルを開いて変更します。AI ライブラリをコンパイルする前に、コンパイル済みファイルの出力パスを確認してください。デフォルトの出力パスは $HOME/build です。デフォルトの出力パスを変更する場合は、cmake.sh 内の「build_dir_default」を編集してください。build_dir_default=$HOME/build/build.${target_info}/${project_name}to build_dir_default=/workspace/build/build.${target_info}/${project_name}

注記: build_dir_default を編集する場合は、$HOME の部分を変更してください。5. 次のコマンドを実行して、AI ライブラリにある DPUCADX8G でサポートされているサンプルをすべてビルドし

ます。$cd /workspace/Vitis-AI-Library$./cmake.sh --clean --type=release --cmake-options=-DCMAKE_PREFIX_PATH=$CONDA_PREFIX --cmake-options=-DENABLE_DPUCADX8G_RUNNER=ON

ビルドが完了すると、build_dir_default ディレクトリに AI ライブラリと実行可能ファイルが生成されます。注記: コンパイル規則を変更する場合は、ライブラリのディレクトリにある cmake.sh を確認して変更してください。

AI ライブラリ ファイルの場所次の表は、インストール完了後の AI ライブラリ ファイルの場所を示しています。表 10: AI ライブラリ ファイルの場所

ファイル 場所ライブラリのソース コード /workspace/Vitis-AI-Library

サンプル /workspace/Vitis-AI-Library/overview/samples

デモ /workspace/Vitis-AI-Library/overview/demo

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 23

Page 24: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 10: AI ライブラリ ファイルの場所 (続き)

ファイル 場所テスト /workspace/Vitis-AI-Library/[model]/test

注記:次の記号/略語が使用されています。• /workspace/ は、Docker システムにある圧縮された AI ライブラリ パッケージを抽出するパスです。• samples は、アプリケーションの構築および評価をすばやく簡単に実行することを望むユーザー向けのファイルです。• demos は、より実用的な開発をサポートするユーザー向けのファイルです。• test は、ライブラリ開発者向けの各モデル ライブラリのテスト サンプルです。

ターゲットをセットアップするターゲットのセットアップには、3 つのステップがあります。最初のステップはボード イメージのインストール、2番目のステップは AI モデル パケットのインストール、そして 3 番目のステップは AI ライブラリ パケットのインストールです。ユーザー体験の向上を目的として、Vitis AI ランタイム パッケージと、Vitis AI ライブラリのサンプルおよびモデルは、ボード イメージに含めてビルドされています。したがって、ユーザーは Vitis AI ランタイム パッケージおよびモデル パッケージをそれぞれボードにインストールする必要はありません。ただし、次の手順に従って、ユーザー独自のイメージまたは公式イメージにモデルあるいは Vitis AI ランタイムをインストールできます。注記: ボード イメージのバージョンは 2020.1 以降である必要があります。

ステップ 1: ボード イメージをインストールするZCU102 の場合、システム イメージは こちら からダウンロードできます。ZCU104 の場合は こちら からダウンロードできます。SD カードへ書き込む場合の推奨されるソフトウェア アプリケーションには、Etcher があります。これは、OS イメージを SD カードに書き込むためのクロスプラットフォーム ツールであり、Windows、Linux、およびMac システムに対応します。次の例は、Windows を使用しています。1. https://etcher.io/ から Etcher をダウンロードして、次の図のようにファイルを保存します。

2. 次の図のように Etcher をインストールします。

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 24

Page 25: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

3. USB フラッシュ ドライブやバックアップ ハードディスクなどの外部ストレージ デバイスを取り出します。これで、SD カードを認識しやすくします。次に、SD カードをコンピューターのスロットまたはリーダーに挿入します。

4. 次の図に示す Etcher アイコンをダブルクリック、または [スタート] メニューから選択して Etcher プログラムを実行します。

次の図のように Etcher が起動します。

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 25

Page 26: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

5. [Select Image] をクリックして、イメージ ファイルを選択します。圧縮ファイルの [.zip] または [.gz] を選択できます。

6. Etcher が SD ドライブの検知を開始します。ドライブ デスティネーションとイメージ サイズを確認します。7. [Flash!] をクリックします。

8. イメージ ファイルが書き込まれた SD カードを目的のボードに挿入します。9. 電源を投入し、システム上で動作させるためにシリアル ポートを使用してボードを起動します。10. シリアル ポート経由で、ボードの IP 情報をセットアップします。これで、SSH を使用してボード上での動作が可能になります。

ステップ 2: AI モデル パッケージをインストールするVitis AI ランタイム パッケージと、Vitis AI ライブラリのサンプルおよびモデルは、ボード イメージに含めてビルドされています。したがって、ユーザーは Vitis AI ランタイム パッケージおよびモデル パッケージをそれぞれボードにインストールする必要はありません。ただし、次の手順に従って、ユーザー独自のイメージまたは公式イメージにモデルをインストールできます。1. ZCU102 の場合、ここから xilinx_model_zoo_zcu102-1.2.0-1.aarch64.rpm パケットをダウンロードします。ZCU104 の場合、ここから xilinx_model_zoo_zcu104-1.2.0-1.aarch64.rpm をダウンロードします。

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 26

Page 27: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

2. 次のコマンドで scp を使用してダウンロード ファイルをボードにコピーします。ここでは、例として ZCU102モデルを使用します。$scp xilinx_model_zoo_zcu102-1.2.0-1.aarch64.rpm root@IP_OF_BOARD:~/

注記: rpm パッケージは、通常のアーカイブとして取得できます。モデル パッケージの一部のみ必要な場合に、ホスト側でコンテンツを抽出できます。操作コマンドは次のとおりです。$rpm2cpio xilinx_model_zoo_zcu102-1.2.0-1.aarch64.rpm | cpio -idmv

3. ボードにログイン (SSH またはシリアル ポートを使用) して、モデル パッケージをインストールします。4. 次のコマンドを実行します。

#rpm -ivh --force xilinx_model_zoo_zcu102-1.2.0-1.aarch64.rpm

インストールが完了すると、モデル ファイルはターゲット側の /usr/share/vitis_ai_library/models に格納されます。

ステップ 3: AI ライブラリ パッケージをインストールするVitis AI ランタイム パッケージと、Vitis AI ライブラリのサンプルおよびモデルは、ボード イメージに含めてビルドされています。したがって、ユーザーは Vitis AI ランタイム パッケージおよびモデル パッケージをそれぞれボードにインストールする必要はありません。ただし、次の手順に従って、ユーザー独自のイメージまたは公式イメージに VitisAI ランタイムをインストールできます。1. こちら から vitis-ai-runtime-1.2.x.tar.gz をダウンロードします。これを解凍し、scp を使用して次の

ファイルをボードにコピーします。$tar -xzvf vitis-ai-runtime-1.2.x.tar.gz$scp -r vitis-ai-runtime-1.2.x/aarch64/centos root@IP_OF_BOARD:~/

注記: rpm パッケージは、通常のアーカイブとして取得できます。ライブラリの一部のみ必要な場合に、ホスト側でコンテンツを抽出できます。個別に分離できるのはモデル ライブラリのみであり、その他は一般的なライブラリです。操作コマンドは次のとおりです。$rpm2cpio libvitis_ai_library-1.2.0-r<x>.aarch64.rpm | cpio -idmv

2. SSH を使用してボードにログインします。シリアル ポートを使用してログインすることも可能です。

3. zynqmp_dpu_optimize.sh スクリプトを実行します。#cd ~/dpu_sw_optimize/zynqmp/#./zynqmp_dpu_optimize.sh

4. Vitis AI ライブラリをインストールします。次のコマンドを実行します。#cd ~/centos#rpm -ivh --force libunilog-1.2.0-r<x>.aarch64.rpm#rpm -ivh --force libxir-1.2.0-r<x>.aarch64.rpm#rpm -ivh --force libtarget-factory-1.2.0-r<x>.aarch64.rpm#rpm -ivh --force libvart-1.2.0-r<x>.aarch64.rpm#rpm -ivh --force libvitis_ai_library-1.2.0-r<x>.aarch64.rpm

インストールが完了すると、次のディレクトリに各ファイルが格納されます。

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 27

Page 28: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

• ライブラリ ファイルは、/usr/lib に格納されています。• ヘッダー ファイルは、/usr/include/vitis/ai に格納されています。

Vitis AI サンプルの実行エッジまたはクラウドで Vitis™ AI ライブラリのサンプルを実行する前に、vitis_ai_library_r1.2.x_images.tar.gz および vitis_ai_library_r1.2.x_video.tar.gz をダウンロードする必要があります。次のサンプルで使用する画像またはビデオは、いずれのパッケージにも含まれます。

エッジの場合Vitis AI ランタイム パッケージと、Vitis AI ライブラリのサンプルおよびモデルは、ボード イメージに含めてビルドされています。サンプルは直接実行できます。新しいプログラムを使用する場合は、そのプログラムをホスト側でコンパイルし、実行可能プログラムをターゲットにコピーします。1. 次のコマンドで scp を使用して、vitis_ai_library_r1.2.x_images.tar.gz および

vitis_ai_library_r1.2.x_video.tar.gz をホストからターゲットへコピーします。[Host]$scp vitis_ai_library_r1.2.x_images.tar.gz root@IP_OF_BOARD:~/[Host]$scp vitis_ai_library_r1.2.x_video.tar.gz root@IP_OF_BOARD:~/

2. ターゲット側でイメージおよびビデオ パッケージを解凍します。#cd ~#tar -xzvf vitis_ai_library_r1.2*_images.tar.gz -C Vitis-AI/vitis-ai-library#tar -xzvf vitis_ai_library_r1.2*_video.tar.gz -C Vitis-AI/vitis-ai-library

3. ターゲット ボードでサンプルの抽出ディレクトリに移動し、サンプルをコンパイルします。ここでは、facedetect の例を示します。#cd ~/Vitis-AI/vitis-ai-library/samples/facedetect

4. サンプル デザインを実行します。#./test_jpeg_facedetect densebox_320_320 sample_facedetect.jpg

5. 実行結果を確認します。結果を表示する方法は 2 つあります。1 つは情報を出力して結果を表示する方法で、もう 1 つは、次の画像のように sample_facedetect_result.jpg をダウンロードして画像を表示する方法です。

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 28

Page 29: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 2: 顔検出の例

6. ビデオ サンプルを実行する場合は、次のコマンドを実行します。#./test_video_facedetect densebox_320_320 video_input.webm -t 8

video_input.webm: 入力用のビデオ ファイル名です。ビデオ ファイルは、ユーザーが準備する必要があります。-t: <num_of_threads>

注記:

• 公式のシステム イメージは、webm または raw 形式のビデオ ファイル入力のみをサポートします。その他の形式のビデオ ファイルを入力として使用する場合は、ffmpeg パッケージなどの関連するパッケージをシステムにインストールする必要があります。

• ベース プラットフォーム システムではビデオの再生および表示に制限があるため、表示規格のフレーム レートでしか表示できず、実際の処理性能を反映できませんでした。ただし、マルチスレッドを使用した場合は特に、次のコマンドで実際のビデオ処理性能を確認できます。env DISPLAY=:0.0 DEBUG_DEMO=1 ./test_video_facedetect \densebox_320_320 'multifilesrc location=~/video_input.webm \! decodebin ! videoconvert ! appsink sync=false' -t 2

7. 入力として USB カメラを使用してプログラムをテストする場合は、次のコマンドを実行します。#./test_video_facedetect densebox_320_320 0 -t 8

0: 最初の USB カメラ デバイス ノードです。複数の USB カメラを使用している場合、値は 1、2、3 などになります。-t: <num_of_threads>

重要: すべてのビデオ サンプルに対して Linux Windows システムが正常に動作することが求められるため、SSH ターミナルを使用してボードにログインする際に、次のコマンドを実行して「X11 forwarding」を有効にする必要があります (この例で、ホスト マシンの IP アドレスは 192.168.0.10 である)。#export DISPLAY=192.168.0.10:0.0

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 29

Page 30: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

8. モデルの性能をテストする場合、次のコマンドを実行します。#./test_performance_facedetect densebox_320_320 test_performance_facedetect.list -t 8 -s 60

-t: <num_of_threads>

-s: <num_of_seconds>

パラメーターの詳細を表示する場合は、-h と入力してください。次の図は、性能テストの結果を 8 スレッドで示しています。

図 3: 顔検出の性能テスト結果

9. デモの実行については、第 5 章: アプリケーション デモ を参照してください。クラウドの場合

クラウド (U50/U50lv/U280) の場合Vitis-AI をダウンロードした場合は、Vitis-AI ディレクトリに移動してから Docker を起動します。したがって、Vitis-AI-Library は Docker システムの /workspace/Vitis_AI_Library/ というパスにあります。1. サンプルのディレクトリに移動し、サンプルをコンパイルします。ここでは、facedetect の例を示します。

$cd /workspace/Vitis_AI_Library/overview/samples/facedetect$bash -x build.sh

2. サンプルを実行します。$./test_jpeg_facedetect densebox_320_320 sample_facedetect.jpg

3. プログラムをバッチ モードで実行するには、「ホストのセットアップ」に示した手順に従って Vitis AI ライブラリ全体をコンパイルしてください。この場合、DPU は複数の画像を一度に処理し、その処理性能が表示されます。その場合、build_dir_default ディレクトリにバッチ プログラムが生成されます。build_dir_default ディレクトリに移動して、次のコマンドを実行します (facedetect の場合の例)。$./test_facedetect_batch densebox_320_320 <img1_url> [<img2_url> ...]

4. ビデオ サンプルを実行する場合は、次のコマンドを実行します。$./test_video_facedetect densebox_320_320 video_input.mp4 -t 8

video_input.mp4: 入力用のビデオ ファイル名です。ビデオ ファイルを準備する必要があります。-t: <num_of_threads>

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 30

Page 31: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

5. モデルの性能をテストする場合、次のコマンドを実行します。#./test_performance_facedetect densebox_320_320 test_performance_facedetect.list -t 8 -s 60

• -t: <num_of_threads>

• -s: <num_of_seconds>

パラメーターの詳細を表示する場合は、-h と入力してください。注記: 性能テスト プログラムは、自動的にバッチ モードで実行されます。

クラウド (U200/U250) の場合1. Docker コンテナーをロードして実行します。

$./docker_run.sh -X xilinx/vitis-ai-cpu:<x.y.z>

2. モデル ディレクトリの [vai_lib_u200_u250_models.tar.gz] パッケージをダウンロードして、解凍します。$cd /workspace/Vitis-AI-Library$wget -O vai_lib_u200_u250_models.tar.gz https://www.xilinx.com/bin/public/openDownload?filename=vai_lib_u200_u250_models.tar.gz$sudo tar -xvf vai_lib_u200_u250_models.tar.gz --absolute-names

注記: すべてのモデルは /usr/share/vitis_ai_library/models ディレクトリにダウンロードされます。現在サポートされているネットワークは、classification、facedetect、facelandmark、reid、yolov3 です。

3. [Collective Knowledge (CK)] を使用して [Imagenet2012] の最小限の検証用セットをダウンロードするには、Alveo サンプル [README] (../alveo/examples/caffe/README.md) を参照してください。

4. 環境をセットアップします。$source /workspace/alveo/overlaybins/setup.sh$export LD_LIBRARY_PATH=$HOME/.local/${taget_info}/lib/:$LD_LIBRARY_PATH

5. ホストのセットアップ に従って、Vitis AI ライブラリ全体をコンパイルする必要があります。classification イメージのテスト サンプルを実行します。$HOME/build/build.${taget_info}/${project_name}/test_classification <model_dir> <img_path>

次に例を示します。$~/build/build.Ubuntu.18.04.x86_64.Release/Vitis-AI-Library/classification/test_classification inception_v1 <img_path>

6. classification 精度のテスト サンプルを実行します。$HOME/build/build..${taget_info}/${project_name}/test_classification_accuracy <model_dir> <img_dir_path> <output_file>

次に例を示します。$~/build/build.Ubuntu.18.04.x86_64.Release/Vitis-AI-Library/classification/test_classification_accuracy inception_v1 <img_dir_path> <output_file>

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 31

Page 32: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

サポートザイリンクスのウェブサイト (https://https://forums.xilinx.com/t5/Machine-Learning/bd-p/Deephi) から Vitis AI ライブラリ コミュニティ フォーラムへアクセスすると、意見交換、知識の共有、FAQ の閲覧、技術サポートのリクエストが可能です。

第 2 章: インストール

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 32

Page 33: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

第 3 章

ライブラリとサンプルVitis™ AI ライブラリには、Caffe フレームワークを使用した次のタイプのニューラル ネットワーク ライブラリが含まれています。• 分類• 顔検出• SSD 検出• 姿勢検出• セマンティック セグメンテーション• 車線検出• YOLOV3 検出• YOLOV2 検出• 骨格検出• RefineDet 検出• ReID 検出• マルチタスク• 顔認識• プレート検出• プレート認識• 医療画像セグメンテーションまた、Vitis AI ライブラリには、Tensorflow フレームワークを使用した次のタイプのニューラル ネットワーク ライブラリが含まれています。• 分類• SSD 検出• YOLOv3 検出また、Vitis AI ライブラリは、Pytorch フレームワークに基づいて次のタイプのニューラル ネットワーク ライブラリをサポートしています。• 分類 (resnet50、squeezenet および inception_v3)

これらに関連するライブラリはオープンソースであり、必要に応じて変更可能です。オープンソース コードは、github から入手できます。これらは、https://github.com/Xilinx/Vitis-AI にあります。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 33

Page 34: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

Vitis AI ライブラリは、上記のすべてのネットワークのイメージ テスト サンプルおよびビデオ テスト サンプルを提供しています。さらに、対応する性能テスト プログラムを提供しています。ビデオ ベースのテストでは、未加工のビデオ データを使用して評価することを推奨しています。それは、Arm® CPU のソフトウェア ライブラリでデコードするとデコード時間に一貫性がないため、評価の精度に影響を及ぼす可能性があるためです。注記: エッジの場合、すべてのサンプル プログラムはターゲット側でのみ実行可能ですが、コンパイルに関してはホスト側でクロス コンパイルすることも、ターゲット側でコンパイルすることもできます。

モデル ライブラリモデル パケットがターゲットにインストールされると、すべてのモデルは /usr/share/vitis_ai_library/models/ に格納されます。各モデルは、デフォルトで次のファイルを含む個別のフォルダーに格納されます。• [model_name].elf

• [model_name].prototxt

注記: Alveo カードの場合、モデルは [model_name].xmodel および [model_name].prototxt で構成されます。ここでは、例として「inception_v1」モデルを使用します。inception_v1.elf は、このモデル データです。inception_v1.prototxt は、このモデルのパラメーターです。注記:

1. モデル ディレクトリ名はモデル名と同じである必要があります。2. sp_net モデルなどのモデルのコンパイル後に生成された elf ファイルが複数ある場合、すべての elf ファイルを 1つに結合する必要があります。結合するには、次のスクリプトを実行します。

${CMAKE_CXX_COMPILER} \ -nostdlib \ -fPIC \ -shared \ ${CMAKE_BINARY_DIR}/output_elf/${MODEL_NAME}/dpu_${MODEL_NAME}*.elf \ -o \ ${CMAKE_BINARY_DIR}/$MODEL_NAME/${MODEL_NAME}.elf

モデルの種類分類このライブラリは、イメージを分類するために使用されます。これらのニューラル ネットワークは、ILSVRC のImageNet でトレーニング済みであり、1000 個のカテゴリからオブジェクトを識別できます。AI ライブラリは、Resnet18、Resnet50、Inception_v1、Inception_v2、Inception_v3、Inception_v4、Vgg、mobilenet_v1、mobilenet_v2、および Squeezenet を統合しています。入力はオブジェクトを含む画像で、出力は上位 K 番目までの最も可能性の高いカテゴリとなります。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 34

Page 35: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 4: 分類の例

次の表に、AI ライブラリでサポートされる分類モデルを示します。表 11: 分類モデルの一覧

番号 モデル名 フレームワーク1 inception_resnet_v2_tf Tensorflow

2 inception_v1_tf

3 inception_v3_tf

4 inception_v4_2016_09_09_tf

5 mobilenet_v1_0_25_128_tf

6 mobilenet_v1_0_5_160_tf

7 mobilenet_v1_1_0_224_tf

8 mobilenet_v2_1_0_224_tf

9 mobilenet_v2_1_4_224_tf

10 resnet_v1_101_tf

11 resnet_v1_152_tf

12 resnet_v1_50_tf

13 vgg_16_tf

14 vgg_19_tf

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 35

Page 36: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 11: 分類モデルの一覧 (続き)

番号 モデル名 フレームワーク15 resnet50 Caffe

16 resnet18

17 inception_v1

18 inception_v2

19 inception_v3

20 inception_v4

21 mobilenet_v2

22 squeezenet

23 resnet50_pt Pytorch

24 squeezenet_pt

25 inception_v3_pt

顔検出このライブラリは、DenseBox ニューロン ネットワークを使用して人物の顔を検出します。入力は、検出対象となる複数の顔を含む画像です。出力は、各ボックスの情報を含む結果構造ベクターです。次に画像に顔検出の結果を示します。

図 5: 顔検出の例

次の表に、AI ライブラリでサポートされる顔検出モデルを示します。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 36

Page 37: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 12: 顔検出モデルの一覧番号 モデル名 フレームワーク

1 densebox_320_320 Caffe

2 densebox_640_360

顔のランドマーク検出顔の 5 つの特徴点を検出するために顔ランドマーク ネットワークを使用します。5 つの特徴点とは、左目、右目、鼻、左唇、右唇です。このネットワークを使用して顔の特徴を抽出する前に、顔の角度を認識してボックスを調整します。顔検出ネットワークで検出する顔を入力画像として取り込み、5 つの特徴点が出力されます。これらの 5 つの特徴点が正規化されます。次の画像に顔検出の結果を示します。

図 6: 顔ランドマーク検出の例

次の表に、AI ライブラリでサポートされる顔ランドマーク モデルを示します。表 13: 顔ランドマーク モデルの一覧

番号 モデル名 フレームワーク1 face_landmark Caffe

SSD 検出このライブラリは、一般的に SSD ニューロン ネットワークで使用されます。SSD は、オブジェクトを検出するために使用されるニューラル ネットワークです。入力は、検出対象となるオブジェクトを含む画像です。出力は、各ボックスの情報を含む構造ベクターです。次の画像に SSD 検出の結果を示します。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 37

Page 38: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 7: SSD 検出の例

次の表に、AI ライブラリでサポートされる SSD 検出モデルを示します。表 14: SSD モデルの一覧

番号 モデル名 フレームワーク1 ssd_mobilenet_v1_coco_tf Tensorflow

2 ssd_mobilenet_v2_coco_tf

3 ssd_resnet_50_fpn_coco_tf

4 mlperf_ssd_resnet34_tf

5 ssd_pedestrain_pruned_0_97 Caffe

6 ssd_traffic_pruned_0_9

7 ssd_adas_pruned_0_95

8 ssd_mobilenet_v2

姿勢検出このライブラリは、人体の姿勢検出に使用されます。このライブラリには、人体の 14 の特徴点をマークできるニューラル ネットワークが含まれています (ザイリンクスの SSD 検出ライブラリが使用可能)。入力は、歩行者検出ニューラル ネットワークの検出対象となる画像です。出力は、各ポイントの座標を含む構造となります。次の画像に姿勢検出の結果を示します。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 38

Page 39: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 8: 姿勢検出の例

次の表に、AI ライブラリでサポートされる姿勢検出モデルを示します。表 15: 姿勢検出モデルの一覧

番号 モデル名 フレームワーク1 sp_net Caffe

注記: 入力画像が定まっておらず、ユーザーが人物の正確な位置を把握していない場合は、SSD 検出を最初に実行する必要があります。 test_jpeg_posedetect_with_ssd.cpp ファイルを参照してください。入力画像が切り取られた人物画像である場合は、姿勢検出のみを実行できます。test_jpeg_posedetect.cpp ファイルを参照してください。

セマンティック セグメンテーション画像のセマンティック セグメンテーションは、入力画像の各ピクセルにセマンティック カテゴリを割り当てることで、ピクセル単位の徹底的なクラス分類が可能です。libsegmentation は、ADAS 分野で使用できるセグメンテーション ライブラリです。開発者がザイリンクス FPGA でセグメンテーション タスクを運用するためのシンプルなインターフェイスを提供します。次の図は、セマンティック セグメンテーションの例であり、画像の各ピクセルが属するクラスを予測します。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 39

Page 40: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 9: セマンティック セグメンテーションの例

次の表に、AI ライブラリでサポートされるセマンティック セグメンテーション モデルを示します。表 16: セマンティック セグメンテーション モデルの一覧

番号 モデル名 フレームワーク1 fpn Caffe

車線検出このモデルは、ADAS ライブラリの車線を描画するために使用されます。各車線は、カテゴリを示す number 型と車線描画に使用される vector<Point> で表されます。テスト コードでは、カラー マップが使用されます。異なる種類の車線が色分けされて表示されます。取得した点はコンテナー ベクターに保存され、OpenCv のポリゴンインターフェイス cv::polylines() を使用して車線が描画されます。次の画像に車線検出の結果を示します。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 40

Page 41: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 10: 車線検出の例

次の表に、AI ライブラリでサポートされる車線検出モデルを示します。表 17: 車線検出モデルの一覧

番号 モデル名 フレームワーク1 vpgnet_pruned_0_99 Caffe

注記: 入力画像のサイズは 480x640 に固定されており、それ以外の場合はサイズを変更する必要があります。

YOLOV3 検出このライブラリは、一般的に YOLO ニューロン ネットワークで使用されます。YOLO は、オブジェクトを検出するために使用するニューラル ネットワークです。現バージョンは v3 です。入力は、1 つ以上の検出対象となるオブジェクトを含む画像です。出力は、検出された情報を含む構造ベクターです。次の画像に YOLOv3 検出の結果を示します。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 41

Page 42: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 11: YOLOv3 検出の例

次の表に、AI ライブラリでサポートされる YOLOv3 検出モデルを示します。表 18: YOLOv3 検出モデルの一覧

番号 モデル名 フレームワーク1 yolov3_voc_tf Tensorflow

2 yolov3_adas_pruned_0_9 Caffe

3 yolov3_voc

4 yolov3_bdd

YOLOV2 検出YOLOV2 は、アップグレード バージョンである YOLOV3 と同じ役割を果たします。次の表に、AI ライブラリでサポートされる YOLOv2 検出モデルを示します。表 19: YOLOv2 検出モデルの一覧

番号 モデル名 フレームワーク1 yolov2_voc Caffe

2 yolov2_voc_pruned_0_66

3 yolov2_voc_pruned_0_71

4 yolov2_voc_pruned_0_77

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 42

Page 43: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

骨格検出このライブラリは、人体の姿勢を描写するために使用されます。ペアで格納されているポイント間の線によって描写されます。すべてのペアが一つのつながりを表し、これらペアの結果がベクターとして格納されます。次の画像に骨格検出の結果を示します。

図 12: 骨格検出の例

次の表に、AI ライブラリでサポートされる骨格検出モデルを示します。表 20: 骨格検出モデルの一覧

番号 モデル名 フレームワーク1 openpose_pruned_0_3 Caffe

RefineDet 検出このライブラリは、一般に RefineDet ニューロン ネットワークに使用されます。RefineDet は、人体の検出に使用するニューラル ネットワークです。入力は、検出対象となる個人の画像です。出力は、各ボックスの情報を含む、結果の構造体のベクターです。次の図に、RefineDet 検出の結果を示しています。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 43

Page 44: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 13: RefineDet 検出の例

次の表に、AI ライブラリでサポートされる RefineDet 検出モデルを示します。表 21: RefineDet 検出モデルの一覧

番号 モデル名 フレームワーク1 refinedet_pruned_0_8 Caffe

2 refinedet_pruned_0_92

3 refinedet_pruned_0_96

4 refinedet_baseline

ReID 検出ReID (person re-identification) は、異なる時間または場所で特定の人物を識別するために使用されます。これは、画像の特徴を抽出して、それらの特徴を比較することで実現できます。同じアイデンティティの画像は同じ特徴を持っているため、特徴点間距離の変化量が小さくなるのに対して、異なるアイデンティティの画像は特徴点間距離の変化量が大きくなります。1 つのクエリ画像と多数の候補画像を比較して、距離変化量が最小の画像がクエリ画像と同じ人物として識別されます。次の表に、AI ライブラリでサポートされる ReID 検出モデルを示します。表 22: ReID 検出モデルの一覧

番号 モデル名 フレームワーク1 reid Caffe

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 44

Page 45: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

マルチタスクマルチタスク ライブラリは、複数のサブタスクを持つモデルに最適です。AI ライブラリのマルチタスク モデルには2 つのサブタスクがあります。1 つはセマンティック セグメンテーション検出、もう 1 つは SSD 検出です。次の表に、AI ライブラリでサポートされるマルチタスク モデルを示します。表 23: マルチタスク モデルの一覧

番号 モデル名 フレームワーク1 multi_task Caffe

顔認識facefeature モデルは顔認識に使用されます。これは人の顔の特徴を抽出できます。このモデルの出力は 512 の特徴点です。2 つの異なるイメージがあり、それらが同じ人物であることを知りたいとします。このモデルを使用して 2つのイメージの特徴を抽出し、計算関数とマップされた関数を使用して 2 つのイメージの類似性を取得できます。

図 14: 顔認識の例

次の表に、AI ライブラリでサポートされる顔認識モデルを示します。表 24: 顔認識モデルの一覧

番号 モデル名 フレームワーク1 facerec_resnet20 Caffe

2 facerec_resnet64

プレート検出このライブラリは、DenseBox ニューロン ネットワークを使用してナンバー プレートを検出します。入力は、SSD によって検出された車の画像です。出力は、1 つのプレートの位置情報を含む構造体です。次の図に、プレート検出の結果を示しています。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 45

Page 46: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 15: プレート検出の例

次の表に、AI ライブラリでサポートされるプレート検出モデルを示します。

表 25: プレート検出モデルの一覧番号 モデル名 フレームワーク

1 plate_detection Caffe

プレートの認識このライブラリは、classification ネットワークを使用してナンバー プレートの番号を認識します (中国のナンバー プレートのみ)。入力は、プレート検出によって検出されたナンバー プレートの画像です。出力は、ナンバー プレートの番号情報を含む構造体です。次の図に、プレート認識の結果を示しています。

図 16: プレート認識の例

次の表に、AI ライブラリでサポートされるプレート認識モデルを示します。表 26: プレート認識モデルの一覧

番号 モデル名 フレームワーク1 plate_recognition Caffe

医療画像セグメンテーション内視鏡検査は、鼻咽頭がん、食道腺がん、胃がん、大腸がん、膀胱がんなどの中空器官のがんを早期に発見するために広く使用されている臨床検査です。罹患したクリティカルな部位の特定およびセグメンテーションを正確かつ時間的に一貫して実行することで、モニタリングや手術計画に欠かせない内視鏡画像からの病変部の正確な定量化およびマッピングが可能です。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 46

Page 47: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

医療画像セグメンテーション モデルは、入力画像内の罹患したクリティカル部位を BE、がん、HGD、ポリープ、病巣候補などの各カテゴリに分類できます。Libmedicalsegmentation は、内視鏡検査における病巣のマルチクラスのセグメンテーションに使用可能なセグメンテーション ライブラリです。ザイリンクス FPGA でセグメンテーション タスクを運用するためのシンプルなインターフェイスを提供します。次に、患部をマークする医療画像セグメンテーションの例を示します。下に示す図は、セマンティック セグメンテーションの例で、画像内の各ピクセルに割り当てられるクラス ラベルを予測します。

図 17: 医療画像セグメンテーションの例

次の表に、AI ライブラリでサポートされる医療画像セグメンテーション モデルを示します。表 27: セマンティック セグメンテーション モデルの一覧

番号 モデル名 フレームワーク1 FPN_Res18_Medical_segmentation Caffe

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 47

Page 48: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

モデル サンプル~/Vitis-AI/Vitis-AI-Library/overview/samples には、最大 14 個のモデル サンプルが格納されています。各サンプルには、次に示す 4 種類のテスト サンプルがあります。• test_jpeg_[model type]

• test_video_[model type]

• test_performance_[model type]

• test_accuracy_[model type]

ここでは、例として yolov3 モデルを使用します。1. yolov3 検出サンプルを実行する前に、実行する yolov3 モデルを次のいずれかから選択できます。

a. yolov3_bdd

b. yolov3_voc

c. yolov3_voc_tf

2. 次のテスト プログラムがあることを確認します。a. test_jpeg_yolov3

b. test_video_yolov3

c. test_performance_yolov3

d. test_accuracy_yolov3_bdd

e. test_accuracy_yolov3_adas_pruned_0_9

f. test_accuracy_yolov3_voc

g. test_accuracy_yolov3_voc_tf

実行可能プログラムが存在しない場合は、実行可能プログラムをホスト側でクロス コンパイルし、それをターゲットにコピーする必要があります。

3. 次のコマンドを実行して画像データをテストします。#./test_jpeg_yolov3 yolov3_bdd sample_yolov3.jpg

端末で実行結果を確認します。出力画像を表示することも可能です(sample_yolov3_result.jpg)。4. 次のコマンドを実行してビデオ データをテストします。

#./test_video_yolov3 yolov3_bdd video_input.mp4 -t 8

5. 次のコマンドを実行してモデルの性能をテストします。#./test_performance_yolov3 yolov3_bdd test_performance_yolov3.list -t 8

端末で実行結果を確認します。6. モデルの精度をテストするには、ユーザー独自の画像データセット、画像リスト ファイル、および画像のグランド トゥルースを用意する必要があります。その後、次のコマンドを実行します。#./test_accuracy_yolov3_bdd [image_list_file] [output_file]

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 48

Page 49: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

output_file が生成された後、結果を自動的に比較するためにスクリプト ファイルが必要です。最後に、精度結果を取得できます。

第 3 章: ライブラリとサンプル

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 49

Page 50: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

第 4 章

プログラム例実際のユーザー アプリケーションの要件はさまざまですが、基本的に 3 つのカテゴリに分類されます。1 つ目は、Vitis AI ライブラリが提供する既製モデルを使用して独自のアプリケーションをすばやく構築すること、2 つ目は、AIライブラリのモデルに類似したユーザー独自のカスタム モデルを使用すること、そして 3 つ目は、AI ライブラリのモデルとはまったく異なる新しいモデルを使用することです。この章では、最初の 2 つのケースの詳細な開発手順について説明します。3 つ目のケースでは、参考用として AI ライブラリのサンプルおよびライブラリの実装を利用することもできます。この章の内容は、次のとおりです。• プリプロセスのカスタマイズ方法• プリプロセスおよびポストプロセスのパラメーターの取得にコンフィギュレーション ファイルを使用する方法• AI ライブラリのポストプロセス ライブラリを使用する方法• 独自のポストプロセス コードを実装する方法次の図に、AI ライブラリ API の関係性とそれぞれの対応例を示しています。このリリースには、3 種類の API があります。• Vitis AI API_0

• AI ライブラリ API_1

• AI ライブラリ API_2

図 18: AI ライブラリ API の図

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 50

Page 51: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

Vitis AI API_0 を使用した開発1. ホスト側にクロス コンパイル システムをインストールします。第 2 章: インストール を参照してください。2. xilinx_model_zoo_zcu102-1.2.0-1.aarch64.rpm パケットをダウンロードして、scp を介してボードに

それをコピーします。3. ターゲット側にザイリンクス モデル パッケージをインストールします。

#rpm -ivh xilinx_model_zoo_zcu102-1.2.0-1.aarch64.rpm

インストールが完了すると、モデルはターゲット側の /usr/share/vitis_ai_library/models ディレクトリに格納されます。注記: 独自のモデルを使用する場合は、ザイリンクスのモデル パケットをインストールする必要はありません。

4. git を使用して、https://github.com/Xilinx/Vitis-AI から対応する AI ライブラリをコピーします。5. 例として分類を使用して、ワークスペースの下にフォルダーを作成します。

$mkdir classification

6. demo_classification.cpp ソース ファイルを作成します。主なフローは次のとおりです。すべてのコード例は、~/Vitis-AI/Vitis-AI-Library/demo/classification/demo_classification.cpp を参照してください。

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 51

Page 52: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 19: メイン プログラム フロー図

7. 次に示すように build.sh ファイルを作成するか、AI ライブラリのデモから 1 つをコピーして、それを変更します。#/bin/shCXX=${CXX:-g++}$CXX -std=c++11 -O3 -I. -o demo_classification demo_classification.cpp -lopencv_core -lopencv_video -lopencv_videoio -lopencv_imgproc -lopencv_imgcodecs -lopencv_highgui -lglog -lvitis_ai_library-dpu_task -lvitis_ai_library-model_config -lvart-runner

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 52

Page 53: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

8. プログラムをクロス コンパイルします。$sh -x build.sh

9. scp 経由で、ターゲット ボードに実行可能なプログラムをコピーします。$scp demo_classification root@IP_OF_BOARD:~/

10. ターゲット ボード上でプログラムを実行します。プログラムを実行する前に、ターゲット ボードに AI ライブラリがインストールされていることを確認して、テストするイメージを準備します。#./demo_classification /usr/share/vitis_ai_library/models/resnet50/resnet50.elf resnet50_0 demo_classification.jpg

注記:

• demo_classification.cpp はユーザー指定のプリプロセス パラメーターを入力として使用します。• demo_classification.cpp は、ユーザーのポストプロセス コードを使用します。AI ライブラリのポストプロセス ライブラリを使用する場合は、AI ライブラリのポストプロセス ライブラリを使用する方法 を参照してください。

ユーザー モデルと AI ライブラリ API_2 を使用した開発独自モデルを使用する場合は、ユーザーのモデル フレームワークが Vitis™ AI ライブラリでサポートされる範囲内であることに注意が必要です。ここでは、Vitis AI ライブラリをベースとする再学習された YOLOv3 Caffe モデルをZCU102 プラットフォームで運用する方法を説明します。1. https://github.com/Xilinx/Vitis-AI から対応する Docker イメージをダウンロードします。2. Docker をロードして実行します。3. ホスト側でフォルダーを作成し、そのフォルダーの下にフロート モデルを配置し、AI Quantizer ツールを使用して量子化を実行します。詳細は、『Vitis AI ユーザー資料』 (UG1431) の 『Vitis AI ユーザー ガイド』 を参照してください。

4. AI Compiler ツールを使用してモデルをコンパイルし、yolov3_custom.elf などの ELF ファイルを取得します。詳細は、『Vitis AI ユーザー資料』 (UG1431) の 『Vitis AI ユーザー ガイド』 を参照してください。

5. 次のように、yolov3_custom.prototxt ファイルを作成します。model { name: "yolov3_custom" kernel { name: "yolov3_custom" mean: 0.0 mean: 0.0 mean: 0.0 scale: 0.00390625 scale: 0.00390625 scale: 0.00390625 } model_type : YOLOv3 yolo_v3_param { num_classes: 20 anchorCnt: 3 layer_name: "59" layer_name: "67"

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 53

Page 54: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

layer_name: "75" conf_threshold: 0.3 nms_threshold: 0.45 biases: 10 biases: 13 biases: 16 biases: 30 biases: 33 biases: 23 biases: 30 biases: 61 biases: 62 biases: 45 biases: 59 biases: 119 biases: 116 biases: 90 biases: 156 biases: 198 biases: 373 biases: 326 test_mAP: false }}

注記: <model_name>.prototxt は、AI ライブラリ API_1 を使用する場合に限り有効です。AI ライブラリ API_2 を使用する場合は、モデルのパラメーターをロードして、手動でプログラムが読み取るようにしてください。詳細は、~/Vitis-AI/Vitis-AI-Library/demo/yolov3/demo_yolov3.cpp を参照してください。

6. demo_yolov3.cpp ファイルを作成します。~/Vitis-AI/Vitis-AI-Library/demo/yolov3/demo_yolov3.cpp を参照してください。

7. 次に示すように build.sh ファイルを作成するか、AI ライブラリのデモから 1 つをコピーして、それを変更します。#/bin/shCXX=${CXX:-g++}$CXX -std=c++11 -O3 -I. -o demo_yolov3 demo_yolov3.cpp -lopencv_core -lopencv_video -lopencv_videoio -lopencv_imgproc -lopencv_imgcodecs -lopencv_highgui -lglog -lxnnpp-xnnpp -lvitis_ai_library-model_config -lprotobuf -lvitis_ai_library-dpu_task

8. Docker ツール システムを終了して、Docker ランタイム システムを起動します。9. プログラムをクロス コンパイルして、実行可能ファイル demo_yolov3 を生成します。

$sh -x build.sh

10. ターゲット側で /usr/share/vitis_ai_library/models の下にモデル フォルダーを作成します。#mkdir yolov3_custom /usr/share/vitis_ai_library/models

/usr/share/vitis_ai_library/models は、プログラムがモデルを読み出すデフォルト フォルダーです。実行可能ファイルと同じディレクトリのモデル フォルダーに置くことも可能です。

11. yolov3_custom.elf and yolov3_custom.prototxt をターゲットにコピーし、/usr/share/vitis_ai_library/models/yolov3_custom の下に置きます。$scp yolov3_custom.elf yolov3_custom.prototxt root@IP_OF_BOARD:/usr/share/vitis_ai_library/models/yolov3_custom

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 54

Page 55: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

12. scp を使用して、実行可能なプログラムをターゲット ボードにコピーします。$scp demo_yolov3 root@IP_OF_BOARD:~/

13. ターゲット ボードでプログラムを実行すると、次の結果が表示されます。プログラムを実行する前に、ターゲット ボードに AI ライブラリがインストールされていることを確認して、テストするイメージを準備します。#./demo_yolov3 yolov3_custom sample.jpg

プリプロセスのカスタマイズ画像データは、たたみ込みニューラル ネットワーク (CNN) 処理を実行する前に、プリプロセスが必要です。あらゆる種類のデータに適用できる基本的なプリプロセス技術は次のとおりです。• Mean subtraction (平均減算)

• Normalization (正規化)

• PCA and Whitening (PCA と白色化)

次の図に示すように、setMeanScaleBGR 関数を呼び出して平均減算と正規化を実行します。詳細は、~/Vitis-AI/Vitis-AI-Library/dpu_task/include/vitis/ai/dpu_task.hpp を参照してください。

図 20: setMeanScaleBGR の例

次の図に示すように、cv::resize 関数を呼び出して画像サイズを変更します。図 21: cv::resize の例

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 55

Page 56: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

コンフィギュレーション ファイルの使用Vitis™ AI ライブラリは、コンフィギュレーション ファイルを読み取ることでモデル パラメーターを取得する手段を提供します。これにより、モデル パラメーターの統一されたコンフィギュレーション管理が可能になります。コンフィギュレーション ファイルは、/usr/share/vitis_ai_library/models/[model_name]/[model_name].prototxt に格納されています。model{ name: "yolov3_voc" kernel { name: "yolov3_voc" mean: 0.0 mean: 0.0 mean: 0.0 scale: 0.00390625 scale: 0.00390625 scale: 0.00390625 } model_type : YOLOv3 yolo_v3_param { … } is_tf: false}

表 28: モデル コンパイルとカーネル パラメーターモデル/カーネル パラメーターの種類 説明

model name ${MODEL_NAME} と同じ名前にする必要がある。model_type 使用するモデルの種類によって異なる。

kernel name DNNC コンパイルの結果を受けて入力する必要がある。接尾辞「_0」が付いている場合は、名前の後に接尾辞を入力する必要がある。(例: inception_v1_0)

mean 通常は 3 行あり、各行はモデルで事前に定義されている「BRG」の平均値。scale 通常 3 行あり、各行は RGB が正規化されたスケール値。トレーニング ステージでモデルにスケール値がない場合は、1 を入力する必要がある。is_tf ブール型。tensorflow でトレーニングされたモデルを使用する場合は、これを追加して true に設定する。prototxt では空白にできるが、モデルが caffe の場合は false に設定することも可能。

yolo_v3_param

model_type : YOLOv3 yolo_v3_param { num_classes: 20 anchorCnt: 3 layer_name: "59" layer_name: "67" layer_name: "75" conf_threshold: 0.3

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 56

Page 57: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

nms_threshold: 0.45 biases: 10 biases: 13 biases: 16 biases: 30 biases: 33 biases: 23 biases: 30 biases: 61 biases: 62 biases: 45 biases: 59 biases: 119 biases: 116 biases: 90 biases: 156 biases: 198 biases: 373 biases: 326 test_mAP: false }

次に、YOLOv3 モデルのパラメーターを示します。これは、モデルの要件に応じて変更可能です。表 29: YOLOv3 モデルのパラメーターパラメーターの種類 説明

num_classes モデルの検出カテゴリの実際の数anchorCnt モデルのアンカーの数layer_name カーネルの出力レイヤー名。モデルの出力が複数の場合、このパラメーターを使用して特定のシーケンスを確保する必要がある。カーネルの名前と同じにする必要がある(無効な名前を入力すると、モデル クリエイターはカーネルのデフォルトの順序を使用する)。conf_threshold ボックスの信頼度を示すしきい値であり、実際のアプリケーションに合うように変更可能nms_threshold NMS のしきい値biases これらのパラメーターはモデルの値と同じになる。各バイアスは、個別の行に書き込む必要がある。

(Biases amount) = anchorCnt * (output-node amount) * 2。prototx で正しい行を設定する。test_mAP モデルがレターボックスでトレーニングされており、mAP をテストする必要がある場合は、true に設定する。通常は高速動作させるために false に設定する。

SSD_param

model_type : SSDssd_param :{ num_classes : 4 nms_threshold : 0.4 conf_threshold : 0.0 conf_threshold : 0.6 conf_threshold : 0.4 conf_threshold : 0.3 keep_top_k : 200 top_k : 400 prior_box_param { layer_width : 60, layer_height: 45, variances: 0.1 variances: 0.1 variances: 0.2

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 57

Page 58: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

variances: 0.2 min_sizes: 21.0 max_sizes: 45.0 aspect_ratios: 2.0 offset: 0.5 step_width: 8.0 step_height: 8.0 flip: true clip: false }}

次に、SSD パラメーターを示します。SSD モデルのパラメーターには、さまざまなしきい値と PriorBox の要件があります。SSD deploy.prototxt を参照して指定してください。表 30: SSD モデル パラメーター

パラメーターの種類 説明num_classes モデルの検出カテゴリの実際の数anchorCnt モデルのアンカーの数conf_threshold ボックスの信頼度を示すしきい値。各カテゴリには異なるしきい値を設定できるが、その数値は num_classes と等しくなる必要がある。nms_threshold NMS のしきい値biases これらのパラメーターはモデルの値と同じになる。各バイアスは、個別の行に書き込む必要がある。(Biases amount) = anchorCnt * (output-node amount) * 2。

prototx で正しい行を設定する。test_mAP モデルがレターボックスでトレーニングされており、mAP をテストする必要がある場合は、true に設定する。通常は高速動作させるために false に設定する。keep_top_k 検出オブジェクトの上位 K 個のボックスの各カテゴリtop_k バックグラウンド (最初のカテゴリ) を除く、すべての検出オブジェクトの上位 K 個のボックスprior_box_param 複数の PriorBox があり、対応するそれぞれ異なるスケール値はオリジナルのモデル

(deploy.prototxt) にある。これらの PriorBoxes は互いに反対となる。(PriorBox のパラメーターは次の表を参照)

表 31: PriorBox のパラメーターパラメーターの種類 説明

layer_width/layer_height このレイヤーの入力の幅/高さ。これらの値は、ネット構造から算出できる。ariances これらの値は、ボックス回帰に使用され、オリジナル モデルとしてのみ入力する。4つの変性がある。min_sizes/max_size deploy.prototxt として入力されるが、各値はぞれぞれ個別の行に入力する必要がある。aspect_ratios 比率の数値 (各値は、別の行に記述される必要がある)。最初の比率はデフォルトの

1.0。ここに新しい数値を設定すると、反対関係が成立する場合には 2 つの比率が作成される。入力した値とその逆数。たとえば、このパラメーターに「ratios: 2.0」というセット要素が 1 つある場合、比率ベクターは 1.0、2.0、0.5 の 3 つとなる。offset 通常、PriorBox は特徴マップの各中心点によって作成されるため、オフセットは 0.5。step_width/step_height オリジナル ファイルからコピーする。これらの値がない場合は、次の式を使用して計算可能。

step_width = img_width ÷ layer_widthstep_height = img_height ÷ layer_height

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 58

Page 59: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 31: PriorBox のパラメーター (続き)

パラメーターの種類 説明offset 通常、PriorBox は特徴マップの各中心点によって作成されるため、オフセットは 0.5。flip PriorBox を回転させて、長さ/幅の比率変更を制御。clip false に設定。true の場合、検出ボックスの座標は [0, 1] を維持。

コード例コードの例は次のとおりです。Mat img = cv::imread(argv[1]);auto yolo = vitis::ai::YOLOv3::create("yolov3_voc", true);auto results = yolo->run(img);for(auto &box : results.bboxes){ int label = box.label; float xmin = box.x * img.cols + 1; float ymin = box.y * img.rows + 1; float xmax = xmin + box.width * img.cols; float ymax = ymin + box.height * img.rows; if(xmin < 0.) xmin = 1.; if(ymin < 0.) ymin = 1.; if(xmax > img.cols) xmax = img.cols; if(ymax > img.rows) ymax = img.rows; float confidence = box.score; cout << "RESULT: " << label << "\t" << xmin << "\t" << ymin << "\t" << xmax << "\t" << ymax << "\t" << confidence << "\n"; rectangle(img, Point(xmin, ymin), Point(xmax, ymax), Scalar(0, 255, 0), 1, 1, 0);}imshow("", img);waitKey(0);

create を使用して、YOLOv3 オブジェクトを作成してください。static std::unique_ptr<YOLOv3> create(const std::string& model_name, bool need_mean_scale_process = true);

注記: model_name は、prototxt の名前と同じです。詳細は、~/Vitis-AI/Vitis-AI-Library/yolov3/test/test_yolov3.cpp を参照してください。

独自のポストプロセス コードを実装必要に応じて独自のポストプロセス関数を呼び出すことも可能です。例として、demo_yolov3.cpp とdemo_classification.cpp を使用します。vitis::ai::DpuTask::create またはvitis::ai::DpuRunner::create_dpu_runner を使用してタスクを作成し、DPU 処理が完了した後、ポストプロセス関数を呼び出すことができます。次の図の post_process 関数がユーザー独自のポストプロセス コードです。

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 59

Page 60: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 22: ユーザー独自のポストプロセス コードの例

詳細は、~/Vitis-AI/Vitis_AI_Library/overview/demo/classification/demo_classification.cppを参照してください。

AI ライブラリのポストプロセス ライブラリを使用する方法

ポストプロセスは、プロセス全体において非常に重要なステップです。各ニューラル ネットワークには異なるポストプロセス方法があります。ユーザー呼び出しをサポートするため、ザイリンクスは AI ライブラリでポストプロセスライブラリ (xnnpp) を提供しています。これはクローズド ソース ライブラリであり、次のニューラル ネットワークのポストプロセスをサポートしています。• 分類• 顔検出• 顔のランドマーク検出• SSD 検出• 姿勢検出• セマンティック セグメンテーション• 車線検出

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 60

Page 61: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

• YOLOV3 検出• YOLOV2 検出• 骨格検出• RefineDet 検出• ReID 検出• マルチタスク• 顔認識• プレート検出• プレート番号認識• 医療画像セグメンテーションxnnpp を呼び出す方法は次の 2 つです。• 自動呼び出しで、vitis::ai::<model>::create を使用して

vitis::ai::YOLOv3::create("yolov3_bdd", true) などのタスクを作成します。<model>-> run が終了すると、xnnpp が自動的に処理されて、ユーザーはモデル コンフィギュレーション ファイルを使用してパラメーターを変更できます。

• 手動呼び出しで、vitis::ai::DpuTask::create を使用して、タスクを作成します。その後、ポストプロセスのオブジェクトを作成し、ポストプロセスを実行します。ここでは例として、SSD のポストプロセスを取り上げます。具体的な手順は次のとおりです。1. 設定ファイルを作成し、ポストプロセスを制御するための相関データを設定します。

using DPU_conf = vitis::ai::proto::DpuModelParam;DPU_conf config;

2. caffemodel の場合は、is_tf を false に設定します。config.set_is_tf(false);

3. その他のパラメーターを設定します。fillconfig(config);

4. SSDPostProcess オブジェクトを作成します。auto input_tensor = task->getInputTensor();auto output_tensor = task->getOutputTensor();auto ssd = vitis::ai::SSDPostProcess::create(input_tensor, output_tensor,config);

5. ポストプロセスを実行します。auto results = ssd->ssd_post_process();

注記: ポストプロセス サンプルの詳細は、ホスト システムの ~/Vitis-AI/Vitis_AI_Library/overview/demo/yolov3/demo_yolov3.cpp および ~/Vitis-AI/Vitis_AI_Library/yolov3/test/test_yolov3.cpp を参照してください。

第 4 章: プログラム例

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 61

Page 62: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

第 5 章

アプリケーション デモこの章では、テスト環境のセットアップ方法とアプリケーション デモの実行方法について説明します。Vitis AI ライブラリ内には 2 つのアプリケーション デモがあります。ここでは、テスト プラットフォームとして ZCU102 ボードを使用します。

デモの概要Vitis AI ライブラリ内には 2 つのアプリケーション デモがあります。AI ライブラリを使用してアプリケーションを構築します。これらのコードは、~/Vitis-AI/Vitis-AI-Library/overview/demo/segs_and_roadline_detect と ~/Vitis-AI/Vitis-AI-Library/overview/demo/seg_and_pose_detect にあります。segs_and_roadline_detect は、マルチタスク セグメンテーション ネットワーク処理、車両検出、および車線検出を含むデモです。4 チャネルのセグメンテーション処理と車両検出、および 1 チャネルの車線検出を同時に実行します。seg_and_pose_detect は、マルチタスク セグメンテーション ネットワーク処理と姿勢検出を含むデモです。1 チャネルのセグメンテーション処理と 1 チャネルの姿勢検出を同時に実行します。注記: 最高性能を達成するために、デモではビデオ ディスプレイ用にダイレクト レンダリング マネージャー (DRM)を使用しています。ssh またはシリアル ポートを使用してボードにログインし、リモートでデモを実行してください。ビデオ ディスプレイ用に DRM を使用しない場合は、コンパイル オプションで「USE_DRM=0」を設定してください。

デモ プラットフォームとセットアップデモ プラットフォーム• ハードウェア:

• 1 x ZCU102 プロダクション シリコン (https://japan.xilinx.com/products/boards-and-kits/ek-u1-zcu102-g.html)

• 1 x Win7/10 ラップトップ• 1 x 16GB SD カード• 1 x イーサネット ケーブル• 1 x DP 1080P 互換モニター• 1 x DP ケーブル

第 5 章: アプリケーション デモ

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 62

Page 63: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

• ソフトウェア:

• ZCU102 ボード イメージ (https://japan.xilinx.com/products/design-tools/ai-inference/ai-developer-hub.html#edge)

• Vitis AI ライブラリ• イメージおよびビデオ ファイル• ターミナル ソフトウェア (MobaXterm、Putty など)

使用する DPU コンフィギュレーションと開発ツール• 3xB4096 @281MHz

• Vivado 2020.1、AI ライブラリ r1.2

デモのセットアップ図図 23: デモのセットアップ

デモ 1: マルチタスク セグメンテーションおよび車両検出と車線検出

ターゲット アプリケーション• ADAS/AD

第 5 章: アプリケーション デモ

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 63

Page 64: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

AI モデル、性能、消費電力• FPN

○ 512x288、4ch、20fps

• VPGNET

○ 640x480、1ch、56fps

• 20W @ ZU9EG

デモを構築して実行ホストでデモを構築し、プログラムをターゲット ボードにコピーします。$cd ~/Vitis-AI/Vitis-AI-Library/overview/demo/segs_and_roadline_detect$bash -x build.sh$scp segs_and_roadline_detect_x segs_and_roadline_detect_drm root@IP_OF_BOARD:~/

OpenCV ディスプレイを使用するには、次のコマンドを実行します。#./segs_and_roadline_detect_x seg_512_288.avi seg_512_288.avi seg_512_288.aviseg_512_288.avi lane_640_480.avi -t 2 -t 2 -t 2 -t 2 -t 3 >/dev/null 2>&1

DRM ディスプレイを使用する場合は、SSH を用いてボードに接続し、次のコマンドを実行します。#./segs_and_roadline_detect_drm seg_512_288.avi seg_512_288.avi seg_512_288.aviseg_512_288.avi lane_640_480.avi -t 2 -t 2 -t 2 -t 2 -t 3 >/dev/null 2>&1

注記:

1. ビデオ ファイルは、vitis_ai_library_r1.2.0_video.tar.gz に含まれています。こちら からパッケージをダウンロードしてください。

2. Docker 環境の制限により、クラウド デバイス上ではマルチ タスク デモは DRM モードで実行できません。

第 5 章: アプリケーション デモ

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 64

Page 65: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

デモの画像図 24: セグメンテーションおよび車線検出デモの画像

デモ 2: マルチタスク セグメンテーションおよび車両検出と姿勢検出

ターゲット アプリケーション• ADAS/AD

• スマート シティAI モデル、性能、消費電力• FPN

○ 960x540、1ch、30fps

• Openpose

○ 960x540、1ch、30fps

• 20W @ ZU9EG

第 5 章: アプリケーション デモ

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 65

Page 66: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

デモを構築して実行ホストでデモを構築し、プログラムをターゲット ボードにコピーします。$cd ~/Vitis-AI/Vitis-AI-Library/overview/demo/seg_and_pose_detect$bash -x build.sh$scp seg_and_pose_detect_x seg_and_pose_detect_drm root@IP_OF_BOARD:~/

OpenCV ディスプレイを使用するには、次のコマンドを実行します。#./seg_and_pose_detect_x seg_960_540.avi pose_960_540.avi -t 4 -t 4 >/dev/null 2>&1

DRM ディスプレイを使用する場合は、SSH を用いてボードに接続し、次のコマンドを実行します。#./seg_and_pose_detect_drm seg_960_540.avi pose_960_540.avi -t 4 -t 4 >/dev/null 2>&1

注記:

1. ビデオ ファイルは、vitis_ai_library_r1.2.0_video.tar.gz に含まれています。こちら からパッケージをダウンロードしてください。

2. Docker 環境の制限により、クラウド デバイス上ではマルチ タスク デモは DRM モードで実行できません。T

デモの画像図 25: セグメンテーションおよび姿勢検出デモの画像

第 5 章: アプリケーション デモ

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 66

Page 67: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

第 6 章

API のプログラミングライブラリを使用するには、開発ボードとクロス コンパイラ環境を準備する必要があります。開発中は、ヘッダー ファイル、ライブラリ ファイル、モデル ライブラリ ファイルに注意を払う必要があります。注記: 開発環境内のファイルは、Vitis 統合ソフトウェア開発者環境で提供されるバージョンと一致する必要があります。これらのライブラリは、ZCU102、ZCU104、およびザイリンクス Alveo U50、U50lv および U280 データセンター アクセラレータ カードで実行できます。1. イメージを選択します。例: cv::Mat。2. クラス インスタンスを取得するには、対応するライブラリで提供される create メソッドを呼び出します。

need_preprocess 変数を false に設定した場合、モデルは平均値とスケール値を差し引きません。3. ネットワークで必要な入力イメージの列と行の値を取得するには、getInputWidth() 関数と

getInputHeight() 関数を呼び出します。4. イメージ サイズを inputWidth x inputHeight に変更します。5. ネットワークの結果を取得するには、run() を呼び出します。API のプログラミングの詳細は、付録 A: API リファレンス を参照してください。また、Vitis AI API の詳細は、『Vitis AI ユーザー資料』 (UG1431) の 『Vitis AI ユーザー ガイド』 を参照してください。ザイリンクス ウェブサイト (https://japan.xilinx.com/products/design-tools/vitis/vitis-ai.html) からダウンロード可能です。

第 6 章: API のプログラミング

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 67

Page 68: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

第 7 章

性能この章では、次の各ボード上での Vitis™ AI ライブラリの性能について詳しく説明します。• ZCU102 (0432055-05)

• ZCU104

• Alveo U50

• Alveo U50lv

• Alveo U280

ZCU102 の性能ZCU102 ボードは、ミッドレンジの ZU9 UltraScale+ デバイスを使用します。ZCU102 ボードには、ヘッダー部分にシリアル番号 0432055-04 が含まれるものとシリアル番号 0432055-05 が含まれる、2 つの異なるハードウェア バージョンがあります。Vitis AI ライブラリの性能は、これらのハードウェア バージョン間で異なります (DDR 性能が異なるため)。ZCU102 の 0432055-04 バージョンは製造が中止されているため、次の表では ZCU102 432055-05 の性能のみを示しています。ZCU102 ボードでは、トリプル B4096F DPU コアがプログラム ロジックに実装されています。次の表では、DPU を使用し、281MHz で動作する ZCU102 (432055-05) のさまざまなニューラル ネットワーク サンプルのスループット性能 (fps) を示しています。注記: ZCU102 上の DPU にはハードウェア Softmax アクセラレーション モジュールがあります。ハードウェアSoftmax モジュールの制限により、カテゴリ数が 1000 に達するとソフトウェア Softmax の方が高速になります。ソフトウェア Softmax (softmax_c) を有効にするには、XLNX_ENABLE_C_SOFTMAX=1 と設定します。XLNX_ENABLE_C_SOFTMAX のデフォルト値は 0 のため、Softmax 手法は次の優先順に従って選択されます。1. Neon アクセラレーション2. ハードウェア Softmax

3. ソフトウェア Softmax_c

ZCU102 では、次のコマンドを使用して分類の性能をテストできます。env XLNX_ENABLE_C_SOFTMAX=1 ./test_performance_classification resnet50 test_performance_classification.list -t 8 -s 60

表 32: ZCU102 (0432055-05) の性能

番号 ニューラル ネットワーク 入力サイズ GOPS 性能 (fps) (単一スレッド)性能 (fps) (複数スレッド)

1 inception_resnet_v2_tf 299x299 26.4 23.1 48.7

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 68

Page 69: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 32: ZCU102 (0432055-05) の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS 性能 (fps) (単一スレッド)性能 (fps) (複数スレッド)

2 inception_v1_tf 224x224 3.0 184.1 423.9

3 inception_v3_tf 299x299 11.5 57.3 126.7

4 inception_v4_2016_09_09_tf 299x299 24.6 28.5 66.2

5 mobilenet_v1_0_25_128_tf 128x128 0.027 1170.7 4043.5

6 mobilenet_v1_0_5_160_tf 160x160 0.15 707.6 2007.1

7 mobilenet_v1_1_0_224_tf 224x224 1.1 284.3 754.9

8 mobilenet_v2_1_0_224_tf 224x224 0.60 230.8 568.4

9 mobilenet_v2_1_4_224_tf 224x224 1.2 167.3 393.1

10 resnet_v1_101_tf 224x224 14.4 43.1 91.3

11 resnet_v1_152_tf 224x224 21.8 29.6 63.7

12 resnet_v1_50_tf 224x224 7.0 79.1 161.9

13 vgg_16_tf 224x224 31.0 20.1 40.9

14 vgg_19_tf 224x224 39.3 17.3 36.5

15 ssd_mobilenet_v1_coco_tf 300x300 2.5 90.1 332.9

16 ssd_mobilenet_v2_coco_tf 300x300 3.8 63.9 193.2

17 ssd_resnet_50_fpn_coco_tf 640x640 178.4 1.3 5.1

18 yolov3_voc_tf 416x416 65.6 13.5 35

19 mlperf_ssd_resnet34_tf 1200x1200 433 2 7.2

20 resnet50 224x224 7.7 73.5 152.7

21 resnet18 224x224 3.7 186.9 441.6

22 inception_v1 224x224 3.2 178 411.7

23 inception_v2 224x224 4.0 144.4 317.3

24 inception_v3 299x299 11.4 57.5 128.1

25 inception_v4 299x299 24.5 28.5 66.2

26 mobilenet_v2 224x224 0.6 226.8 548

27 squeezenet 227x227 0.76 265.8 1012.3

28 ssd_pedestrain_pruned_0_97 360x360 5.9 76.3 282.6

29 ssd_traffic_pruned_0_9 360x480 11.6 54.5 201.5

30 ssd_adas_pruned_0_95 360x480 6.3 82.9 279.7

31 ssd_mobilenet_v2 360x480 6.6 38.4 114.4

32 refinedet_pruned_0_8 360x480 25 31.7 101.3

33 refinedet_pruned_0_92 360x480 10.1 59.9 196.8

34 refinedet_pruned_0_96 360x480 5.1 82.9 276.2

35 vpgnet_pruned_0_99 480x640 2.5 104.5 381.4

36 fpn 256x512 8.9 59.7 175.5

37 sp_net 128x224 0.55 381.6 1317.4

38 openpose_pruned_0_3 368x368 49.9 3.5 15.1

39 densebox_320_320 320x320 0.49 390 1172.3

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 69

Page 70: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 32: ZCU102 (0432055-05) の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS 性能 (fps) (単一スレッド)性能 (fps) (複数スレッド)

40 densebox_640_360 360x640 1.1 200.4 588.7

41 face_landmark 96x72 0.14 849.4 1382.7

42 reid 80x160 0.95 364.2 665.6

43 multi_task 288x512 14.8 35.5 127.7

44 yolov3_adas_pruned_0_9 256x512 5.5 84.1 229.7

45 yolov3_voc 416x416 65.4 13.5 35.3

46 yolov3_bdd 288x512 53.7 13 34.3

47 yolov2_voc 448x448 34 26.8 71

48 yolov2_voc_pruned_0_66 448x448 11.6 63.2 185.9

49 yolov2_voc_pruned_0_71 448x448 9.9 72.8 214.8

50 yolov2_voc_pruned_0_77 448x448 7.8 85.2 258.7

51 facerec_resnet20 112x96 3.5 167.1 320.6

52 facerec_resnet64 112x96 11.0 73 173

53 plate_detection 320x320 0.49 500 1792.2

54 plate_recognition 96x288 1.75 113.4 383.2

55 FPN_Res18_Medical_segmentation 320x320 45.3 12.2 40.3

56 refinedet_baseline 480x360 123 8.3 24.4

ZCU104 の性能ZCU104 ボードは、ミッドレンジの ZU7ev UltraScale+ デバイスを使用します。デュアル B4096F DPU コアがプログラム ロジックに実装されており、2.4 TOPS INT8 のピーク性能を達成できるため、深層学習の推論高速化に最適です。次の表では、DPU を使用し、300MHz で動作する ZCU104 のさまざまなニューラル ネットワーク サンプルのスループット性能 (fps) を示しています。表 33: ZCU104 の性能

番号 ニューラル ネットワーク 入力サイズ GOPS 性能 (fps) (単一スレッド)性能 (fps) (複数スレッド)

1 inception_resnet_v2_tf 299x299 26.4 25 46.2

2 inception_v1_tf 224x224 3.0 197.5 403.1

3 inception_v3_tf 299x299 11.5 60.6 117.4

4 inception_v4_2016_09_09_tf 299x299 24.6 30.3 58.4

5 mobilenet_v1_0_25_128_tf 128x128 0.027 1197.2 3744.2

6 mobilenet_v1_0_5_160_tf 160x160 0.15 737.6 1941.7

7 mobilenet_v1_1_0_224_tf 224x224 1.1 309.1 719.3

8 mobilenet_v2_1_0_224_tf 224x224 0.60 244.7 529.2

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 70

Page 71: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 33: ZCU104 の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS 性能 (fps) (単一スレッド)性能 (fps) (複数スレッド)

9 mobilenet_v2_1_4_224_tf 224x224 1.2 179.9 370.7

10 resnet_v1_101_tf 224x224 14.4 46.1 86.2

11 resnet_v1_152_tf 224x224 21.8 31.6 59.1

12 resnet_v1_50_tf 224x224 7.0 84.6 158.3

13 vgg_16_tf 224x224 31.0 21.3 37

14 vgg_19_tf 224x224 39.3 18.4 32.6

15 ssd_mobilenet_v1_coco_tf 300x300 2.5 93.2 294.6

16 ssd_mobilenet_v2_coco_tf 300x300 3.8 66.3 185.4

17 ssd_resnet_50_fpn_coco_tf 640x640 178.4 1.4 5.2

18 yolov3_voc_tf 416x416 65.6 14.1 29.2

19 mlperf_ssd_resnet34_tf 1200x1200 433 1.7 5.4

20 resnet50 224x224 7.7 78.7 148.1

21 resnet18 224x224 3.7 197.4 411.1

22 inception_v1 224x224 3.2 190.8 389.4

23 inception_v2 224x224 4.0 153.5 302.1

24 inception_v3 299x299 11.4 60.8 117.9

25 inception_v4 299x299 24.5 30.3 58.3

26 mobilenet_v2 224x224 0.6 242.8 520.8

27 squeezenet 227x227 0.76 271 943.6

28 ssd_pedestrain_pruned_0_97 360x360 5.9 78.5 220.5

29 ssd_traffic_pruned_0_9 360x480 11.6 56.2 152.9

30 ssd_adas_pruned_0_95 360x480 6.3 84.9 231.9

31 ssd_mobilenet_v2 360x480 6.6 25.7 101.4

32 refinedet_pruned_0_8 360x480 25 32.6 75.9

33 refinedet_pruned_0_92 360x480 10.1 61.3 154.1

34 refinedet_pruned_0_96 360x480 5.1 83.7 228.4

35 vpgnet_pruned_0_99 480x640 2.5 107.3 354.9

36 fpn 256x512 8.9 61.9 169.4

37 sp_net 128x224 0.55 494.4 1209.8

38 openpose_pruned_0_3 368x368 49.9 3.7 10.9

39 densebox_320_320 320x320 0.49 397.3 1263.9

40 densebox_640_360 360x640 1.1 204.1 621.9

41 face_landmark 96x72 0.14 891.4 1449.5

42 reid 80x160 0.95 387.7 700.3

43 multi_task 288x512 14.8 36 109.1

44 yolov3_adas_pruned_0_9 256x512 5.5 85.2 221.5

45 yolov3_voc 416x416 65.4 14.2 29.5

46 yolov3_bdd 288x512 53.7 13.6 28.6

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 71

Page 72: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 33: ZCU104 の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS 性能 (fps) (単一スレッド)性能 (fps) (複数スレッド)

47 yolov2_voc 448x448 34 28.4 58.7

48 yolov2_voc_pruned_0_66 448x448 11.6 66.6 152.9

49 yolov2_voc_pruned_0_71 448x448 9.9 76.6 179.5

50 yolov2_voc_pruned_0_77 448x448 7.8 89.4 216.1

51 facerec_resnet20 112x96 3.5 177.6 309

52 facerec_resnet64 112x96 11.0 77.7 147.5

53 plate_detection 320x320 0.49 501.8 1761.2

54 plate_recognition 96x288 1.75 225.3 541.2

55 FPN_Res18_Medical_segmentation 320x320 45.3 12.7 31.5

56 refinedet_baseline 480x360 123 8.7 18.2

U50/U50lv の性能ザイリンクス Alveo U50 データセンター アクセラレータ カードは、ザイリンクス 16nm UltraScale+ テクノロジを採用した PCIe® (Peripheral Component Interconnect Express) Gen3x16 準拠および Gen4x8 互換カードです。このリリースでは、深層学習の推論アクセラレーション用として DPU がプログラム ロジックに実装されています。次の表では、DPU を使用し、6E@300MHz で動作する U50 Gen3x4 のさまざまなニューラル ネットワーク サンプルのスループット性能 (fps) を示しています。注記: 一部のモデルは DPU の最大周波数で実行できないため、DPU の周波数を下げる必要があります。DPU の周波数を下げる方法については、ホストのセットアップ を参照してください。表 34: 6E300MHz DPU での U50 の性能

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

1 inception_resnet_v2_tf 299x299 26.4 300 173.2

2 inception_v1_tf 224x224 3.0 300 1195.8

3 inception_v3_tf 299x299 11.5 300 398.5

4 inception_v4_2016_09_09_tf 299x299 24.6 300 187.6

5 mobilenet_v1_0_25_128_tf 128x128 0.027 N/A N/A

6 mobilenet_v1_0_5_160_tf 160x160 0.15 N/A N/A

7 mobilenet_v1_1_0_224_tf 224x224 1.1 N/A N/A

8 mobilenet_v2_1_0_224_tf 224x224 0.60 N/A N/A

9 mobilenet_v2_1_4_224_tf 224x224 1.2 N/A N/A

10 resnet_v1_101_tf 224x224 14.4 300 365.1

11 resnet_v1_152_tf 224x224 21.8 300 244.7

12 resnet_v1_50_tf 224x224 7.0 300 703.8

13 vgg_16_tf 224x224 31.0 300 164.7

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 72

Page 73: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 34: 6E300MHz DPU での U50 の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

14 vgg_19_tf 224x224 39.3 300 137

15 ssd_mobilenet_v1_coco_tf 300x300 2.5 N/A N/A

16 ssd_mobilenet_v2_coco_tf 300x300 3.8 N/A N/A

17 ssd_resnet_50_fpn_coco_tf 640x640 178.4 300x0.9 32.7

18 yolov3_voc_tf 416x416 65.6 300x0.9 79.2

19 mlperf_ssd_resnet34_tf 1200x1200 433 N/A N/A

20 resnet50 224x224 7.7 300 631.2

21 resnet18 224x224 3.7 300 1430

22 inception_v1 224x224 3.2 300 1183.3

23 inception_v2 224x224 4.0 300 983.6

24 inception_v3 299x299 11.4 300 405.4

25 inception_v4 299x299 24.5 300 187.7

26 mobilenet_v2 224x224 0.6 N/A N/A

27 squeezenet 227x227 0.76 300 3016.1

28 ssd_pedestrain_pruned_0_97 360x360 5.9 300 621.5

29 ssd_traffic_pruned_0_9 360x480 11.6 300 433

30 ssd_adas_pruned_0_95 360x480 6.3 300 629

31 ssd_mobilenet_v2 360x480 6.6 N/A N/A

32 refinedet_pruned_0_8 360x480 25 300x0.9 193.6

33 refinedet_pruned_0_92 360x480 10.1 300x0.9 420.6

34 refinedet_pruned_0_96 360x480 5.1 300x0.9 617.2

35 vpgnet_pruned_0_99 480x640 2.5 300 478.8

36 fpn 256x512 8.9 300 450.9

37 sp_net 128x224 0.55 300 1158.5

38 openpose_pruned_0_3 368x368 49.9 300x0.9 29.1

39 densebox_320_320 320x320 0.49 300 1929.2

40 densebox_640_360 360x640 1.1 300 877.3

41 face_landmark 96x72 0.14 300 8513.7

42 reid 80x160 0.95 300 3612.9

43 multi_task 288x512 14.8 300 237.3

44 yolov3_adas_pruned_0_9 256x512 5.5 300x0.9 642.9

45 yolov3_voc 416x416 65.4 300x0.9 79

46 yolov3_bdd 288x512 53.7 300x0.9 77.2

47 yolov2_voc 448x448 34 300x0.9 165.6

48 yolov2_voc_pruned_0_66 448x448 11.6 300x0.9 409.6

49 yolov2_voc_pruned_0_71 448x448 9.9 300x0.9 481.5

50 yolov2_voc_pruned_0_77 448x448 7.8 300x0.9 585.4

51 facerec_resnet20 112x96 3.5 300 1278.3

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 73

Page 74: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 34: 6E300MHz DPU での U50 の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

52 facerec_resnet64 112x96 11.0 300 495.7

53 plate_detection 320x320 0.49 300 5135.8

54 plate_recognition 96x288 1.75 N/A N/A

55 FPN_Res18_Medical_segmentation 320x320 45.3 300 103.1

56 refinedet_baseline 480x360 123 300x0.9 50

57 resnet50_pt 224x224 4.1 300 546.4

58 squeezenet_pt 224x224 0.82 300 2024.4

59 inception_v3_pt 299x299 5.7 300 405.3

次の表では、DPU を使用し、9E@275MHz で動作する U50lv Gen3x4 のさまざまなニューラル ネットワーク サンプルのスループット性能 (fps) を示しています。表 35: 9E275MHz DPU での U50lv の性能

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

1 inception_resnet_v2_tf 299x299 26.4 275 224.1

2 inception_v1_tf 224x224 3.0 275 1607.4

3 inception_v3_tf 299x299 11.5 275 549.7

4 inception_v4_2016_09_09_tf 299x299 24.6 275 256.5

5 mobilenet_v1_0_25_128_tf 128x128 0.027 N/A N/A

6 mobilenet_v1_0_5_160_tf 160x160 0.15 N/A N/A

7 mobilenet_v1_1_0_224_tf 224x224 1.1 N/A N/A

8 mobilenet_v2_1_0_224_tf 224x224 0.60 N/A N/A

9 mobilenet_v2_1_4_224_tf 224x224 1.2 N/A N/A

10 resnet_v1_101_tf 224x224 14.4 275 458.1

11 resnet_v1_152_tf 224x224 21.8 275 305.9

12 resnet_v1_50_tf 224x224 7.0 275 880.6

13 vgg_16_tf 224x224 31.0 275 228.9

14 vgg_19_tf 224x224 39.3 275 189.9

15 ssd_mobilenet_v1_coco_tf 300x300 2.5 N/A N/A

16 ssd_mobilenet_v2_coco_tf 300x300 3.8 N/A N/A

17 ssd_resnet_50_fpn_coco_tf 640x640 178.4 275x0.9 42.6

18 yolov3_voc_tf 416x416 65.6 275x0.9 104

19 mlperf_ssd_resnet34_tf 1200x1200 433 N/A N/A

20 resnet50 224x224 7.7 275 802.5

21 resnet18 224x224 3.7 275 1927.4

22 inception_v1 224x224 3.2 275 1565.3

23 inception_v2 224x224 4.0 275 1289.1

24 inception_v3 299x299 11.4 275 552.4

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 74

Page 75: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 35: 9E275MHz DPU での U50lv の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

25 inception_v4 299x299 24.5 275 256.2

26 mobilenet_v2 224x224 0.6 N/A N/A

27 squeezenet 227x227 0.76 275 3767.1

28 ssd_pedestrain_pruned_0_97 360x360 5.9 275 664.2

29 ssd_traffic_pruned_0_9 360x480 11.6 275 483.3

30 ssd_adas_pruned_0_95 360x480 6.3 275 715

31 ssd_mobilenet_v2 360x480 6.6 N/A N/A

32 refinedet_pruned_0_8 360x480 25 275 235.6

33 refinedet_pruned_0_92 360x480 10.1 275 514.7

34 refinedet_pruned_0_96 360x480 5.1 275 725.8

35 vpgnet_pruned_0_99 480x640 2.5 275 595.3

36 fpn 256x512 8.9 275x0.9 530.9

37 sp_net 128x224 0.55 275 2687.7

38 openpose_pruned_0_3 368x368 49.9 275 43.3

39 densebox_320_320 320x320 0.49 275 2431.2

40 densebox_640_360 360x640 1.1 275 1074.4

41 face_landmark 96x72 0.14 275 11759.4

42 reid 80x160 0.95 275 5013.9

43 multi_task 288x512 14.8 275 192.2

44 yolov3_adas_pruned_0_9 256x512 5.5 275x0.9 810

45 yolov3_voc 416x416 65.4 275x0.9 104.2

46 yolov3_bdd 288x512 53.7 275x0.9 103

47 yolov2_voc 448x448 34 275x0.9 227.5

48 yolov2_voc_pruned_0_66 448x448 11.6 275x0.9 565.2

49 yolov2_voc_pruned_0_71 448x448 9.9 275x0.9 662.6

50 yolov2_voc_pruned_0_77 448x448 7.8 275x0.9 807.8

51 facerec_resnet20 112x96 3.5 275 1760.9

52 facerec_resnet64 112x96 11.0 275 663.7

53 plate_detection 320x320 0.49 275 5563.8

54 plate_recognition 96x288 1.75 N/A N/A

55 FPN_Res18_Medical_segmentation 320x320 45.3 275 140.2

56 refinedet_baseline 480x360 123 275 70.5

57 resnet50_pt 224x224 4.1 275 768.1

58 squeezenet_pt 224x224 0.82 275 2540.6

59 inception_v3_pt 299x299 5.7 275 551.5

次の表では、DPU を使用し、10E@275MHz で動作する U50lv Gen3x4 のさまざまなニューラル ネットワーク サンプルのスループット性能 (fps) を示しています。

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 75

Page 76: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 36: 10E275MHz DPU での U50lv の性能

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

1 inception_resnet_v2_tf 299x299 26.4 N/A N/A

2 inception_v1_tf 224x224 3.0 275x0.9 1552.5

3 inception_v3_tf 299x299 11.5 N/A N/A

4 inception_v4_2016_09_09_tf 299x299 24.6 N/A N/A

5 mobilenet_v1_0_25_128_tf 128x128 0.027 N/A N/A

6 mobilenet_v1_0_5_160_tf 160x160 0.15 N/A N/A

7 mobilenet_v1_1_0_224_tf 224x224 1.1 N/A N/A

8 mobilenet_v2_1_0_224_tf 224x224 0.60 N/A N/A

9 mobilenet_v2_1_4_224_tf 224x224 1.2 N/A N/A

10 resnet_v1_101_tf 224x224 14.4 275x0.9 458.9

11 resnet_v1_152_tf 224x224 21.8 275x0.9 306.5

12 resnet_v1_50_tf 224x224 7.0 275x0.9 882.93

13 vgg_16_tf 224x224 31.0 275x0.9 229.3

14 vgg_19_tf 224x224 39.3 275x0.9 189.9

15 ssd_mobilenet_v1_coco_tf 300x300 2.5 N/A N/A

16 ssd_mobilenet_v2_coco_tf 300x300 3.8 N/A N/A

17 ssd_resnet_50_fpn_coco_tf 640x640 178.4 275x0.8 41.8

18 yolov3_voc_tf 416x416 65.6 275x0.8 102.4

19 mlperf_ssd_resnet34_tf 1200x1200 433 N/A N/A

20 resnet50 224x224 7.7 275x0.9 802.5

21 resnet18 224x224 3.7 275x0.9 1934.5

22 inception_v1 224x224 3.2 275x0.9 1536.6

23 inception_v2 224x224 4.0 275x0.9 1314

24 inception_v3 299x299 11.4 N/A N/A

25 inception_v4 299x299 24.5 N/A N/A

26 mobilenet_v2 224x224 0.6 N/A N/A

27 squeezenet 227x227 0.76 275x0.9 3451.1

28 ssd_pedestrain_pruned_0_97 360x360 5.9 275x0.9 755.2

29 ssd_traffic_pruned_0_9 360x480 11.6 275x0.9 570.8

30 ssd_adas_pruned_0_95 360x480 6.3 275x0.9 818.2

31 ssd_mobilenet_v2 360x480 6.6 N/A N/A

32 refinedet_pruned_0_8 360x480 25 275x0.9 273.8

33 refinedet_pruned_0_92 360x480 10.1 275x0.9 574.8

34 refinedet_pruned_0_96 360x480 5.1 275x0.9 795.1

35 vpgnet_pruned_0_99 480x640 2.5 275 659

36 fpn 256x512 8.9 275x0.9 552.2

37 sp_net 128x224 0.55 275 1707

38 openpose_pruned_0_3 368x368 49.9 275x0.8 39.7

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 76

Page 77: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 36: 10E275MHz DPU での U50lv の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

39 densebox_320_320 320x320 0.49 275 2572.7

40 densebox_640_360 360x640 1.1 275 1125.1

41 face_landmark 96x72 0.14 275 12917.2

42 reid 80x160 0.95 275 5548.1

43 multi_task 288x512 14.8 275x0.9 177

44 yolov3_adas_pruned_0_9 256x512 5.5 275x0.8 771.3

45 yolov3_voc 416x416 65.4 275x0.8 102.2

46 yolov3_bdd 288x512 53.7 275x0.8 100.6

47 yolov2_voc 448x448 34 275x0.8 223.3

48 yolov2_voc_pruned_0_66 448x448 11.6 275x0.8 547.6

49 yolov2_voc_pruned_0_71 448x448 9.9 275x0.8 639.1

50 yolov2_voc_pruned_0_77 448x448 7.8 275x0.8 770.9

51 facerec_resnet20 112x96 3.5 275 1943.4

52 facerec_resnet64 112x96 11.0 275 736.4

53 plate_detection 320x320 0.49 275 5521.4

54 plate_recognition 96x288 1.75 N/A N/A

55 FPN_Res18_Medical_segmentation 320x320 45.3 275x0.9 139.8

56 refinedet_baseline 480x360 123 N/A N/A

57 resnet50_pt 224x224 4.1 275 764.6

58 squeezenet_pt 224x224 0.82 275x0.9 2393.2

59 inception_v3_pt 299x299 5.7 N/A N/A

U280 の性能ザイリンクス Alveo U280 データセンター アクセラレータ カードは、ザイリンクス 16nm UltraScale+ テクノロジを採用した PCIe® (Peripheral Component Interconnect Express) Gen3x16 準拠および Gen4x8 互換カードです。このリリースでは、深層学習の推論アクセラレーション用として DPU がプログラム ロジックに実装されています。次の表では、DPU を使用し、14E@300MHz で動作する U280 Gen3x16 のさまざまなニューラル ネットワーク サンプルのスループット性能 (fps) を示しています。注記: 一部のモデルは DPU の最大周波数で実行できないため、DPU の周波数を下げる必要があります。DPU の周波数を下げる方法については、ホストのセットアップ を参照してください。表 37: 14E300MHz DPU での U280 の性能

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

1 inception_resnet_v2_tf 299x299 26.4 300x0.5 150.1

2 inception_v1_tf 224x224 3.0 300x0.5 1117.9

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 77

Page 78: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 37: 14E300MHz DPU での U280 の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

3 inception_v3_tf 299x299 11.5 300x0.5 371.8

4 inception_v4_2016_09_09_tf 299x299 24.6 300x0.5 168

5 mobilenet_v1_0_25_128_tf 128x128 0.027 N/A N/A

6 mobilenet_v1_0_5_160_tf 160x160 0.15 N/A N/A

7 mobilenet_v1_1_0_224_tf 224x224 1.1 N/A N/A

8 mobilenet_v2_1_0_224_tf 224x224 0.60 N/A N/A

9 mobilenet_v2_1_4_224_tf 224x224 1.2 N/A N/A

10 resnet_v1_101_tf 224x224 14.4 300x0.5 387.5

11 resnet_v1_152_tf 224x224 21.8 300x0.5 258.9

12 resnet_v1_50_tf 224x224 7.0 300x0.6 890.3

13 vgg_16_tf 224x224 31.0 300x0.5 182.7

14 vgg_19_tf 224x224 39.3 300x0.5 153.1

15 ssd_mobilenet_v1_coco_tf 300x300 2.5 N/A N/A

16 ssd_mobilenet_v2_coco_tf 300x300 3.8 N/A N/A

17 ssd_resnet_50_fpn_coco_tf 640x640 178.4 300x0.5 28.8

18 yolov3_voc_tf 416x416 65.6 300x0.6 112.4

19 mlperf_ssd_resnet34_tf 1200x1200 433 N/A N/A

20 resnet50 224x224 7.7 300x0.7 918.1

21 resnet18 224x224 3.7 300x0.5 1634.4

22 inception_v1 224x224 3.2 300x0.5 1069.5

23 inception_v2 224x224 4.0 300x0.5 937

24 inception_v3 299x299 11.4 300x0.5 372

25 inception_v4 299x299 24.5 300x0.5 167

26 mobilenet_v2 224x224 0.6 N/A N/A

27 squeezenet 227x227 0.76 300x0.5 2821.7

28 ssd_pedestrain_pruned_0_97 360x360 5.9 300x0.5 423.3

29 ssd_traffic_pruned_0_9 360x480 11.6 300x0.5 306

30 ssd_adas_pruned_0_95 360x480 6.3 300x0.5 476.1

31 ssd_mobilenet_v2 360x480 6.6 N/A N/A

32 refinedet_pruned_0_8 360x480 25 N/A N/A

33 refinedet_pruned_0_92 360x480 10.1 N/A N/A

34 refinedet_pruned_0_96 360x480 5.1 N/A N/A

35 vpgnet_pruned_0_99 480x640 2.5 300x0.5 567.8

36 fpn 256x512 8.9 300x0.5 362.9

37 sp_net 128x224 0.55 300x0.5 2126.6

38 openpose_pruned_0_3 368x368 49.9 300x0.5 36.5

39 densebox_320_320 320x320 0.49 300x0.5 2622.3

40 densebox_640_360 360x640 1.1 300x0.5 1138.8

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 78

Page 79: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 37: 14E300MHz DPU での U280 の性能 (続き)

番号 ニューラル ネットワーク 入力サイズ GOPS DPU 周波数 (MHz) 性能 (fps) (複数スレッド)

41 face_landmark 96x72 0.14 300x0.5 11302.4

42 reid 80x160 0.95 300x0.5 4608

43 multi_task 288x512 14.8 300x0.5 128.3

44 yolov3_adas_pruned_0_9 256x512 5.5 300x0.6 893.1

45 yolov3_voc 416x416 65.4 300x0.6 113.6

46 yolov3_bdd 288x512 53.7 300x0.6 108.6

47 yolov2_voc 448x448 34 N/A N/A

48 yolov2_voc_pruned_0_66 448x448 11.6 300x0.5 490.3

49 yolov2_voc_pruned_0_71 448x448 9.9 300x0.5 570.3

50 yolov2_voc_pruned_0_77 448x448 7.8 300x0.5 679.6

51 facerec_resnet20 112x96 3.5 300x0.5 1576.9

52 facerec_resnet64 112x96 11.0 300x0.5 575.4

53 plate_detection 320x320 0.49 300x0.5 4235.7

54 plate_recognition 96x288 1.75 N/A N/A

55 FPN_Res18_Medical_segmentation 320x320 45.3 300x0.5 104.9

56 refinedet_baseline 480x360 123 N/A N/A

57 resnet50_pt 224x224 4.1 300x0.7 878.4

58 squeezenet_pt 224x224 0.82 300x0.5 1655.7

59 inception_v3_pt 299x299 5.7 300x0.5 371

第 7 章: 性能

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 79

Page 80: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

付録 A

API リファレンスvitis::ai::Classification

入力イメージ (cv::Mat) 内の物体を検出するためのベース クラス。入力はイメージ (cv::Mat)。出力は、入力イメージ内の物体のインデックスおよびスコアです。サンプル コード:

auto image = cv::imread("sample_classification.jpg");auto network = vitis::ai::Classification::create( "resnet_50", true);auto result = network->run(image);for (const auto &r : result.scores) { auto score = r.score; auto index = network->lookup(r.index);}

関数クイック リファレンス次の表に、vitis::ai::Classification クラスに定義されているすべての関数を示します。表 38: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<Classification >

createconst std::string & model_namebool need_preprocess

const char * lookupint index

vitis::ai::ClassificationResult

runconst cv::Mat & image

std::vector<vitis::ai::ClassificationResult>

runconst std::vector< cv::Mat > & images

int getInputWidthvoid

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 80

Page 81: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 38: 関数クイック リファレンス (続き)

タイプ 名前 引数int getInputHeight

void

size_t get_input_batchvoid

関数createクラス Classification の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< Classification > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 39: create の引数

タイプ 名前 説明const std::string & model_name モデル名。bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス Classification のインスタンス。

lookupインデックスを指定して、対応する分類を取得します。

プロトタイプconst char * lookup(int index);

パラメーター次の表に、lookup 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 81

Page 82: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 40: lookup の引数タイプ 名前 説明

int index ネットワークの結果

戻り値Classification の説明。index < 0 の場合は、空の文字列が返されます。

runclassification ニューロン ネットワークの実行結果を取得する関数。

プロトタイプ

vitis::ai::ClassificationResult run(const cv::Mat &image)=0;

パラメーター次の表に、run 関数の引数を示します。表 41: run の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値ClassificationResult。

runバッチ モードの classification ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< vitis::ai::ClassificationResult > run(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run 関数の引数を示します。表 42: run の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images バッチ入力イメージ (vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 82

Page 83: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値ClassificationResult のベクター。

getInputWidthclassification ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値classification ネットワークの InputWidth。

getInputHeightclassification ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値classification ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

vitis::ai::DpuTaskDPU タスクを実行するためのベース クラス。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 83

Page 84: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

関数クイック リファレンス次の表に、vitis::ai::DpuTask クラスに定義されているすべての関数を示します。表 43: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<DpuTask >

createkernel_name

void runvoid

void setMeanScaleBGRconst std::vector< float > & meanconst std::vector< float > & scale

void setImageBGRconst cv::Mat & img

void setImageRGBconst cv::Mat & img

std::vector< float > getMeanvoid

std::vector< float > getScalevoid

std::vector<vitis::ai::library::InputTensor >

getInputTensorvoid

std::vector<vitis::ai::library::OutputTensor >

getOutputTensorvoid

size_t get_num_of_kernelsvoid

const xir::Graph * get_graphvoid

関数createDPU タスクを作成するためのスタティック メソッド。

プロトタイプstd::unique_ptr< DpuTask > create(const std::string &kernal_name);

パラメーター次の表に、create 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 84

Page 85: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 44: create の引数タイプ 名前 説明

コメントされたパラメーター kernel_name は関数create に存在しません。

kernel_name dpu カーネル名。たとえば kernel_name が "resnet_50" の場合、次のdpu モデル ファイルが検索されます。./libdpumodelrestnet_50.so /usr/lib/libdpumodelrestnet_50.so

戻り値DpuTask インスタンス。

rundpu タスクを実行します。注記: この関数を実行する前に、setImageBGR または setImageRGB を使用して入力データを入力テンソルに適切にコピーしておく必要があります。プロトタイプvoid run(size_t idx)=0;

戻り値

setMeanScaleBGR平均/スケール値を設定します。注記: デフォルトでは平均/スケール処理は実行されず、この関数を実行すると平均/スケール処理が有効になります。有効にした後にオフにはできません。プロトタイプvoid setMeanScaleBGR(const std::vector< float > &mean, const std::vector< float > &scale)=0;

パラメーター次の表に、setMeanScaleBGR 関数の引数を示します。表 45: setMeanScaleBGR の引数

タイプ 名前 説明const std::vector< float >&

mean 平均値。正規化を使用します。

const std::vector< float >&

scale スケール値。正規化を使用します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 85

Page 86: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値

setImageBGRBGR フォーマットの入力イメージを入力テンソルにコピーします。

プロトタイプvoid setImageBGR(const cv::Mat &img)=0;

パラメーター次の表に、setImageBGR 関数の引数を示します。表 46: setImageBGR の引数

タイプ 名前 説明const cv::Mat & img 入力イメージ (cv::Mat)。

setImageRGBRGB フォーマットの入力イメージを入力テンソルにコピーします。

プロトタイプvoid setImageRGB(const cv::Mat &img)=0;

パラメーター次の表に、setImageRGB 関数の引数を示します。表 47: setImageRGB の引数

タイプ 名前 説明const cv::Mat & img 入力イメージ (cv::Mat)。

getMean平均値を取得します。

プロトタイプstd::vector< float > getMean()=0;

戻り値平均値

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 86

Page 87: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

getScaleスケール値を取得します。

プロトタイプstd::vector< float > getScale()=0;

戻り値スケール値

getInputTensor入力テンソルを取得します。

プロトタイプstd::vector< vitis::ai::library::InputTensor > getInputTensor(size_t idx)=0;

戻り値入力テンソル。

getOutputTensor出力テンソルを取得します。

プロトタイプstd::vector< vitis::ai::library::OutputTensor > getOutputTensor(size_t idx)=0;

戻り値出力テンソル。

get_num_of_kernelsタスクの数を取得します。

プロトタイプsize_t get_num_of_kernels() const =0;

get_graph

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 87

Page 88: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプconst xir::Graph * get_graph() const =0;

vitis::ai::FaceDetect入力イメージ (cv::Mat) 内の顔の位置を検出するためのベース クラス。入力はイメージ (cv::Mat)。出力は、入力イメージ内の顔の位置およびスコアのベクターです。サンプル コード:

auto image = cv::imread("sample_facedetect.jpg");auto network = vitis::ai::FaceDetect::create( "densebox_640_360", true);auto result = network->run(image);for (const auto &r : result.rects) { auto score = r.score; auto x = r.x * image.cols; auto y = r.y * image.rows; auto width = r.width * image.cols; auto height = r.height * image.rows;}

モデル結果を次に表示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 88

Page 89: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 26: 結果イメージ

関数クイック リファレンス次の表に、vitis::ai::FaceDetect クラスに定義されているすべての関数を示します。表 48: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<FaceDetect >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

float getThresholdvoid

void setThresholdfloat threshold

FaceDetectResult runconst cv::Mat & img

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 89

Page 90: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 48: 関数クイック リファレンス (続き)

タイプ 名前 引数std::vector<FaceDetectResult>

runimages

関数createクラス FaceDetect の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< FaceDetect > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 49: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス FaceDetect のインスタンス。

getInputWidthfacedetect ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値facedetect ネットワークの InputWidth。

getInputHeightfacedetect ネットワークの InputHeight を取得する関数 (入力イメージの行)。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 90

Page 91: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプint getInputHeight() const =0;

戻り値facedetect ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

getThreshold検出しきい値を取得する関数。

プロトタイプfloat getThreshold() const =0;

戻り値検出しきい値。範囲は 0 ~ 1 です。

setThreshold検出しきい値を更新する関数。注記: 検出結果は、検出しきい値でフィルタリングされます (score >= threshold)。プロトタイプvoid setThreshold(float threshold)=0;

パラメーター次の表に、setThreshold 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 91

Page 92: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 50: setThreshold の引数タイプ 名前 説明

float threshold 検出しきい値。範囲は 0 ~ 1 です。

戻り値

runfacedetect ネットワークの実行結果を取得する関数。

プロトタイプ

FaceDetectResult run(const cv::Mat &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 51: run の引数

タイプ 名前 説明const cv::Mat & img 入力データ。入力イメージ (cv::Mat) は、ネットワークで必要な

InputWidth および InputHeight に合わせてサイズを変更する必要があります。

戻り値facedetect ネットワークの検出結果 (score >= det_threshold)。

runバッチ モードの facedetect ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< FaceDetectResult > run(const std::vector< cv::Mat > &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 52: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。入力イメージは、ネットワークで必要な InputWidth および InputHeight に合わせてサイズを変更する必要があります。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 92

Page 93: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値FaceDetectResult のベクター。

vitis::ai::FaceFeature顔イメージ (cv::Mat) の特徴点を取得するためのベース クラス。入力は顔イメージ (cv::Mat) です。出力は、入力イメージ内の顔の特徴点です。浮動小数点のサンプル コードを次に示します。注記: 浮動小数点の特徴点と固定小数点の特徴点を取得するために、2 つのインターフェイスが提供されています。特徴点は、512 のエレメントから成るベクターです。cv:Mat image = cv::imread("test_face.jpg");auto network = vitis::ai::FaceFeature::create("facerec_resnet20", true);auto result = network->run(image);

固定小数点のサンプル コードを次に示します。cv:Mat image = cv::imread("test_face.jpg");auto network = vitis::ai::FaceFeature::create("facerec_resnet20", true);auto result = network->run_fixed(image);

類似性を求める計算式を次に示します。固定小数点比較サンプル コードを次に示します。 float feature_norm(const int8_t *feature) { int sum = 0; for (int i = 0; i < 512; ++i) { sum += feature[i] * feature[i]; } return 1.f / sqrt(sum); }

/// This function is used for computing dot product of two vectorstatic float feature_dot(const int8_t *f1, const int8_t *f2) { int dot = 0; for (int i = 0; i < 512; ++i) { dot += f1[i] * f2[i]; } return (float)dot;}

float feature_compare(const int8_t *feature, const int8_t *feature_lib) { float norm = feature_norm(feature); float feature_norm_lib = feature_norm(feature_lib); return feature_dot(feature, feature_lib) * norm * feature_norm_lib;}

/// This function is used for model "facerec_resnet20" float score_map_l20(float score) { return 1.0 / (1 + exp(-12.4 * score +

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 93

Page 94: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

3.763)); }

/// This function is used for type "facerec_resnet64"float score_map_l64(float score) { return 1.0 / (1 + exp(-17.0836 * score + 5.5707)); }

浮動小数点と固定小数点のイメージを比較した結果を次に示します。図 27: facecompare の結果イメージ

関数クイック リファレンス次の表に、vitis::ai::FaceFeature クラスに定義されているすべての関数を示します。表 53: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<FaceFeature >

createconst std::string & model_namebool need_preprocess

FaceFeaturevoid

FaceFeaturevoid

FaceFeature & operator=void

~FaceFeaturevoid

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

FaceFeatureFloatResult

runconst cv::Mat & img

FaceFeatureFixedResult

run_fixedconst cv::Mat & img

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 94

Page 95: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 53: 関数クイック リファレンス (続き)

タイプ 名前 引数std::vector<FaceFeatureFloatResult >

runimages

std::vector<FaceFeatureFixedResult >

run_fixedimages

関数createクラス FaceFeature の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< FaceFeature > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 54: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス FaceFeature のインスタンス。

FaceFeature

プロトタイプ FaceFeature();

FaceFeature

プロトタイプ FaceFeature(const FaceFeature &)=delete;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 95

Page 96: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

operator=

プロトタイプ

FaceFeature & operator=(const FaceFeature &)=delete;

~FaceFeature

プロトタイプ ~FaceFeature();

getInputWidthfeature ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値feature ネットワークの InputWidth。

getInputHeightfeature ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値feature ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 96

Page 97: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値バッチ サイズ。

runfeature ネットワークの実行結果を取得する関数。

プロトタイプ

FaceFeatureFloatResult run(const cv::Mat &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 55: run の引数

タイプ 名前 説明const cv::Mat & img facedetect ネットワークによって検出された後、関連付けられてアラインされたイメージ (cv::Mat) の入力データ。

戻り値FaceFeatureFloatResult

run_fixedfeature ネットワークの実行結果を取得する関数。

プロトタイプ

FaceFeatureFixedResult run_fixed(const cv::Mat &img)=0;

パラメーター次の表に、run_fixed 関数の引数を示します。表 56: run_fixed の引数

タイプ 名前 説明const cv::Mat & img 検出された対象物の、InputWidth と InputHeight に合わせてサイズが変更された入力イメージ (cv::Mat) の入力データ。

戻り値FaceFeatureFixedResult

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 97

Page 98: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

runバッチ モードの feature ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< FaceFeatureFloatResult > run(const std::vector< cv::Mat > &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 57: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images facedetect ネットワークによって検出された後、関連付けられてアラインされたバッチ入力イメージ (vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値FaceFeatureFloatResult のベクター。

run_fixedバッチ モードの feature ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< FaceFeatureFixedResult > run_fixed(const std::vector< cv::Mat > &img)=0;

パラメーター次の表に、run_fixed 関数の引数を示します。表 58: run_fixed の引数

タイプ 名前 説明コメントされたパラメーター images は関数run_fixed に存在しません。

images facedetect ネットワークによって検出された後、関連付けられてアラインされたバッチ入力イメージ (vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値FaceFeatureFixedResult のベクター。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 98

Page 99: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::FaceLandmark顔イメージ (cv::Mat) から 5 個の特徴点とスコアを検出するためのベース クラス。入力は顔イメージ (cv::Mat) です。出力は顔の 5 個の特徴点とスコアです。サンプル コード:

注記: 通常、入力イメージに含まれる顔は 1 つだけです。複数の顔が含まれる場合は、最も高いスコアが返されます。cv:Mat image = cv::imread("sample_facelandmark.jpg");auto landmark = vitis::ai::FaceLandmark::create("face_landmark");auto result = landmark->run(image);float score = result.score;auto points = result.points;for(int i = 0; i< 5 ; ++i){ auto x = points[i].frist * image.cols; auto y = points[i].second * image.rows;}

モデルの結果を次に示します (画像幅 100px)。図 28: 結果イメージ

関数クイック リファレンス次の表に、vitis::ai::FaceLandmark クラスに定義されているすべての関数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 99

Page 100: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 59: 関数クイック リファレンスタイプ 名前 引数

std::unique_ptr<FaceLandmark >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

FaceLandmarkResult

runconst cv::Mat & input_image

std::vector<FaceLandmarkResult >

runimages

関数createクラス FaceLandmark の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< FaceLandmark > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 60: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス FaceLandmark のインスタンス。

getInputWidthfacelandmark ネットワークの InputWidth を取得する関数 (入力イメージの列)。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 100

Page 101: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプint getInputWidth() const =0;

戻り値facelandmark ネットワークの InputWidth。

getInputHeightfacelandmark ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値facelandmark ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

runfacelandmark ネットワークの実行結果を取得する関数。顔のデータ (cv::Mat など) を設定し、5 個の特徴点を取得します。

プロトタイプ

FaceLandmarkResult run(const cv::Mat &input_image)=0;

パラメーター次の表に、run 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 101

Page 102: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 61: run の引数タイプ 名前 説明

const cv::Mat & input_image facedetect ネットワークで検出され、inputwidth と inputheight に合わせてサイズが変更された入力イメージ (cv::Mat) の入力データ。

戻り値FaceLandmarkResult 構造体

runバッチ モードの facelandmark ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< FaceLandmarkResult > run(const std::vector< cv::Mat > &input_image)=0;

パラメーター次の表に、run 関数の引数を示します。表 62: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。入力イメージは、ネットワークで必要な InputWidth および InputHeight に合わせてサイズを変更する必要があります。

戻り値FaceLandmarkResult のベクター。

vitis::ai::MedicalSegmentationCOCO データセットの 90 個のオブジェクトを検出するためのベース クラス。入力はイメージ (cv:Mat)。出力は、MedicalSegmentationResult という名前の検出結果の構造体です。サンプル コード:

Mat img = cv::imread("sample_medicalsegmentation.jpg"); auto medicalsegmentation = vitis::ai::MedicalSegmentation::create("ssd_resnet_50_fpn_coco_tf",true); auto results = medicalsegmentation->run(img); for(const auto &r : results.bboxes){ auto label = r.label;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 102

Page 103: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

auto x = r.x * img.cols; auto y = r.y * img.rows; auto width = r.width * img.cols; auto heigth = r.height * img.rows; auto score = r.score; std::cout << "RESULT: " << label << "\t" << x << "\t" << y << "\t" <<width << "\t" << height << "\t" << score << std::endl; }

モデル結果を次に表示します。図 29: 検出結果

関数クイック リファレンス次の表に、vitis::ai::MedicalSegmentation クラスに定義されているすべての関数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 103

Page 104: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 63: 関数クイック リファレンスタイプ 名前 引数

std::unique_ptr<MedicalSegmentation >

createconst std::string & model_namebool need_preprocess

vitis::ai::MedicalSegmentationResult

runconst cv::Mat & img

std::vector<vitis::ai::MedicalSegmentationResult >

runimages

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

関数createクラス SSD の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< MedicalSegmentation > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 64: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス SSD のインスタンス。

runssd ニューロン ネットワークの結果を取得する関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 104

Page 105: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプ

vitis::ai::MedicalSegmentationResult run(const cv::Mat &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 65: run の引数

タイプ 名前 説明const cv::Mat & img 入力イメージ (cv::Mat) の入力データ。

戻り値MedicalSegmentationResult。

runバッチ モードの SSD ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< vitis::ai::MedicalSegmentationResult > run(const std::vector< cv::Mat > &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 66: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されるバッチ サイズと同じです。

戻り値MedicalSegmentationResult のベクター。

getInputWidthSSD ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 105

Page 106: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値SSD ネットワークの InputWidth。

getInputHeightSSD ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値SSD ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

vitis::ai::MedicalSegmentationPostProcessssd ポストプロセスのクラス。プログラムが実行されるたびに計算するのではなく、パラメーターを一度に初期化します。

関数クイック リファレンス次の表に、vitis::ai::MedicalSegmentationPostProcess クラスに定義されているすべての関数を示します。表 67: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<MedicalSegmentationPostProcess >

createconst std::vector< vitis::ai::library::InputTensor > &input_tensorsconst std::vector< vitis::ai::library::OutputTensor > &output_tensorsconst vitis::ai::proto::DpuModelParam & config

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 106

Page 107: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 67: 関数クイック リファレンス (続き)

タイプ 名前 引数MedicalSegmentationResult

medicalsegmentation_post_processvoid

std::vector<MedicalSegmentationResult >

medicalsegmentation_post_processvoid

関数createMedicalSegmentationPostProcess オブジェクトを作成します。

プロトタイプstd::unique_ptr< MedicalSegmentationPostProcess > create(const std::vector< vitis::ai::library::InputTensor > &input_tensors, const std::vector< vitis::ai::library::OutputTensor > &output_tensors, const vitis::ai::proto::DpuModelParam &config);

パラメーター次の表に、create 関数の引数を示します。表 68: create の引数

タイプ 名前 説明const std::vector<vitis::ai::library::InputTensor > &

input_tensors ネットワーク内のすべての入力テンソルのベクター。使用法:input_tensors[input_tensor_index]。

const std::vector<vitis::ai::library::OutputTensor > &

output_tensors ネットワーク内のすべての出力テンソルのベクター。使用法:output_tensors[output_index]。

constvitis::ai::proto::DpuModelParam &

config DPU モデルの構成情報。

戻り値一意の MedicalSegmentationPostProcess の出力。

medicalsegmentation_post_processssd ネットワークのポストプロセス関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 107

Page 108: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプ

MedicalSegmentationResult medicalsegmentation_post_process(unsigned int idx)=0;

戻り値MedicalSegmentationResult 構造体。

medicalsegmentation_post_processssd ネットワークのバッチ モード ポストプロセス関数。

プロトタイプstd::vector< MedicalSegmentationResult > medicalsegmentation_post_process()=0;

戻り値MedicalSegmentationResult の構造体のベクター。

vitis::ai::MultiTaskMultitask ネットワーク タイプ、宣言 multitask ネットワーク。クラスの番号。label: 0 の名前: "background" label: 1 の名前: "person" label: 2 の名前: "car" label: 3 の名前: "truck"label: 4 の名前: "bus" label: 5 の名前: "bike" label: 6 の名前: "sign" label: 7 の名前: "light"

イメージ (cv::Mat) からの ADAS MultiTask のベース クラス。入力はイメージ (cv::Mat)。出力は、セグメンテーション結果、検出結果、および車両から成る MultiTaskResult 構造体です。サンプル コード:

auto det = vitis::ai::MultiTask::create("multi_task");auto image = cv::imread("sample_multitask.jpg");auto result = det->run_8UC3(image);cv::imwrite("sample_multitask_result.jpg",result.segmentation);

モデル結果を次に表示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 108

Page 109: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 30: 結果イメージ

関数クイック リファレンス次の表に、vitis::ai::MultiTask クラスに定義されているすべての関数を示します。表 69: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<MultiTask >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

MultiTaskResult run_8UC1const cv::Mat & image

std::vector<MultiTaskResult>

run_8UC1const std::vector< cv::Mat > & images

MultiTaskResult run_8UC3const cv::Mat & image

std::vector<MultiTaskResult>

run_8UC3const std::vector< cv::Mat > & images

関数createMultitask の派生クラスのインスタンスを取得するファクトリ関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 109

Page 110: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::unique_ptr< MultiTask > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 70: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値Multitask クラスのインスタンス。

getInputWidthmultitask ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値multitask ネットワークの InputWidth。

getInputHeightmultitask ネットワークの InputHeight を取得する関数 (入力イメージの列)。

プロトタイプint getInputHeight() const =0;

戻り値multitask ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 110

Page 111: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

run_8UC1MultiTask ネットワークから実行結果を取得する関数。注記: タイプは MultiTaskResult.segmentation の CV_8UC1。プロトタイプ

MultiTaskResult run_8UC1(const cv::Mat &image)=0;

パラメーター次の表に、run_8UC1 関数の引数を示します。表 71: run_8UC1 の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ

戻り値MultiTaskResult 構造体

run_8UC1バッチ モードの MultiTask ニューロン ネットワークの実行結果を取得する関数。注記: タイプは MultiTaskResult.segmentation の CV_8UC1。プロトタイプstd::vector< MultiTaskResult > run_8UC1(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run_8UC1 関数の引数を示します。表 72: run_8UC1 の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 111

Page 112: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値MultiTaskResult のベクター。

run_8UC3MultiTask ネットワークから実行結果を取得する関数。注記: タイプは MultiTaskResult.segmentation.の CV_8UC3。プロトタイプ

MultiTaskResult run_8UC3(const cv::Mat &image)=0;

パラメーター次の表に、run_8UC3 関数の引数を示します。表 73: run_8UC3 の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ

戻り値MultiTaskResult 構造体

run_8UC3バッチ モードの MultiTask ニューロン ネットワークの実行結果を取得する関数。注記: タイプは MultiTaskResult.segmentation の CV_8UC3。プロトタイプstd::vector< MultiTaskResult > run_8UC3(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run_8UC3 関数の引数を示します。表 74: run_8UC3 の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値MultiTaskResult のベクター。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 112

Page 113: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::MultiTask8UC1イメージ (cv::Mat) からの ADAS MuiltTask8UC1 のベース クラス。入力はイメージ (cv::Mat)。出力は、セグメンテーション結果、検出結果、および車両から成る MultiTaskResult 構造体です。結果 cv::Mat のタイプは CV_8UC1。サンプル コード:

auto det = vitis::ai::MultiTask8UC1::create(vitis::ai::MULTITASK);auto image = cv::imread("sample_multitask.jpg");auto result = det->run(image);cv::imwrite("res.jpg",result.segmentation);

関数クイック リファレンス次の表に、vitis::ai::MultiTask8UC1 クラスに定義されているすべての関数を示します。表 75: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<MultiTask8UC1 >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

MultiTaskResult runconst cv::Mat & image

std::vector<MultiTaskResult>

runconst std::vector< cv::Mat > & images

関数createクラス MultiTask8UC1 の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< MultiTask8UC1 > create(const std::string &model_name, bool need_preprocess=true);

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 113

Page 114: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

パラメーター次の表に、create 関数の引数を示します。表 76: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス MultiTask8UC1 のインスタンス。

getInputWidthmultitask ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const;

戻り値multitask ネットワークの InputWidth。

getInputHeightmultitask ネットワークの InputHeight を取得する関数 (入力イメージの列)。

プロトタイプint getInputHeight() const;

戻り値multitask ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const;

戻り値バッチ サイズ。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 114

Page 115: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

runMultiTask ネットワークから実行結果を取得する関数。注記: タイプは MultiTaskResult.segmentation の CV_8UC1。プロトタイプ

MultiTaskResult run(const cv::Mat &image);

パラメーター次の表に、run 関数の引数を示します。表 77: run の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ

戻り値MultiTaskResult 構造体

runバッチ モードの MultiTask ニューロン ネットワークの実行結果を取得する関数。注記: タイプは MultiTaskResult.segmentation の CV_8UC1。プロトタイプstd::vector< MultiTaskResult > run(const std::vector< cv::Mat > &images);

パラメーター次の表に、run 関数の引数を示します。表 78: run の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値MultiTaskResult のベクター。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 115

Page 116: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::MultiTask8UC3イメージ (cv::Mat) からの ADAS MuiltTask8UC3 のベース クラス。入力はイメージ (cv::Mat)。出力は、セグメンテーション結果、検出結果、および車両から成る MultiTaskResult 構造体です。結果 cv::Mat のタイプは CV_8UC3。サンプル コード:

auto det = vitis::ai::MultiTask8UC3::create(vitis::ai::MULITASK);auto image = cv::imread("sample_multitask.jpg");auto result = det->run(image);cv::imwrite("res.jpg",result.segmentation);

関数クイック リファレンス次の表に、vitis::ai::MultiTask8UC3 クラスに定義されているすべての関数を示します。表 79: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<MultiTask8UC3 >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

MultiTaskResult runconst cv::Mat & image

std::vector<MultiTaskResult>

runconst std::vector< cv::Mat > & images

関数createクラス MultiTask8UC3 の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< MultiTask8UC3 > create(const std::string &model_name, bool need_preprocess=true);

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 116

Page 117: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

パラメーター次の表に、create 関数の引数を示します。表 80: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス MultiTask8UC3 のインスタンス。

getInputWidthmultitask ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const;

戻り値multitask ネットワークの InputWidth。

getInputHeightmultitask ネットワークの InputHeight を取得する関数 (入力イメージの列)。

プロトタイプint getInputHeight() const;

戻り値multitask ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const;

戻り値バッチ サイズ。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 117

Page 118: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

runMultiTask ネットワークから実行結果を取得する関数。注記: タイプは MultiTaskResult.segmentation の CV_8UC3。プロトタイプ

MultiTaskResult run(const cv::Mat &image);

パラメーター次の表に、run 関数の引数を示します。表 81: run の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ

戻り値MultiTaskResult 構造体

runバッチ モードの MultiTask ニューロン ネットワークの実行結果を取得する関数。注記: タイプは MultiTaskResult.segmentation の CV_8UC3。プロトタイプstd::vector< MultiTaskResult > run(const std::vector< cv::Mat > &images);

パラメーター次の表に、run 関数の引数を示します。表 82: run の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値MultiTaskResult のベクター。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 118

Page 119: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::MultiTaskPostProcess

関数クイック リファレンス次の表に、vitis::ai::MultiTaskPostProcess クラスに定義されているすべての関数を示します。表 83: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<MultiTaskPostProcess >

createconst std::vector< std::vector<vitis::ai::library::InputTensor >> & input_tensorsconst std::vector< std::vector<vitis::ai::library::OutputTensor >> & output_tensorsconst vitis::ai::proto::DpuModelParam & config

std::vector<MultiTaskResult>

post_process_segvoid

std::vector<MultiTaskResult>

post_process_seg_visualizationvoid

関数createMultiTaskPostProcess の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< MultiTaskPostProcess > create(const std::vector< std::vector< vitis::ai::library::InputTensor >> &input_tensors, const std::vector< std::vector< vitis::ai::library::OutputTensor >> &output_tensors, const vitis::ai::proto::DpuModelParam &config);

パラメーター次の表に、create 関数の引数を示します。表 84: create の引数

タイプ 名前 説明const std::vector<std::vector<vitis::ai::library::InputTensor >> &

input_tensors ネットワーク内のすべての入力テンソルのベクター。使用法:input_tensors[kernel_index][input_tensor_index]。

const std::vector<std::vector<vitis::ai::library::OutputTensor >> &

output_tensors ネットワーク内のすべての出力テンソルのベクター。使用法:output_tensors[kernel_index][output_index]。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 119

Page 120: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 84: create の引数 (続き)

タイプ 名前 説明constvitis::ai::proto::DpuModelParam &

config DPU モデルの構成情報。

戻り値MultiTaskResult 構造体。

post_process_segmultitask のポストプロセス関数で、元のセグメンテーション クラスを保存します。

プロトタイプstd::vector< MultiTaskResult > post_process_seg()=0;

戻り値SegmentationResult 構造体。

post_process_seg_visualizationmultitask のポストプロセス関数で、色分けされたセグメンテーション イメージを含む結果を返します。

プロトタイプstd::vector< MultiTaskResult > post_process_seg_visualization()=0;

戻り値SegmentationResult 構造体。

vitis::ai::OpenPoseopenpose モデル。入力サイズは 368x368。人間の姿勢を検出するためのベース クラス。入力はイメージ (cv:Mat)。出力は OpenPoseResult です。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 120

Page 121: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

サンプル コード:

auto image = cv::imread("sample_openpose.jpg"); if (image.empty()) { std::cerr << "cannot load image" << std::endl; abort(); } auto det = vitis::ai::OpenPose::create("openpose_pruned_0_3"); int width = det->getInputWidth(); int height = det->getInputHeight(); vector<vector<int>> limbSeq = {{0,1}, {1,2}, {2,3}, {3,4}, {1,5}, {5,6},{6,7}, {1,8}, \ {8,9}, {9,10}, {1,11}, {11,12}, {12,13}}; float scale_x =float(image.cols) / float(width); float scale_y = float(image.rows) /float(height); auto results = det->run(image); for(size_t k = 1; k <results.poses.size(); ++k){ for(size_t i = 0; i < results.poses[k].size();++i){ if(results.poses[k][i].type == 1){ results.poses[k][i].point.x *=scale_x; results.poses[k][i].point.y *= scale_y; cv::circle(image,results.poses[k][i].point, 5, cv::Scalar(0, 255, 0), -1); } } for(size_t i = 0; i < limbSeq.size(); ++i){ Result a = results.poses[k][limbSeq[i][0]]; Result b = results.poses[k][limbSeq[i][1]]; if(a.type == 1 && b.type == 1){ cv::line(image, a.point, b.point, cv::Scalar(255, 0, 0), 3, 4); } } }

openpose モデルの結果を次に表示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 121

Page 122: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 31: openpose の結果イメージ

関数クイック リファレンス次の表に、vitis::ai::OpenPose クラスに定義されているすべての関数を示します。表 85: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<OpenPose >

createconst std::string & model_namebool need_preprocess

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 122

Page 123: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 85: 関数クイック リファレンス (続き)

タイプ 名前 引数OpenPoseResult run

const cv::Mat & image

std::vector<OpenPoseResult >

runvoid

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

関数createクラス OpenPose の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< OpenPose > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 86: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス OpenPose のインスタンス。

runopenpose ニューロン ネットワークの実行結果を取得する関数。

プロトタイプ

OpenPoseResult run(const cv::Mat &image)=0;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 123

Page 124: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

パラメーター次の表に、run 関数の引数を示します。表 87: run の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値OpenPoseResult。

run

プロトタイプstd::vector< OpenPoseResult > run(const std::vector< cv::Mat > &images)=0;

getInputWidthopenpose ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値openpose ネットワークの InputWidth。

getInputHeightopenpose ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値openpose ネットワークの InputHeight。

get_input_batch

プロトタイプsize_t get_input_batch() const =0;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 124

Page 125: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::PlateDetect車のイメージ (cv::Mat) 内のプレートの位置を検出するためのベース クラス。入力は車のイメージ (cv::Mat) です。出力は、入力イメージ内のプレートの位置およびスコアです。サンプル コード:

cv::Mat image = cv::imread("car.jpg");auto network = vitis::ai::PlateDetect::create(true);auto r = network->run(image);auto score = r.box.score.auto x = r.box.x * image.cols;auto y = r.box.y * image.rows;auto witdh = r.box.width * image.cols;auto height = r.box.height * image.rows;

関数クイック リファレンス次の表に、vitis::ai::PlateDetect クラスに定義されているすべての関数を示します。表 88: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<PlateDetect >

createneed_mean_scale_process

PlateDetectvoid

PlateDetectvoid

PlateDetect & operator=void

~PlateDetectvoid

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

PlateDetectResult

runimg

std::vector<PlateDetectResult >

runimages

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 125

Page 126: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

関数createplatedetect の派生クラスのインスタンスを取得するファクトリ関数。PlaterDatect クラスのインスタンスです。

プロトタイプstd::unique_ptr< PlateDetect > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 89: create の引数

タイプ 名前 説明コメントされたパラメーターneed_mean_scale_process は関数 create に存在しません。

need_mean_scale_process

平均値/スケール値で正規化するかどうか。デフォルト値は true。

PlateDetect

プロトタイプ PlateDetect();

PlateDetect

プロトタイプ PlateDetect(const PlateDetect &)=delete;

operator=

プロトタイプ

PlateDetect & operator=(const PlateDetect &)=delete;

~PlateDetect

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 126

Page 127: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプ ~PlateDetect();

getInputWidthplatedetect ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値platedetect ネットワークの InputWidth。

getInputHeightplatedetect ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値platedetect ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

runplatedetect ネットワークの実行結果を取得する関数。

プロトタイプ

PlateDetectResult run(const cv::Mat &image)=0;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 127

Page 128: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

パラメーター次の表に、run 関数の引数を示します。表 90: run の引数

タイプ 名前 説明コメントされたパラメーター img は関数 run に存在しません。

img 検出された対象物の入力イメージ (cv::Mat) の入力データで、InputWidth および OutputHeight に合わせてサイズを変更します。

戻り値プレートの位置およびプレートのスコア。

runバッチ モードの platedetect ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< PlateDetectResult > run(const std::vector< cv::Mat > &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 91: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。入力イメージは、ネットワークで必要な InputWidth および InputHeight に合わせてサイズを変更する必要があります。

戻り値PLateDetectResult のベクター。

vitis::ai::PlateNumイメージ (cv::Mat) から プレートを認識するためのベース クラス。入力はプレート イメージ (cv::Mat) です。出力は、入力イメージのプレートの番号とプレートの色です。サンプル コード:

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 128

Page 129: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

注記: エッジ プラットフォームでは中国のプレートのみがサポート対象となります。cv::Mat image = cv::imread("plate.jpg");auto network = vitis::ai::PlateNum::create(true);auto r = network->run(image);auto plate_number = r.plate_number;auto plate_color = r.plate_color;

関数クイック リファレンス次の表に、vitis::ai::PlateNum クラスに定義されているすべての関数を示します。表 92: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<PlateNum >

createneed_mean_scale_process

PlateNumvoid

PlateNumvoid

PlateNum & operator=void

~PlateNumvoid

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

PlateNumResult runimg

std::vector<PlateNumResult >

runimages

関数createクラス PlateNum の派生クラスのインスタンスを取得するファクトリ関数。PlateNum クラスのインスタンス。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 129

Page 130: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::unique_ptr< PlateNum > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 93: create の引数

タイプ 名前 説明コメントされたパラメーターneed_mean_scale_process は関数 create に存在しません。

need_mean_scale_process

平均値/スケール値で正規化するかどうか。デフォルト値は true。

PlateNum

プロトタイプ PlateNum();

PlateNum

プロトタイプ PlateNum(const PlateNum &)=delete;

operator=

プロトタイプ

PlateNum & operator=(const PlateNum &)=delete;

~PlateNum

プロトタイプ ~PlateNum();

getInputWidthPlatenum ネットワークの InputWidth を取得する関数 (入力イメージの列)。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 130

Page 131: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプint getInputWidth() const =0;

戻り値platenum ネットワークの InputWidth。

getInputHeightplatenum ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値platenum ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

runplatenum ネットワークの実行結果を取得する関数。

プロトタイプ

PlateNumResult run(const cv::Mat &image)=0;

パラメーター次の表に、run 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 131

Page 132: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 94: run の引数タイプ 名前 説明

コメントされたパラメーター img は関数 run に存在しません。img InputWidth と IntputHeight に合わせてサイズが変更された入力イメージ (cv::Mat) の入力データ。

戻り値プレートの数およびプレートの色。

runバッチ モードの platenum ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< PlateNumResult > run(const std::vector< cv::Mat > &imgs)=0;

パラメーター次の表に、run 関数の引数を示します。表 95: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。入力イメージは、ネットワークで必要な InputWidth および InputHeight に合わせてサイズを変更する必要があります。

戻り値PLateNumResult のベクター。

vitis::ai::PoseDetect入力イメージ (cv::Mat) から姿勢を検出するためのベース クラス。入力はイメージ (cv::Mat)。注記: 単一の姿勢の検出をサポートします。出力は PoseDetectResult 構造体で、14 個の点を含みます。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 132

Page 133: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

サンプル コード:

auto det = vitis::ai::PoseDetect::create("sp_net");auto image = cv::imread("sample_posedetect.jpg");auto results = det->run(image);for(auto result: results.pose14pt) { std::cout << result << std::endl;}

posedetect モデルの結果を次に表示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 133

Page 135: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

関数クイック リファレンス次の表に、vitis::ai::PoseDetect クラスに定義されているすべての関数を示します。表 96: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<PoseDetect >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

PoseDetectResult runconst cv::Mat & image

std::vector<PoseDetectResult>

runconst std::vector< cv::Mat > & images

関数createクラス PoseDetect の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< PoseDetect > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 97: create の引数

タイプ 名前 説明const std::string & model_name モデル名。bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス PoseDetect のインスタンス。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 135

Page 136: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

getInputWidthPoseDetect ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値PoseDetect ネットワークの InputWidth。

getInputHeightPoseDetect ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値PoseDetect ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

runposedetect ニューロン ネットワークの実行結果を取得する関数。

プロトタイプ

PoseDetectResult run(const cv::Mat &image)=0;

パラメーター次の表に、run 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 136

Page 137: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 98: run の引数タイプ 名前 説明

const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値PoseDetectResult。

runバッチ モードの posedetect ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< PoseDetectResult > run(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run 関数の引数を示します。表 99: run の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値PoseDetectResult のベクター。

vitis::ai::RefineDet入力イメージ (cv::Mat) 内の歩行者を検出するためのベース クラス。入力はイメージ (cv::Mat)。出力は、入力イメージ内の歩行者の位置およびスコアです。サンプル コード:

auto det = vitis::ai::RefineDet::create("refinedet_pruned_0_8");auto image = cv::imread("sample_refinedet.jpg");cout << "load image" << endl;if (image.empty()) { cerr << "cannot load " << argv[1] << endl; abort();}

auto results = det->run(image);

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 137

Page 138: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

auto img = image.clone();for (auto &box : results.bboxes) { float x = box.x * (img.cols); float y = box.y * (img.rows); int xmin = x; int ymin = y; int xmax = x + (box.width) * (img.cols); int ymax = y + (box.height) * (img.rows); float score = box.score; xmin = std::min(std::max(xmin, 0), img.cols); xmax = std::min(std::max(xmax, 0), img.cols); ymin = std::min(std::max(ymin, 0), img.rows); ymax = std::min(std::max(ymax, 0), img.rows);

cv::rectangle(img, cv::Point(xmin, ymin), cv::Point(xmax, ymax), cv::Scalar(0, 255, 0), 1, 1, 0);}auto out = "sample_refinedet_result.jpg";LOG(INFO) << "write result to " << out;cv::imwrite(out, img);

モデル結果を次に表示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 138

Page 139: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 33: 結果イメージ

関数クイック リファレンス次の表に、vitis::ai::RefineDet クラスに定義されているすべての関数を示します。表 100: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<RefineDet >

createconst std::string & model_namebool need_preprocess

RefineDetResult runconst cv::Mat & image

std::vector<RefineDetResult>

runimage

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 139

Page 140: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 100: 関数クイック リファレンス (続き)

タイプ 名前 引数int getInputWidth

void

int getInputHeightvoid

size_t get_input_batchvoid

関数createクラス RefineDet の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< RefineDet > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 101: create の引数

タイプ 名前 説明const std::string & model_name

bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス RefineDet のインスタンス。

runRefineDet ニューロン ネットワークの実行結果を取得する関数。

プロトタイプ

RefineDetResult run(const cv::Mat &image)=0;

パラメーター次の表に、run 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 140

Page 141: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 102: run の引数タイプ 名前 説明

const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値RefineDetResult の構造体。

runバッチ モードの RefineDet ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< RefineDetResult > run(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run 関数の引数を示します。表 103: run の引数

タイプ 名前 説明コメントされたパラメーター image は関数 run に存在しません。

image 入力イメージ (cv::Mat) の入力データ。

戻り値RefineDetResult の構造体のベクター。

getInputWidthrefinedet ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値refinedet ネットワークの InputWidth。

getInputHeightrefinedet ネットワークの InputHeight を取得する関数 (入力イメージの行)。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 141

Page 142: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプint getInputHeight() const =0;

戻り値refinedet ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

vitis::ai::RefineDetPostProcessrefinedet ポストプロセスのクラス。プログラムが実行されるたびに計算するのではなく、パラメーターを一度に初期化します。

関数クイック リファレンス次の表に、vitis::ai::RefineDetPostProcess クラスに定義されているすべての関数を示します。表 104: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<RefineDetPostProcess >

createconst std::vector< vitis::ai::library::InputTensor > &input_tensorsconst std::vector< vitis::ai::library::OutputTensor > &output_tensorsconst vitis::ai::proto::DpuModelParam & config

RefineDetResult refine_det_post_processvoid

std::vector<RefineDetResult>

refine_det_post_processvoid

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 142

Page 143: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

関数createRefineDetPostProcess オブジェクトを作成します。

プロトタイプstd::unique_ptr< RefineDetPostProcess > create(const std::vector< vitis::ai::library::InputTensor > &input_tensors, const std::vector< vitis::ai::library::OutputTensor > &output_tensors, const vitis::ai::proto::DpuModelParam &config);

パラメーター次の表に、create 関数の引数を示します。表 105: create の引数

タイプ 名前 説明const std::vector<vitis::ai::library::InputTensor > &

input_tensors ネットワーク内のすべての入力テンソルのベクター。使用法:input_tensors[input_tensor_index]。

const std::vector<vitis::ai::library::OutputTensor > &

output_tensors ネットワーク内のすべての出力テンソルのベクター。使用法:output_tensors[output_index]。

constvitis::ai::proto::DpuModelParam &

config DPU モデルの構成情報。

戻り値一意の RefineDetPostProcess の出力。

refine_det_post_processrefinedet ポストプロセスを実行します。

プロトタイプ

RefineDetResult refine_det_post_process(unsigned int idx)=0;

戻り値RefineDetResult 構造体。

refine_det_post_processバッチ モードで refinedet ポストプロセスを実行します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 143

Page 144: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::vector< RefineDetResult > refine_det_post_process()=0;

戻り値RefineDetResult の構造体のベクター。

vitis::ai::Reidイメージ (cv::Mat) から車線を検出するためのベース クラス。入力はイメージ (cv::Mat)。出力は、車線のタイプと点でマーキングされた車線です。サンプル コード:

注記: 入力イメージ サイズは 640x480。if(argc < 3){ cerr<<"need two images"<<endl; return -1;}Mat imgx = imread(argv[1]);if(imgx.empty()){ cerr<<"can't load image! "<<argv[1]<<endl; return -1;}Mat imgy = imread(argv[2]);if(imgy.empty()){ cerr<<"can't load image! "<<argv[2]<<endl; return -1;}auto det = vitis::ai::Reid::create("reid");Mat featx = det->run(imgx).feat;Mat featy = det->run(imgy).feat;double dismat= cosine_distance(featx, featy);printf("dismat : %.3lf \n", dismat);

関数クイック リファレンス次の表に、vitis::ai::Reid クラスに定義されているすべての関数を示します。表 106: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<Reid >

createconst std::string & model_namebool need_preprocess

ReidResult runconst cv::Mat & image

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 144

Page 145: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 106: 関数クイック リファレンス (続き)

タイプ 名前 引数std::vector<ReidResult >

runimage

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

関数createクラス Reid の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< Reid > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 107: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス Reid のインスタンス。

runreid ニューロン ネットワークの実行結果を取得する関数。

プロトタイプ

ReidResult run(const cv::Mat &image)=0;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 145

Page 146: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

パラメーター次の表に、run 関数の引数を示します。表 108: run の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値ReidResult。

runバッチ モードの reid ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< ReidResult > run(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run 関数の引数を示します。表 109: run の引数

タイプ 名前 説明コメントされたパラメーター image は関数 run に存在しません。

image 入力イメージ (cv::Mat) の入力データ。

戻り値ReidResult のベクター。

getInputWidthreid ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値reid ネットワークの InputWidth。

getInputHeightreid ネットワークの InputHeight を取得する関数 (入力イメージの行)。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 146

Page 147: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプint getInputHeight() const =0;

戻り値reid ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

vitis::ai::RoadLineイメージ (cv::Mat) から車線を検出するためのベース クラス。入力はイメージ (cv::Mat)。出力は、車線のタイプと点でマーキングされた車線です。サンプル コード:

注記: 入力イメージ サイズは 640x480。auto det = vitis::ai::RoadLine::create("vpgnet_pruned_0_99");auto image = cv::imread("sample_lanedetect.jpg");// Mat image;// resize(img, image, Size(640, 480));if (image.empty()) { cerr << "cannot load " << argv[1] << endl; abort();}

vector<int> color1 = {0, 255, 0, 0, 100, 255};vector<int> color2 = {0, 0, 255, 0, 100, 255};vector<int> color3 = {0, 0, 0, 255, 100, 255};

RoadLineResult results = det->run(image);for (auto &line : results.lines) { vector<Point> points_poly = line.points_cluster; // for (auto &p : points_poly) { // std::cout << p.x << " " << (int)p.y << std::endl; //} int type = line.type < 5 ? line.type : 5;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 147

Page 148: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

if (type == 2 && points_poly[0].x < image.rows * 0.5) continue; cv::polylines(image, points_poly, false, Scalar(color1[type], color2[type], color3[type]), 3, CV_AA, 0);}

モデル結果を次に表示します。図 34: 結果イメージ

関数クイック リファレンス次の表に、vitis::ai::RoadLine クラスに定義されているすべての関数を示します。表 110: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<RoadLine >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 148

Page 149: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 110: 関数クイック リファレンス (続き)

タイプ 名前 引数size_t get_input_batch

void

RoadLineResult runconst cv::Mat & image

std::vector<RoadLineResult >

runimages

関数createクラス RoadLine の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< RoadLine > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 111: create の引数

タイプ 名前 説明const std::string & model_name モデル名の文字列bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス RoadLine のインスタンス。

getInputWidthlanedetect ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値lanedetect ネットワークの InputWidth。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 149

Page 150: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

getInputHeightlanedetect ネットワークの InputHeight を取得する関数 (入力イメージの列)。

プロトタイプint getInputHeight() const =0;

戻り値lanedetect ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

runRoadLine ネットワークの実行結果を取得する関数。

プロトタイプ

RoadLineResult run(const cv::Mat &image)=0;

パラメーター次の表に、run 関数の引数を示します。表 112: run の引数

タイプ 名前 説明const cv::Mat & image 入力データ。入力イメージ (cv::Mat) は 640x480 にサイズを変更する必要があります。

戻り値RoadLineResult 構造体

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 150

Page 151: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

runバッチ モードの RoadLine ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< RoadLineResult > run(const std::vector< cv::Mat > &image)=0;

パラメーター次の表に、run 関数の引数を示します。表 113: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されるバッチ サイズと同じです。

戻り値RoadLineResult のベクター。

vitis::ai::RoadLinePostProcessroadline ポストプロセスのクラス。プログラムが実行されるたびに計算するのではなく、パラメーターを一度に初期化します。

関数クイック リファレンス次の表に、vitis::ai::RoadLinePostProcess クラスに定義されているすべての関数を示します。表 114: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<RoadLinePostProcess >

createconst std::vector< vitis::ai::library::InputTensor > &input_tensorsconst std::vector< vitis::ai::library::OutputTensor > &output_tensorsconst vitis::ai::proto::DpuModelParam & config

RoadLineResult road_line_post_processvoid

std::vector<RoadLineResult >

road_line_post_processvoid

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 151

Page 152: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

関数createRoadLinePostProcess オブジェクトを作成します。

プロトタイプstd::unique_ptr< RoadLinePostProcess > create(const std::vector< vitis::ai::library::InputTensor > &input_tensors, const std::vector< vitis::ai::library::OutputTensor > &output_tensors, const vitis::ai::proto::DpuModelParam &config);

パラメーター次の表に、create 関数の引数を示します。表 115: create の引数

タイプ 名前 説明const std::vector<vitis::ai::library::InputTensor > &

input_tensors ネットワーク内のすべての入力テンソルのベクター。使用法:input_tensors[input_tensor_index]。

const std::vector<vitis::ai::library::OutputTensor > &

output_tensors ネットワーク内のすべての出力テンソルのベクター。使用法:output_tensors[output_index]。

constvitis::ai::proto::DpuModelParam &

config DPU モデルの構成情報。

戻り値一意の RoadLinePostProcess の出力。

road_line_post_processroadline ポストプロセスを実行します。

プロトタイプ

RoadLineResult road_line_post_process(int inWidth, int inHeight, unsigned int idx)=0;

戻り値RoadLineResult 構造体。

road_line_post_processバッチ モードで roadline ポストプロセスを実行します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 152

Page 153: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::vector< RoadLineResult > road_line_post_process(const std::vector< int > &inWidth, const std::vector< int > &inHeight)=0;

戻り値RoadLineResult の構造体のベクター。

vitis::ai::SegmentationSegmentation のベース クラス。宣言 Segmentation。segmentation クラスのネットワーク番号。label 0 の名前: "unlabeled" label 1 の名前: "egovehicle" label 2 の名前: "rectification border" label 3 の名前: "out of roi" label 4 の名前: "static" label 5 の名前:"dynamic" label 6 の名前: "ground" label 7 の名前: "road" label 8 の名前: "sidewalk" label 9 の名前: "parking" label 10の名前: "rail track" label 11 の名前: "building" label 12 の名前: "wall" label 13 の名前: "fence" label 14 の名前: "guardrail" label 15 の名前: "bridge" label 16 の名前: "tunnel" label 17 の名前: "pole" 入力はイメージ (cv::Mat)。出力は Segmentation ネットワークの実行の結果です。サンプル コード:

auto det =vitis::ai::Segmentation::create("fpn", true);

auto img= cv::imread("sample_segmentation.jpg"); int width = det->getInputWidth(); int height = det->getInputHeight(); cv::Mat image; cv::resize(img, image, cv::Size(width, height), 0, 0, cv::INTER_LINEAR); auto result = det->run_8UC1(image); for (auto y = 0; y < result.segmentation.rows; y++) { for (auto x = 0; x < result.segmentation.cols; x++) { result.segmentation.at<uchar>(y,x) *= 10; } } cv::imwrite("segres.jpg",result.segmentation);

auto resultshow = det->run_8UC3(image); resize(resultshow.segmentation, resultshow.segmentation,cv::Size(resultshow.cols * 2, resultshow.rows * 2)); cv::imwrite("sample_segmentation_result.jpg",resultshow.segmentation);

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 153

Page 154: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 35: セグメンテーション可視化の結果イメージ

関数クイック リファレンス次の表に、vitis::ai::Segmentation クラスに定義されているすべての関数を示します。表 116: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<Segmentation >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

SegmentationResult

run_8UC1const cv::Mat & image

std::vector<SegmentationResult >

run_8UC1const std::vector< cv::Mat > & images

SegmentationResult

run_8UC3const cv::Mat & image

std::vector<SegmentationResult >

run_8UC3const std::vector< cv::Mat > & images

関数createクラス Segmentation の派生クラスのインスタンスを取得するファクトリ関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 154

Page 155: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::unique_ptr< Segmentation > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 117: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス Segmentation のインスタンス。

getInputWidthsegmentation ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値segmentation ネットワークの InputWidth。

getInputHeightsegmentation ネットワークの InputHeight を取得する関数 (入力イメージの列)。

プロトタイプint getInputHeight() const =0;

戻り値segmentation ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 155

Page 156: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

run_8UC1segmentation ネットワークの実行結果を取得する関数。注記: タイプは結果のセグメンテーションの CV_8UC1。プロトタイプ

SegmentationResult run_8UC1(const cv::Mat &image)=0;

パラメーター次の表に、run_8UC1 関数の引数を示します。表 118: run_8UC1 の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値セグメンテーション出力データを含む結果。

run_8UC1バッチ モードの segmentation ニューロン ネットワークの実行結果を取得する関数。注記: タイプは結果のセグメンテーションの CV_8UC1。プロトタイプstd::vector< SegmentationResult > run_8UC1(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run_8UC1 関数の引数を示します。表 119: run_8UC1 の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 156

Page 157: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値SegmentationResult のベクター。

run_8UC3segmentation ネットワークの実行結果を取得する関数。注記: タイプは結果のセグメンテーションの CV_8UC3。プロトタイプ

SegmentationResult run_8UC3(const cv::Mat &image)=0;

パラメーター次の表に、run_8UC3 関数の引数を示します。表 120: run_8UC3 の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値セグメンテーション イメージと形状を含む結果。

run_8UC3バッチ モードの segmentation ニューロン ネットワークの実行結果を取得する関数。注記: タイプは結果のセグメンテーションの CV_8UC3。プロトタイプstd::vector< SegmentationResult > run_8UC3(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run_8UC3 関数の引数を示します。表 121: run_8UC3 の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値SegmentationResult のベクター。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 157

Page 158: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::Segmentation8UC1Segmentation8UC1 のクラス。このクラスの run 関数はタイプ cv_8UC1 の cv::Mat を返します。次にサンプル コードを示します。 auto det =vitis::ai::Segmentation8UC1::create(vitis::ai::SEGMENTATION_FPN); auto img = cv::imread("sample_segmentation.jpg"); int width = det->getInputWidth(); int height = det->getInputHeight(); cv::Mat image; cv::resize(img, image, cv::Size(width, height), 0, 0, cv::INTER_LINEAR); auto result = det->run(image); for (auto y = 0; y < result.segmentation.rows; y++) { for (auto x = 0; x < result.segmentation.cols; x++) { result.segmentation.at<uchar>(y,x) *= 10; } } cv::imwrite("segres.jpg",result.segmentation);

関数クイック リファレンス次の表に、vitis::ai::Segmentation8UC1 クラスに定義されているすべての関数を示します。表 122: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<Segmentation8UC1>

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

SegmentationResult

runconst cv::Mat & image

std::vector<SegmentationResult >

runconst std::vector< cv::Mat > & images

関数createクラス Segmentation8UC1 の派生クラスのインスタンスを取得するファクトリ関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 158

Page 159: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::unique_ptr< Segmentation8UC1 > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 123: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス Segmentation8UC1 のインスタンス。

getInputWidthsegmentation ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const;

戻り値segmentation ネットワークの InputWidth。

getInputHeightsegmentation ネットワークの InputHeight を取得する関数 (入力イメージの列)。

プロトタイプint getInputHeight() const;

戻り値segmentation ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 159

Page 160: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプsize_t get_input_batch() const;

戻り値バッチ サイズ。

runsegmentation ネットワークの実行結果を取得する関数。注記: 結果 cv::Mat のタイプは CV_8UC1。プロトタイプ

SegmentationResult run(const cv::Mat &image);

パラメーター次の表に、run 関数の引数を示します。表 124: run の引数

タイプ 名前 説明const cv::Mat & image イメージ (cv::Mat) の入力データ。

戻り値segmentation ネットワークの結果の SegmentationResult 構造体。

runバッチ モードの segmentation ニューロン ネットワークの実行結果を取得する関数。注記: タイプは結果のセグメンテーションの CV_8UC1。プロトタイプstd::vector< SegmentationResult > run(const std::vector< cv::Mat > &images);

パラメーター次の表に、run 関数の引数を示します。表 125: run の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 160

Page 161: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値SegmentationResult のベクター。

vitis::ai::Segmentation8UC3Segmentation8UC3 のクラス。このクラスの run 関数はタイプ cv_8UC3 の cv::Mat を返します。サンプル コード:

auto det =vitis::ai::Segmentation8UC3::create(vitis::ai::SEGMENTATION_FPN); auto img = cv::imread("sample_segmentation.jpg");

int width = det->getInputWidth(); int height = det->getInputHeight(); cv::Mat image; cv::resize(img, image, cv::Size(width, height), 0, 0, cv::INTER_LINEAR); auto result = det->run(image); cv::imwrite("segres.jpg",result.segmentation);

関数クイック リファレンス次の表に、vitis::ai::Segmentation8UC3 クラスに定義されているすべての関数を示します。表 126: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<Segmentation8UC3>

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

SegmentationResult

runconst cv::Mat & image

std::vector<SegmentationResult >

runconst std::vector< cv::Mat > & images

関数createクラス Segmentation8UC3 の派生クラスのインスタンスを取得するファクトリ関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 161

Page 162: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::unique_ptr< Segmentation8UC3 > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 127: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス Segmentation8UC3 のインスタンス。

getInputWidthsegmentation ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const;

戻り値segmentation ネットワークの InputWidth。

getInputHeightsegmentation ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputHeight() const;

戻り値segmentation ネットワークの InputWidth。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 162

Page 163: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプsize_t get_input_batch() const;

戻り値バッチ サイズ。

runsegmentation ネットワークの実行結果を取得する関数。注記: 結果 cv::Mat のタイプは CV_8UC3。プロトタイプ

SegmentationResult run(const cv::Mat &image);

パラメーター次の表に、run 関数の引数を示します。表 128: run の引数

タイプ 名前 説明const cv::Mat & image イメージ (cv::Mat) の入力データ。

戻り値SegmentationResult (segmentation ネットワークの結果)。

runバッチ モードの segmentation ニューロン ネットワークの実行結果を取得する関数。注記: タイプは結果のセグメンテーションの CV_8UC3。プロトタイプstd::vector< SegmentationResult > run(const std::vector< cv::Mat > &images);

パラメーター次の表に、run 関数の引数を示します。表 129: run の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 163

Page 164: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値SegmentationResult のベクター。

vitis::ai::SSD車両、歩行者などの位置を検出するためのベース クラス。入力はイメージ (cv:Mat)。出力は、SSDResult という名前の検出結果の構造体です。サンプル コード:

Mat img = cv::imread("sample_ssd.jpg"); auto ssd = vitis::ai::SSD::create("ssd_traffic_pruned_0_9",true); auto results = ssd->run(img); for(const auto &r : results.bboxes){ auto label = r.label; auto x = r.x * img.cols; auto y = r.y * img.rows; auto width = r.width * img.cols; auto heigth = r.height * img.rows; auto score = r.score; std::cout << "RESULT: " << label << "\t" << x << "\t" << y << "\t" <<width << "\t" << height << "\t" << score << std::endl; }

モデル結果を次に表示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 164

Page 165: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

図 36: 検出結果

関数クイック リファレンス次の表に、vitis::ai::SSD クラスに定義されているすべての関数を示します。表 130: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<SSD >

createconst std::string & model_namebool need_preprocess

vitis::ai::SSDResult

runconst cv::Mat & image

std::vector<vitis::ai::SSDResult >

runconst std::vector< cv::Mat > & images

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 165

Page 166: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

関数createクラス SSD の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< SSD > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 131: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス SSD のインスタンス。

runSSD ニューロン ネットワークの実行結果を取得する関数。

プロトタイプ

vitis::ai::SSDResult run(const cv::Mat &image)=0;

パラメーター次の表に、run 関数の引数を示します。表 132: run の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値SSDResult。

runバッチ モードの SSD ニューロン ネットワークの実行結果を取得する関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 166

Page 167: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::vector< vitis::ai::SSDResult > run(const std::vector< cv::Mat > &images)=0;

パラメーター次の表に、run 関数の引数を示します。表 133: run の引数

タイプ 名前 説明const std::vector< cv::Mat> &

images 入力イメージ (vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されるバッチ サイズと同じです。

戻り値SSDResult のベクター。

getInputWidthSSD ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値SSD ネットワークの InputWidth。

getInputHeightSSD ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値SSD ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 167

Page 168: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

vitis::ai::SSDPostProcessssd ポストプロセスのクラス。プログラムが実行されるたびに計算するのではなく、パラメーターを一度に初期化します。

関数クイック リファレンス次の表に、vitis::ai::SSDPostProcess クラスに定義されているすべての関数を示します。表 134: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<SSDPostProcess >

createconst std::vector< vitis::ai::library::InputTensor > &input_tensorsconst std::vector< vitis::ai::library::OutputTensor > &output_tensorsconst vitis::ai::proto::DpuModelParam & config

std::vector<SSDResult >

ssd_post_processvoid

関数createSSDPostProcess オブジェクトを作成します。

プロトタイプstd::unique_ptr< SSDPostProcess > create(const std::vector< vitis::ai::library::InputTensor > &input_tensors, const std::vector< vitis::ai::library::OutputTensor > &output_tensors, const vitis::ai::proto::DpuModelParam &config);

パラメーター次の表に、create 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 168

Page 169: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 135: create の引数タイプ 名前 説明

const std::vector<vitis::ai::library::InputTensor > &

input_tensors ネットワーク内のすべての入力テンソルのベクター。使用法:input_tensors[input_tensor_index]。

const std::vector<vitis::ai::library::OutputTensor > &

output_tensors ネットワーク内のすべての出力テンソルのベクター。使用法:output_tensors[output_index]。

constvitis::ai::proto::DpuModelParam &

config DPU モデルの構成情報。

戻り値一意の SSDPostProcess の出力。

ssd_post_processssd ネットワークのバッチ モード ポストプロセス関数。

プロトタイプstd::vector< SSDResult > ssd_post_process(size_t batch_size)=0;

戻り値SSDResult の構造体のベクター。

vitis::ai::TFSSDCOCO データセットの 90 個のオブジェクトを検出するためのベース クラス。入力はイメージ (cv:Mat)。出力は、TFSSDResult という名前の検出結果の構造体です。サンプル コード:

Mat img = cv::imread("sample_tfssd.jpg"); auto tfssd = vitis::ai::TFSSD::create("ssd_resnet_50_fpn_coco_tf",true); auto results = tfssd->run(img); for(const auto &r : results.bboxes){ auto label = r.label; auto x = r.x * img.cols; auto y = r.y * img.rows; auto width = r.width * img.cols; auto heigth = r.height * img.rows;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 169

Page 170: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

auto score = r.score; std::cout << "RESULT: " << label << "\t" << x << "\t" << y << "\t" <<width << "\t" << height << "\t" << score << std::endl; }

モデル結果を次に表示します。図 37: 検出結果

関数クイック リファレンス次の表に、vitis::ai::TFSSD クラスに定義されているすべての関数を示します。表 136: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<TFSSD >

createconst std::string & model_namebool need_preprocess

vitis::ai::TFSSDResult

runconst cv::Mat & img

std::vector<vitis::ai::TFSSDResult >

runimages

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 170

Page 171: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

関数createクラス SSD の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< TFSSD > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 137: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス SSD のインスタンス。

runssd ニューロン ネットワークの結果を取得する関数。

プロトタイプ

vitis::ai::TFSSDResult run(const cv::Mat &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 138: run の引数

タイプ 名前 説明const cv::Mat & img 入力イメージ (cv::Mat) の入力データ。

戻り値TFSSDResult。

runバッチ モードの SSD ニューロン ネットワークの実行結果を取得する関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 171

Page 172: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::vector< vitis::ai::TFSSDResult > run(const std::vector< cv::Mat > &img)=0;

パラメーター次の表に、run 関数の引数を示します。表 139: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されるバッチ サイズと同じです。

戻り値TFSSDResult のベクター。

getInputWidthSSD ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値SSD ネットワークの InputWidth。

getInputHeightSSD ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値SSD ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 172

Page 173: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

vitis::ai::TFSSDPostProcessssd ポストプロセスのクラス。プログラムが実行されるたびに計算するのではなく、パラメーターを一度に初期化します。

関数クイック リファレンス次の表に、vitis::ai::TFSSDPostProcess クラスに定義されているすべての関数を示します。表 140: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<TFSSDPostProcess>

createconst std::vector< vitis::ai::library::InputTensor > &input_tensorsconst std::vector< vitis::ai::library::OutputTensor > &output_tensorsconst vitis::ai::proto::DpuModelParam & config

TFSSDResult ssd_post_processvoid

std::vector<TFSSDResult >

ssd_post_processvoid

関数createTFSSDPostProcess オブジェクトを作成します。

プロトタイプstd::unique_ptr< TFSSDPostProcess > create(const std::vector< vitis::ai::library::InputTensor > &input_tensors, const std::vector< vitis::ai::library::OutputTensor > &output_tensors, const vitis::ai::proto::DpuModelParam &config, const std::string &dirname);

パラメーター次の表に、create 関数の引数を示します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 173

Page 174: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 141: create の引数タイプ 名前 説明

const std::vector<vitis::ai::library::InputTensor > &

input_tensors ネットワーク内のすべての入力テンソルのベクター。使用法:input_tensors[input_tensor_index]。

const std::vector<vitis::ai::library::OutputTensor > &

output_tensors ネットワーク内のすべての出力テンソルのベクター。使用法:output_tensors[output_index]。

constvitis::ai::proto::DpuModelParam &

config DPU モデルの構成情報。

戻り値一意の TFSSDPostProcess の出力。

ssd_post_processssd ネットワークのポストプロセス関数。

プロトタイプ

TFSSDResult ssd_post_process(unsigned int idx)=0;

戻り値TFSSDResult 構造体。

ssd_post_processssd ネットワークのバッチ モード ポストプロセス関数。

プロトタイプstd::vector< TFSSDResult > ssd_post_process()=0;

戻り値TFSSDResult の構造体のベクター。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 174

Page 175: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::YOLOv2入力イメージ (cv::Mat) 内の物体を検出するためのベース クラス。入力はイメージ (cv::Mat)。出力は、入力イメージ内の物体の位置です。サンプル コード:

auto img = cv::imread("sample_yolov2.jpg"); auto model = vitis::ai::YOLOv2::create("yolov2_voc"); auto result = model->run(img); for (const auto &bbox : result.bboxes) { int label = bbox.label; float xmin = bbox.x * img.cols + 1; float ymin = bbox.y * img.rows + 1; float xmax = xmin + bbox.width * img.cols; float ymax = ymin + bbox.height * img.rows; if (xmax > img.cols) xmax = img.cols; if (ymax > img.rows) ymax = img.rows; float confidence = bbox.score;

cout << "RESULT: " << label << "\t" << xmin << "\t" << ymin << "\t" << xmax << "\t" << ymax << "\t" << confidence << "\n"; rectangle(img, Point(xmin, ymin), Point(xmax, ymax), Scalar(0, 255, 0), 1, 1, 0);}

関数クイック リファレンス次の表に、vitis::ai::YOLOv2 クラスに定義されているすべての関数を示します。表 142: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<YOLOv2 >

createconst std::string & model_namebool need_preprocess

YOLOv2Result runconst cv::Mat & image

std::vector<YOLOv2Result >

runimages

int getInputWidthvoid

int getInputHeightvoid

size_t get_input_batchvoid

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 175

Page 176: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

関数createクラス YOLOv2 の派生クラスのインスタンスを取得するファクトリ関数。

プロトタイプstd::unique_ptr< YOLOv2 > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 143: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス YOLOv2 のインスタンス。

runYOLOv2 ニューロン ネットワークの実行結果を取得する関数。

プロトタイプ

YOLOv2Result run(const cv::Mat &image)=0;

パラメーター次の表に、run 関数の引数を示します。表 144: run の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値YOLOv2Result の構造体。

runバッチ モードの YOLOv2 ニューロン ネットワークの実行結果を取得する関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 176

Page 177: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::vector< YOLOv2Result > run(const std::vector< cv::Mat > &image)=0;

パラメーター次の表に、run 関数の引数を示します。表 145: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値YOLOv2Result のベクター。

getInputWidthYOLOv2 ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値YOLOv2 ネットワークの InputWidth

getInputHeightYOLOv2 ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値YOLOv2 ネットワークの InputHeight。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 177

Page 178: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプsize_t get_input_batch() const =0;

戻り値バッチ サイズ。

vitis::ai::YOLOv3入力イメージ (cv::Mat) 内の物体を検出するためのベース クラス。入力はイメージ (cv::Mat)。出力は、入力イメージ内の歩行者の位置です。サンプル コード:

auto yolo =vitis::ai::YOLOv3::create("yolov3_adas_pruned_0_9", true); Mat img = cv::imread("sample_yolov3.jpg");

auto results = yolo->run(img);

for(auto &box : results.bboxes){ int label = box.label; float xmin = box.x * img.cols + 1; float ymin = box.y * img.rows + 1; float xmax = xmin + box.width * img.cols; float ymax = ymin + box.height * img.rows; if(xmin < 0.) xmin = 1.; if(ymin < 0.) ymin = 1.; if(xmax > img.cols) xmax = img.cols; if(ymax > img.rows) ymax = img.rows; float confidence = box.score;

cout << "RESULT: " << label << "\t" << xmin << "\t" << ymin << "\t" << xmax << "\t" << ymax << "\t" << confidence << "\n"; if (label == 0) { rectangle(img, Point(xmin, ymin), Point(xmax, ymax), Scalar(0, 255, 0), 1, 1, 0); } else if (label == 1) { rectangle(img, Point(xmin, ymin), Point(xmax, ymax), Scalar(255, 0, 0), 1, 1, 0); } else if (label == 2) { rectangle(img, Point(xmin, ymin), Point(xmax, ymax), Scalar(0, 0, 255), 1, 1, 0); } else if (label == 3) { rectangle(img, Point(xmin, ymin), Point(xmax, ymax), Scalar(0, 255, 255), 1, 1, 0); }

} imwrite("sample_yolov3_result.jpg", img);

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 178

Page 179: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

モデル結果を次に表示します。図 38: 出力イメージ

関数クイック リファレンス次の表に、vitis::ai::YOLOv3 クラスに定義されているすべての関数を示します。表 146: 関数クイック リファレンス

タイプ 名前 引数std::unique_ptr<YOLOv3 >

createconst std::string & model_namebool need_preprocess

int getInputWidthvoid

int getInputHeightvoid

YOLOv3Result runconst cv::Mat & image

std::vector<YOLOv3Result >

runimages

size_t get_input_batchvoid

関数createクラス YOLOv3 の派生クラスのインスタンスを取得するファクトリ関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 179

Page 180: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプstd::unique_ptr< YOLOv3 > create(const std::string &model_name, bool need_preprocess=true);

パラメーター次の表に、create 関数の引数を示します。表 147: create の引数

タイプ 名前 説明const std::string & model_name モデル名bool need_preprocess 平均値/スケール値で正規化するかどうか。デフォルト値は true。

戻り値クラス YOLOv3 のインスタンス。

getInputWidthYOLOv3 ネットワークの InputWidth を取得する関数 (入力イメージの列)。

プロトタイプint getInputWidth() const =0;

戻り値YOLOv3 ネットワークの InputWidth

getInputHeightYOLOv3 ネットワークの InputHeight を取得する関数 (入力イメージの行)。

プロトタイプint getInputHeight() const =0;

戻り値YOLOv3 ネットワークの InputHeight。

runYOLOv3 ニューロン ネットワークの実行結果を取得する関数。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 180

Page 181: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

プロトタイプ

YOLOv3Result run(const cv::Mat &image)=0;

パラメーター次の表に、run 関数の引数を示します。表 148: run の引数

タイプ 名前 説明const cv::Mat & image 入力イメージ (cv::Mat) の入力データ。

戻り値YOLOv3Result。

runバッチ モードの YOLOv3 ニューロン ネットワークの実行結果を取得する関数。

プロトタイプstd::vector< YOLOv3Result > run(const std::vector< cv::Mat > &image)=0;

パラメーター次の表に、run 関数の引数を示します。表 149: run の引数

タイプ 名前 説明コメントされたパラメーター images は関数 run に存在しません。

images 入力イメージ (std:vector<cv::Mat>) の入力データ。入力イメージのサイズは、get_input_batch で取得されたバッチ サイズと同じ。

戻り値YOLOv3Result のベクター。

get_input_batchDPU で一度に処理される画像の数を取得する関数。注記: DPU コアによってはバッチ サイズが異なる場合があります。これは使用する IP に依存します。プロトタイプsize_t get_input_batch() const =0;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 181

Page 182: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

戻り値バッチ サイズ。

データ構造索引次に、データ構造の一覧を示します。• vitis::ai::ClassificationResult

• vitis::ai::ClassificationResult::Score

• vitis::ai::FaceDetectResult

• vitis::ai::FaceDetectResult::BoundingBox

• vitis::ai::FaceFeatureFixedResult

• vitis::ai::FaceFeatureFloatResult

• vitis::ai::FaceLandmarkResult

• vitis::ai::MedicalSegmentationResult

• vitis::ai::MultiTaskResult

• vitis::ai::OpenPoseResult

• vitis::ai::OpenPoseResult::PosePoint

• vitis::ai::PlateDetectResult

• vitis::ai::PlateDetectResult::BoundingBox

• vitis::ai::PlateDetectResult::Point

• vitis::ai::PlateNumResult

• vitis::ai::PoseDetectResult

• vitis::ai::PoseDetectResult::Pose14Pt

• vitis::ai::RefineDetResult

• vitis::ai::RefineDetResult::BoundingBox

• vitis::ai::ReidResult

• vitis::ai::RoadLineResult

• vitis::ai::RoadLineResult::Line

• vitis::ai::SSDResult

• vitis::ai::SSDResult::BoundingBox

• vitis::ai::SegmentationResult

• vitis::ai::TFSSDResult

• vitis::ai::TFSSDResult::BoundingBox

• vitis::ai::VehicleResult

• vitis::ai::YOLOv2Result

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 182

Page 183: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

• vitis::ai::YOLOv2Result::BoundingBox

• vitis::ai::YOLOv3Result

• vitis::ai::YOLOv3Result::BoundingBox

vitis::ai::ClassificationResultclassification ネットワークの結果の構造体。宣言typedef struct{ int width, int height, std::vector< Score > scores} vitis::ai::ClassificationResult;

表 150: 構造体 vitis::ai::ClassificationResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。scores 信頼度が上位 k (デフォルトは 5) の物体のベクター。k の値はモデル コンフィギュレーション ファイルで変更できます。

vitis::ai::ClassificationResult::Score物体のインデックスおよび信頼度の構造体。宣言typedef struct{ int index, float score} vitis::ai::ClassificationResult::Score;

表 151: 構造体 vitis::ai::ClassificationResult::Score のメンバーの説明メンバー 説明

index 結果の ImageNet インデックス。score このカテゴリであることの信頼度。

vitis::ai::FaceDetectResultfacedetect ネットワークの結果の構造体。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 183

Page 184: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

宣言typedef struct{ int width, int height, std::vector< BoundingBox > rects} vitis::ai::FaceDetectResult;

表 152: 構造体 vitis::ai::FaceDetectResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。rects すべての顔 (信頼度が検出しきい値以上のもの)。

vitis::ai::FaceDetectResult::BoundingBox顔の座標と信頼度。宣言typedef struct{ float x, float y, float width, float height, float score} vitis::ai::FaceDetectResult::BoundingBox;

表 153: 構造体 vitis::ai::FaceDetectResult::BoundingBox のメンバーの説明メンバー 説明

x x 座標。x は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1です。y y 座標。y は入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1です。width 顔の幅。幅は入力イメージの列を基準に正規化されており、値の範囲は 0 ~

1 です。height 顔の高さ。高さは入力イメージの行を基準に正規化されており、値の範囲は

0 ~ 1 です。score 顔の信頼度。範囲は 0 ~ 1 です。

vitis::ai::FaceFeatureFixedResultFaceFeature の結果は、512 次元のベクター、固定小数点の値です。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 184

Page 185: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

宣言typedef struct{ std::array< int8_t, 512 > vector_t int width, int height, float scale std::unique_ptr< vector_t > feature,

} vitis::ai::FaceFeatureFixedResult;

表 154: 構造体 vitis::ai::FaceFeatureFixedResult のメンバーの説明メンバー 説明

vector_t 512 次元のベクター、固定小数点形式。width 入力イメージの幅。height 入力イメージの高さ。scale 固定小数点。feature

vitis::ai::FaceFeatureFloatResultFaceFeature の結果は、512 次元のベクター、浮動小数点の値です。宣言typedef struct{ std::array< float, 512 > vector_t int width, int height std::unique_ptr< vector_t > feature,

} vitis::ai::FaceFeatureFloatResult;

表 155: 構造体 vitis::ai::FaceFeatureFloatResult のメンバーの説明メンバー 説明

vector_t 512 次元のベクター。width 入力イメージの幅。height 入力イメージの高さ。feature

vitis::ai::FaceLandmarkResultfacelandmark ネットワークによって返された結果の構造体。宣言typedef struct{ std::array< std::pair< float, float >, 5 > points} vitis::ai::FaceLandmarkResult;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 185

Page 186: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 156: 構造体 vitis::ai::FaceLandmarkResult のメンバーの説明メンバー 説明

points 5 個の特徴点の座標。この <x,y> の配列には 5 個の要素があります。x/y はwidth/height を基準に正規化され、値の範囲は 0 ~ 1 です。

vitis::ai::MedicalSegmentationResultssd ニューロン ネットワークによって返された結果の構造体。宣言typedef struct{ int width, int height, std::vector< cv::Mat > segmentation} vitis::ai::MedicalSegmentationResult;

表 157: 構造体 vitis::ai::MedicalSegmentationResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。segmentation

vitis::ai::MultiTaskResultMultiTask ネットワークによって返された結果の構造体 (可視化が必要な場合に使用)。宣言typedef struct{ int width, int height, std::vector< VehicleResult > vehicle, cv::Mat segmentation} vitis::ai::MultiTaskResult;

表 158: 構造体 vitis::ai::MultiTaskResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。vehicle SSD タスクの検出結果。segmentation 可視化のための Segmentation 結果。cv::Mat タイプは CV_8UC1 または

CV_8UC3。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 186

Page 187: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::OpenPoseResultopenpose ネットワークの結果。宣言typedef struct{ int width, int height, std::vector< std::vector< PosePoint > > poses} vitis::ai::OpenPoseResult;

表 159: 構造体 vitis::ai::OpenPoseResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。poses 姿勢のベクター。姿勢は PosePoint のベクターで表されます。関節点の順番は次のとおりです。0: head、1: neck、2: L_shoulder、3: L_elbow、4:

L_wrist、5: R_shoulder、6: R_elbow、7: R_wrist、8: L_hip、9: L_knee、10:L_ankle、11: R_hip、12: R_knee、13: R_ankle

vitis::ai::OpenPoseResult::PosePoint座標点および点タイプの構造体。宣言typedef struct{ int type, cv::Point2f point} vitis::ai::OpenPoseResult::PosePoint;

表 160: 構造体 vitis::ai::OpenPoseResult::PosePoint のメンバーの説明メンバー 説明

type 点タイプ。• 1: "valid"

• 3: "invalid"

point 座標点。

vitis::ai::PlateDetectResultplatedetect ネットワークによって返された結果の構造体。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 187

Page 188: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

宣言typedef struct{ int width, int height, BoundingBox box, Point top_left, Point top_right, Point bottom_left, Point bottom_right} vitis::ai::PlateDetectResult;

表 161: 構造体 vitis::ai::PlateDetectResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。box プレートの位置。top_left 左上の点。top_right 右上の点。bottom_left 左下の点。bottom_right 右下の点。

vitis::ai::PlateDetectResult::BoundingBox宣言typedef struct{ float score, float x, float y, float width, float height} vitis::ai::PlateDetectResult::BoundingBox;

表 162: 構造体 vitis::ai::PlateDetectResult::BoundingBox のメンバーの説明メンバー 説明

score プレートの信頼度。範囲は 0 ~ 1 です。x プレートの x 座標。x は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1 です。y プレートの y 座標。y は入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1 です。width プレートの幅。幅は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1 です。height プレートの高さ。高さは入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1 です。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 188

Page 189: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::PlateDetectResult::Pointプレートの座標点宣言typedef struct{ float x, float y} vitis::ai::PlateDetectResult::Point;

表 163: 構造体 vitis::ai::PlateDetectResult::Point のメンバーの説明メンバー 説明

x x 座標。範囲は 0 ~ 1 です。y y 座標。範囲は 0 ~ 1 です。

vitis::ai::PlateNumResultplatenum ネットワークの結果の構造体。宣言typedef struct{ int width, int height, std::string plate_number, std::string plate_color} vitis::ai::PlateNumResult;

表 164: 構造体 vitis::ai::PlateNumResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。plate_number プレートの番号。plate_color プレートの色、青色/黄色。

vitis::ai::PoseDetectResultposedetect ネットワークによって返された結果の構造体。宣言typedef struct{ cv::Point2f Point int width, int height Pose14Pt pose14pt,

} vitis::ai::PoseDetectResult;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 189

Page 190: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 165: 構造体 vitis::ai::PoseDetectResult のメンバーの説明メンバー 説明

Point 座標点。width 入力イメージの幅。height 入力イメージの高さ。pose14pt 入力イメージの姿勢。

vitis::ai::PoseDetectResult::Pose14Pt14 個の座標点で表される姿勢。宣言typedef struct{ Point right_shoulder, Point right_elbow, Point right_wrist, Point left_shoulder, Point left_elbow, Point left_wrist, Point right_hip, Point right_knee, Point right_ankle, Point left_hip, Point left_knee, Point left_ankle, Point head, Point neck} vitis::ai::PoseDetectResult::Pose14Pt;

表 166: 構造体 vitis::ai::PoseDetectResult::Pose14Pt のメンバーの説明メンバー 説明

right_shoulder R_shoulder の座標。right_elbow R_elbow の座標。right_wrist R_wrist の座標。left_shoulder L_shoulder の座標。left_elbow L_elbow の座標。left_wrist L_wrist の座標。right_hip R_hip の座標。right_knee R_knee の座標。right_ankle R_ankle の座標。left_hip L_hip の座標。left_knee L_knee の座標。left_ankle L_ankle の座標。head head の座標。neck neck の座標。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 190

Page 191: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

vitis::ai::RefineDetResultrefinedet ネットワークの結果の構造体。宣言typedef struct{ int width, int height, std::vector< BoundingBox > bboxes} vitis::ai::RefineDetResult;

表 167: 構造体 vitis::ai::RefineDetResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。bboxes BoundingBox のベクター。

vitis::ai::RefineDetResult::BoundingBox物体の座標および信頼度の構造体。宣言typedef struct{ float x, float y, float width, float height, float score} vitis::ai::RefineDetResult::BoundingBox;

表 168: 構造体 vitis::ai::RefineDetResult::BoundingBox のメンバーの説明メンバー 説明

x x 座標。x は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1です。y y 座標。y は入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1です。width 身体の幅。幅は入力イメージの列を基準に正規化されており、値の範囲は 0~ 1 です。height 身体の高さ。高さは入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1 です。score 身体検出の信頼度。範囲は 0 ~ 1 です。

vitis::ai::ReidResultreid ネットワークの結果。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 191

Page 192: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

宣言typedef struct{ int width, int height, cv::Mat feat} vitis::ai::ReidResult;

表 169: 構造体 vitis::ai::ReidResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。feat 入力イメージの特徴点。

vitis::ai::RoadLineResultroadline ネットワークによって返された結果の構造体。宣言typedef struct{ int width, int height, std::vector< Line > lines} vitis::ai::RoadLineResult;

表 170: 構造体 vitis::ai::RoadLineResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。lines 車線のベクター。

vitis::ai::RoadLineResult::Lineroadline ネットワークによって返された結果の構造体。宣言typedef struct{ int type, std::vector< cv::Point > points_cluster} vitis::ai::RoadLineResult::Line;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 192

Page 193: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 171: 構造体 vitis::ai::RoadLineResult::Line のメンバーの説明メンバー 説明

type 車線タイプ。範囲は 0 ~ 3 です。• 0: 背景• 1: 白点線• 2: 白実線• 3: 黄色の線

points_cluster 点クラスター。これらで線を形成します。

vitis::ai::SegmentationResultsegementation ネットワークによって返された結果の構造体。セグメンテーション クラスの FPN 番号• 0: "unlabeled"

• 1: "ego vehicle"

• 2: "rectification border"

• 3: "out of roi"

• 4: "static"

• 5: "dynamic"

• 6: "ground"

• 7: "road"

• 8: "sidewalk"

• 9: "parking"

• 10: "rail track"

• 11: "building"

• 12: "wall"

• 13: "fence"

• 14: "guard rail"

• 15: "bridge"

• 16: "tunnel"

• 17: "pole"

• 18: "polegroup"

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 193

Page 194: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

宣言typedef struct{ int width, int height, cv::Mat segmentation} vitis::ai::SegmentationResult;

表 172: 構造体 vitis::ai::SegmentationResult のメンバーの説明メンバー 説明

width

height

segmentation

vitis::ai::SSDResultssd ニューロン ネットワークによって返された結果の構造体。宣言typedef struct{ int width, int height, std::vector< BoundingBox > bboxes} vitis::ai::SSDResult;

表 173: 構造体 vitis::ai::SSDResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。bboxes すべての物体。BoundingBox のベクター。

vitis::ai::SSDResult::BoundingBox物体の座標、信頼度、分類の構造体。宣言typedef struct{ int label, float score, float x, float y, float width, float height} vitis::ai::SSDResult::BoundingBox;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 194

Page 195: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 174: 構造体 vitis::ai::SSDResult::BoundingBox のメンバーの説明メンバー 説明

label Classification。score 信頼度。x x 座標。x は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1です。y y 座標。y は入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1です。width 幅。幅は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1 です。height 高さ。高さは入力イメージの行を基準に正規化されており、値の範囲は 0 ~

1 です。

vitis::ai::TFSSDResultssd ニューロン ネットワークによって返された結果の構造体。宣言typedef struct{ int width, int height, std::vector< BoundingBox > bboxes} vitis::ai::TFSSDResult;

表 175: 構造体 vitis::ai::TFSSDResult のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。bboxes すべての物体。BoundingBox のベクター。

vitis::ai::TFSSDResult::BoundingBox物体の座標、信頼度、分類の構造体。宣言typedef struct{ int label, float score, float x, float y, float width, float height} vitis::ai::TFSSDResult::BoundingBox;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 195

Page 196: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 176: 構造体 vitis::ai::TFSSDResult::BoundingBox のメンバーの説明メンバー 説明

label Classification。score 信頼度。x x 座標。x は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1です。y y 座標。y は入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1です。width 幅。幅は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1 です。height 高さ。高さは入力イメージの行を基準に正規化されており、値の範囲は 0 ~

1 です。

vitis::ai::VehicleResultMultiTask の検出結果を定義するための構造体。宣言typedef struct{ int label, float score, float x, float y, float width, float height, float angle} vitis::ai::VehicleResult;

表 177: 構造体 vitis::ai::VehicleResult のメンバーの説明メンバー 説明

label クラスの番号。• 0: "background"

• 1: "person"

• 2: "car"

• 3: "truck"

• 4: "bus"

• 5: "bike"

• 6: "sign"

• 7: "light"

score このターゲットの信頼度x x 座標。x は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1です。y y 座標。y は入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1です。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 196

Page 197: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 177: 構造体 vitis::ai::VehicleResult のメンバーの説明 (続き)

メンバー 説明width 幅。幅は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1 です。height 高さ。高さは入力イメージの行を基準に正規化されており、値の範囲は 0 ~

1 です。angle ターゲット車両と自分自身の間の角度。

vitis::ai::YOLOv2Result@brie yolov2 ネットワークによって返された結果の構造体。宣言typedef struct{ int width, int height, std::vector< BoundingBox > bboxes} vitis::ai::YOLOv2Result;

表 178: 構造体 vitis::ai::YOLOv2Result のメンバーの説明メンバー 説明

width 入力イメージの幅。height 入力イメージの高さ。bboxes すべての物体。

vitis::ai::YOLOv2Result::BoundingBox物体の座標、信頼度、分類の構造体。宣言typedef struct{ int label, float score, float x, float y, float width, float height} vitis::ai::YOLOv2Result::BoundingBox;

表 179: 構造体 vitis::ai::YOLOv2Result::BoundingBox のメンバーの説明メンバー 説明

label 分類。score 信頼度。範囲は 0 ~ 1 です。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 197

Page 198: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 179: 構造体 vitis::ai::YOLOv2Result::BoundingBox のメンバーの説明 (続き)

メンバー 説明x x 座標。x は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1です。y y 座標。y は入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1です。width 幅。幅は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1 です。height 高さ。高さは入力イメージの行を基準に正規化されており、値の範囲は 0 ~

1 です。

vitis::ai::YOLOv3Resultyolov3 ニューロン ネットワークによって返された結果の構造体。注記: VOC データセット カテゴリ:string label[20] = {"aeroplane", "bicycle", "bird", "boat", "bottle", "bus","car", "cat","chair", "cow", "diningtable", "dog", "horse", "motorbike","person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"};

注記: ADAS データセット カテゴリ: string label[3] = {"car", "person", "cycle"};

宣言typedef struct{ int width, int height, std::vector< BoundingBox > bboxes} vitis::ai::YOLOv3Result;

表 180: 構造体 vitis::ai::YOLOv3Result のメンバーの説明メンバー 説明

width 入力イメージの幅。height 出力イメージの高さ。bboxes すべての物体。BoundingBox のベクター。

vitis::ai::YOLOv3Result::BoundingBox@Brief 物体の検出結果の構造体宣言typedef struct{ int label, float score, float x, float y, float width, float height} vitis::ai::YOLOv3Result::BoundingBox;

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 198

Page 199: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

表 181: 構造体 vitis::ai::YOLOv3Result::BoundingBox のメンバーの説明メンバー 説明

label 分類。score 信頼度。範囲は 0 ~ 1 です。x x 座標。x は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1です。y y 座標。y は入力イメージの行を基準に正規化されており、値の範囲は 0 ~ 1です。width 幅。幅は入力イメージの列を基準に正規化されており、値の範囲は 0 ~ 1 です。height 高さ。高さは入力イメージの行を基準に正規化されており、値の範囲は 0 ~

1 です。

付録 A: API リファレンス

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 199

Page 200: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

付録 B

その他のリソースおよび法的通知

ザイリンクス リソースアンサー、資料、ダウンロード、フォーラムなどのサポート リソースは、ザイリンクス サポート サイトを参照してください。

Documentation Navigator およびデザイン ハブザイリンクス Documentation Navigator (DocNav) では、ザイリンクスの資料、ビデオ、サポート リソースにアクセスでき、特定の情報を取得するためにフィルター機能や検索機能を利用できます。DocNav を開くには、次のいずれかを実行します。• Vivado® IDE で [Help] → [Documentation and Tutorials] をクリックします。• Windows で [スタート] → [すべてのプログラム ] → [Xilinx Design Tools] → [DocNav] をクリックします。• Linux コマンド プロンプトに「docnav」と入力します。ザイリンクス デザイン ハブには、資料やビデオへのリンクがデザイン タスクおよびトピックごとにまとめられており、これらを参照することでキー コンセプトを学び、よくある質問 (FAQ) を参考に問題を解決できます。デザイン ハブにアクセスするには、次のいずれかを実行します。• DocNav で [Design Hub View] タブをクリックします。• ザイリンクス ウェブサイトでデザイン ハブ ページを参照します。注記: DocNav の詳細は、ザイリンクス ウェブサイトの Documentation Navigator ページを参照してください。DocNav からは、日本語版は参照できません。ウェブサイトのデザイン ハブ ページをご利用ください。

お読みください: 重要な法的通知本通知に基づいて貴殿または貴社 (本通知の被通知者が個人の場合には「貴殿」、法人その他の団体の場合には「貴社」。以下同じ) に開示される情報 (以下「本情報」といいます) は、ザイリンクスの製品を選択および使用することのためにのみ提供されます。適用される法律が許容する最大限の範囲で、(1) 本情報は「現状有姿」、およびすべて受領者の責任で (with all faults) という状態で提供され、ザイリンクスは、本通知をもって、明示、黙示、法定を問わず (商品性、非侵害、特定目的適合性の保証を含みますがこれらに限られません)、すべての保証および条件を負わない (否認する) ものとします。また、(2) ザイリンクスは、本情報 (貴殿または貴社による本情報の使用を含む) に関係し、起

付録 B: その他のリソースおよび法的通知

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 200

Page 201: Vitis AI Library User Guide...• Chapter 1 is an introduction to the AI Library. This chapter provides a clear understanding of the AI Library in general, its framework, supported

因し、関連する、いかなる種類・性質の損失または損害についても、責任を負わない (契約上、不法行為上 (過失の場合を含む)、その他のいかなる責任の法理によるかを問わない) ものとし、当該損失または損害には、直接、間接、特別、付随的、結果的な損失または損害 (第三者が起こした行為の結果被った、データ、利益、業務上の信用の損失、その他あらゆる種類の損失や損害を含みます) が含まれるものとし、それは、たとえ当該損害や損失が合理的に予見可能であったり、ザイリンクスがそれらの可能性について助言を受けていた場合であったとしても同様です。ザイリンクスは、本情報に含まれるいかなる誤りも訂正する義務を負わず、本情報または製品仕様のアップデートを貴殿または貴社に知らせる義務も負いません。事前の書面による同意のない限り、貴殿または貴社は本情報を再生産、変更、頒布、または公に展示してはなりません。一定の製品は、ザイリンクスの限定的保証の諸条件に従うこととなるので、https://japan.xilinx.com/legal.htm#tos で見られるザイリンクスの販売条件を参照してください。IP コアは、ザイリンクスが貴殿または貴社に付与したライセンスに含まれる保証と補助的条件に従うことになります。ザイリンクスの製品は、フェイルセーフとして、または、フェイルセーフの動作を要求するアプリケーションに使用するために、設計されたり意図されたりしていません。そのような重大なアプリケーションにザイリンクスの製品を使用する場合のリスクと責任は、貴殿または貴社が単独で負うものです。https://japan.xilinx.com/legal.htm#tos で見られるザイリンクスの販売条件を参照してください。

自動車用のアプリケーションの免責条項オートモーティブ製品 (製品番号に「XA」が含まれる) は、ISO 26262 自動車用機能安全規格に従った安全コンセプトまたは余剰性の機能 (「セーフティ設計」) がない限り、エアバッグの展開における使用または車両の制御に影響するアプリケーション (「セーフティ アプリケーション」) における使用は保証されていません。顧客は、製品を組み込むすべてのシステムについて、その使用前または提供前に安全を目的として十分なテストを行うものとします。セーフティ設計なしにセーフティ アプリケーションで製品を使用するリスクはすべて顧客が負い、製品責任の制限を規定する適用法令および規則にのみ従うものとします。

著作権© Copyright 2019–2020 Xilinx, Inc. Xilinx、Xilinx のロゴ、Alveo、Artix、Kintex、Spartan、Versal、Virtex、Vivado、Zynq、およびこの文書に含まれるその他の指定されたブランドは、米国およびその他各国のザイリンクス社の商標です。AMBA、AMBA Designer、Arm、ARM1176JZ-S、CoreSight、Cortex、PrimeCell、Mali、および MPCore は、EUおよびその他各国の Arm Limited の商標です。PCI、PCIe、および PCI Express は PCI-SIG の商標であり、ライセンスに基づいて使用されています。 すべてのその他の商標は、それぞれの保有者に帰属します。

この資料に関するフィードバックおよびリンクなどの問題につきましては、[email protected] まで、または各ページの右下にある [フィードバック送信] ボタンをクリックすると表示されるフォームからお知らせください。フィードバックは日本語で入力可能です。いただきましたご意見を参考に早急に対応させていただきます。なお、このメール アドレスへのお問い合わせは受け付けておりません。あらかじめご了承ください。

付録 B: その他のリソースおよび法的通知

UG1354 (v1.2) 2020 年 7 月 21 日 japan.xilinx.comVitis AI ライブラリ ユーザー ガイド 201