Giter Club home page Giter Club logo

mrcnn-docker's Introduction

MaskRCNN ML Flask App


Running locally

  1. Clone repo with submodules

    $ git clone --recurse-submodules [email protected]:charyeezy/mrcnn-docker.git
  2. Set up Conda or virtual environment and install reqs for frontend and backend

    $ conda env create -f environment.yml
    $ conda activate mrcnn
  3. Set up MaskRCNN project and pycoco tools

    $ cd backend/Mask_RCNN && python3 setup.py install
    $ cd coco/PythonAPI && make
  4. Download Coco weights

     $ wget -O backend/mask_rcnn_coco.h5 https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_coco.h5
  5. Install Jupyter kernel and make sure mrcnn-predict runs with this kernel

    python -m ipykernel install --user --name mrcnn 
  6. Jupyter Gateway

    $ jupyter kernelgateway --KernelGatewayApp.api='kernel_gateway.notebook_http' --KernelGatewayApp.ip=0.0.0.0 --KernelGatewayApp.port=9090 --KernelGatewayApp.seed_uri=mrcnn-predict.ipynb --KernelGatewayApp.allow_origin='*'

Running Flask in HTTPS

  1. Use self-signed certificates using openssl

    $ cd frontend/src && openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365

Build DockerFiles

  1. Create data volume

    $ docker volume create --name mrcnn-data
  2. Create a user-defined bridge using built-in bridge network driver for app

    $ docker network create mrcnn-net
  3. Build and run frontend docker with data volume

    $ docker build --rm -f "frontend/DockerFile" -t mrcnn-frontend:latest "frontend"
    $ docker run --network mrcnn-net -itd --rm --name mrcnn-frontend -p 5000:5000  -v  mrcnn-data:/app mrcnn-frontend 
  4. Build and run backend docker with data volume and connect

    $ docker build --rm -f "backend/DockerFile" -t mrcnn-backend:latest "backend"
    $ docker run --network mrcnn-net -it --rm --name mrcnn-backend -p 9001:8888  -p 9090:9090 --volumes-from mrcnn-frontend mrcnn-backend 
  5. [Optional] Run with Jupyter notebook to edit

    $ docker run --network mrcnn-net -it --rm --name mrcnn-backend -p 9001:8888  -p 9090:9090 --volumes-from mrcnn-frontend mrcnn-backend  jupyter notebook --allow-root 

Frontend

  1. Upload pictures using Flask-Dropzone
  2. Shows prediction returned from model

Backend

Matterport's MaskRCNN is main model. The HTTP REST API is hosted using a Jupter Kernel Gateway in Jupyter notebook.

Get Docker IP

$ docker network inspect mrcnn-net
$ docker inspect <containerNameOrId> | grep '"IPAddress"' | head -n 1

mrcnn-docker's People

Contributors

charleneleong-ai avatar

Watchers

James Cloos avatar  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.