MCPcopy Create free account
hub / github.com/ChenhongyiYang/QueryDet-PyTorch / default_argument_parser

Function default_argument_parser

train_tools/visdrone_train.py:166–220  ·  view source on GitHub ↗

Create a parser with some common arguments used by detectron2 users. Args: epilog (str): epilog passed to ArgumentParser describing the usage. Returns: argparse.ArgumentParser:

(epilog=None)

Source from the content-addressed store, hash-verified

164
165
166def default_argument_parser(epilog=None):
167 """
168 Create a parser with some common arguments used by detectron2 users.
169
170 Args:
171 epilog (str): epilog passed to ArgumentParser describing the usage.
172
173 Returns:
174 argparse.ArgumentParser:
175 """
176 parser = argparse.ArgumentParser(
177 epilog=epilog
178 or f"""
179 Examples:
180
181 Run on single machine:
182 $ {sys.argv[0]} --num-gpus 8 --config-file cfg.yaml MODEL.WEIGHTS /path/to/weight.pth
183
184 Run on multiple machines:
185 (machine0)$ {sys.argv[0]} --machine-rank 0 --num-machines 2 --dist-url <URL> [--other-flags]
186 (machine1)$ {sys.argv[0]} --machine-rank 1 --num-machines 2 --dist-url <URL> [--other-flags]
187 """,
188 formatter_class=argparse.RawDescriptionHelpFormatter,
189 )
190 parser.add_argument("--config-file", default="", metavar="FILE", help="path to config file")
191 parser.add_argument(
192 "--resume",
193 action="store_true",
194 help="whether to attempt to resume from the checkpoint directory",
195 )
196 parser.add_argument("--eval-only", action="store_true", help="perform evaluation only")
197 parser.add_argument("--no-pretrain", action="store_true", help="whether to load pretrained model")
198 parser.add_argument("--num-gpus", type=int, default=1, help="number of gpus *per machine*")
199 parser.add_argument("--num-machines", type=int, default=1, help="total number of machines")
200 parser.add_argument(
201 "--machine-rank", type=int, default=0, help="the rank of this machine (unique per machine)"
202 )
203
204 # PyTorch still may leave orphan processes in multi-gpu training.
205 # Therefore we use a deterministic way to obtain port,
206 # so that users are aware of orphan processes by seeing the port occupied.
207 port = 2 ** 15 + 2 ** 14 + hash(os.getuid() if sys.platform != "win32" else 1) % 2 ** 14
208 parser.add_argument(
209 "--dist-url",
210 default="tcp://127.0.0.1:{}".format(port),
211 help="initialization URL for pytorch distributed backend. See "
212 "https://pytorch.org/docs/stable/distributed.html for details.",
213 )
214 parser.add_argument(
215 "opts",
216 help="Modify config options using the command-line",
217 default=None,
218 nargs=argparse.REMAINDER,
219 )
220 return parser
221
222
223def setup(args):

Callers 1

train_visdrone.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected