MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / BaseExp

Class BaseExp

yolox/exp/base_exp.py:17–75  ·  view source on GitHub ↗

Basic class for any experiment.

Source from the content-addressed store, hash-verified

15
16
17class BaseExp(metaclass=ABCMeta):
18 """Basic class for any experiment."""
19
20 def __init__(self):
21 self.seed = None
22 self.output_dir = "./YOLOX_outputs"
23 self.print_interval = 100
24 self.eval_interval = 10
25
26 @abstractmethod
27 def get_model(self) -> Module:
28 pass
29
30 @abstractmethod
31 def get_data_loader(
32 self, batch_size: int, is_distributed: bool
33 ) -> Dict[str, torch.utils.data.DataLoader]:
34 pass
35
36 @abstractmethod
37 def get_optimizer(self, batch_size: int) -> torch.optim.Optimizer:
38 pass
39
40 @abstractmethod
41 def get_lr_scheduler(
42 self, lr: float, iters_per_epoch: int, **kwargs
43 ) -> LRScheduler:
44 pass
45
46 @abstractmethod
47 def get_evaluator(self):
48 pass
49
50 @abstractmethod
51 def eval(self, model, evaluator, weights):
52 pass
53
54 def __repr__(self):
55 table_header = ["keys", "values"]
56 exp_table = [
57 (str(k), pprint.pformat(v))
58 for k, v in vars(self).items()
59 if not k.startswith("_")
60 ]
61 return tabulate(exp_table, headers=table_header, tablefmt="fancy_grid")
62
63 def merge(self, cfg_list):
64 assert len(cfg_list) % 2 == 0
65 for k, v in zip(cfg_list[0::2], cfg_list[1::2]):
66 # only update value with same key
67 if hasattr(self, k):
68 src_value = getattr(self, k)
69 src_type = type(src_value)
70 if src_value is not None and src_type != type(v):
71 try:
72 v = src_type(v)
73 except Exception:
74 v = ast.literal_eval(v)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected