🚸 [Add] auto download option for download dataset
Browse files- config/config.py +7 -0
- config/data/download.yaml +1 -0
- model/yolo.py +1 -0
- train.py +4 -5
- utils/get_dataset.py +1 -1
config/config.py
CHANGED
@@ -8,6 +8,13 @@ class Model:
|
|
8 |
model: Dict[str, List[Dict[str, Union[Dict, List, int]]]]
|
9 |
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
@dataclass
|
12 |
class Config:
|
13 |
model: Model
|
|
|
|
8 |
model: Dict[str, List[Dict[str, Union[Dict, List, int]]]]
|
9 |
|
10 |
|
11 |
+
@dataclass
|
12 |
+
class Download:
|
13 |
+
auto: bool
|
14 |
+
path: str
|
15 |
+
|
16 |
+
|
17 |
@dataclass
|
18 |
class Config:
|
19 |
model: Model
|
20 |
+
download: Download
|
config/data/download.yaml
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
path: data/coco
|
2 |
images:
|
3 |
base_url: http://images.cocodataset.org/zips/
|
|
|
1 |
+
auto: True
|
2 |
path: data/coco
|
3 |
images:
|
4 |
base_url: http://images.cocodataset.org/zips/
|
model/yolo.py
CHANGED
@@ -92,6 +92,7 @@ def get_model(model_cfg: dict) -> YOLO:
|
|
92 |
Returns:
|
93 |
YOLO: An instance of the model defined by the given configuration.
|
94 |
"""
|
|
|
95 |
model = YOLO(model_cfg)
|
96 |
logger.info("✅ Success load model")
|
97 |
return model
|
|
|
92 |
Returns:
|
93 |
YOLO: An instance of the model defined by the given configuration.
|
94 |
"""
|
95 |
+
OmegaConf.set_struct(model_cfg, False)
|
96 |
model = YOLO(model_cfg)
|
97 |
logger.info("✅ Success load model")
|
98 |
return model
|
train.py
CHANGED
@@ -1,18 +1,17 @@
|
|
1 |
from loguru import logger
|
2 |
from model.yolo import get_model
|
3 |
from tools.log_helper import custom_logger
|
4 |
-
from utils.get_dataset import
|
5 |
import hydra
|
6 |
from config.config import Config
|
7 |
-
from omegaconf import OmegaConf
|
8 |
|
9 |
|
10 |
@hydra.main(config_path="config", config_name="config", version_base=None)
|
11 |
def main(cfg: Config):
|
12 |
-
|
13 |
-
|
|
|
14 |
model = get_model(cfg.model)
|
15 |
-
logger.info("Success load model")
|
16 |
|
17 |
|
18 |
if __name__ == "__main__":
|
|
|
1 |
from loguru import logger
|
2 |
from model.yolo import get_model
|
3 |
from tools.log_helper import custom_logger
|
4 |
+
from utils.get_dataset import prepare_dataset
|
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 |
+
if cfg.download.auto:
|
12 |
+
prepare_dataset(cfg.download)
|
13 |
+
|
14 |
model = get_model(cfg.model)
|
|
|
15 |
|
16 |
|
17 |
if __name__ == "__main__":
|
utils/get_dataset.py
CHANGED
@@ -44,7 +44,7 @@ def check_files(directory, expected_count):
|
|
44 |
|
45 |
|
46 |
@hydra.main(config_path="../config/data", config_name="download", version_base=None)
|
47 |
-
def
|
48 |
data_dir = download_cfg.path
|
49 |
base_url = download_cfg.images.base_url
|
50 |
datasets = download_cfg.images.datasets
|
|
|
44 |
|
45 |
|
46 |
@hydra.main(config_path="../config/data", config_name="download", version_base=None)
|
47 |
+
def prepare_dataset(download_cfg):
|
48 |
data_dir = download_cfg.path
|
49 |
base_url = download_cfg.images.base_url
|
50 |
datasets = download_cfg.images.datasets
|