Commit 98f513a7 authored by Yuxin Wu's avatar Yuxin Wu

[MaskRCNN] update docs about training coco-format dataset (fix #1038)

parent 6f6787db
...@@ -16,9 +16,13 @@ This is a minimal implementation that simply contains these files: ...@@ -16,9 +16,13 @@ This is a minimal implementation that simply contains these files:
Data: Data:
1. It's easy to train on your own data. 1. It's easy to train on your own data by changing `dataset.py`.
If your data is not in COCO format, you can just rewrite all the methods of
`DetectionDataset` following its documents in `dataset.py`. + If your data is in COCO format, modify `COCODetection`
to change the class names and the id mapping.
+ If your data is not in COCO format, ignore `COCODetection` completely and
rewrite all the methods of
`DetectionDataset` following its documents.
You'll implement the logic to load your dataset and evaluate predictions. You'll implement the logic to load your dataset and evaluate predictions.
2. You can easily add more augmentations such as rotation, but be careful how a box should be 2. You can easily add more augmentations such as rotation, but be careful how a box should be
......
...@@ -25,8 +25,10 @@ class COCODetection(object): ...@@ -25,8 +25,10 @@ class COCODetection(object):
COCO_id_to_category_id = {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} # noqa COCO_id_to_category_id = {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} # noqa
""" """
Mapping from the incontinuous COCO category id to an id in [1, #category] Mapping from the incontinuous COCO category id to an id in [1, #category]
For your own dataset, this should usually be an identity mapping.
""" """
# 80 names for COCO
class_names = [ class_names = [
"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"] # noqa "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"] # noqa
...@@ -191,10 +193,9 @@ class DetectionDataset(object): ...@@ -191,10 +193,9 @@ class DetectionDataset(object):
This function is responsible for setting the dataset-specific This function is responsible for setting the dataset-specific
attributes in both cfg and self. attributes in both cfg and self.
""" """
self.num_category = cfg.DATA.NUM_CATEGORY = 80 self.num_category = cfg.DATA.NUM_CATEGORY = len(COCODetection.class_names)
self.num_classes = self.num_category + 1 self.num_classes = self.num_category + 1
self.class_names = cfg.DATA.CLASS_NAMES = ["BG"] + COCODetection.class_names self.class_names = cfg.DATA.CLASS_NAMES = ["BG"] + COCODetection.class_names
assert len(self.class_names) == self.num_classes
def load_training_roidbs(self, names): def load_training_roidbs(self, names):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment