-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
59 lines (49 loc) · 1.96 KB
/
models.py
File metadata and controls
59 lines (49 loc) · 1.96 KB
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
from monai.networks.nets import UNet, BasicUNet, SwinUNETR, UNETR, BasicUNetPlusPlus, AttentionUnet
class modelFactory:
def __init__(self) -> None:
self.unetFilter = ( 32, 64, 128, 256, 512, 32)
self.unetFilterRes = ( 32, 64, 128, 256, 512)
self.norm = "instance"
self.act = "ReLu"
self.stride = 2
def getModel(self, Network:str):
if Network == "BasicUnet":
model = BasicUNet(
spatial_dims=2,
in_channels=1,
out_channels=1,
features= self.unetFilter,
act=self.act,
norm=self.norm
)
elif Network == "ResiduelUnet":
model = UNet(spatial_dims=2,
in_channels=1,
out_channels=1,
channels= self.unetFilterRes,
strides=(self.stride, self.stride, self.stride, self.stride),
num_res_units=2,
kernel_size=3,
up_kernel_size=3,
norm=self.norm,
act=self.act
)
elif Network == "UnetPlusPlus":
model = BasicUNetPlusPlus(spatial_dims=2,
act = self.act,
in_channels=1,
out_channels=1,
norm=self.norm)
elif Network == "AttentionUnet":
model = AttentionUnet(spatial_dims=2,
in_channels=1,
out_channels=1,
channels= self.unetFilterRes,
strides=(self.stride, self.stride, self.stride, self.stride),
norm=self.norm,
)
elif Network == "Unetr":
model = UNETR(in_channels=1, out_channels=1, img_size=256, feature_size=32, norm_name='batch', spatial_dims=2)
elif Network == "SwinUnetr":
model = SwinUNETR(img_size=(256,256), in_channels=1, out_channels=1, spatial_dims=2)
return model