Skip to content

Arg parser

Xavier edited this page Aug 17, 2021 · 1 revision

Arg Parser 💬

You can run scripts with args to do some basic settings. It is coded in utils/arg_parsers.py

Training

You can run launcher.py with args listed below

  • exp_name to specify your experiment name, default value is 'exp1'
  • gpus to specify the working gpus, default value is -1
  • log_dir to specify the log output directory, default value is './logs/'
  • save_path to specify the final pth output path, default value is './checkpoint/model.pth'

Testing

You can run test.py with args listed below

  • test_name to specify your test name, default value is 'test1'
  • gpus to specify the working gpus, default value is -1
  • ckpt to specify the checkpoint path, default value is './logs/main/version_2/checkpoints/epoch=4-step=1954.ckpt' (you need to modify this)

Predicting

You can run Predictor.py with args listed below

  • input to specify the input image, default value is './input'
  • ckpt to specify the checkpoint path, default value is './logs/main/version_2/checkpoints/epoch=4-step=1954.ckpt' (you need to modify this)

Appendix

# utils/arg_parsers.py
from argparse import ArgumentParser

# launcher.py args
def train_arg_parser():
    parser = ArgumentParser()
    parser.add_argument("--exp_name", default='exp1')
    parser.add_argument("--gpus", default=-1)
    parser.add_argument("--log_dir", default='./logs/')
    parser.add_argument("--save_path", default='./checkpoint/model.pth')
    args = parser.parse_args()
    return args

# test.py args
def test_arg_parser():
    parser = ArgumentParser()
    parser.add_argument("--test_name", default='test1')
    parser.add_argument("--log_dir", default='./logs/')
    parser.add_argument("--ckpt", default='./logs/main/version_2/checkpoints/epoch=4-step=1954.ckpt')
    args = parser.parse_args()
    return args

# predictor.py args
def predict_arg_parser():
    parser = ArgumentParser()
    parser.add_argument("--input", default='./input')
    parser.add_argument("--ckpt", default='./logs/main/version_2/checkpoints/epoch=4-step=1954.ckpt')
    args = parser.parse_args()
    return args

Clone this wiki locally