Skip to content

v0.2.0

Choose a tag to compare

@sbatchelder sbatchelder released this 31 Oct 16:33
· 4 commits to main since this release

Multiclass model training now uses pydantic typing, and the cli args are automatically generated from them.

usage: image_classifier_dojo TRAIN MULTICLASS 
    [--logger [JSON]] 
    [--dataset_config [JSON]]
    [--model [JSON]] 
    [--training [JSON]]
    [--runtime [JSON]]

options:
  -h, --help            show this help message and exit

logger options:
  --logger [JSON]       set logger from JSON string (default: {})
  --logger.repo str     Aim repo path. (required)
  --logger.experiment {str,null}
                        The broader category/grouping this RUN belongs to (default: null)
  --logger.run {str,null}
                        The name of this run. May get overwritten by RuntimeConfig.run_name (default: null)
  --logger.note {str,null}
                        Add any kind of note or description to the trained model. (default: null)
  --logger.context_prefixes {Dict[str,Dict[str,str]],null}
                        Sets a metric's context based on the logged metric's name's prefix (default: null)
  --logger.context_postfixes {Dict[str,Dict[str,str]],null}
                        Sets a metric's context based on the logged metric's name's postfix (default: null)

logger.artifacts_location options:
  default: null (undefined)
  Aim Artifacts location. Either a local path or an S3 location

  --logger.artifacts_location [{str,JSON,null}]
                        set logger.artifacts_location from JSON string (default: {})
  --logger.artifacts_location.bucket str
                        S3 Bucket Name (ifdef: required)
  --logger.artifacts_location.prefix {str,null}
                        Optional Prefix/Folder in the Bucket (default: )
  --logger.artifacts_location.endpoint str
                        S3 Endpoint for (ifdef: required)
  --logger.artifacts_location.accesskey str
                        Access Key (ifdef: required)
  --logger.artifacts_location.secretkey str
                        Secret Key (ifdef: required)

dataset_config options:
  --dataset_config [JSON]
                        set dataset_config from JSON string (default: {})

dataset_config.dataset options:
  --dataset_config.dataset [JSON]
                        set dataset_config.dataset from JSON string (default: {})
  --dataset_config.dataset.classlist str
                        A text file, each line is a class label (the label order is significant) (required)
  --dataset_config.dataset.trainlist str
                        A text file, one sample per line, each sample has a class-index and image path (required)
  --dataset_config.dataset.vallist str
                        Like trainlist, but for validation metrics and early-stopping/overfit-prevention (required)
  --dataset_config.dataset.testlist {str,null}
                        Like trainlist, but for final test metrics. Optional (default: null)

dataset_config.img_norm options:
  default: null (undefined)

  --dataset_config.img_norm [{JSON,null}]
                        set dataset_config.img_norm from JSON string (default: {})
  --dataset_config.img_norm.mean {float,Tuple[float,float,float]}
                        Mean values for each channel used in normalization. Defaults to ImageNet standards (default: (0.485, 0.456, 0.406))
  --dataset_config.img_norm.std {float,Tuple[float,float,float]}
                        Standard deviation values for each channel used in normalization. Defaults to ImageNet standards (default: (0.229, 0.224,
                        0.225))

dataset_config.training_transforms options:
  default: null (undefined)

  --dataset_config.training_transforms [{JSON,null}]
                        set dataset_config.training_transforms from JSON string (default: {})
  --dataset_config.training_transforms.flip {{x,y,xy},null}
                        Training images have 50% chance of being flipped along the designated axis: (x) vertically, (y) horizontally, (xy)
                        either/both. (default: null)

model options:
  --model [JSON]        set model from JSON string (default: {})
  --model.weights {str,null}
                        Path to model weights/checkpoint to load (default: null)

model.backbone options:
  The model backbone configuration

  --model.backbone [JSON]
                        set model.backbone from JSON string (default: {})
  --model.backbone.model_name str
                        Model Class/Module Name (required)
  --model.backbone.pretrained_weights {str,null}
                        Specify a model's downloadable pretrained weights. Either "DEFAULT", some specific identifier, or "None" for no-pretrained-
                        weights (default: null)

model.head options:
  The model head (output) configuration

  --model.head [JSON]   set model.head from JSON string (default: {})
  --model.head.head_type multiclass
                        (default: multiclass)
  --model.head.name {str,null}
                        An optional name for this head, if multiple heads are used (default: head)
  --model.head.num_classes {int,null}
                        The number of classes to predict (default: null)
  --model.head.embedding_size list[int]
                        The size of the output embedding vector (required)
  --model.head.range_min {float,null}
                        The minimum possible value of the output (default: null)
  --model.head.range_max {float,null}
                        The maximum possible value of the output (default: null)

training options:
  Training configuration

  --training [JSON]     set training from JSON string (default: {})
  --training.batch_size int
                        Number of images per batch. Defaults is 256 (default: 256)
  --training.precision {transformer-engine,transformer-engine-float16,16-true,16-mixed,bf16-true,bf16-mixed,32-true,64-true}
                        dtype Precision (default: 16-mixed)

training.epochs options:
  Epoch configuration

  --training.epochs [JSON]
                        set training.epochs from JSON string (default: {})
  --training.epochs.max_epochs int
                        Maximum number of training epochs. Default is 100 (default: 100)
  --training.epochs.min_epochs {int,null}
                        Minimum number of training epochs. Default is 10 (default: null)
  --training.epochs.patience {int,null}
                        Early Stopping: Number of epochs following a best-epoch after-which to stop training (default: null)

