NAV
python

TRAINING INTRODUCTION

Welcome to the REBOTNIX World! You can use our VISIONTOOLS to build your own custom AI pipelines, including Tracking, Training and Inference.

We have language bindings in Python!

SETUP

A REBOTNIX license key is required. Without a valid key the results will be limited to 100 frames.

To utilize your NVIDIA GPU for a speedup please install the CUDA Toolkit as well as CUDnn.

Please use Python version 3.7 and OpenCV version 3.2.

In addition we strongly recommend to install all neccessary python packages within a virtual environment. To do so we are providing a file named "requirements.txt". An example on how to install the packages can be found on the right side.

# execute in terminal
virtualenv -p python3.7 rebotnix_venv
source rebotnix_venv
pip install -r requirements.txt

TRAINING

A REBOTNIX license key is required. Without a valid key the results will be limited to 1000 training epochs.

REBOTNIX Training is a tool to train a custom Object Detection Model.

Please use Python version 3.7 and OpenCV version 3.2.

This module runs only on a NVIDIA GPU.

from preprocessor_rebotnix_license import preprocessor_rebotnix
import sys

# initialize the trainer with an input path and your license key
license_key = ""
datapath = "/path/to/input_dir"
trainer = preprocessor_rebotnix(datapath, license_key)

# path to store the training files
output_path = "/path/to/output_dir"

# categories defines the classes you wanr to train on, if None then you train all available categories
categories = None

#mode defines the type of training. You can choose between ["small", "normal", "spp", "big"]
mode = "small"

#train_ratio defines how to split the training and the validation files, per default this is 80:20
train_ratio = 0.8

#image_size defines the size to train on. The smaller the image_size the faster the training process
img_size = 416

#set max epochs number to "auto" or a fixed value (best multiple of 1000)
max_epochs = "auto"

#start the training
result = trainer.preprocess(output_path, categories, mode, train_ratio, img_size, max_epochs=max_epochs)

# get statistics during the training in form of json
control = 1
while control:
    status = trainer.getStats()
    if "status" in status:
        print(status)
        s = str(status["status"])
        if "fin" in s or "failed" in s:
            control = 0
            time.sleep(5)
            try:
                os.kill(status["pid"], 9)
            finally:
                break

The above command returns a list of JSON structured like this:

  {
    "max_epochs": 1000,
    "timestamp": 1600867984.3213663,
    "epoch": 1,
    "loss": 409.427307,
    "avg_loss": 409.427307,
    "status": "running",
    "pid": 16971,
    "progress": 0.1
  },
  ...
  ,
  {
    "max_epochs": 1000,
    "timestamp": 1600982972.343197,
    "epoch": 5,
    "loss": 0.25,
    "avg_loss": 0.2785,
    "status": "finished",
    "pid": 16971,
    "progress": 100
  }