콘텐츠로 건너뛰기

A Guide on YOLO11 Model Export to TFLite for Deployment

TFLite 로고

Deploying computer vision models on edge devices or embedded devices requires a format that can ensure seamless performance.

The TensorFlow Lite or TFLite export format allows you to optimize your Ultralytics YOLO11 models for tasks like object detection and image classification in edge device-based applications. In this guide, we'll walk through the steps for converting your models to the TFLite format, making it easier for your models to perform well on various edge devices.

TFLite로 내보내야 하는 이유는 무엇인가요?

2017년 5월에 Google ( TensorFlow )에서 프레임워크의 일부로 도입한 TensorFlow Lite 또는 줄여서 TFLite는 엣지 컴퓨팅이라고도 하는 온디바이스 추론을 위해 설계된 오픈 소스 딥 러닝 프레임워크입니다. 개발자에게 기존 컴퓨터뿐만 아니라 모바일, 임베디드, IoT 기기에서 학습된 모델을 실행하는 데 필요한 도구를 제공합니다.

TensorFlow Lite는 임베디드 Linux, Android, iOS, MCU 등 다양한 플랫폼과 호환됩니다. 모델을 TFLite로 내보내면 애플리케이션을 더 빠르고 안정적으로 오프라인에서 실행할 수 있습니다.

TFLite 모델의 주요 기능

TFLite 모델은 개발자가 모바일, 임베디드 및 에지 디바이스에서 모델을 실행할 수 있도록 지원하여 온디바이스 머신 러닝을 가능하게 하는 다양한 주요 기능을 제공합니다:

  • 온디바이스 최적화: TFLite는 온디바이스 ML에 최적화되어 데이터를 로컬에서 처리하여 대기 시간을 줄이고, 개인 데이터를 전송하지 않음으로써 개인 정보를 보호하며, 모델 크기를 최소화하여 공간을 절약합니다.

  • 다양한 플랫폼 지원: TFLite는 광범위한 플랫폼 호환성을 제공하여 Android, iOS, 임베디드 Linux 및 마이크로 컨트롤러를 지원합니다.

  • 다양한 언어 지원: TFLite는 Java, Swift, Objective-C, C++ 및 Python 를 포함한 다양한 프로그래밍 언어와 호환됩니다.

  • 고성능: 하드웨어 가속 및 모델 최적화를 통해 뛰어난 성능을 달성합니다.

TFLite의 배포 옵션

Before we look at the code for exporting YOLO11 models to the TFLite format, let's understand how TFLite models are normally used.

TFLite는 다음과 같은 머신러닝 모델을 위한 다양한 온디바이스 배포 옵션을 제공합니다:

  • Android 및 iOS 으로 배포: TFLite를 사용하는 Android 및 iOS 애플리케이션은 모두 에지 기반 카메라 피드와 센서를 분석하여 물체를 감지하고 식별할 수 있습니다. TFLite는 SwiftObjective-C로 작성된 기본 iOS 라이브러리도 제공합니다. 아래 아키텍처 다이어그램은 Android 및 iOS 플랫폼에 TensorFlow Lite를 사용하여 학습된 모델을 배포하는 프로세스를 보여줍니다.

아키텍처

  • 임베디드 Linux로 구현하기: Ultralytics 가이드에 따라 라즈베리 파이에서 추론을 실행해도 사용 사례의 속도 요구 사항을 충족하지 못하는 경우, 내보낸 TFLite 모델을 사용하여 추론 시간을 가속화할 수 있습니다. 또한 Coral Edge TPU 장치를 활용하여 성능을 더욱 향상시킬 수 있습니다.

  • 마이크로컨트롤러와 함께 배포: TFLite 모델은 메모리가 몇 킬로바이트에 불과한 마이크로컨트롤러 및 기타 디바이스에도 배포할 수 있습니다. 코어 런타임은 Arm Cortex M3에서 16KB에 불과하며 많은 기본 모델을 실행할 수 있습니다. 운영 체제 지원, 표준 C 또는 C++ 라이브러리, 동적 메모리 할당이 필요하지 않습니다.

Export to TFLite: Converting Your YOLO11 Model

온디바이스 모델 실행 효율을 개선하고 TFLite 형식으로 변환하여 성능을 최적화할 수 있습니다.

설치

필요한 패키지를 설치하려면 실행합니다:

설치

# 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 TFLite format
model.export(format="tflite")  # creates 'yolo11n_float32.tflite'

# Load the exported TFLite model
tflite_model = YOLO("yolo11n_float32.tflite")

# Run inference
results = tflite_model("https://ultralytics.com/images/bus.jpg")
# Export a YOLO11n PyTorch model to TFLite format
yolo export model=yolo11n.pt format=tflite  # creates 'yolo11n_float32.tflite'

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

내보내기 프로세스에 대한 자세한 내용은 내보내기 관련 문서 페이지(Ultralytics )를 참조하세요.

Deploying Exported YOLO11 TFLite Models

