انتقل إلى المحتوى

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 جزءًا من النظام البيئي TensorFlow الذي طوره Google كما هو موضح أدناه. وهو مصمم لحفظ وتسلسل النماذج TensorFlow بسلاسة. وهو يغلف التفاصيل الكاملة للنماذج مثل البنية والأوزان وحتى معلومات التجميع. وهذا يجعل من السهل مشاركة النماذج ونشرها ومواصلة التدريب عبر بيئات مختلفة.

TF SavedModel

ال TF SavedModel له ميزة رئيسية: توافقه. يعمل بشكل جيد مع TensorFlow خدمه TensorFlow لايت، و TensorFlow.شبيبه. يسهل هذا التوافق مشاركة النماذج ونشرها عبر الأنظمة الأساسية المختلفة ، بما في ذلك تطبيقات الويب والجوال. ال TF SavedModel الشكل مفيد لكل من البحث والإنتاج. يوفر طريقة موحدة لإدارة نماذجك ، مما يضمن أنها جاهزة لأي تطبيق.

الميزات الرئيسية ل TF النماذج المحفوظة

فيما يلي الميزات الرئيسية التي تجعل TF SavedModel خيار رائع لمطوري الذكاء الاصطناعي:

  • قابلية النقل: TF SavedModel يوفر تنسيق تسلسل محكم محايد لغوي وقابل للاسترداد. إنها تمكن الأنظمة والأدوات عالية المستوى من الإنتاج والاستهلاك والتحويل TensorFlow نماذج. يمكن مشاركة النماذج المحفوظة ونشرها بسهولة عبر منصات وبيئات مختلفة.

  • سهولة النشر: TF SavedModel يجمع الرسم البياني الحسابي والمعلمات المدربة والبيانات الوصفية الضرورية في حزمة واحدة. يمكن تحميلها بسهولة واستخدامها للاستدلال دون الحاجة إلى الكود الأصلي الذي أنشأ النموذج. هذا يجعل نشر 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 التقديم هو نظام خدمة مرن وعالي الأداء مصمم لبيئات الإنتاج. يدعم أصلا TF SavedModels، مما يجعل من السهل نشر النماذج الخاصة بك وتقديمها على الأنظمة الأساسية السحابية أو الخوادم المحلية أو أجهزة الحافة.

  • المنصات السحابية: يقدم موفرو الخدمات السحابية الرئيسيون مثل Google Cloud Platform (GCP) و Amazon Web Services (AWS) و Microsoft Azure خدمات لنشر وتشغيل نماذج TensorFlow ، بما في ذلك TF SavedModels. توفر هذه الخدمات بنية تحتية قابلة للتطوير والإدارة، مما يتيح لك نشر نماذجك وتوسيع نطاقها بسهولة.

  • الأجهزة المحمولة والمدمجة: TensorFlow Lite ، وهو حل خفيف الوزن لتشغيل نماذج التعلم الآلي على الأجهزة المحمولة والمضمنة وأجهزة إنترنت الأشياء ، يدعم التحويل TF تم حفظ النماذج إلى TensorFlow تنسيق لايت. يتيح لك ذلك نشر نماذجك على مجموعة واسعة من الأجهزة ، من الهواتف الذكية والأجهزة اللوحية إلى وحدات التحكم الدقيقة وأجهزة الحافة.

  • 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 النماذج ، ألق نظرة على الموارد التالية:

  • TensorFlow الخدمة: إليك وثائق المطورين الخاصة بكيفية نشر نماذج TF SavedModel الخاصة بك باستخدام خدمة TensorFlow .

  • تشغيل TensorFlow SavedModel في Node.js: أ TensorFlow بلوق وظيفة على تشغيل TensorFlow SavedModel في Node.js مباشرة دون تحويل.

  • النشر على السحابة: أ TensorFlow منشور مدونة حول نشر ملف TensorFlow 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 لمزيد من التفاصيل.

لماذا يجب استخدام تنسيق 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 المنصة السحابية (GCP) وخدمات أمازون ويب سيرفيسز (AWS) و Microsoft أزور لنشر النماذج القابلة للتطوير.
  • الأجهزة المحمولة والأجهزة المدمجة: يتيح استخدام TensorFlow Lite لتحويل TF المحفوظة للنماذج المحفوظة إمكانية النشر على الأجهزة المحمولة وأجهزة إنترنت الأشياء والمتحكمات الدقيقة.
  • TensorFlow وقت التشغيل: For C++ environments needing low-latency inference with better performance.

للاطلاع على خيارات النشر التفصيلية، قم بزيارة الأدلة الرسمية الخاصة بنشر نماذج 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 التنسيق مفيد لمطوري الذكاء الاصطناعي بسبب الميزات التالية:

  • قابلية النقل: تتيح المشاركة والنشر عبر بيئات مختلفة دون عناء.
  • سهولة النشر: يغلف الرسم البياني الحسابي والمعلمات المدربة والبيانات الوصفية في حزمة واحدة، مما يسهل التحميل والاستدلال.
  • إدارة الأصول: تدعم الأصول الخارجية مثل المفردات، مما يضمن توفرها عند تحميل النموذج.

لمزيد من التفاصيل، اطلع على الوثائق الرسمية TensorFlow .

📅 Created 7 months ago ✏️ Updated 22 days ago

التعليقات