Coder Social home page Coder Social logo

bitou_inference's Introduction

bitou_inference

Inference Repository for the bitou model - deployment

Usage

Docker

  1. Ensure that you have docker installed on your computer
  2. Only once - Build the image defined in the Dockerfile.
    1. Either through docker compose build flask-deploy. This will build the image with the name bitouflask
    2. Through running docker build --target prod -t bitouflask in the command line
  3. Deploy the image with the name bitouflask (which should show up as built when running docker images)
    1. Either through docker compose up flask-deploy
    2. Or through docker run -p 5000:5000 bitouflask
  4. Open a private browser window (otherwise the content of the html will be cached and updates not displayed correctly) and enter 127.0.0.1:5000
  5. Select an image and click "upload" to show inference results

Notes

  • Building the image (steps 1 and 2) are only necessary when definitions have changed. Otherwise start at step 3 to use the local image
  • Building the image will take a significant amount of time (~45 minutes) and Hard drive space (~8 GB)

Conda

The package can also be installed using conda on Ubuntu Linux 22.04.

  1. run conda env create -f csuinf.txt to create the environment
  2. run conda activate csuinf to activate the environment. This has flask and all necessary files installed
  3. download / symlink the files model.py and utils.py from the bitou segmentation repository
    1. Download model.py and place it in src/csuinf
    2. Download utils.py and place it in src/csuinf
  4. Install the local files locally into the conda environment through running pip install -e .
  5. Download the colour_code.json and place it in config
  6. Run app.py by running python app.py. Alternatively use the default flask config that is targeted.
  7. Access 127.0.0.1:500 in a local private browser and upload an image. The uploaded images can be found in the images directory and are persistent!

Explanation

Debugging Configuration

A debugging configuration is provided that allows running the model inside a docker container and attaching to it through a vscode debugger.

  1. build the dev configuration of the container.
    1. Through docker compose build flask-debug
    2. Through docker build --target dev -t dev/pytorchflask .
  2. Deploy the container through running docker compose up flask-debug - this will ensure correct port forwarding
  3. Place a breakpoint in app.py in vscode.
  4. Use the launch configuration Python: Remote Attach defined in launch.json to run app.py
  5. Open a private browser and enter 127.0.0.1:5000 and follow the desired commands
  6. vscode should stop at the breakpoint

Tutorials and helpful resources

  1. This basic one from the pytorch development team, on their website
  2. This one from docker itself how to run a flask application inside docker on git
  3. This one from an AI Engineer on Medium
  4. This one from another engineer, which also includse docker on his website
  5. This one from some guy who already wrote a git for this stuff on GitHub
  6. This better Github Version of a dockerfile on GitHub
  7. Something about Docker Port mapping and exposing here
  8. This one about uploading images with flask to a website from some guy on Youtube
  9. Image Upload and display without saving to storage - on GitHub
  10. Image upload and display with saving to storage - a blog post
  11. Debugging flask and python with vscode
  12. Displaying an image in flask with python on Stackoverflow
  13. Debugging docker and flask inside vscode in this medium post
  14. Dockerizing and debugging flask and vscode with docker in this blog post

bitou_inference's People

Contributors

nicomandel avatar dwheelerau avatar

Stargazers

 avatar

Watchers

 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.