I’m trying to use the pre-trained model: mask_rcnn_X_101_32x8d_FPN_3x for identifying roofs/ridges/obstacles simultaneously. The speciality that I have is, that I want to use segmentation annotation (which I’m using for polygon shapes –> roofs/obstacles/some others) and keypoint annotation (which I’m using for line shapes –> ridge/valleys) simultaneously.
My annotation datasets for training and validation consequently have segmentation annotations and keypoint annotations. I already added dummy arrays/values for segmentation annotations (keypoints array and num_keypoints = 0) to have a similar data structure within the annotations. However this didn’t solve the problem. My annotations look like this:
**Segmentation:
**
{
"area": 187,
"bbox": [
354,
323,
30,
13
],
"category_id": 6,
"id": 13,
"image_id": 1,
"iscrowd": 0,
"segmentation": [
[
354,
323,
367,
335,
383,
329
]
],
"keypoints": [],
"num_keypoints": 0
},
**Keypoints:
**
{
"area": 3240,
"bbox": [
81,
280,
60,
53
],
"category_id": 4,
"id": 1,
"image_id": 1,
"iscrowd": 0,
"keypoints": [
139,
280,
2,
81,
333,
2
],
"num_keypoints": 2,
"segmentation": []
},
In my training file I activated model_mask and model_keypoint. My file looks like this:
def setup_cfg():
cfg = get_cfg()
cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml"))
cfg.MODEL.MASK_ON = True
cfg.MODEL.KEYPOINT_ON = True
# Set device programmatically
cfg.MODEL.DEVICE = "cpu"
# Set custom configurations
cfg.DATASETS.TRAIN = ("roof_train",)
cfg.DATASETS.TEST = ("roof_val",)
cfg.DATALOADER.NUM_WORKERS = 2
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml")
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 7
cfg.MODEL.ROI_KEYPOINT_HEAD.NUM_KEYPOINTS = 2
cfg.SOLVER.IMS_PER_BATCH = 2
cfg.SOLVER.BASE_LR = 0.001
cfg.SOLVER.MAX_ITER = 500
cfg.SOLVER.STEPS = [] # Remove if unnecessary
cfg.OUTPUT_DIR = ".../models/new"
return cfg
I unfortunately always get this error:
“ValueError: expected sequence of length 2 at dim 1 (got 0)”
When only exporting the segmentation annotations and deactivating the model.keypoints or vice versa (exporting keypoint annotations only and deactivating model.mask) it works. However, multitask it seems not working…
Someone any idea on that?
Thanks in advance!
Used individual data structures for keypoints and segmentation annotation
Used similar data structure (dummy values for “num_keypoints”/”keypoints” in segmentation) for annotations
Both did not work
Tried independently exporting segmentation and keypoints and it worked
Multitask no approach worked yet