0

I want to train my mask rcnn model on pretrained model resnet50. What part in the code do I need to change? Currently, it has option of coco, imagenet and last

def load_training_model(config):
    model = modellib.MaskRCNN(mode="training", config=config,
                              model_dir=MODEL_DIR)

    # Which weights to start with?
    init_with = "imagenet"  # imagenet, coco, or last

    if init_with == "imagenet":
        model.load_weights(model.get_image_weights(), by_name=True)
    elif init_with == "coco":
        # Load weights trained on MS COCO, but skip layers that
        # are different due to the different number of classes
        # See README for instructions to download the COCO weights
        print(COCO_MODEL_PATH)
        model.load_weights(COCO_MODEL_PATH, by_name=True,
                           exclude=["mrcnn_class_logits", "mrcnn_bbox_fc",
                                    "mrcnn_bbox", "mrcnn_mask"])
    elif init_with == "last":
        # Load the last model you trained and continue training
        model.load_weights(model.find_last(), by_name=True)

I tried doing but nothing came up.

Azhar Khan
  • 3,829
  • 11
  • 26
  • 32
champ
  • 1
  • 2
  • Hi @champ, modellib.MaskRCNN() method has a parameter ‘mode’ which decides whether we want to train the model or test the model. If you want to test set ‘mode’ to ‘inference’ . ‘model_dir’ is for saving the data while training for backup. Then, we have to download the pre-trained weights (COCO,imagenet, etc.). For more details please refer to this [link](https://towardsdatascience.com/mask-rcnn-implementation-on-a-custom-dataset-fd9a878123d4). Thank You. –  Dec 26 '22 at 05:46

0 Answers0