Skip to content

Latest commit

 

History

History
109 lines (64 loc) · 3.64 KB

README.md

File metadata and controls

109 lines (64 loc) · 3.64 KB

Deep Learning web inference engine in Rust

This project is a showcase of Deep leaarning inference engine implemented as fullstack Rust web applications.

The Deep learning frameworks used by this application are PyTorch and TensorFlow.

Both frameworks are already ported to rust from native C/C++ library. The purpose of this project is to build powerful fullstack webb application that has Deep Learning capabilities. By leveraging rust high performance web backend, the inference engine is way better than python in term of performance and easy integration with frontend compared to C++.

Features :

  • Object detection : This feature uses PyTorch pretrained model generated by TorchScript
  • Face detection : This features use TensorFlow pretrained mtcnn model.

links:

Object detection

This feature is a simple computer vision image classification. Uploaded image will be feeded into PyTorch pretrained model via REST API. The backend will response the object detection results in a JSON format. Then, the front end web displays it into the page. The result labels are displayed as list of chips components between title and uploaded image.

Face detection

Screen shots

Object detection

Object Detection

Face detection

Face Detection

Getting Started with Create Rust App

This project was bootstrapped with Create Rust App.

Requirements

  • stable Rust
  • Diesel CLI
    • if using postgres, cargo install diesel_cli --no-default-features --features postgres
    • if using sqlite, cargo install diesel_cli --no-default-features --features sqlite-bundled
  • cargo-watch to recompile on change:
    • cargo install cargo-watch (allows running cargo watch -x run -i frontend/ for continuous compilation; see "available scripts")

Notes

  • In development, the .env file is read (use .env.example for reference)
  • In production, environment variables are sourced directly

Available Scripts

In the project directory, you can run:

cargo fullstack

Runs the app in development mode and watches for changes. Visit http://localhost:3000 to view it.

Any frontend changes should instantly appear. Backend changes will need to recompile. Needs cargo-watch installed, see requirements.

To test/debug issues with the production build, set the debug-assertions to true for [profile.dev] in Cargo.toml. This way, development-only code paths are discarded and instead, production-only code paths are included.

Alternatively, use cargo run to run the app in development mode without watching for file changes.

cargo build

Builds a production-ready build.

cargo tsync

Generates the typescript types from rust code marked with tsync. Outputs to frontend/src/types/rust.d.ts.

Running frontend and backend individually

# frontend
cd frontend && yarn && yarn start
# backend
cargo watch -x run -i frontend/

Database Migrations

  • diesel migration generate <migration_name>

  • diesel migration run

  • diesel migration revert

  • diesel database setup

  • diesel database reset

Containerize your application

Building a container

docker build -t image-name .

Running the container

docker run -e SECRET_KEY=123 -e DATABASE_URL=postgres://postgres:postgres@localhost/database -p 3000:3000 image-name