henry000 commited on
Commit
5fed6e3
·
1 Parent(s): 1faad6a

🔨 [Change] argparse to hydra, faster-easier!

Browse files
Files changed (1) hide show
  1. train.py +6 -16
train.py CHANGED
@@ -2,25 +2,15 @@ import argparse
2
  from loguru import logger
3
  from model.yolo import get_model
4
  from utils.tools import load_model_cfg, custom_logger
 
 
5
 
6
 
7
- def parse_arguments() -> argparse.Namespace:
8
- """
9
- Parse command-line arguments to get the model configuration file.
10
-
11
- Returns:
12
- argparse.Namespace: The command-line arguments object with 'config' attribute.
13
- """
14
- parser = argparse.ArgumentParser(description="Load a YOLO model configuration and display the model.")
15
- parser.add_argument(
16
- "--model-config", type=str, default="v7-base", help="Name or path to the model configuration file."
17
- )
18
- return parser.parse_args()
19
 
20
 
21
  if __name__ == "__main__":
22
  custom_logger()
23
- args = parse_arguments()
24
- model_cfg = load_model_cfg(args.model_config)
25
- model = get_model(model_cfg)
26
- logger.info("Success load model: {}", model)
 
2
  from loguru import logger
3
  from model.yolo import get_model
4
  from utils.tools import load_model_cfg, custom_logger
5
+ import hydra
6
+ from config.config import Config
7
 
8
 
9
+ @hydra.main(config_path="config", config_name="config", version_base=None)
10
+ def main(cfg: Config):
11
+ model = get_model(cfg.model)
 
 
 
 
 
 
 
 
 
12
 
13
 
14
  if __name__ == "__main__":
15
  custom_logger()
16
+ main()