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

Function default_argument_parser

train_tools/coco_infer.py:68–123  ·  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

66 return DatasetEvaluators(evaluator_list)
67
68def default_argument_parser(epilog=None):
69 """
70 Create a parser with some common arguments used by detectron2 users.
71
72 Args:
73 epilog (str): epilog passed to ArgumentParser describing the usage.
74
75 Returns:
76 argparse.ArgumentParser:
77 """
78 parser = argparse.ArgumentParser(
79 epilog=epilog
80 or f"""
81 Examples:
82
83 Run on single machine:
84 $ {sys.argv[0]} --num-gpus 8 --config-file cfg.yaml MODEL.WEIGHTS /path/to/weight.pth
85
86 Run on multiple machines:
87 (machine0)$ {sys.argv[0]} --machine-rank 0 --num-machines 2 --dist-url <URL> [--other-flags]
88 (machine1)$ {sys.argv[0]} --machine-rank 1 --num-machines 2 --dist-url <URL> [--other-flags]
89 """,
90 formatter_class=argparse.RawDescriptionHelpFormatter,
91 )
92 parser.add_argument("--config-file", default="", metavar="FILE", help="path to config file")
93 parser.add_argument(
94 "--resume",
95 action="store_true",
96 help="whether to attempt to resume from the checkpoint directory",
97 )
98 parser.add_argument("--eval-only", action="store_true", help="perform evaluation only")
99 parser.add_argument("--no-pretrain", action="store_true", help="whether to load pretrained model")
100 parser.add_argument("--num-gpus", type=int, default=1, help="number of gpus *per machine*")
101 parser.add_argument("--num-machines", type=int, default=1, help="total number of machines")
102 parser.add_argument(
103 "--machine-rank", type=int, default=0, help="the rank of this machine (unique per machine)"
104 )
105
106
107 # PyTorch still may leave orphan processes in multi-gpu training.
108 # Therefore we use a deterministic way to obtain port,
109 # so that users are aware of orphan processes by seeing the port occupied.
110 port = 2 ** 15 + 2 ** 14 + hash(os.getuid() if sys.platform != "win32" else 1) % 2 ** 14
111 parser.add_argument(
112 "--dist-url",
113 default="tcp://127.0.0.1:{}".format(port),
114 help="initialization URL for pytorch distributed backend. See "
115 "https://pytorch.org/docs/stable/distributed.html for details.",
116 )
117 parser.add_argument(
118 "opts",
119 help="Modify config options using the command-line",
120 default=None,
121 nargs=argparse.REMAINDER,
122 )
123 return parser
124
125def setup(args):

Callers 1

infer_coco.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected