GithubHelp home page GithubHelp logo

kleinyuan / tf-segmentation Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 2.0 138 KB

Real-time semantic segmentation inference production ready code based on deeplab-resnet/psp-net and tensorflow

License: MIT License

Python 99.80% Shell 0.08% Makefile 0.12%
semantic-segmentation segmentation tensorflow deeplab-resnet resnet real-time pspnet pspnet-tensorflow docker api

tf-segmentation's Introduction

Introduction

Real time segmentation inference production ready code based on DeepLab-ResNet, PSP Net.

Demo Segmentation

Note

This repo is basically a cleaned unified re-organized code from multiple open sourced projects. I tried to implement as good practice as possible. However, there are still some ugly code borrowed from the original repo requiring tons of time to refine, while I haven't got enough bandwidth yet. Ultimately, I will even rewrite all the models/network layers so that it's easier to understand, modify, deploy on all levels, with clean level similar to this one.

Honestly, if the pre-trained model can be frozen well, we can just use similar architecture for inference. However, unfortunately, my previous efforts on freeze the graph and fetch tensor running the compute does not really give reasonable predictions. I may spend more time on that issue later so that we can remove the ugly network constructing code.

This repo is all about inference, server, api instead of training, or research.

Therefore, you are expected to do following things with this repo:

  • Real Time Segmentation with multiple models against Camera

  • Segmentation API wrapped up with Docker container, ready to deploy

  • Multiple open source pre-trained segmentation model performance evaluation against single image

Dependencies

Actually simply using Anaconda may save you a year!

  • Python 2.X

  • Tensorflow > 1.0.0

  • OpenCV

  • No GPU required

Run Demo

  1. Download pre-trained model first
  1. Put model.* files under /model folder ensuring the name is consistent with model name
--model
  |-- deeplab
      |-- checkpoint
      |-- model.ckpt-100000.data-00000-of-00001
      |-- model.ckpt-100000.index
      |-- model.ckpt-100000.meta
  |-- pspnet50
      |-- checkpoint
      |-- model.ckpt-0.data-00000-of-00001
      |-- model.ckpt-0.index
      |-- model.ckpt-0.meta
  |-- pspnet101
      |-- checkpoint
      |-- model.ckpt-0.data-00000-of-00001
      |-- model.ckpt-0.index
      |-- model.ckpt-0.meta

  1. run below:
make demo

Note: you can change this line to be with DeepLab, PSPNet101 and PSPNet50.

Freeze Model [Optional]

# Navigate to tf-segmentation
bash freeze.sh

References

Paper:

  1. Chen, Liang-Chieh, et al. "Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs." arXiv preprint arXiv:1606.00915 (2016).

  2. Zhao, Hengshuang, et al. "Pyramid scene parsing network." IEEE Conf. on Computer Vision and Pattern Recognition (CVPR). 2017.

Borrowed Code

  1. model.py/network.py are borrowed from DrSleep's implementation. The layout does not seem ideal to me and I may re-implement them later on, but for now, I will just stick with it.

  2. Pre-trained weight can be referred from Indoor-segmentation

  3. PSP Network code borrowed but refined from PSP-tensorflow

Docker

make build run

API

URL: http://0.0.0.0:8080/segmentation

HEADERS: {'Content-Type': application/json}

BODY: {url: ''}

Future Work

  • Freeze model as a google protobuf file

  • Wrap up this with flask as a Restful API

  • Wrap up this with Docker as a micro-server

tf-segmentation's People

Contributors

kleinyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tf-segmentation's Issues

Frozen model for inference

Thanks for writing this beautiful piece.

I was looking for inference from frozen graph (for higher fps after optimizing). The inference script loads from checkpoint, for frozen graph, what would be input, output nodes?

Thanks!

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.