def get_model(classes):
    num_classes = len(classes)
    model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
    # get number of input features for the classifier
    in_features = model.roi_heads.box_predictor.cls_score.in_features
    # replace the pre-trained head with a new one
    model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes+1)
    model.to('cuda')
    _classes = ['__background__'] + classes
    int_mapping = {label: index for index, label in enumerate(_classes)}
    return model, int_mapping

modelx,_ = get_model(classes)
modelx.load_state_dict(torch.load(model_path))
modelx.eval()