training.model_optims options:
  loss, optimizer, and freeze configs

  --training.model_optims [JSON]
                        set training.model_optims from JSON string (default: {})
  --training.model_optims.freeze {int,float,null}
                        Freezes a models leading feature layers. Positive int freezes the first N layers/features/blocks. A negative int like '-1'
                        freezes all but the last N feature/layer/block. A positive float like '0.8' freezes the leading 80% of features/layers/blocks.
                        fc or final_classifier layers are never frozen. (default: null)

training.model_optims.loss_config options:
  Loss Function.

  --training.model_optims.loss_config [JSON]
                        set training.model_optims.loss_config from JSON string (default: {})
  --training.model_optims.loss_config.reduction {sum,mean,none}
                        How loss for each input gets aggregated. (default: sum)
  --training.model_optims.loss_config.label_smoothing float
                        Label Smoothing Regularization arg. Range is 0-1. Default is 0 (default: 0.0)
  --training.model_optims.loss_config.weight {normalize,list[float],null}
                        If "normalize", rare class instances will be boosted. Otherwise accepts a list of per-class weights. Length must match number
                        of classes (default: null)
  --training.model_optims.loss_config.gamma float
                        Rate at which easy examples are down-weighted (default: 1.0)
  --training.model_optims.loss_config.alpha {list[float],null}
                        A list of per-class weights. Length must match number of classes (default: null)

training.model_optims.optimizer_config options:
  Optimizer configuration. Defaults to Adam with lr=0.001

  --training.model_optims.optimizer_config [JSON]
                        set training.model_optims.optimizer_config from JSON string (default: {})
  --training.model_optims.optimizer_config.lr float
                        Initial Learning Rate. Default is 0.001 (default: 0.001)
  --training.model_optims.optimizer_config.amsgrad bool
                        Use the AMSGrad variant of Adam (default: False)
  --training.model_optims.optimizer_config.momentum float
                        SGD momentum factor (default: 0.0)
  --training.model_optims.optimizer_config.dampening float
                        SGD dampening for momentum (default: 0.0)
  --training.model_optims.optimizer_config.weight_decay float
                        L2 penalty (weight decay) (default: 0.0)
  --training.model_optims.optimizer_config.nesterov bool
                        Enable Nesterov momentum (default: False)

training.swa options:
  Stochastic Weight Averaging (SWA) configuration. If provided, enables SWA training or SWA best-epoch polishing.

  --training.swa [{JSON,null}]
                        set training.swa from JSON string (default: {})
  --training.swa.swa_lr float
                        Stochastic Weight Averaging learning rate. Should be 0.1 to 0.3 of the global learning rate (typically 0.001) (default:
                        0.0003)
  --training.swa.swa_epoch_start {int,float}
                        If provided as int, the procedure will start from the ``swa_epoch_start``-th epoch.If provided as float between 0 and 1, the
                        procedure will start from ``int(swa_epoch_start * max_epochs)`` epoch (default: 0)
  --training.swa.annealing_epochs int
                        Reduces the learning rate to swa_lr over these many epochs (default: 5)
  --training.swa.annealing_strategy {cos,linear}
                        Stochastic Weight Averaging annealing strategy (default: cos)
  --training.swa.epochs int
                        Number of epochs to run SWA polishing for at the end of training. 2-5 epochs should be fine (default: 5)
  --training.swa.sgd_momentum float
                        SGD momentum factor for SWA polishing (default: 0.9)

runtime options:
  --runtime [JSON]      set runtime from JSON string (default: {})
  --runtime.experiment {str,null}
                        The broader category/grouping this RUN belongs to (default: null)
  --runtime.run_name {str,null}
                        The name of this run. By Default, a run name is automatically generated (default factory: RuntimeConfig.<lambda>)
  --runtime.seed {int,null}
                        Set a specific seed for deterministic output (default factory: RuntimeConfig.<lambda>)
  --runtime.num_workers int
                        Number of data-loading threads. 4 per GPU is typical (default: 4)
  --runtime.fast_dev_run, --no-runtime.fast_dev_run
                        Runs a single batch of train, val, and test to find any bugs. Default is False (default: False)
  --runtime.onnx_callback_configs {List[JSON],null}
                        If provided, exports the trained model to ONNX (default: [])

runtime.checkpoint_callback_config options:
  --runtime.checkpoint_callback_config [JSON]
                        set runtime.checkpoint_callback_config from JSON string (default: {})
  --runtime.checkpoint_callback_config.dirpath str
                        (default: ./experiments/{EXPERIMENT}/{RUN})
  --runtime.checkpoint_callback_config.filename str
                        (default: loss-{val_loss:3.3f}_ep-{epoch:03.0f})
  --runtime.checkpoint_callback_config.monitor str
                        (default: val_loss)
  --runtime.checkpoint_callback_config.save_last str
                        (default: link)
  --runtime.checkpoint_callback_config.save_top_k int
                        (default: 3)
  --runtime.checkpoint_callback_config.auto_insert_metric_name bool
                        (default: False)

runtime.autobatch options:
  default: null (undefined)
  Auto-Tunes batch_size prior to training/inference.

  --runtime.autobatch [{JSON,null}]
                        set runtime.autobatch from JSON string (default: {})
  --runtime.autobatch.mode {power,binsearch}
                        Power-of-2 scaling or binary search (default: power)
  --runtime.autobatch.max_size int
                        batch size limit (default: 1024)
  --runtime.autobatch.min_size int
                        batch size minimum. Error is raised if autobatch tries to go lower. (default: 32)