Zum Inhalt springen

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.

Warum solltest du auf TF SavedModel exportieren?

Das TensorFlow SavedModel Format ist ein Teil des TensorFlow Ökosystems, das von Google entwickelt wurde (siehe unten). Es wurde entwickelt, um TensorFlow Modelle nahtlos zu speichern und zu serialisieren. Es kapselt alle Details der Modelle, wie z. B. die Architektur, die Gewichte und sogar die Kompilierungsinformationen. Das macht es einfach, Modelle zu teilen, einzusetzen und in verschiedenen Umgebungen weiter zu trainieren.

TF SavedModel

Der TF SavedModel hat einen entscheidenden Vorteil: seine Kompatibilität. Sie funktioniert gut mit TensorFlow Serving, TensorFlow Lite und TensorFlow.js. Diese Kompatibilität erleichtert die gemeinsame Nutzung und den Einsatz von Modellen auf verschiedenen Plattformen, einschließlich Web- und Mobilanwendungen. Das Format TF SavedModel ist sowohl für die Forschung als auch für die Produktion nützlich. Es bietet eine einheitliche Methode zur Verwaltung deiner Modelle und stellt sicher, dass sie für jede Anwendung bereit sind.

Hauptmerkmale von TF SavedModels

Hier sind die wichtigsten Funktionen, die TF SavedModel zu einer guten Wahl für KI-Entwickler machen:

  • Portabilität: TF SavedModel bietet ein sprachneutrales, wiederherstellbares, hermetisches Serialisierungsformat. Sie ermöglichen es übergeordneten Systemen und Tools, TensorFlow Modelle zu erstellen, zu konsumieren und zu transformieren. SavedModels lassen sich leicht über verschiedene Plattformen und Umgebungen hinweg austauschen und einsetzen.

  • Einfacher Einsatz: TF SavedModel bündelt den Berechnungsgraphen, die trainierten Parameter und die notwendigen Metadaten in einem einzigen Paket. Sie können einfach geladen und für Schlussfolgerungen verwendet werden, ohne dass der ursprüngliche Code, der das Modell erstellt hat, benötigt wird. Das macht den Einsatz von TensorFlow Modellen in verschiedenen Produktionsumgebungen einfach und effizient.

  • 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.

