glenn-jocher
commited on
Commit
•
f80c463
1
Parent(s):
b4ac3df
Attempt `edgetpu-compiler` autoinstall (#6223)
Browse files* Attempt `edgetpu-compiler` autoinstall
Attempt to install edgetpu-compiler dependency if missing on Linux.
* Update export.py
* Update export.py
export.py
CHANGED
@@ -309,11 +309,16 @@ def export_edgetpu(keras_model, im, file, prefix=colorstr('Edge TPU:')):
|
|
309 |
# YOLOv5 Edge TPU export https://coral.ai/docs/edgetpu/models-intro/
|
310 |
try:
|
311 |
cmd = 'edgetpu_compiler --version'
|
312 |
-
|
313 |
-
assert platform.system() == 'Linux', f'export only supported on Linux. {
|
314 |
-
|
315 |
-
|
316 |
-
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
|
319 |
f = str(file).replace('.pt', '-int8_edgetpu.tflite') # Edge TPU model
|
|
|
309 |
# YOLOv5 Edge TPU export https://coral.ai/docs/edgetpu/models-intro/
|
310 |
try:
|
311 |
cmd = 'edgetpu_compiler --version'
|
312 |
+
help_url = 'https://coral.ai/docs/edgetpu/compiler/'
|
313 |
+
assert platform.system() == 'Linux', f'export only supported on Linux. See {help_url}'
|
314 |
+
if subprocess.run(cmd, shell=True).returncode != 0:
|
315 |
+
LOGGER.info(f'\n{prefix} export requires Edge TPU compiler. Attempting install from {help_url}')
|
316 |
+
for c in ['curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -',
|
317 |
+
'echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list',
|
318 |
+
'sudo apt-get update',
|
319 |
+
'sudo apt-get install edgetpu-compiler']:
|
320 |
+
subprocess.run(c, shell=True, check=True)
|
321 |
+
ver = subprocess.run(cmd, shell=True, capture_output=True, check=True).stdout.decode().split()[-1]
|
322 |
|
323 |
LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
|
324 |
f = str(file).replace('.pt', '-int8_edgetpu.tflite') # Edge TPU model
|