コンテンツへスキップ

Export to TF.js Model Format From a YOLO11 Model Format

Deploying machine learning models directly in the browser or on Node.js can be tricky. You'll need to make sure your model format is optimized for faster performance so that the model can be used to run interactive applications locally on the user's device. The TensorFlow.js, or TF.js, model format is designed to use minimal power while delivering fast performance.

The 'export to TF.js model format' feature allows you to optimize your Ultralytics YOLO11 models for high-speed and locally-run object detection inference. In this guide, we'll walk you through converting your models to the TF.js format, making it easier for your models to perform well on various local browsers and Node.js applications.

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

TensorFlow のエコシステムの一部としてTensorFlow チームによって開発されたTensorFlow.js に機械学習モデルをエクスポートすると、機械学習アプリケーションを展開する際に多くの利点があります。機密データをデバイス上に保持することで、ユーザーのプライバシーとセキュリティを強化することができます。下の画像は、TensorFlow.jsのアーキテクチャと、機械学習モデルがどのように変換され、ウェブブラウザとNode.jsの両方でデプロイされるかを示しています。

TF.jsアーキテクチャ

Running models locally also reduces latency and provides a more responsive user experience. TensorFlow.js also comes with offline capabilities, allowing users to use your application even without an internet connection. TF.js is designed for efficient execution of complex models on devices with limited resources as it is engineered for scalability, with GPU acceleration support.

TF.jsの主な特徴

TF.jsを開発者にとって強力なツールにしている主な機能を紹介しよう:

  • クロスプラットフォームのサポート: TensorFlow.js は、ブラウザと Node.js の両方の環境で使用できるため、さまざまなプラットフォームに柔軟に対応できます。開発者は、より簡単にアプリケーションを構築し、デプロイすることができます。

  • 複数のバックエンドのサポート: TensorFlow.jsは、CPU 、GPU アクセラレーションのためのWebGL、ネイティブに近い実行速度のためのWebAssembly(WASM)、および高度なブラウザベースの機械学習機能のためのWebGPUを含む計算のための様々なバックエンドをサポートしています。

  • オフライン機能: TensorFlow.jsでは、インターネット接続を必要とせずにブラウザ上でモデルを実行できるため、オフラインで機能するアプリケーションの開発が可能です。

TensorFlow.js での展開オプション

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

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

  • ブラウザ内MLアプリケーション:機械学習モデルをブラウザ上で直接実行するウェブ・アプリケーションを構築できます。サーバーサイドの計算が不要になり、サーバーの負荷が軽減されます。

  • Node.jsアプリケーション:: TensorFlow.jsはNode.js環境へのデプロイもサポートしており、サーバーサイドの機械学習アプリケーションの開発が可能です。サーバーの処理能力やサーバーサイドのデータへのアクセスを必要とするアプリケーションに特に有効です。

  • Chrome拡張機能: TensorFlow.jsを使ったChrome拡張機能の作成は、興味深い展開シナリオだ。例えば、ユーザーがウェブページ内の画像を右クリックして、事前に訓練されたMLモデルを使って画像を分類できるような拡張機能を開発できる。TensorFlow.jsは、機械学習に基づく即時の洞察や補強を提供するために、日常のウェブ閲覧体験に統合することができます。

Exporting YOLO11 Models to TensorFlow.js

You can expand model compatibility and deployment flexibility by converting YOLO11 models to TF.js.

インストール

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

インストール

# 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.js format
model.export(format="tfjs")  # creates '/yolo11n_web_model'

# Load the exported TF.js model
tfjs_model = YOLO("./yolo11n_web_model")

# Run inference
results = tfjs_model("https://ultralytics.com/images/bus.jpg")
# Export a YOLO11n PyTorch model to TF.js format
yolo export model=yolo11n.pt format=tfjs  # creates '/yolo11n_web_model'

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

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

Deploying Exported YOLO11 TensorFlow.js Models

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

