-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdataset.py
67 lines (57 loc) · 2.55 KB
/
dataset.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
55
56
57
58
59
60
61
62
63
64
65
66
67
from collections import namedtuple
import json
from os.path import exists, join
Dataset = namedtuple('Dataset', ['model_hash', 'classes', 'mean', 'std',
'eigval', 'eigvec', 'name'])
imagenet = Dataset(name='imagenet',
classes=1000,
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225],
eigval=[55.46, 4.794, 1.148],
eigvec=[[-0.5675, 0.7192, 0.4009],
[-0.5808, -0.0045, -0.8140],
[-0.5836, -0.6948, 0.4203]],
model_hash={'dla34': 'ba72cf86',
'dla46_c': '2bfd52c3',
'dla46x_c': 'd761bae7',
'dla60x_c': 'b870c45c',
'dla60': '24839fc4',
'dla60x': 'd15cacda',
'dla102': 'd94d9790',
'dla102x': 'ad62be81',
'dla102x2': '262837b6',
'dla169': '0914e092'})
# monuseg = Dataset(name='MoNuSeg',
# classes=2,
# mean=[0.6743682882352942, 0.4711362002614377, 0.6204416456209151],
# std=[0.21792378060808987, 0.23067648118994308, 0.18450216349991813],
# model_hash={'dla34': 'ba72cf86',
# 'dla46_c': '2bfd52c3',
# 'dla46x_c': 'd761bae7',
# 'dla60x_c': 'b870c45c',
# 'dla60': '24839fc4',
# 'dla60x': 'd15cacda',
# 'dla102': 'd94d9790',
# 'dla102x': 'ad62be81',
# 'dla102x2': '262837b6',
# 'dla169': '0914e092'})
def get_data(data_name):
try:
return globals()[data_name]
except KeyError:
return None
def load_dataset_info(data_dir, data_name='new_data'):
#info_path = join(data_dir, 'info.json')
info_path = data_dir
if not exists(info_path):
return None
info = json.load(open(info_path, 'r'))
assert 'mean' in info and 'std' in info, \
'mean and std are required for a dataset'
data = Dataset(name=data_name, classes=0,
mean=None,
std=None,
eigval=None,
eigvec=None,
model_hash=dict())
return data._replace(**info)