Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edgetpu_compiler checks #6218

Merged
merged 7 commits into from
Jan 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add edgetpu_compiler checks
  • Loading branch information
glenn-jocher authored Jan 5, 2022
commit 39066fe50174b199ef9a8cb44df38566e11fd67e
7 changes: 6 additions & 1 deletion export.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import argparse
import json
import os
import platform
import subprocess
import sys
import time
Expand Down Expand Up @@ -307,9 +308,13 @@ def export_tflite(keras_model, im, file, int8, data, ncalib, prefix=colorstr('Te
def export_edgetpu(keras_model, im, file, prefix=colorstr('Edge TPU:')):
# YOLOv5 Edge TPU export https://coral.ai/docs/edgetpu/models-intro/
try:
cmd = 'edgetpu_compiler --version' # install https://coral.ai/docs/edgetpu/compiler/
cmd = 'edgetpu_compiler --version'
help_url = 'https://coral.ai/docs/edgetpu/compiler/'
assert platform.system() == 'Linux', 'export only supported on Linux'
assert subprocess.run(cmd, shell=True, check=True), f'export requires edgetpu-compiler. See {help_url}'
out = subprocess.run(cmd, shell=True, capture_output=True, check=True)
ver = out.stdout.decode().split()[-1]

LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
f = str(file).replace('.pt', '-int8_edgetpu.tflite')
f_tfl = str(file).replace('.pt', '-int8.tflite') # TFLite model
Expand Down