After successfully exporting your Ultralytics YOLO11 models to TFLite format, you can now deploy them. The primary and recommended first step for running a TFLite model is to utilize the YOLO("model.tflite") method, as outlined in the previous usage code snippet. However, for in-depth instructions on deploying your TFLite models in various other settings, take a look at the following resources:

  • Android: A quick start guide for integrating TensorFlow Lite into Android applications, providing easy-to-follow steps for setting up and running machine learning models.

  • iOS: 단계별 지침과 리소스를 제공하는 iOS 애플리케이션에서 TensorFlow 라이트 모델을 통합하고 배포하는 방법에 대한 개발자용 상세 가이드를 확인하세요.

  • 엔드투엔드 예시: 이 페이지에서는 개발자가 모바일 및 엣지 디바이스에서 머신 러닝 프로젝트에 TensorFlow Lite를 구현하는 데 도움이 되도록 설계된 실용적인 애플리케이션과 튜토리얼을 보여주는 다양한 TensorFlow Lite 예제에 대한 개요를 제공합니다.

요약

In this guide, we focused on how to export to TFLite format. By converting your Ultralytics YOLO11 models to TFLite model format, you can improve the efficiency and speed of YOLO11 models, making them more effective and suitable for edge computing environments.

사용법에 대한 자세한 내용은 TFLite 공식 문서를 참조하세요.

Also, if you're curious about other Ultralytics YOLO11 integrations, make sure to check out our integration guide page. You'll find tons of helpful info and insights waiting for you there.

자주 묻는 질문

How do I export a YOLO11 model to TFLite format?

To export a YOLO11 model to TFLite format, you can use the Ultralytics library. First, install the required package using:

pip install ultralytics

그런 다음 다음 코드 스니펫을 사용하여 모델을 내보냅니다:

from ultralytics import YOLO

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

# Export the model to TFLite format
model.export(format="tflite")  # creates 'yolo11n_float32.tflite'

CLI 사용자의 경우 다음을 사용하여 이 작업을 수행할 수 있습니다:

yolo export model=yolo11n.pt format=tflite  # creates 'yolo11n_float32.tflite'

자세한 내용은 내보내기 가이드(Ultralytics )를 참조하세요.

What are the benefits of using TensorFlow Lite for YOLO11 model deployment?

TensorFlow Lite (TFLite) is an open-source deep learning framework designed for on-device inference, making it ideal for deploying YOLO11 models on mobile, embedded, and IoT devices. Key benefits include:

  • 온디바이스 최적화: 데이터를 로컬에서 처리하여 지연 시간을 최소화하고 개인정보 보호를 강화합니다.
  • 플랫폼 호환성: Android , iOS, 임베디드 Linux 및 MCU를 지원합니다.
  • 성능: 하드웨어 가속을 활용하여 모델 속도와 효율성을 최적화합니다.

자세한 내용은 TFLite 가이드에서 확인하세요.

Is it possible to run YOLO11 TFLite models on Raspberry Pi?

Yes, you can run YOLO11 TFLite models on Raspberry Pi to improve inference speeds. First, export your model to TFLite format as explained here. Then, use a tool like TensorFlow Lite Interpreter to execute the model on your Raspberry Pi.

추가 최적화를 위해 Coral Edge TPU 를 사용하는 것도 고려해 볼 수 있습니다. 자세한 단계는 라즈베리파이 배포 가이드를 참조하세요.

Can I use TFLite models on microcontrollers for YOLO11 predictions?

Yes, TFLite supports deployment on microcontrollers with limited resources. TFLite's core runtime requires only 16 KB of memory on an Arm Cortex M3 and can run basic YOLO11 models. This makes it suitable for deployment on devices with minimal computational power and memory.

시작하려면 마이크로컨트롤러용 TFLite 마이크로 가이드를 참조하세요.

What platforms are compatible with TFLite exported YOLO11 models?

TensorFlow Lite provides extensive platform compatibility, allowing you to deploy YOLO11 models on a wide range of devices, including:

  • Android 및 iOS: TFLite Android 및 iOS 라이브러리를 통한 네이티브 지원.
  • 임베디드 Linux: 라즈베리 파이와 같은 단일 보드 컴퓨터에 이상적입니다.
  • 마이크로컨트롤러: 리소스가 제한된 MCU에 적합합니다.

배포 옵션에 대한 자세한 내용은 자세한 배포 가이드를 참조하세요.

How do I troubleshoot common issues during YOLO11 model export to TFLite?

If you encounter errors while exporting YOLO11 models to TFLite, common solutions include:

  • 패키지 호환성을 확인하세요: 호환되는 버전의 Ultralytics 및 TensorFlow 을 사용하고 있는지 확인하세요. 설치 가이드를 참조하세요.
  • Model support: Verify that the specific YOLO11 model supports TFLite export by checking here.

추가적인 문제 해결 팁은 일반적인 문제 가이드를 참조하세요.

📅 Created 7 months ago ✏️ Updated 22 days ago

댓글