Giter Site home page Giter Site logo

sachsbl / segmental Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 9.94 MB

Dockerized Semantic Image Segmentation service using Tensorflow, Keras, and DeepLabv3+

License: MIT License

Python 97.22% Dockerfile 1.73% Shell 1.04%
deep-learning keras keras-tensorflow tensorflow segmentation computer-vision python docker deeplab deeplab-v3-plus tensorflow-examples

segmental's Introduction

Segmental

An example application that runs Google's DeepLabv3+ to perform Semantic Image Segmentation. It is backed by the latest Tensorflow/Keras distributions. Segmental can be run as a CLI, but is also Dockerized and can be run as a Flask app in a Docker container. The goal of this project is to provide an example of how to productionize the latest Deep Learning tech, and provide a QuickStart example for people interested in this approach. I do not claim that the segmentation results are perfect, but the model can be re-trained to provide better results and the framework provided should still work well.

Network/Model

Segmental uses Google's DeepLabv3+ with pre-trained weights. It supports MobileNetv2 (and perhaps Xception with some mods). The latest (currently Alpha) release of Tensorflow (2.0 Alpha) is used.

This work builds on the original models here: https://github.com/bonlime/keras-deeplab-v3-plus

QuickStart/Running the CLI

Clone the repo and install the dependencies using pip. Virtual Environment strongly recommended.
Only Python 3.7+ is supported.

pip install -r requirements_cli.txt

Run python segmental_cli.py --help for the CLI interface. It will display the text below

Usage: segmental_cli.py [OPTIONS] IMAGE_PATH

Options:
  --help  Show this message and exit.

To test the code on your image, run the following:

python segmental_cli.py /Path/To/Your/Image.jpg

The result should pop up in a window for viewing. Only JPEG and PNG formats are supported. Note that the first time it runs, it will take a bit longer as it needs to download and cache parameters for the model.

Docker

The Dockerfile provided can be used to build a Docker image that runs Segmental as a Flask application. See the tests for example usage. Basically it takes an image file as a parameter and returns the resulting array as a json list. Gunicorn is used for a more robust web server. You can also pull my Docker image:

docker pull sachsbl/segmental
docker run -p 80:5000 segmental

Tests

Automated tests can used to verify functionality.
These can be run with PyTest, which may need to be installed separately.

Make sure the project's directory is part of your PYTHONPATH:

export PYTHONPATH="${PYTHONPATH}:/path/to/segmental"

Install PyTest and other dependencies

pip install -r requirements_test.txt

Run the following from the root directory to run all tests:

pytest test

Example Result

Alt text Alt text

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.