Skip to content

The "Prediction" project is an object detection service in Rust and Actix-Web with high performance and robustness.

Notifications You must be signed in to change notification settings

automataIA/Rust-MLOps-predictor-RestAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎯 Yolo prediction service

Rust Actix-web ONNX Runtime Docker License

High performance detection service based on Yolov8 and implemented in rust.

🚀 Characteristics

  • ⚡ Asynchronous processing of requests
  • 🔍 Real time detection in real time
  • 🎨 Support for images in basic format64
  • 📊 Structured json output
  • 🛡️ Robust management of errors
  • 🔄 Optimized Prestimized Images

🏗️ Project structure

├── assets
│   └── coco_classes.txt     # Coco classes for labeling
├── models
│   ├── coco_classes.txt     # Classes configuration
│   ├── coco.yaml            # Coco configuration
│   └── yolov8n.onnx         # YOLO Model pre-trained with COCO dataset
├── outputs                  # Directory Output Predizioni
├── src
│   └── main.rs              # Main source code
└── Dockerfile               # Docker configuration

⚙️ Configuration

The service requires the following ambient variables:

  • RUST_LOG: Logging level (es. "info", "debug")
  • MODEL_PATH: Path of the onnx model
  • CLASSES_PATH: Classes' route route
  • HOST: Service host (default: "0.0.0.0")
  • PORT: Service door (default: 5000)

🛠️ Build and start

Buil

cargo build --release

Docker use

docker build -t yolo-prediction .
docker run -p 5000:5000 yolo-prediction

🔌 API Endpoints

Prediction objects

  • URL: /predict
  • Metodo: POST
  • Body:
    {
      "image": "base64_encoded_image"
    }
  • Risposta:
    {
      "detections": [
        {
          "class": "person",
          "confidence": 0.95,
          "bbox": [x, y, width, height]
        }
      ]
    }

Health control

  • URL: /health
  • Method: GET
  • Answer: 200 OK

📈 Performance

  • asynchronous processing to manage multiple requests
  • uploading the model only once to startup
  • Optimized Pretimized Images
  • Configurable confidence Threshold (default: 0.25)

📝 Notes

  • The service uses Yolov8 in Onnx format for object detection
  • Supports the 80 Coco Standard classes
  • Optimized input size: 640x640 pixels

About

The "Prediction" project is an object detection service in Rust and Actix-Web with high performance and robustness.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published