Lost the original classes while adding new classes
I found that the yolact_base_54_80000.pth supports 80 categories. Now, I want to extend the classes. I already prepared my custom dataset(600 images) for the new 2 classes and created COCO-style annotation file. I made my own config like the following:
CUSTOM_CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',
'train', 'truck', 'boat', 'traffic light', 'fire hydrant',
'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog',
'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe',
'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat',
'baseball glove', 'skateboard', 'surfboard', 'tennis racket',
'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl',
'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot',
'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop',
'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven',
'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase',
'scissors', 'teddy bear', 'hair drier', 'toothbrush',
'my_class_1', 'my_class_2')
CUSTOM_LABEL_MAP = { 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8,
9: 9, 10: 10, 11: 11, 13: 12, 14: 13, 15: 14, 16: 15, 17: 16,
18: 17, 19: 18, 20: 19, 21: 20, 22: 21, 23: 22, 24: 23, 25: 24,
27: 25, 28: 26, 31: 27, 32: 28, 33: 29, 34: 30, 35: 31, 36: 32,
37: 33, 38: 34, 39: 35, 40: 36, 41: 37, 42: 38, 43: 39, 44: 40,
46: 41, 47: 42, 48: 43, 49: 44, 50: 45, 51: 46, 52: 47, 53: 48,
54: 49, 55: 50, 56: 51, 57: 52, 58: 53, 59: 54, 60: 55, 61: 56,
62: 57, 63: 58, 64: 59, 65: 60, 67: 61, 70: 62, 72: 63, 73: 64,
74: 65, 75: 66, 76: 67, 77: 68, 78: 69, 79: 70, 80: 71, 81: 72,
82: 73, 84: 74, 85: 75, 86: 76, 87: 77, 88: 78, 89: 79, 90: 80,
91: 81, 92: 82}
my_custom_dataset = dataset_base.copy({
'name': 'My Dataset',
'train_images': './data/coco/data_dataset_coco_train/',
'train_info': './data/coco/data_dataset_coco_train/annotations.json',
'valid_images': './data/coco/data_dataset_coco_val/',
'valid_info': './data/coco/data_dataset_coco_val/annotations.json',
'class_names': CUSTOM_CLASSES,
'label_map': CUSTOM_LABEL_MAP
})
my_custom_yolact_config = yolact_base_config.copy({
'name': 'my_custom_yolact',
'dataset': my_custom_dataset,
'num_classes': len(my_custom_dataset.class_names) + 1
})
I followed the #36 and #334 already.
To train the last layer, I already updated yolact.py with this p = pred_layer(pred_x.detach()).
When I run python train.py --config=my_custom_yolact_config --resume=yolact_base_54_80000.pth, it works.
But when I evaluate the new-generated model, it can detect the new 2 classes but can not detect the original classes. What am I missing? or is it impossible to add new classes without original dataset? Thank you for any suggestion.