しかし、TF.jsモデルのデプロイに関する詳しい説明は、以下のリソースをご覧ください:

概要

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

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

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.

よくあるご質問

How do I export Ultralytics YOLO11 models to TensorFlow.js format?

Exporting Ultralytics YOLO11 models to TensorFlow.js (TF.js) format is straightforward. You can follow these steps:

使用方法

from ultralytics import YOLO

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

# Export the model to TF.js format
model.export(format="tfjs")  # creates '/yolo11n_web_model'

# Load the exported TF.js model
tfjs_model = YOLO("./yolo11n_web_model")

# Run inference
results = tfjs_model("https://ultralytics.com/images/bus.jpg")
# Export a YOLO11n PyTorch model to TF.js format
yolo export model=yolo11n.pt format=tfjs  # creates '/yolo11n_web_model'

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

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

Why should I export my YOLO11 models to TensorFlow.js?

Exporting YOLO11 models to TensorFlow.js offers several advantages, including:

  1. ローカル実行:モデルはブラウザまたはNode.jsで直接実行できるため、待ち時間が短縮され、ユーザーエクスペリエンスが向上します。
  2. クロスプラットフォームのサポート: TF.jsは複数の環境をサポートしており、柔軟なデプロイが可能です。
  3. オフライン機能:インターネット接続がなくてもアプリケーションを機能させることができ、信頼性とプライバシーを確保します。
  4. GPU アクセラレーション:WebGL を活用してGPU アクセラレーションを行い、リソースが限られたデバイスでのパフォーマンスを最適化します。

包括的な概要については、 TensorFlow.js との統合をご覧ください。

TensorFlow.jsは、ブラウザベースの機械学習アプリケーションにどのようなメリットをもたらすのか?

TensorFlow.jsは、ブラウザとNode.js環境でMLモデルを効率的に実行するために特別に設計されています。ここでは、ブラウザベースのアプリケーションにどのようなメリットがあるかを紹介します:

  • 待ち時間の短縮:機械学習モデルをローカルで実行するため、サーバーサイドの計算に依存することなく、すぐに結果を得ることができます。
  • プライバシーの向上:機密データをユーザーのデバイスに保持し、セキュリティリスクを最小限に抑えます。
  • オフラインでの使用が可能:インターネットに接続していない状態でも動作するため、安定した機能を確保できます。
  • 複数のバックエンドをサポート: CPU 、WebGL、WebAssembly (WASM)、WebGPUなど、さまざまな計算ニーズに柔軟に対応するバックエンドを提供します。

TF.jsについてもっと知りたいですか? TensorFlow.js 公式ガイドをご覧ください。

What are the key features of TensorFlow.js for deploying YOLO11 models?

TensorFlow.jsの主な特徴は以下の通り:

  • クロスプラットフォームのサポート: TF.jsは、ウェブブラウザとNode.jsの両方で使用することができ、広範なデプロイの柔軟性を提供します。
  • 複数のバックエンド: CPU 、GPU アクセラレーションのための WebGL、WebAssembly (WASM)、高度な操作のための WebGPU をサポートしています。
  • オフライン機能:モデルはインターネット接続なしでブラウザ上で直接実行できるため、レスポンシブ・ウェブ・アプリケーションの開発に最適です。

デプロイシナリオやより詳細な情報については、 TensorFlow.js でのデプロイオプションのセクションを参照してください。

Can I deploy a YOLO11 model on server-side Node.js applications using TensorFlow.js?

Yes, TensorFlow.js allows the deployment of YOLO11 models on Node.js environments. This enables server-side machine learning applications that benefit from the processing power of a server and access to server-side data. Typical use cases include real-time data processing and machine learning pipelines on backend servers.

Node.jsのデプロイを始めるには、TensorFlow の「RunTensorFlow.js in Node.js」ガイドを参照してください。

📅 Created 6 months ago ✏️ Updated 22 days ago

コメント