multimodallearning/pytorch-mask-rcnn

How to generate the score of a determined label for a determined region of an image using Mask R-CNN

mingqiJ opened this issue · 0 comments

I want to change the RegionProposalNetwork of Mask R-CNN to generate the score for a determined region of an image using Mask R-CNN.

import torch
from torch import nn
import torchvision.models as models
import torchvision
from torchvision.models.detection import MaskRCNN
from torchvision.models.detection.anchor_utils import AnchorGenerator

model = models.detection.maskrcnn_resnet50_fpn(pretrained=True)

class rpn_help(nn.Module):
    def __init__(self,) -> None:
        super().__init__()
    def forward(self,) :
        proposals=torch.tensor([ 78.0753,  12.7310, 165.6465, 153.7253])
        proposal_losses=0
        return proposals, proposal_losses

model.rpn= rpn_help
model.eval()
model(input_tensor) # input_tensor is an image

It takes error like this
WeChat2c25a7cb2c1677cda18d2ca820630990

Does anyone know how to generate the score for a determined region of an image using Mask R-CNN
?