How to train your own AI model for an Inference Overlay
Jump to navigation
Jump to search
To train your own Mask R-CNN AI model for an Inference Overlay in the Tygron Platform, you will need datasets to train on.
To export these datasets using your projects in the Tygron Platform, follow this how-to.
Tygron AI Suite
A Tygron AI Suite is available at github. This repository contains the necessary files to configure a Conda environment to train a new Mask R-CNN AI model.
Anaconda Navigator will be used to manage a Conda environment and run Jupyter Notebooks with python.
Example notebooks provided in the repository can be used as a basis to train your own model.
How to train your own AI model for an Inference Overlay:
- If you are not familiar with github, you can download the zip containing all the files that you need. Otherwise, clone the git repository
- Optionally unzip and open the folder containing the downloaded files; the local repository.
- Download and install Anaconda Navigator.
- Open the Anaconda Navigator application
- Select the tab Environments and click on the Import button.
- Select the file "tygronai.yml" from the local repository of the tygron-ai-suite. This file will automatically setup the environment needed to open, edit and execute the Jupyter Notebooks.
- Once configured, select the Home tab
- Open either the JupyterLab or Jupyter Notebook application. You might need to install it first by click on the install button.
- A browser will open with the selected application.
- Browse to the folder of the tygron-ai-suite repository and select the "example_config.ipynb".
- Adjust the following parameters:
trainDirectory = "PATH TO TRAIN FILES"
testDirectory = "PATH TO TEST FILES"
to the folders containing the exported datasets. See how to export AI datasets for more information. - Press the double arrow button named Restart kernel and execute all cells to run the Jupyter Notebook. See the images below of what to expect.
- Eventually an ONNX file will be created.
Notes
- The train sets can obtain data files from sub-folders. For example, if data was exported to user/documents/foliage/train/demo_training_data, the PATH TO TRAIN FILES can be user/documents/foliage/train/. This makes it easier to train on data exported from multiple projects and combining it with your own custom data.
- Once an ONNX file is created, open the folder containing this file and drag this file into the Tygron Client Application to automatically import it with an Inference Overlay.
- In the step with the Configuration of the example_config notebook, cuda should be printed. If not, cpu will be printed. Training a model on your cpu is significantly slower. You might need to open the command line tool on your computer and run the command nvidia-smi to find out what version of cuda is supported on your gpu.
- To train a better model, increase the number of trained epochs, for example to 10:
config.setEpochs(10)
Please note that training with too many epochs may not improve the model; it will become too strict.