Code Monkey home page Code Monkey logo

coral-deeplab's Introduction

coral-deeplab

Coral Edge TPU compilable version of DeepLab v3 and DeepLab v3 Plus implemented in tf.keras with pretrained weights and 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.

Thanks to pretrained weights and tf.keras implementation it's easy to fine tune this model, or even train it from scratch.

Instalation

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

Usage

You can train from scratch...

import tensorflow as tf
import coral_deeplab as cdl

model = cdl.applications.CoralDeepLabV3()
isinstance(model, tf.keras.Model)
# True

...finetune...

import tensorflow as tf
import coral_deeplab as cdl

model = cdl.applications.CoralDeepLabV3(weights="pascal_voc")
isinstance(model, tf.keras.Model)
# True

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

import coral_deeplab as cdl
import tflite_runtime.interpreter as tflite

interpreter = tflite.Interpreter(
    cdl.from_precompiled(cdl.pretrained.EdgeTPUModel.DEEPLAB_V3_DM1),
    experimental_delegates=[tflite.load_delegate("libedgetpu.so.1")]
)

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

coral-deeplab's People

Contributors

xadrianzetx avatar bsteiner-dandy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.