-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (37 loc) · 1.26 KB
/
main.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
import gin
import logging
import wandb
from absl import app, flags
from train import Trainer
from evaluation.eval import evaluate
from input_pipeline import datasets
from utils import utils_params, utils_misc
from models.vgg_likemodel import vgg_like
FLAGS = flags.FLAGS
flags.DEFINE_boolean('train', True, 'Specify whether to train or evaluate a model.')
wandb.login(key='b81f56792d51604905352f578e15e44d4e5cf12b')
def main(argv):
# generate folder structures
run_paths = utils_params.gen_run_folder()
# set loggers
utils_misc.set_loggers(run_paths['path_logs_train'], logging.INFO)
# gin-config
gin.parse_config_files_and_bindings(['configs/config.gin'], [])
utils_params.save_config(run_paths['path_gin'], gin.config_str())
# setup pipeline
ds_train, ds_val, ds_test, ds_info = datasets.load()
# model
model = vgg_like(input_shape=(256,256,3), n_classes=2)
if FLAGS.train:
run = wandb.init(project='project1')
trainer = Trainer(model, ds_train, ds_val, ds_info, run_paths)
for _ in trainer.train():
continue
else:
evaluate(model,
checkpoint,
ds_test,
ds_info,
run_paths)
if __name__ == "__main__":
app.run(main)