This is a project I created prior to the start of an internship I completed for Nokia Bell Labs' AIMS (Autonomous Inventory Monitoring Service) team. Using drones with cameras attached, and later computer vision segmentation and classification models during postprocessing, the team created a monitoring service for warehouses, allowing their clients to keep better track of their inventory and recover any of it that was lost.
This project implements an end-to-end machine learning pipeline for automated warehouse inventory monitoring. The system trains ResNet and EfficientNet-B0 convolutional neural networks to classify warehouse shelf images as either "empty" or "filled", then deploys the trained model as a REST API service using FastAPI and Docker. The workflow includes data preprocessing with augmentation techniques, model training with class-weighted loss to handle imbalanced datasets, and containerized deployment for real-time inference on new warehouse images.
This project served as a preparation for my internship. More context about the results and directions of how to train the vision models and deploy them for classification on new images of warehouse shelves are given below. Enjoy!
Name: Alexander Romanus
Email: aromanus@gmail.com
- Model and Training Scripts: Located in the
src/directory. - API Service: Implemented in
src/app/main.py. - Model Weights: Should be stored in
src/checkpoints/warehouse_classifier.pthafter being trained in associated Colab notebook. - Dockerfile: In the project root directory.
The classification model is based on EfficientNet-B0, a pre-trained convolutional neural network from the torchvision library.
EfficientNet-B0 offers a good balance between accuracy and computational efficiency, making it suitable for deployment in resource-constrained environments.
- Total Images: 1,006 images.
- Classes:
- Empty Shelves: 325 images.
- Filled Shelves: 681 images.
- Class Imbalance: During EDA, I found that the dataset is imbalanced, with more images of filled shelves.
- Because of the strong imbalance, I trained the EfficientNet-B0 with a loss that was weighted by the proportions of the class labels
- The images are clear and well-centered, which was beneficial for model training.
To address improve model generalization and robustness, the following augmentations were applied to the training data:
- Normalization
- Random Horizontal Flips
- Color Jittering:
- Brightness Adjustment
- Contrast Adjustment
- Saturation Adjustment
- Improved Generalization: The augmentations help the model perform better on unseen data by simulating variations.
- Reduced Overfitting: The data augmentation increases the effective size of the dataset, which reducing overfitting.
- Handled Class Imbalance: The class-weighted loss during training helps give the model more importance to the minority class (empty shelves).
The final model trained is the EfficientNet-B0 with class-imbalance weighted loss.
- Training Accuracy: ~99%
- Validation Accuracy: 100%
To view training results, go here
- Docker installed on your system
- Access to Google Colab for model training
IMPORTANT: Before running the application, you must first generate the trained model weights:
- Open the Google Colab notebook
- Run all cells in the notebook to train the EfficientNet model
- The notebook will generate a
warehouse_classifier.pthfile - Download this file and place it in the
src/checkpoints/directory of this project
To build the image:
- Ensure you are in the root directory of this project
- Ensure the
warehouse_classifier.pthfile is insrc/checkpoints/ - Run the following command to build the docker image:
docker build -t warehouse-classifier .To run the docker container, enter the following command:
docker run -d --name warehouse-classifier -p 8080:8080 warehouse-classifierIf you're running on a device with an NVIDIA GPU and you'd like to run the image with GPU support, use the following command:
docker run -d --name warehouse-classifier --gpus all -p 8080:8080 warehouse-classifierOnce the container is running, you can classify warehouse images using curl:
curl -X POST -F "file=@path/to/your/image.jpg" http://localhost:8080/classify{
"confidence": 0.5755093097686768,
"prediction": "empty",
"probabilities": {
"empty": 0.5755093097686768,
"full": 0.42449072003364563
}
}GET /author- Returns author informationPOST /classify- Classifies uploaded warehouse imagesGET /health- Health check endpoint
If you encounter issues:
- Ensure the
warehouse_classifier.pthfile exists insrc/checkpoints/ - Check Docker container logs:
docker logs warehouse-classifier - Verify the container is running:
docker ps