Closed gmari57 closed 2 years ago
I solved it by changing single to double slashes (/ to //) ``class MaskHead(nn.Module): def init(self, cfg, in_channels=128): super(MaskHead, self).init() self.num_class = cfg['num_class']
self.up1 = nn.Sequential(
nn.Upsample(scale_factor=2, mode='trilinear'),
nn.Conv3d(in_channels, 64, kernel_size=3, padding=1),
nn.InstanceNorm3d(64, momentum=bn_momentum, affine=affine),
nn.ReLU(inplace = True))
self.up2 = nn.Sequential(
nn.Upsample(scale_factor=2, mode='trilinear'),
nn.Conv3d(in_channels, 64, kernel_size=3, padding=1),
nn.InstanceNorm3d(64, momentum=bn_momentum, affine=affine),
nn.ReLU(inplace = True))
self.up3 = nn.Sequential(
nn.Upsample(scale_factor=2, mode='trilinear'),
nn.Conv3d(64, 64, kernel_size=3, padding=1),
nn.InstanceNorm3d(64, momentum=bn_momentum, affine=affine),
nn.ReLU(inplace = True))
self.back1 = nn.Sequential(
nn.Conv3d(128, 64, kernel_size=3, padding=1),
nn.InstanceNorm3d(64, momentum=bn_momentum, affine=affine),
nn.ReLU(inplace = True))
self.back2 = nn.Sequential(
nn.Conv3d(96, 64, kernel_size=3, padding=1),
nn.InstanceNorm3d(64, momentum=bn_momentum, affine=affine),
nn.ReLU(inplace = True))
self.back3 = nn.Sequential(
nn.Conv3d(65, 64, kernel_size=3, padding=1),
nn.InstanceNorm3d(64, momentum=bn_momentum, affine=affine),
nn.ReLU(inplace = True))
for i in range(self.num_class):
setattr(self, 'logits' + str(i + 1), nn.Conv3d(64, 1, kernel_size=1))
def forward(self, detections, features):
img, f_2, f_4 = features
# Squeeze the first dimension to recover from protection on avoiding split by dataparallel
img = img.squeeze(0)
f_2 = f_2.squeeze(0)
f_4 = f_4.squeeze(0)
_, _, D, H, W = img.shape
out = []
for detection in detections:
b, z_start, y_start, x_start, z_end, y_end, x_end, cat = detection
up1 = f_4[b, :, z_start // 4:z_end // 4, y_start // 4:y_end // 4, x_start // 4:x_end // 4].unsqueeze(0)
up2 = self.up2(up1)
up2 = self.back2(torch.cat((up2, f_2[b, :, z_start // 2:z_end // 2, y_start // 2:y_end // 2, x_start // 2:x_end // 2].unsqueeze(0)), 1))
up3 = self.up3(up2)
im = img[b, :, z_start:z_end, y_start:y_end, x_start:x_end].unsqueeze(0)
up3 = self.back3(torch.cat((up3, im), 1))
logits = getattr(self, 'logits' + str(int(cat)))(up3)
logits = logits.squeeze()
mask = Variable(torch.zeros((D, H, W))).cuda()
mask[z_start:z_end, y_start:y_end, x_start:x_end] = logits
mask = mask.unsqueeze(0)
out.append(mask)
out = torch.cat(out, 0)
return out
Hey there,
I want to run your implementation on my machine(win10) but I am getting a storage error from nodule_net.py
I am using the net folder from the original Nodule net repo and the model they have uploaded.
If you have time pls take a look, Thanks in advance!