ArgumentParser
This module provides functions to create argument parsers for configuring, training, and running the image classification model.
argparser()
Creates an argument parser for configuring and training the machine learning model.
Arguments:
--datapath(str): Path to the tar file containing the training data. Default is/store/empa/em09/aquascope/phyto.tar.--train_outpath(str): Output path for training artifacts. Default is./train_out.--main_param_path(str): Main directory where the training parameters are saved. Default is./params/.--dataset(str): Name of the dataset. Default isphyto.--use_wandb(flag): Use Weights and Biases for logging. Default isFalse.--priority_classes(str): Path to the JSON file specifying priority classes for training. Default is an empty string.--rest_classes(str): Path to the JSON file specifying rest classes for training. Default is an empty string.--balance_classes(flag): Balance the classes for training. Default isFalse.--batch_size(int): Batch size for training. Default is180.--max_epochs(int): Number of epochs to train. Default is20.--lr(float): Learning rate for training. Default is1e-2.--lr_factor(float): Learning rate factor for training of full body. Default is0.01.--no_gpu(flag): Use no GPU for training. Default isFalse.--testing(flag): Set this toTrueif in testing mode,Falsefor training. Default isFalse.--loss(str): Loss function to use (choices:cross_entropy,focal). Default iscross_entropy.--no_TTA(flag): Enable Test Time Augmentation. Default isFalse.
Returns:
argparse.ArgumentParser: The argument parser with defined arguments.
inference_argparser()
Creates an argument parser for using the classifier on unlabeled data.
Arguments:
--batch_size(int): Batch size for inference. Default is180.--outpath(str): Directory where predictions will be saved. Default is./preds/.--model_path(str): Path to the model checkpoint file. Default is./checkpoints/model.ckpt.--datapath(str): Path to the tar file containing the data to classify. Default is/store/empa/em09/aquascope/phyto.tar.--no_gpu(flag): Use no GPU for inference. Default isFalse.--no_TTA(flag): Disable test-time augmentation. Default isFalse.--gpu_id(int): GPU ID to use for inference. Default is0.--limit_pred_batches(int): Limit the number of batches to predict. Default is0, meaning no limit, set a low number to debug.--prog_bar(flag): Enable progress bar. Default isFalse.
Returns:
argparse.ArgumentParser: The argument parser with defined arguments.
Example Usage
if __name__ == "__main__":
parser = argparser() # or inference_argparser()
args = parser.parse_args()
print(args)