Einsatzoptionen mit 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 bietet eine Reihe von Optionen für den Einsatz deiner Machine Learning-Modelle:

  • TensorFlow Servieren: TensorFlow Serving ist ein flexibles, leistungsstarkes Serving-System, das für Produktionsumgebungen entwickelt wurde. Es unterstützt TF SavedModels und macht es einfach, deine Modelle auf Cloud-Plattformen, Servern vor Ort oder Edge-Geräten bereitzustellen.

  • Cloud-Plattformen: Große Cloud-Anbieter wie Google Cloud Platform (GCP), Amazon Web Services (AWS) und Microsoft Azure bieten Dienste für die Bereitstellung und den Betrieb von TensorFlow Modellen, einschließlich TF SavedModels. Diese Dienste bieten eine skalierbare und verwaltete Infrastruktur, mit der du deine Modelle einfach einsetzen und skalieren kannst.

  • Mobile und eingebettete Geräte: TensorFlow Lite, eine leichtgewichtige Lösung für die Ausführung von Machine Learning-Modellen auf mobilen, eingebetteten und IoT-Geräten, unterstützt die Konvertierung von TF SavedModels in das TensorFlow Lite-Format. So kannst du deine Modelle auf einer Vielzahl von Geräten einsetzen, von Smartphones und Tablets bis hin zu Mikrocontrollern und Edge-Geräten.

  • TensorFlow Laufzeit: TensorFlow Laufzeit (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.

Installation

Um das benötigte Paket zu installieren, führe es aus:

Installation

# 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.

Verwendung

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.

Verwendung

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'

Weitere Details zu den unterstützten Exportoptionen findest du auf der Ultralytics Dokumentationsseite zu den Bereitstellungsoptionen.

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.

Ausführliche Anleitungen für den Einsatz deiner TF SavedModel Modelle findest du in den folgenden Ressourcen:

Zusammenfassung

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.

Weitere Einzelheiten zur Verwendung findest du in der offiziellen DokumentationTF 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.

FAQ

Wie exportiere ich ein Ultralytics YOLO Modell in das TensorFlow SavedModel Format?

Das Exportieren eines Ultralytics YOLO Modells in das TensorFlow SavedModel Format ist ganz einfach. Dazu kannst du entweder Python oder CLI verwenden:

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'

Weitere Informationen findest du in der DokumentationUltralytics Export.

Warum sollte ich das Format TensorFlow SavedModel verwenden?

The TensorFlow SavedModel format offers several advantages for model deployment:

  • Übertragbarkeit: Es bietet ein sprachneutrales Format, das die gemeinsame Nutzung und den Einsatz von Modellen in verschiedenen Umgebungen erleichtert.
  • Kompatibilität: Integriert sich nahtlos in Tools wie TensorFlow Serving, TensorFlow Lite und TensorFlow.js, die für den Einsatz von Modellen auf verschiedenen Plattformen, einschließlich Web- und Mobilanwendungen, unerlässlich sind.
  • Vollständige Verkapselung: Verschlüsselt die Modellarchitektur, die Gewichte und die Kompilierungsinformationen und ermöglicht so eine unkomplizierte Weitergabe und Fortsetzung des Trainings.

Weitere Vorteile und Einsatzmöglichkeiten findest du unter Ultralytics YOLO model deployment options.

Was sind die typischen Einsatzszenarien für TF SavedModel ?

TF SavedModel kann in verschiedenen Umgebungen eingesetzt werden, darunter:

  • TensorFlow Serving: Ideal für Produktionsumgebungen, die ein skalierbares und leistungsstarkes Model Serving erfordern.
  • Cloud-Plattformen: Unterstützt die wichtigsten Cloud-Dienste wie Google Cloud Platform (GCP), Amazon Web Services (AWS) und Microsoft Azure für eine skalierbare Modellbereitstellung.
  • Mobile und eingebettete Geräte: Die Umwandlung von TF SavedModels mit TensorFlow Lite ermöglicht den Einsatz auf mobilen Geräten, IoT-Geräten und Mikrocontrollern.
  • TensorFlow Laufzeit: Für C++-Umgebungen, die Inferenzen mit niedriger Latenz und besserer Leistung benötigen.

Ausführliche Informationen zu den Einsatzmöglichkeiten findest du in den offiziellen Leitfäden zum Einsatz der TensorFlow Modelle.

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

To export YOLO11 models, you need to install the ultralytics Paket. Führe den folgenden Befehl in deinem Terminal aus:

pip install ultralytics

Ausführlichere Installationsanweisungen und Best Practices findest du in unserem Ultralytics Installationsleitfaden. Wenn du auf Probleme stößt, sieh in unserem Leitfaden für allgemeine Probleme nach.

Was sind die wichtigsten Merkmale des Formats TensorFlow SavedModel ?

TF SavedModel Format ist für KI-Entwickler aufgrund der folgenden Merkmale von Vorteil:

  • Portabilität: Ermöglicht die gemeinsame Nutzung und den mühelosen Einsatz in verschiedenen Umgebungen.
  • Einfacher Einsatz: Verkapselt den Berechnungsgraphen, die trainierten Parameter und die Metadaten in einem einzigen Paket, was das Laden und die Schlussfolgerungen vereinfacht.
  • Asset Management: Unterstützt externe Assets wie Vokabulare und stellt sicher, dass sie beim Laden des Modells verfügbar sind.

Weitere Einzelheiten findest du in der offiziellen Dokumentation TensorFlow .

📅 Created 7 months ago ✏️ Updated 22 days ago

Kommentare