forked from dilligencer-zrj/code_zoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__factory
44 lines (31 loc) · 946 Bytes
/
__factory
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
"""Create data loader"""
__factory = {
'liver': LiverDataset, # 此处为定义的数据类
}
def get_names():
return __factory.keys()
def init_data_loader(name, dataset, **kwargs):
if name not in __factory.keys():
raise KeyError("Unknown data loader: {}".format(name))
return __factory[name](dataset, **kwargs)
"""Create loss"""
__factory = {
'dice': DiceLoss,
}
def get_names():
return __factory.keys()
def init_loss(name, **kwargs):
if name not in __factory.keys():
raise KeyError("Unknown loss: {}".format(name))
return __factory[name](**kwargs)
"""Create dataset"""
__factory = {
'tumor': Tumor,
'tumortest': TumorTest
}
def get_names():
return __factory.keys()
def init_dataset(name, data_root, config, **kwargs):
if name not in __factory.keys():
raise KeyError("Unknown dataset: {}".format(name))
return __factory[name](data_root, config, **kwargs)