Hi,
I’m using the FasterRCNN framework of torchvision to build a network for lesion detection on CT images. However, I encountered two issues:


Even though I activate the cuda mode with ‘model.to(cudadevice)’ or ‘model.cuda()’ the call is not passed through to all sub-modules of the Faster R-CNN model. That results in the model running on the CPU very slowly. I even tried to pass the move of the models to cuda through, which worked by calling them after the model was setup and called the previous mentioned methods. Anyway, the result remains the same. I can see on my task manager, that the application allocates GPU memory and the tensors device is ‘cuda:0’, but never executes anything on the cuda cores. Any ideas?


The lesion detection does not work at all so far. The proposals from the Region Proposal Network mostly never get above a score of 0.12 and I can’t figure out why. I’m using a structure of the network as followed. The images are already pre-processed (gray-scale pictures in rgb format) resized to 224x224. I use the DeepLesion Dataset 3.


# VGG16 backbone
vgg = vgg16(pretrained=True)
backbone = vgg.features[:-1]
for layer in backbone[:10]:
    for p in layer.parameters():
        p.requires_grad = False
backbone.out_channels = 512

class BoxHead(torch.nn.Module):
    def __init__(self, vgg, dropout=False):
        super(BoxHead, self).__init__()
        classifier = list(vgg.classifier._modules.values())[:-1]
        if not dropout:
            del classifier[5]
            del classifier[2]
        self.classifier = torch.nn.Sequential(*classifier)

    def forward(self, x):
        x = x.flatten(start_dim=1)
        x = self.classifier(x)
        return x

box_head = BoxHead(vgg)

# RPN - Anchor Generator
anchor_generator = AnchorGenerator(sizes=((8, 16, 32),), aspect_ratios=((0.5, 1.0, 1.5),))

# Head - Box RoI pooling
roi_pooler = MultiScaleRoIAlign(featmap_names=['0'], output_size=7, sampling_ratio=2)

# Faster RCNN - Model
model = FasterRCNN(
    backbone=backbone,
    min_size=224, max_size=224,
    rpn_anchor_generator=anchor_generator,
    box_roi_pool=roi_pooler,
    box_head=box_head,
    box_predictor=FastRCNNPredictor(4096, num_classes=2)
)

# Init weights
torch.nn.init.normal_(model.roi_heads.box_predictor.cls_score.weight, std=0.01)
torch.nn.init.constant_(model.roi_heads.box_predictor.cls_score.bias, 0)
torch.nn.init.normal_(model.roi_heads.box_predictor.bbox_pred.weight, std=0.001)
torch.nn.init.constant_(model.roi_heads.box_predictor.bbox_pred.bias, 0)

Furthermore, I use the SGD as optimizer with a learning rate of 0.00001 and weight_decay of 0.005 and momentum of 0.9.
I would really appreciate any help. Thanks!