-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
54 lines (42 loc) · 1.29 KB
/
test.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
"""
#
# This script is used together with a configuration file to train a model
#
"""
import yaml
import argparse
import os
import torch
import sys
from utils.reproducability import set_seed, set_device
from utils.data_handling import load_model, get_dataloaders
from utils.test_functions import get_test_fn
from utils.wandb import initialize
from utils.create_submission import create_submission
def main():
# Config arguments
parser = argparse.ArgumentParser()
parser.add_argument("--config_path", default="configs/classic/test.yaml")
args = parser.parse_args()
config = yaml.safe_load(open(args.config_path, "r"))
yaml.dump(config, sys.stdout)
# Wandb support
initialize(config)
if config['debug']:
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
torch.autograd.set_detect_anomaly(True)
# Set seed and device
set_seed(config['seed'])
device = set_device(config['device'])
# Create Dataset and Dataloader
_, _, test_dataloader = get_dataloaders(config)
# Load model
models = load_model(config, device)
# Get test function
test_fn = get_test_fn(config)
# Prediction
test_fn(models, test_dataloader, config, device)
# Create submission file
create_submission(config)
if __name__ == "__main__":
main()