Skip to content

ConfTrainer

A flexible tool for deep CNN training and evaluation

Overview

The main purpose is to make training experiments easier. Conftrainer allows to change network architecture, callbacks and hyperparameters within the shell.

It's built on top of tensorflow.

Setup

Conftrainer comes with all the necessary requirements. For argcomplete to work correctly, run after installation:

sudo activate-global-python-argcomplete

Usage

CLI commands

Some functionality is wrapped onto cli commands that run predefined. All the commands have command line arguments, which are parsed with argparser and validated through pydantic.

Every command has an option --config_path that allows to pass a .yaml file with configurations. This configurations will be used as a base, while every other specified argument will overwrite corresponding argument. For example, one can specify architecture and names of the classes in .yaml file, and parse only learning rate or batch size in the shell.

conftrainer-train [--options]

Trains a network with given parameters and saves in a given directory. First pretrains classification head with a frozen backbone, then makes some layers of backbone trainable and finetunes it too. Also saves aim logs & predictions on train/test/val datasets.

Two types of models are supported: BYOL and a regular Classifier. We plan to add more options in the future.

Configs allow to:

  • Load backbones from tf.keras.applications or kecam package and initialize with custom parameters
  • Define classification head architecture layer by layer
  • Add preprocessing layers to the network
  • Add augmentations using conftrainer.augmentation module
  • Pick loss, metrics, optimizers from tensorflow,tensorflow_addons or conftrainer.optimization
  • Define callbacks
  • Change hyperparameters for pretraining and finetuning phases

More details on config fields in the code reference

conftrainer-eval [--options]

Evaluates one or multiple models on given labeled dataset, exports a heatmap with results.

More details on config fields in the code reference

conftrainer-train-multibranch [--options]

Trains a network with multiple branches that share an encoder. This is a HARD parameter sharing, and the input data should have labels for all tasks

More details on config fields in the code reference

conftrainer-eval-multibranch [--options]

Evaluate a multibranch network.

More details on config fields in the code reference

conftrain-infer [--options]

Takes directory and model path as input, infers the network on the images within that directory

More details on config fields in the code reference

conftrainer-generate --for {task} --save_dir

Generate configurations for given task with default values, and save .yaml files in a directory.

It is helpful when creating a new default config for new data

conftrainer-modify [--options]

Modify the input and output signatures of given network(s) to prepare them for serving, and generate a tensorflow serving configuration

other

One can freely use any submodule as regular python objects in their code. For example, one can use augmentation layers when creating custom experiments.