-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
92 lines (70 loc) · 2.06 KB
/
config.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
# -*- coding: utf-8 -*-
r"""Python ♡ Nasy.
| * *
| . .
| . 登
| * ,
| . 至
|
| * 恖
| |\___/|
| ) -( . 聖 ·
| =\ - /=
| )===( *
| / - \
| |- |
| / - \ 0.|.0
| NASY___\__( (__/_____(\=/)__+1s____________
| ______|____) )______|______|______|______|_
| ___|______( (____|______|______|______|____
| ______|____\_|______|______|______|______|_
| ___|______|______|______|______|______|____
| ______|______|______|______|______|______|_
| ___|______|______|______|______|______|____
author : Nasy https://nasy.moe
date : Sep 1, 2023
email : Nasy <nasyxx+python@gmail.com>
filename : config.py
project : lab_exp_2023f
license : GPL-3.0+
SMILE LAB Tranining Project
"""
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
from rich import console
import tyro
@dataclass
class Data:
"""Dataset config."""
raw: Path = field(default=Path("./raw"))
base: Path = field(default=Path("./data"))
@dataclass
class Params:
"""Hyper Parameters."""
lr: float = 1e-4
batch_size: int = 2
@dataclass
class Conf:
"""Configuration."""
data: Data = field(default_factory=Data)
params: Params = field(default_factory=Params)
seed: int = 7
epoch: int = 191
train: bool = True
infer: bool = True
predict: bool = True
have_mask: bool = False
def __post_init__(self) -> None:
"""Post initialize."""
self.console = console.Console()
def log(self, msg: Any) -> None: # noqa: ANN401
"""Log MSG."""
self.console.log(msg)
def print(self, msg: Any) -> None: # noqa: ANN401, A003
"""Print MSG."""
self.console.print(msg)
if __name__ == "__main__":
conf = tyro.cli(Conf)
conf.print(conf)