Edge TPU compiler comment (#6196)
Browse files* Edge TPU compiler comment
* 7 to 8 fix
- export.py +3 -3
- models/common.py +2 -2
export.py
CHANGED
@@ -17,7 +17,7 @@ TensorFlow Edge TPU | `edgetpu` | yolov5s_edgetpu.tf
|
|
17 |
TensorFlow.js | `tfjs` | yolov5s_web_model/
|
18 |
|
19 |
Usage:
|
20 |
-
$ python path/to/export.py --weights yolov5s.pt --include torchscript onnx
|
21 |
|
22 |
Inference:
|
23 |
$ python path/to/detect.py --weights yolov5s.pt # PyTorch
|
@@ -179,7 +179,7 @@ def export_engine(model, im, file, train, half, simplify, workspace=4, verbose=F
|
|
179 |
export_onnx(model, im, file, 12, train, False, simplify) # opset 12
|
180 |
model.model[-1].anchor_grid = grid
|
181 |
else: # TensorRT >= 8
|
182 |
-
check_version(trt.__version__, '
|
183 |
export_onnx(model, im, file, 13, train, False, simplify) # opset 13
|
184 |
onnx = file.with_suffix('.onnx')
|
185 |
assert onnx.exists(), f'failed to export ONNX file: {onnx}'
|
@@ -308,7 +308,7 @@ def export_tflite(keras_model, im, file, int8, data, ncalib, prefix=colorstr('Te
|
|
308 |
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 |
out = subprocess.run(cmd, shell=True, capture_output=True, check=True)
|
313 |
ver = out.stdout.decode().split()[-1]
|
314 |
LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
|
|
|
17 |
TensorFlow.js | `tfjs` | yolov5s_web_model/
|
18 |
|
19 |
Usage:
|
20 |
+
$ python path/to/export.py --weights yolov5s.pt --include torchscript onnx openvino engine coreml tflite ...
|
21 |
|
22 |
Inference:
|
23 |
$ python path/to/detect.py --weights yolov5s.pt # PyTorch
|
|
|
179 |
export_onnx(model, im, file, 12, train, False, simplify) # opset 12
|
180 |
model.model[-1].anchor_grid = grid
|
181 |
else: # TensorRT >= 8
|
182 |
+
check_version(trt.__version__, '8.0.0', hard=True) # require tensorrt>=8.0.0
|
183 |
export_onnx(model, im, file, 13, train, False, simplify) # opset 13
|
184 |
onnx = file.with_suffix('.onnx')
|
185 |
assert onnx.exists(), f'failed to export ONNX file: {onnx}'
|
|
|
308 |
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' # install https://coral.ai/docs/edgetpu/compiler/
|
312 |
out = subprocess.run(cmd, shell=True, capture_output=True, check=True)
|
313 |
ver = out.stdout.decode().split()[-1]
|
314 |
LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
|
models/common.py
CHANGED
@@ -376,8 +376,8 @@ class DetectMultiBackend(nn.Module):
|
|
376 |
elif tflite: # https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python
|
377 |
if 'edgetpu' in w.lower(): # Edge TPU
|
378 |
LOGGER.info(f'Loading {w} for TensorFlow Lite Edge TPU inference...')
|
379 |
-
import tflite_runtime.interpreter as tfli
|
380 |
-
delegate = {'Linux': 'libedgetpu.so.1',
|
381 |
'Darwin': 'libedgetpu.1.dylib',
|
382 |
'Windows': 'edgetpu.dll'}[platform.system()]
|
383 |
interpreter = tfli.Interpreter(model_path=w, experimental_delegates=[tfli.load_delegate(delegate)])
|
|
|
376 |
elif tflite: # https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python
|
377 |
if 'edgetpu' in w.lower(): # Edge TPU
|
378 |
LOGGER.info(f'Loading {w} for TensorFlow Lite Edge TPU inference...')
|
379 |
+
import tflite_runtime.interpreter as tfli # install https://coral.ai/software/#edgetpu-runtime
|
380 |
+
delegate = {'Linux': 'libedgetpu.so.1',
|
381 |
'Darwin': 'libedgetpu.1.dylib',
|
382 |
'Windows': 'edgetpu.dll'}[platform.system()]
|
383 |
interpreter = tfli.Interpreter(model_path=w, experimental_delegates=[tfli.load_delegate(delegate)])
|