-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (54 loc) · 2.1 KB
/
Copy pathmain.py
File metadata and controls
67 lines (54 loc) · 2.1 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
Script principale (Entry Point) dell'applicazione: gestisce il parsing degli argomenti CLI,
carica i file di configurazione YAML e avvia i diversi moduli della pipeline
(tracking, validazione, analisi comportamentale o valutazione) in base alla modalità selezionata.
"""
import argparse
from src.behavior import BehaviorAnalyzer
from src.contest_runner import ContestRunner
from src.evaluator import Evaluator
from src.tracker import Tracker
from src.data_manager import *
from src.validator import *
import os
def load_config(path):
"""
Legge un file di configurazione in formato YAML dal percorso specificato
e ne restituisce il contenuto sotto forma di dizionario utilizzabile.
"""
with open(path, 'r') as f:
return yaml.safe_load(f)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--mode", type=str, required=True, choices=["prepare", "val", "track", "eval_hota", "eval_roi" ,"roi", "contest"], help="Mode of operation")
parser.add_argument("--config", type=str, required=False, help="Config file")
args = parser.parse_args()
print(os.getcwd())
cfg = load_config("./configs/config.yaml")
no_config_modes = ["eval_hota", "prepare", "eval_roi"]
if not args.config and args.mode not in no_config_modes:
print("Config file not provided")
exit(1)
elif args.mode not in no_config_modes:
cfg_mode = load_config(str(args.config))
if args.mode == "eval_roi":
evaluator = Evaluator(cfg)
evaluator.run_behavior()
elif args.mode == "contest":
contest = ContestRunner(cfg, cfg_mode)
contest.run()
elif args.mode == "prepare":
dm = DataManager(cfg)
dm.prepare_dataset()
elif args.mode == "val":
validator = Validator(cfg, cfg_mode)
validator.run()
elif args.mode == "track":
validator = Tracker(cfg, cfg_mode)
validator.run()
elif args.mode == "eval_hota":
evaluator = Evaluator(cfg)
evaluator.run_hota()
elif args.mode == "roi":
roi = BehaviorAnalyzer(cfg, cfg_mode)
roi.run()