Skip to content

Jonathancasjar/Inventory_management_with_object_detection

Repository files navigation


Inventory management with object detection.

Imagen Imagen2

Data Preparation steps

1. First download the data from S3 AWS with AWS CLI:

AWS CLI

2. Then prepare the data into the correct folder structure:

  • DOCKER CONTAINER

Project container - Docker

Install

You can use Docker to easily install all the needed packages and libraries:

  • CPU:

To build Docker use:

$ docker build -t casjar_obj_detect --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -f docker/Dockerfile .
  • GPU:

$ docker build -t casjar_obj_detect_gpu --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -f docker/Dockerfile_gpu .

To Run Docker use:

  • CPU:
$ docker run --rm --net host -it \
    -v $(pwd):/home/app/src \
    --workdir /home/app/src \
    casjar_obj_detect \
    bash
  • GPU:
$ docker run --rm --net host --gpus all -it \
    -v $(pwd):/home/app/src \
    --workdir /home/app/src \
    casjar_obj_detect_gpu \
    bash

To prepare the dataset run the following code:

$ python3 scripts/prepare_train_test_dataset.py "/home/app/src/data/SKU110K_fixed/images" "/home/app/src/data/SKU110K_fixed/annotations" "/home/app/src/data/SKU110K_fixed/data_v2"

Download the Yolov5 model and the Dataset with the Missing products from Roboflow

  1. Run the model:
  • In the terminal run:
 - git clone https://github.com/ultralytics/yolov5
  • To download the dataset with the missing spaces run the next code:
rf = Roboflow(api_key="YOUR API KEY HERE")
project = rf.workspace("final-project-object-detection-for-instore-inventory-management").project("empty-spaces-in-a-supermarket-hanger-1upsp")
dataset = project.version(26).download("yolov5")

Notebooks

Open and run the notebooks located in notebooks/ folder in the following order:

  • EDA Make an exploratory data analysis.
  • Training_notebook Train the first model with Yolov5 and fine-tune the model with the Missing-spaces dataset
  • Evaluation Evaluate your trained models in the test set.

Docker API Services

  1. To run the services need to use compose:
$ docker-compose up --build -d
  1. The best model obtained is moved to the model/models folder for use in the API.

To obtain a good model I train the model with 150 epochs, here are the results:

  • Results obtained with the main model Results