项目作者: xadrianzetx

项目描述 :
Coral Edge TPU compilable version of DeepLab V3
高级语言: Python
项目地址: git://github.com/xadrianzetx/coral-deeplab.git
创建时间: 2021-03-06T19:20:55Z
项目社区:https://github.com/xadrianzetx/coral-deeplab

开源协议:MIT License

下载


coral-deeplab

Coral Edge TPU compilable version of DeepLab v3 and DeepLab v3 Plus implemented in tf.keras with Edge TPU pre-compiled models included.

Implementation follows original paper as close as possible, while still being compatible with Edge TPU. The only difference is that last upsampling layer has been removed from decoder due to performance reasons. Thanks to multi subgraph support in edgetpu_compiler, model runs almost all operations on TPU, where original model delegates entirety of decoder to run on CPU.

Instalation

  1. pip install git+https://github.com/xadrianzetx/coral-deeplab.git

Usage

You can train from scratch…

  1. import tensorflow as tf
  2. import coral_deeplab as cdl
  3. model = cdl.applications.CoralDeepLabV3()
  4. isinstance(model, tf.keras.Model)
  5. # True

…or just pull pre-compiled Edge TPU models straight to interpreter (can use --no-deps for lightweight install).

  1. import coral_deeplab as cdl
  2. import tflite_runtime.interpreter as tflite
  3. interpreter = tflite.Interpreter(
  4. cdl.from_precompiled(cdl.pretrained.EdgeTPUModel.DEEPLAB_V3_DM1),
  5. experimental_delegates=[tflite.load_delegate("libedgetpu.so.1")]
  6. )

Compiler

Use edgetpu_compiler version 14.1 or 15.0 to compile finetuned or trained from scratch models. Correct version can be obtained
by running ./compiler/compiler.sh or here.

Latency

All models have been tested with 513x513 input on fresh install of Raspbian GNU/Linux 10 (buster).

Model Backbone Depth mul. ARM Cortex-A53 (RPi3B+) ARM Cortex-A72 (RPi4)
DeepLab v3 (google) MobileNet v2 1.0 ~368.6 ms/iter (~2.7 FPS) ~147.5 ms/iter (~6.8 FPS)
DeepLab v3 (this) MobileNet v2 1.0 ~143.0 ms/iter (~7.0 FPS) ~43.7 ms/iter (~22.9 FPS)
DeepLab v3 (this) MobileNet v2 0.5 ~129.4 ms/iter (~7.8 FPS) ~32.6 ms/iter (~30.6 FPS)

Results

From left: original image, DeepLab v3 (google), DeepLab v3 (this). All segmentation masks were produced with Edge TPU.



References