コンテンツへスキップ

Understand How to Export to TF SavedModel Format From YOLO11

Deploying machine learning models can be challenging. However, using an efficient and flexible model format can make your job easier. TF SavedModel is an open-source machine-learning framework used by TensorFlow to load machine-learning models in a consistent way. It is like a suitcase for TensorFlow models, making them easy to carry and use on different devices and systems.

Learning how to export to TF SavedModel from Ultralytics YOLO11 models can help you deploy models easily across different platforms and environments. In this guide, we'll walk through how to convert your models to the TF SavedModel format, simplifying the process of running inferences with your models on different devices.

なぜTF SavedModel にエクスポートする必要があるのですか?

TensorFlow SavedModel フォーマットは、以下に示すようにGoogle によって開発されたTensorFlow エコシステムの一部である。TensorFlow モデルをシームレスに保存し、シリアライズするように設計されている。これは、アーキテクチャ、重み、さらにはコンパイル情報など、モデルの完全な詳細をカプセル化する。これにより、異なる環境間でモデルを共有、展開、トレーニング継続することが容易になります。

TF SavedModel

TF SavedModel には、互換性という重要な利点がある。TensorFlow Serving、TensorFlow Lite、TensorFlow.jsとうまく機能する。この互換性により、ウェブやモバイルアプリケーションを含むさまざまなプラットフォームでモデルを共有し、展開することが容易になります。TF SavedModel フォーマットは、研究にも生産にも便利です。モデルを管理する統一された方法を提供し、どのようなアプリケーションにも対応できるようにします。

TF SavedModelsの主な機能

以下は、TF SavedModel がAI開発者にとって素晴らしい選択肢となる主な特徴である:

  • 移植性:TF SavedModel は、言語に依存しない、回復可能な、密閉された直列化フォーマットを提供する。これにより、より上位のシステムやツールでTensorFlow モデルの生成、利用、変換が可能になります。SavedModelsは、異なるプラットフォームや環境間で簡単に共有し、デプロイすることができます。

  • 導入の容易さ:TF SavedModel は、計算グラフ、学習済みパラメータ、必要なメタデータを1つのパッケージにバンドルしている。これらは、モデルを構築した元のコードを必要とすることなく、簡単にロードして推論に使用することができる。このため、TensorFlow モデルの展開は、さまざまな実運用環境において簡単で効率的なものとなる。

  • Asset Management: TF SavedModel supports the inclusion of external assets such as vocabularies, embeddings, or lookup tables. These assets are stored alongside the graph definition and variables, ensuring they are available when the model is loaded. This feature simplifies the management and distribution of models that rely on external resources.

配備オプションTF SavedModel

Before we dive into the process of exporting YOLO11 models to the TF SavedModel format, let's explore some typical deployment scenarios where this format is used.

TF SavedModel には、機械学習モデルを展開するためのさまざまなオプションが用意されている:

  • TensorFlow サービング TensorFlow Serving: Servingは、プロダクション環境向けに設計された、柔軟で高性能なサービングシステムです。TF SavedModelsをネイティブにサポートし、クラウドプラットフォーム、オンプレミスサーバー、エッジデバイスへのモデルのデプロイと提供を容易にします。

  • クラウドプラットフォーム: Google Cloud Platform (GCP)、Amazon Web Services (AWS)、Microsoft Azure などの主要なクラウドプロバイダーは、TF SavedModels を含むTensorFlow モデルのデプロイと実行のためのサービスを提供しています。これらのサービスは、スケーラブルで管理されたインフラストラクチャを提供するため、モデルのデプロイとスケーリングを簡単に行うことができます。

  • モバイルおよび組み込みデバイス: TensorFlow モバイル、組込み、IoTデバイス上で機械学習モデルを実行するための軽量ソリューションであるLiteは、TF SavedModelsをTensorFlow Liteフォーマットに変換することをサポートします。これにより、スマートフォンやタブレットからマイコンやエッジデバイスまで、幅広いデバイスにモデルを展開することができます。

  • TensorFlow ランタイム: TensorFlow ランタイムtfrt) is a high-performance runtime for executing TensorFlow graphs. It provides lower-level APIs for loading and running TF SavedModels in C++ environments. TensorFlow Runtime offers better performance compared to the standard TensorFlow runtime. It is suitable for deployment scenarios that require low-latency inference and tight integration with existing C++ codebases.

Exporting YOLO11 Models to TF SavedModel

By exporting YOLO11 models to the TF SavedModel format, you enhance their adaptability and ease of deployment across various platforms.

インストール

必要なパッケージをインストールするには、以下を実行する:

インストール

# Install the required package for YOLO11
pip install ultralytics

For detailed instructions and best practices related to the installation process, check our Ultralytics Installation guide. While installing the required packages for YOLO11, if you encounter any difficulties, consult our Common Issues guide for solutions and tips.

使用方法

Before diving into the usage instructions, it's important to note that while all Ultralytics YOLO11 models are available for exporting, you can ensure that the model you select supports export functionality here.

使用方法

from ultralytics import YOLO

# Load the YOLO11 model
model = YOLO("yolo11n.pt")

# Export the model to TF SavedModel format
model.export(format="saved_model")  # creates '/yolo11n_saved_model'

