forked from OlyaBakay/AutomaticPageLayoutAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (25 loc) · 847 Bytes
/
Copy pathmain.py
File metadata and controls
31 lines (25 loc) · 847 Bytes
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
import os
import shutil
import yaml
from unet.train import Trainer
DEVICE = os.getenv("DEVICE", None)
assert DEVICE is not None, "Please specife env var `DEVICE`"
def main():
with open("config_template.yml") as f:
config = yaml.load(f)
exp_path = os.path.join("experiments", config["experiment"])
if os.path.exists(exp_path):
ans = None
while ans != "y" and ans != "n":
ans = input("Path [{}] exists do you want to delete?[Y/n]".format(exp_path))
if ans == "n":
return
shutil.rmtree(exp_path)
if not os.path.exists(exp_path):
os.makedirs(exp_path)
with open(os.path.join(exp_path, "config.yml"), "w") as f:
yaml.dump(config, f)
trainer = Trainer(exp_path, config, device=DEVICE)
trainer.train()
if __name__ == '__main__':
main()