| 53 | |
| 54 | |
| 55 | def parse_option(): |
| 56 | parser = argparse.ArgumentParser( |
| 57 | 'InternVL training and evaluation script', add_help=False) |
| 58 | parser.add_argument('--cfg', |
| 59 | type=str, |
| 60 | required=True, |
| 61 | metavar='FILE', |
| 62 | help='path to config file') |
| 63 | parser.add_argument( |
| 64 | '--opts', |
| 65 | help="Modify config options by adding 'KEY VALUE' pairs. ", |
| 66 | default=None, |
| 67 | nargs='+') |
| 68 | |
| 69 | # easy config modification |
| 70 | parser.add_argument('--batch-size', |
| 71 | type=int, |
| 72 | help='batch size for single GPU') |
| 73 | parser.add_argument('--dataset', |
| 74 | type=str, |
| 75 | help='dataset name', |
| 76 | default=None) |
| 77 | parser.add_argument('--data-path', type=str, help='path to dataset') |
| 78 | parser.add_argument('--zip', |
| 79 | action='store_true', |
| 80 | help='use zipped dataset instead of folder dataset') |
| 81 | parser.add_argument( |
| 82 | '--cache-mode', |
| 83 | type=str, |
| 84 | default='part', |
| 85 | choices=['no', 'full', 'part'], |
| 86 | help='no: no cache, ' |
| 87 | 'full: cache all data, ' |
| 88 | 'part: sharding the dataset into nonoverlapping pieces and only cache one piece' |
| 89 | ) |
| 90 | parser.add_argument( |
| 91 | '--pretrained', |
| 92 | help= |
| 93 | 'pretrained weight from checkpoint, could be imagenet22k pretrained weight' |
| 94 | ) |
| 95 | parser.add_argument('--resume', help='resume from checkpoint') |
| 96 | parser.add_argument('--accumulation-steps', |
| 97 | type=int, |
| 98 | default=1, |
| 99 | help='gradient accumulation steps') |
| 100 | parser.add_argument( |
| 101 | '--use-checkpoint', |
| 102 | action='store_true', |
| 103 | help='whether to use gradient checkpointing to save memory') |
| 104 | parser.add_argument( |
| 105 | '--amp-opt-level', |
| 106 | type=str, |
| 107 | default='O1', |
| 108 | choices=['O0', 'O1', 'O2'], |
| 109 | help='mixed precision opt level, if O0, no amp is used') |
| 110 | parser.add_argument( |
| 111 | '--output', |
| 112 | default='work_dirs', |