-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
50 lines (41 loc) · 1.13 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 os
import random
import sys
import importlib
from tqdm import tqdm
from collections import defaultdict, OrderedDict
from datetime import datetime
import subprocess
import time
import torch
import torch.nn.functional as F
from torch.utils.data import DataLoader, random_split
import numpy as np
from util import *
from prepare import *
if args.dataset.startswith('cifar'):
from cifar import *
elif args.dataset == 'digits':
from digits import *
elif args.dataset == 'visda17':
from visda17 import *
else:
from imagenet import *
def test(args):
data = CorruptedData(args)
print(len(data.test_set))
args.num_classes = len(data.test_set.classes)
test_loader = DataLoader(data.test_set,batch_size=args.batchsize,shuffle=True,num_workers=4)
algo = importlib.import_module('methods.'+args.method).Model(args=args).to(device)
algo.test(test_loader)
print('==========================')
def test_all(args):
for i in range(15):
print('Env:', i)
args.test_env = i
test(args)
if __name__=='__main__':
if args.test_env == -1:
test_all(args)
else:
test(args)