Coral Edge TPU on a Raspberry Pi with Ultralytics YOLO11 🚀
코랄 엣지란 무엇인가요 TPU?
The Coral Edge TPU is a compact device that adds an Edge TPU coprocessor to your system. It enables low-power, high-performance ML inference for TensorFlow Lite models. Read more at the Coral Edge TPU home page.
Watch: How to Run Inference on Raspberry Pi using Google Coral Edge TPU
코랄 엣지로 라즈베리파이 모델 성능 향상하기 TPU
Many people want to run their models on an embedded or mobile device such as a Raspberry Pi, since they are very power efficient and can be used in many different applications. However, the inference performance on these devices is usually poor even when using formats like ONNX or OpenVINO. The Coral Edge TPU is a great solution to this problem, since it can be used with a Raspberry Pi and accelerate inference performance greatly.
라즈베리 파이의 엣지 TPU TensorFlow 라이트(신규)⭐ (신규)
라즈베리 파이에서 Edge TPU 를 사용하는 방법에 대한 Coral의 기존 가이드는 오래되었으며, 현재 Coral Edge TPU 런타임 빌드는 현재 TensorFlow 라이트 런타임 버전에서 더 이상 작동하지 않습니다. 또한 Google 은 Coral 프로젝트를 완전히 포기한 것으로 보이며 2021년부터 2024년 사이에 업데이트가 이루어지지 않았습니다. 이 가이드에서는 최신 버전의 TensorFlow 라이트 런타임과 업데이트된 Coral Edge TPU 런타임을 사용하여 Edge TPU 를 라즈베리파이 단일 보드 컴퓨터(SBC)에서 작동시키는 방법을 보여드립니다.
전제 조건
- 라즈베리 파이 4B (2GB 이상 권장) 또는 라즈베리 파이 5 (권장)
- 데스크톱이 있는 Raspberry Pi OS Bullseye/Bookworm(64비트)(권장)
- 코랄 USB 가속기
- A non-ARM based platform for exporting an Ultralytics PyTorch model
설치 연습
이 가이드는 이미 작동하는 라즈베리 파이 OS가 설치되어 있고 다음을 설치했다고 가정합니다. ultralytics
및 모든 종속성. 얻으려면 ultralytics
설치된 경우 빠른 시작 가이드 를 클릭하여 설정을 완료한 후 계속 진행하세요.
Edge TPU 런타임 설치
먼저 Edge TPU 런타임을 설치해야 합니다. 다양한 버전이 있으므로 사용 중인 운영 체제에 맞는 버전을 선택해야 합니다.
라즈베리 파이 OS | 고주파 모드 | 다운로드할 버전 |
---|---|---|
Bullseye 32비트 | 아니요 | libedgetpu1-std_ ... .bullseye_armhf.deb |
Bullseye 64비트 | 아니요 | libedgetpu1-std_ ... .bullseye_arm64.deb |
Bullseye 32비트 | 예 | libedgetpu1-max_ ... .bullseye_armhf.deb |
Bullseye 64비트 | 예 | libedgetpu1-max_ ... .bullseye_arm64.deb |
북웜 32비트 | 아니요 | libedgetpu1-std_ ... .bookworm_armhf.deb |
북웜 64비트 | 아니요 | libedgetpu1-std_ ... .bookworm_arm64.deb |
북웜 32비트 | 예 | libedgetpu1-max_ ... .bookworm_armhf.deb |
북웜 64비트 | 예 | libedgetpu1-max_ ... .bookworm_arm64.deb |
파일을 다운로드한 후 다음 명령어를 사용하여 설치할 수 있습니다:
런타임을 설치한 후, 코랄 엣지( TPU )를 라즈베리파이의 USB 3.0 포트에 연결해야 합니다. 이는 공식 가이드에 따르면 새로운 udev
규칙을 설치한 후에 적용해야 합니다.
중요
Coral Edge TPU 런타임이 이미 설치되어 있는 경우 다음 명령을 사용하여 제거하세요.
모델을 Edge TPU 호환 모델로 내보내기
Edge TPU 를 사용하려면 모델을 호환 가능한 형식으로 변환해야 합니다. ARM에서는 Edge TPU 컴파일러를 사용할 수 없으므로 공식 Ultralytics Docker 컨테이너를 사용하거나 Ultralytics HUB를 사용하여 Google Colab, x86_64 Linux 시스템에서 내보내기를 실행하는 것이 좋습니다. 사용 가능한 인수는 내보내기 모드를 참조하세요.
Exporting the model
내보낸 모델은 <model_name>_saved_model/
폴더에 <model_name>_full_integer_quant_edgetpu.tflite
. It is important that your model ends with the suffix _edgetpu.tflite
, otherwise ultralytics doesn't know that you're using a Edge TPU model.
모델 실행
Before you can actually run the model, you will need to install the correct libraries.
만약 tensorflow
가 설치되어 있으면 다음 명령으로 tensorflow 을 제거합니다:
그런 다음 설치/업데이트 tflite-runtime
:
Now you can run inference using the following code:
모델 실행
전체 예측 모드에 대한 자세한 내용은 예측 페이지에서 종합 정보를 확인하세요.
Inference with multiple Edge TPUs
If you have multiple Edge TPUs you can use the following code to select a specific TPU.
from ultralytics import YOLO
# Load a model
model = YOLO("path/to/<model_name>_full_integer_quant_edgetpu.tflite") # Load an official model or custom model
# Run Prediction
model.predict("path/to/source.png") # Inference defaults to the first TPU
model.predict("path/to/source.png", device="tpu:0") # Select the first TPU
model.predict("path/to/source.png", device="tpu:1") # Select the second TPU
자주 묻는 질문
What is a Coral Edge TPU and how does it enhance Raspberry Pi's performance with Ultralytics YOLO11?
The Coral Edge TPU is a compact device designed to add an Edge TPU coprocessor to your system. This coprocessor enables low-power, high-performance machine learning inference, particularly optimized for TensorFlow Lite models. When using a Raspberry Pi, the Edge TPU accelerates ML model inference, significantly boosting performance, especially for Ultralytics YOLO11 models. You can read more about the Coral Edge TPU on their home page.
라즈베리파이에 Coral Edge TPU 런타임을 설치하려면 어떻게 해야 하나요?
라즈베리 파이에 Coral Edge TPU 런타임을 설치하려면, 해당 런타임을 다운로드하세요. .deb
에서 라즈베리 파이 OS 버전용 패키지를 다운로드하십시오. 이 링크. 다운로드가 완료되면 다음 명령을 사용하여 설치합니다:
설치 연습 섹션에 설명된 단계에 따라 이전 Coral Edge TPU 런타임 버전을 제거해야 합니다.
Can I export my Ultralytics YOLO11 model to be compatible with Coral Edge TPU?
Yes, you can export your Ultralytics YOLO11 model to be compatible with the Coral Edge TPU. It is recommended to perform the export on Google Colab, an x86_64 Linux machine, or using the Ultralytics Docker container. You can also use Ultralytics HUB for exporting. Here is how you can export your model using Python and CLI:
Exporting the model
자세한 내용은 내보내기 모드 문서를 참조하세요.
라즈베리파이에 TensorFlow 이 이미 설치되어 있는데 대신 tflite-runtime을 사용하려면 어떻게 해야 하나요?
라즈베리 파이에 TensorFlow 가 설치되어 있고 다음과 같이 전환해야 하는 경우 tflite-runtime
를 사용하여 TensorFlow 을 먼저 제거해야 합니다:
그런 다음 다음을 설치 또는 업데이트합니다. tflite-runtime
를 다음 명령어로 대체합니다:
특정 휠의 경우(예: TensorFlow 2.15.0) tflite-runtime
에서 다운로드할 수 있습니다. 이 링크 를 클릭하고 다음을 사용하여 설치합니다. pip
. 자세한 지침은 모델 실행 섹션에서 확인할 수 있습니다. 모델 실행.
How do I run inference with an exported YOLO11 model on a Raspberry Pi using the Coral Edge TPU?
After exporting your YOLO11 model to an Edge TPU-compatible format, you can run inference using the following code snippets:
모델 실행
전체 예측 모드 기능에 대한 자세한 내용은 예측 페이지에서 확인할 수 있습니다.