Get started with the USB Accelerator

2innnnn0·2021년 1월 1일
0

GoogleCoral

목록 보기
1/2
post-thumbnail

본 포스팅은 아래 링크를 기준으로 작성되었습니다.
https://coral.ai/docs/accelerator/get-started/

드디어.. 2개월에 걸쳐서 물건을 받았다.
관세 5만원은 덤이다.(30만원 이상은 관세가 붙는줄 몰랐다)
이제 하나씩 이 녀석을 파헤쳐보려 한다.

설치

  • 작성자 환경 :
OS: macOS Catalina 10.15.7
CPU : 2.3Ghz 8core Intel Core i9
Memory : 16GB DDR4

1: Edge TPU 런타임 설치하기(Install the Edge TPU runtime)

  1. Edge TPU runtime을 다운로드 및 압축풀기
curl -O https://dl.google.com/coral/edgetpu_api/edgetpu_runtime_20201204.zip

unzip edgetpu_runtime_20201204.zip
  1. Edge TPU runtime을 설치한다.
cd edgetpu_runtime
sudo bash install.sh


스크립트 실행시 해당 TPU 사용시에 기기에 열을 받을 수 있으니 주의하라는 내용이있다. 성능을 최대한으로 쓰고 싶기에 Yes를 눌렀다.

  1. 이제 USB Accelerator를 맥북USB 3.0으로 연결하면 끝!

2: 텐서플로우 라이트 라이브러리 설치(Install the TensorFlow Lite library)

https://www.tensorflow.org/lite/guide/python
위 링크에서 본인의 컴퓨터 OS플랫폼과 설치된 파이썬 버전을 기준으로 설치를 진행.
e.g. 맥OS 10.15이고 python 3.8이 설치되어있다면 아래 처럼 설치하기.

pip3 install 	https://github.com/google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-cp38-cp38-macosx_10_15_x86_64.whl

3: 텐서플로우 라이트API를 사용해서 예시 모델을 실행(Run a model using the TensorFlow Lite API)

  1. 적절한 위치에서 아래 코드를 실행해준다(Download the example code from GitHub:)
mkdir coral && cd coral

git clone https://github.com/google-coral/tflite.git
  1. 새 분류 모델, 라벨값, 새 사진을 다운받는다.(Download the bird classifier model, labels file, and a bird photo:)
cd tflite/python/examples/classification

bash install_requirements.sh
  1. 분류모델을 실행해 본다!(Run the image classifier with the bird photo (shown in figure 1):)
python3 classify_image.py \
--model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--labels models/inat_bird_labels.txt \
--input images/parrot.jpg

예시로 코드대로 실행했을때, 위에 사진처럼 실행이 되어진다.

INFERNCE TIME에 있는 설명은 다음과 같다.
"Edge TPU에 대한 첫 번째 추론은 모델을 Edge TPU 메모리에 로드하는 것을 포함하기 때문에 느리다"고 설명한다.
그리고 결과값으로 Ara macao(Scarlet Macaw)를 2.4ms라는 빠른 시간안에 분류한것을 확인할 수 있다!

추가적인 설명으로 다양한 추론 속도를 입증하기 위해 이 예제는 동일한 추론을 다섯 번 반복한다고 한다. 각 추론을 수행한 후 최상위 분류 결과(라벨 ID/이름)를 인쇄하고 신뢰 점수(0 ~ 1.0). 추론 속도는 호스트 시스템 또는 USB 3.0 연결 사용 여부에 따라 다를 수 있다고 한다.

위 예제 외에도 https://coral.ai/examples/ 링크를 ㅌ오해 실시간 객체 탐지, 포즈 추정, 키프레이즈 등을 수행하는 예제 포함 탐지, 온 디바이스 전송 학습 등을 확인할 수 있다고 하니 다음 포스팅은 예시를 다뤄보려 한다.

(EOD)

profile
성장하고 싶은 데이터분석가.

0개의 댓글