Unverified 提交 f80c4630 authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Attempt `edgetpu-compiler` autoinstall (#6223)

* Attempt `edgetpu-compiler` autoinstall Attempt to install edgetpu-compiler dependency if missing on Linux. * Update export.py * Update export.py
上级 b4ac3df6
...@@ -309,11 +309,16 @@ def export_edgetpu(keras_model, im, file, prefix=colorstr('Edge TPU:')): ...@@ -309,11 +309,16 @@ def export_edgetpu(keras_model, im, file, prefix=colorstr('Edge TPU:')):
# YOLOv5 Edge TPU export https://coral.ai/docs/edgetpu/models-intro/ # YOLOv5 Edge TPU export https://coral.ai/docs/edgetpu/models-intro/
try: try:
cmd = 'edgetpu_compiler --version' cmd = 'edgetpu_compiler --version'
help = 'See https://coral.ai/docs/edgetpu/compiler/' help_url = 'https://coral.ai/docs/edgetpu/compiler/'
assert platform.system() == 'Linux', f'export only supported on Linux. {help}' assert platform.system() == 'Linux', f'export only supported on Linux. See {help_url}'
assert subprocess.run(cmd, shell=True).returncode == 0, f'export requires edgetpu-compiler. {help}' if subprocess.run(cmd, shell=True).returncode != 0:
out = subprocess.run(cmd, shell=True, capture_output=True, check=True) LOGGER.info(f'\n{prefix} export requires Edge TPU compiler. Attempting install from {help_url}')
ver = out.stdout.decode().split()[-1] for c in ['curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -',
'echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list',
'sudo apt-get update',
'sudo apt-get install edgetpu-compiler']:
subprocess.run(c, shell=True, check=True)
ver = subprocess.run(cmd, shell=True, capture_output=True, check=True).stdout.decode().split()[-1]
LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...') LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
f = str(file).replace('.pt', '-int8_edgetpu.tflite') # Edge TPU model f = str(file).replace('.pt', '-int8_edgetpu.tflite') # Edge TPU model
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论