# Load the exported TF SavedModel model
tf_savedmodel_model = YOLO("./yolo11n_saved_model")

# Run inference
results = tf_savedmodel_model("https://ultralytics.com/images/bus.jpg")
# Export a YOLO11n PyTorch model to TF SavedModel format
yolo export model=yolo11n.pt format=saved_model  # creates '/yolo11n_saved_model'

# Run inference with the exported model
yolo predict model='./yolo11n_saved_model' source='https://ultralytics.com/images/bus.jpg'

サポートされているエクスポートオプションの詳細については、Ultralytics 配置オプションのドキュメントページを参照してください。

Deploying Exported YOLO11 TF SavedModel Models

Now that you have exported your YOLO11 model to the TF SavedModel format, the next step is to deploy it. The primary and recommended first step for running a TF GraphDef model is to use the YOLO("./yolo11n_saved_model") method, as previously shown in the usage code snippet.

ただし、TF SavedModel モデルの展開に関する詳細な手順については、以下のリソースを参照してください:

概要

In this guide, we explored how to export Ultralytics YOLO11 models to the TF SavedModel format. By exporting to TF SavedModel, you gain the flexibility to optimize, deploy, and scale your YOLO11 models on a wide range of platforms.

使い方の詳細については、TF SavedModel 公式ドキュメントをご覧ください。

For more information on integrating Ultralytics YOLO11 with other platforms and frameworks, don't forget to check out our integration guide page. It's packed with great resources to help you make the most of YOLO11 in your projects.

よくあるご質問

Ultralytics YOLO のモデルをTensorFlow SavedModel 形式にエクスポートするにはどうすればよいですか?

Ultralytics YOLO モデルをTensorFlow SavedModel フォーマットにエクスポートするのは簡単です。このためには、Python またはCLI のいずれかを使用することができます:

Exporting YOLO11 to TF SavedModel

from ultralytics import YOLO

# Load the YOLO11 model
model = YOLO("yolo11n.pt")

# Export the model to TF SavedModel format
model.export(format="saved_model")  # creates '/yolo11n_saved_model'

# Load the exported TF SavedModel for inference
tf_savedmodel_model = YOLO("./yolo11n_saved_model")
results = tf_savedmodel_model("https://ultralytics.com/images/bus.jpg")
# Export the YOLO11 model to TF SavedModel format
yolo export model=yolo11n.pt format=saved_model  # creates '/yolo11n_saved_model'

# Run inference with the exported model
yolo predict model='./yolo11n_saved_model' source='https://ultralytics.com/images/bus.jpg'

詳細については、Ultralytics Exportのドキュメントを参照してください。

なぜTensorFlow SavedModel フォーマットを使う必要があるのですか?

The TensorFlow SavedModel format offers several advantages for model deployment:

  • 移植性:言語に依存しないフォーマットを提供するため、異なる環境間でのモデルの共有や展開が容易です。
  • 互換性: TensorFlow Serving、TensorFlow Lite、TensorFlow.jsなどのツールとシームレスに統合され、ウェブやモバイルアプリケーションを含むさまざまなプラットフォーム上でモデルを展開するために不可欠です。
  • 完全なカプセル化:モデルのアーキテクチャ、重み、コンパイル情報をエンコードし、共有とトレーニングの継続を容易にします。

その他の利点と展開オプションについては、Ultralytics YOLO モデルの展開オプションをご覧ください。

TF SavedModel の典型的な展開シナリオは?

TF SavedModel を含む様々な環境で展開することができる:

  • TensorFlow サービングスケーラブルで高性能なモデルサービングを必要とするプロダクション環境に最適。
  • クラウドプラットフォーム: Google Cloud Platform (GCP)、Amazon Web Services (AWS)、Microsoft Azureなどの主要なクラウドサービスをサポートし、スケーラブルなモデル展開を実現します。
  • モバイルおよび組み込みデバイス: TF SavedModelsの変換にTensorFlow Liteを使用することで、モバイルデバイス、IoTデバイス、マイクロコントローラへの展開が可能になります。
  • TensorFlow ランタイム:低レイテンシーでより優れたパフォーマンスを必要とするC++環境向け。

詳細な展開オプションについては、 TensorFlow モデルの展開に関する公式ガイドをご覧ください。

How can I install the necessary packages to export YOLO11 models?

To export YOLO11 models, you need to install the ultralytics パッケージを作成します。ターミナルで以下のコマンドを実行する:

pip install ultralytics

より詳細なインストール手順とベストプラクティスについては、Ultralytics インストールガイドを参照してください。問題が発生した場合は、よくある問題ガイドを参照してください。

TensorFlow SavedModel フォーマットの主な特徴は何ですか?

TF SavedModel フォーマットは、以下のような特徴があり、AI開発者にとって有益である:

  • 移植性:さまざまな環境での共有と展開が容易になります。
  • 導入の容易さ:計算グラフ、学習済みパラメータ、メタデータを単一のパッケージにカプセル化し、ロードと推論を簡素化。
  • 資産管理:語彙のような外部アセットをサポートし、モデルのロード時に利用できるようにします。

詳しくは、 TensorFlow の公式ドキュメントをご覧ください。

📅 Created 7 months ago ✏️ Updated 22 days ago

コメント