Пример #1
0
def register_voc(basedir):
    """
    Add COCO datasets like "coco_train201x" to the registry,
    so you can refer to them with names in `cfg.DATA.TRAIN/VAL`.

    Note that train2017==trainval35k==train2014+val2014-minival2014, and
    val2017==minival2014.
    """

    # 80 names for COCO
    # For your own coco-format dataset, change this.
    #class_names = [
    #    "boat", "cat", "dog", "person", "tvmonitor", "sofa", "car", "bird", "horse", "pottedplant", "bicycle", "chair", "bottle", "cow", "aeroplane", "train", "sheep", "diningtable", "bus", "motorbike"]  # noqa
    #class_names = [
    #     "person", "chair", "aeroplane", "bus", "cow", "bird", "motorbike", "boat", "car", "horse", "sofa", "pottedplant", "tvmonitor", "cat", "train", "bottle", "diningtable", "dog", "bicycle", "sheep"]
    class_names = [
        'motorbike', 'dog', 'person', 'horse', 'sofa', 'bicycle', 'cow',
        'boat', 'train', 'car', 'bird', 'cat', 'chair', 'pottedplant', 'sheep',
        'aeroplane', 'bottle', 'bus', 'diningtable', 'tvmonitor'
    ]
    class_names = ['BG'] + class_names

    for split in [
            'VOC2007/instances_trainval', 'VOC2007/instances_test',
            'VOC2012/instances_trainval'
    ]:
        name = split
        DatasetRegistry.register(name,
                                 lambda x=split: VOCDetection(basedir, x))
        DatasetRegistry.register_metadata(name, 'class_names', class_names)

    logger.info('Register dataset {}'.format(
        [a for a in DatasetRegistry._registry.keys()]))
Пример #2
0
def register_coco_for_voc(basedir):
    class_names = [
        "person", "chair", "aeroplane", "bus", "cow", "bird", "motorbike",
        "boat", "car", "horse", "sofa", "pottedplant", "tvmonitor", "cat",
        "train", "bottle", "diningtable", "dog", "bicycle", "sheep"
    ]
    class_names = ["BG"] + class_names
    for split in SEMI_SUPERVISED_SPLITS[-NUM_20CLASS:]:
        name = "coco_" + split
        DatasetRegistry.register(
            name, lambda x=split: COCODetectionForVOC(basedir, x))
        DatasetRegistry.register_metadata(name, "class_names", class_names)

    logger.info("Register dataset {}".format(
        [a for a in DatasetRegistry._registry.keys()]))
Пример #3
0
def register_coco(basedir):
    """Register COCO.

  Add COCO datasets like "coco_train201x" to the registry,
  so you can refer to them with names in `cfg.DATA.TRAIN/VAL`.

  Note that train2017==trainval35k==train2014+val2014-minival2014, and
  val2017==minival2014.

  Args:
    basedir: root dir that saves datasets.
  """

    # 80 names for COCO
    # For your own coco-format dataset, change this.
    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
    class_names = ["BG"] + class_names
    register_coco_supervised(basedir)

    for split in SEMI_SUPERVISED_SPLITS[:-NUM_20CLASS]:
        name = "coco_" + split
        DatasetRegistry.register(name,
                                 lambda x=split: COCODetection(basedir, x))
        DatasetRegistry.register_metadata(name, "class_names", class_names)

    logger.info("Register dataset {}".format(
        [a for a in DatasetRegistry._registry.keys()]))  # pylint: disable=protected-access

    assert os.environ["COCODIR"], "COCODIR environ variable is not set".format(
        os.environ["COCODIR"])
    # also register coco train set 20 class for voc experiments
    register_coco_for_voc(os.environ["COCODIR"])