Scheaven
2021-09-18 291deeb1fcf45dbf39a24aa72a213ff3fd6b3405
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
U
”Š`áã@sˆdZddlZddlZddlZddlZddlmZddlmZddl    m
Z
ddl m Z ddl mZddlmZddlZd    d
„Zd d „ZdS) ab
    This file contains components with some default boilerplate logic user may need
    in training / testing. They will not work for everyone, but many users may find them useful.
    The behavior of functions/classes in this file is subject to change,
    since they are meant to represent the "common default behavior" people need in their projects.
éN)Úcomm)Ú seed_all_rng)Ú PathManager)Ú setup_logger)Úcollect_env_info)Ú OrderedDictcCstjdd}|jddddd|jdd    d
d |jd d    d d |jdd    dd |jdtddd|jdtddd|jdddd|jdddd|jdddd|jdddd|jdtd d!dd"ttjd#krÚt ¡ndƒd$}|jd%d&     |¡d'|jd(d)d*tj
d+|S),zz
    Create a parser with some common arguments used by fastreid users.
    Returns:
        argparse.ArgumentParser:
    zfastreid Training)Ú descriptionz --config-fileÚZFILEzpath to config file)ÚdefaultÚmetavarÚhelpz
--finetuneÚ
store_truez5whether to attempt to finetune from the trained model)Úactionr z--resumez:whether to attempt to resume from the checkpoint directoryz --eval-onlyzperform evaluation onlyz
--num-gpuséznumber of gpus *per machine*)Útyper
r z--num-machinesztotal number of machinesz--img_a1z1.jpgz input image)r
r z--img_a2z2.jpgz input image2z--img_b1z--img_b2z--machine-rankrz-the rank of this machine (unique per machine)iÀÚwin32i@z
--dist-urlztcp://127.0.0.1:{})r
Úoptsz,Modify config options using the command-lineN)r r
Únargs) ÚargparseÚArgumentParserÚ add_argumentÚintÚhashÚsysÚplatformÚosÚgetuidÚformatZ    REMAINDER)ÚparserÚport©r ú./engine/defaults.pyÚdefault_argument_parsersD ýýÿ"ür"c    CsB|j}t ¡r|rt |¡t ¡}t||ddt||d}| d |t     ¡¡¡| dt
ƒ¡| dt |ƒ¡t |dƒr¬|j dkr¬| d     |j t |j d
¡ ¡¡¡| d  |¡¡t ¡r|rtj |d ¡}t |d ¡}| | ¡¡W5QRX| d tj |¡¡¡tƒt |dƒr2|js>|jtjj_dS)az
    Perform some basic common setups at the beginning of a job, including:
    1. Set up the detectron2 logger
    2. Log basic information about environment, cmdline arguments, and config
    3. Backup the config to the output directory
    Args:
        cfg (CfgNode): the full config to be used
        args (argparse.NameSpace): the command line arguments to be logged
    Zfvcore)Údistributed_rankÚname)r#z+Rank of current process: {}. World size: {}zEnvironment info:
zCommand line arguments: Ú config_filer    z#Contents of args.config_file={}:
{}ÚrzRunning with full config:
{}z config.yamlÚwzFull config saved to {}Ú    eval_onlyN)Ú
OUTPUT_DIRrÚis_main_processrÚmkdirsÚget_rankrÚinforÚget_world_sizerÚstrÚhasattrr%ÚopenÚreadrÚpathÚjoinÚwriteÚdumpÚabspathrr(ÚCUDNN_BENCHMARKÚtorchÚbackendsÚcudnnÚ    benchmark)ÚcfgÚargsZ
output_dirÚrankÚloggerr3Úfr r r!Ú default_setupGs2
 
 ÿÿrB)Ú__doc__rÚloggingrrÚutilsrZ    utils.envrÚ utils.file_iorZ utils.loggerrZutils.collect_envrÚ collectionsrr9r"rBr r r r!Ú<module>s      *