I am trying to train a custom data for image segmentation with Detectron2, but I have an issue while using the config files (like mask_rcnn_R_50_FPN_3x.yaml).
Here is the the configuration that I use for training:
cfg = get_cfg()
cfg.MODEL.DEVICE = "cpu"
cfg.DATASETS.TRAIN = ("category_train",)
cfg.DATASETS.TEST = ()
cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml"))
cfg.MODEL.WEIGHTS = "COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml"
cfg.DATALOADER.NUM_WORKERS = 0
cfg.SOLVER.IMS_PER_BATCH = 8
cfg.SOLVER.BASE_LR = 0.00025 # pick a good LR
cfg.SOLVER.MAX_ITER = 25000
cfg.SOLVER.STEPS = []
cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 512
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 6
The part where I get error is cfg.merge_from_file() part. If I remove it and cfg.MODEL.WEIGHTS, then the code works and model successfully trains the object detection model. I need image segmentation, so I need to use these configurations.
However, using them gives the following error:
FileNotFoundError: [Errno 2] No such file or directory: 'datasets\\coco/annotations/instances_train2017.json'
I looked in the Detectron2 issues and someone also had the same error, and the solution was to put the following in code:
cfg.DATASETS.TEST = ()
However, I had already done that, and it did not help me. Does anyone have any ideas on why this could not work?