The following python modules are required:
- numpy
- pandas
- yaml
- tensorflow
- nets (pip only)
- tqdm
- json
Specify various parameters for training, validating, and testing the model in a YAML file. An example is provided in config.yml.example. This example has been modified from the original to better reflect the state of the code.
The following tables describe parameters that must be set. There are no defaults within the code.
Parameters for the storage of log files, checkpoints, etc.
| Name | Function |
|---|---|
| TENSORBOARD_LOG_DIR | Directory for saving log information |
| CHECKPOINT_DIR | Directory for storing checkpoints |
| FINAL_SAVE_DIR | Directory for saving the final training data |
| BACKUP_DIR | Directory for storing backup data; this is an experimental Keras feature |
Parameters for specifying dataset location and metadata. Datasets should be stored in JSON format and are read in using Pandas.
| Name | Function |
|---|---|
| TRAINING_DATA | JSON file with training data |
| VAL_DATA | JSON file with validation data |
| TEST_DATA | JSON file with test data |
| NUM_CLASSES | Number of output classes |
| LABEL_COLUMN_NAME | Name of the column containing class labels |
Parameters specifying the neural network.
| Name | Function |
|---|---|
| IMAGE_SIZE | 2D list of integers specifying the size of each input image. |
| DROPOUT_PCT | Dropout percentage for the layer between "pool" and "logits" |
| PRETRAINED_MODEL | "None" (for random initialization), "imagenet" (if pre-training is hosted there), or path to a weights file |
Parameters for training the model. The training framework is hardcoded to use the "rmsprop" optimizer.
| Name | Function |
|---|---|
| TRAIN_MIXED_PRECISION | Set to "True" only if your GPU supports CUDA >= 7.0 |
| MULTIGPU | Boolean; use more than one GPU |
| BATCH_SIZE | Size of batch per GPU |
| NUM_EPOCHS | Number of training epochs |
| DO_LABEL_SMOOTH | Enable label smoothing in the categorical cross entropy loss function |
| LABEL_SMOOTH_MODE | Distribution; the only currently supported mode is "flat" |
| LABEL_SMOOTH_PCT | Percentage by which to smooth the labels |
| INITIAL_LEARNING_RATE | Initial learning rate |
| LR_DECAY_FACTOR | Learning rate decay factor |
| EPOCHS_PER_LR_DECAY | Number of epochs over which to decay by |
| RMSPROP_RHO | Parameter "rho" for the "rmsprop" optimizer |
| RMSPROP_MOMENTUM | Parameter "momentum" for the "rmsprop" optimizer |
| RMSPROP_EPSILON | Parameter "epsilon" for the "rmsprop" optimizer |
After constructing a configuration file, the model can be trained by running python train.py --config_file <config.yml>.
Some basic augmentation is performed on the training data. This augmentation includes:
- Random cropping (image is resized to IMAGE_SIZE)
- Flip 50% of the time
- Recolor 30% of the time (random hue, saturation, brightness, contrast)
A trained model can be evaluated using python eval.py --config_file <config.yml>. This is the one required argument.
There are also the following optional arguments:
| Argument | Function |
|---|---|
--use_checkpoint |
If present, will evaluate using a checkpoint rather than the final export |
--should_save_results |
If yes, will save evaluation results to --save_file |
--save_file |
File in which to save evaluation results. Will be .npz. |