Runtime fallback: install local detectron2 if import fails (no build isolation)
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitignore +1 -1
- MaskClustering/third_party/Entity/Entity/EntitySeg/entityseg/data/Auginput.py +68 -0
- MaskClustering/third_party/Entity/Entity/EntitySeg/entityseg/data/__init__.py +2 -0
- MaskClustering/third_party/Entity/Entity/EntitySeg/entityseg/data/dataset_mapper.py +200 -0
- MaskClustering/third_party/Entity/Entity/EntitySeg/entityseg/data/datasets.py +40 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/Auginput.py +68 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/__init__.py +3 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/__init__.py +0 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/__init__.py +0 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/box_level_augs.py +68 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/color_augs.py +209 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/gaussian_maps.py +47 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/geometric_augs.py +120 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/image_level_augs/img_level_augs.py +31 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/image_level_augs/scale_jitter.py +55 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/image_level_augs/zoom_in.py +64 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/image_level_augs/zoom_out.py +96 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/scale_aware_aug.py +63 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/vis.py +17 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/coco_instance_new_baseline_dataset_mapper.py +188 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/dataset_mapper.py +234 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/dataset_mapper_only_det.py +234 -0
- MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/datasets.py +295 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/__init__.py +2 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/__init__.py +1 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/coco_instance_new_baseline_dataset_mapper.py +197 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/coco_panoptic_new_baseline_dataset_mapper.py +165 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/crop_augmentations.py +421 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/entity_crop_dataset_mapper.py +209 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/mask_former_instance_dataset_mapper.py +180 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/mask_former_panoptic_dataset_mapper.py +165 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/mask_former_semantic_dataset_mapper.py +184 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/__init__.py +14 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_ade20k_full.py +964 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_ade20k_instance.py +53 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_ade20k_panoptic.py +390 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_coco_panoptic_annos_semseg.py +181 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_coco_stuff_10k.py +223 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_entityv2_entity.py +742 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_entityv2_instances.py +258 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_entityv2_panoptic_350.py +486 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_entityv2_semseg_150.py +225 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_mapillary_vistas.py +507 -0
- MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_mapillary_vistas_panoptic.py +508 -0
- MaskClustering/third_party/detectron2/configs/common/data/coco.py +48 -0
- MaskClustering/third_party/detectron2/configs/common/data/coco_keypoint.py +13 -0
- MaskClustering/third_party/detectron2/configs/common/data/coco_panoptic_separated.py +26 -0
- MaskClustering/third_party/detectron2/configs/common/data/constants.py +9 -0
- MaskClustering/third_party/detectron2/detectron2/data/__init__.py +19 -0
- MaskClustering/third_party/detectron2/detectron2/data/benchmark.py +225 -0
.gitignore
CHANGED
|
@@ -152,7 +152,7 @@ temp/
|
|
| 152 |
**/*.ply
|
| 153 |
**/*.glb
|
| 154 |
**/*.bin
|
| 155 |
-
data/
|
| 156 |
**/*.pth
|
| 157 |
|
| 158 |
# macOS junk
|
|
|
|
| 152 |
**/*.ply
|
| 153 |
**/*.glb
|
| 154 |
**/*.bin
|
| 155 |
+
./data/
|
| 156 |
**/*.pth
|
| 157 |
|
| 158 |
# macOS junk
|
MaskClustering/third_party/Entity/Entity/EntitySeg/entityseg/data/Auginput.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pprint
|
| 4 |
+
from abc import ABCMeta, abstractmethod
|
| 5 |
+
from typing import List, Optional, Tuple, Union
|
| 6 |
+
from fvcore.transforms.transform import Transform, TransformList
|
| 7 |
+
from detectron2.data.transforms import AugInput
|
| 8 |
+
from detectron2.data.transforms.augmentation import _check_img_dtype
|
| 9 |
+
|
| 10 |
+
class ItemAugInput(AugInput):
|
| 11 |
+
"""
|
| 12 |
+
A standard implementation of :class:`AugInput` for the majority of use cases.
|
| 13 |
+
This class provides the following standard attributes that are common to use by
|
| 14 |
+
Augmentation (augmentation policies). These are chosen because most
|
| 15 |
+
:class:`Augmentation` won't need anything more to define a augmentation policy.
|
| 16 |
+
After applying augmentations to these special attributes, the returned transforms
|
| 17 |
+
can then be used to transform other data structures that users have.
|
| 18 |
+
|
| 19 |
+
Attributes:
|
| 20 |
+
image (ndarray): image in HW or HWC format. The meaning of C is up to users
|
| 21 |
+
boxes (ndarray or None): Nx4 boxes in XYXY_ABS mode
|
| 22 |
+
sem_seg (ndarray or None): HxW semantic segmentation mask
|
| 23 |
+
|
| 24 |
+
Examples:
|
| 25 |
+
::
|
| 26 |
+
input = StandardAugInput(image, boxes=boxes)
|
| 27 |
+
tfms = input.apply_augmentations(list_of_augmentations)
|
| 28 |
+
transformed_image = input.image
|
| 29 |
+
transformed_boxes = input.boxes
|
| 30 |
+
transformed_other_data = tfms.apply_other(other_data)
|
| 31 |
+
|
| 32 |
+
An extended project that works with new data types may require augmentation
|
| 33 |
+
policies that need more inputs. An algorithm may need to transform inputs
|
| 34 |
+
in a way different from the standard approach defined in this class. In those
|
| 35 |
+
situations, users can implement new subclasses of :class:`AugInput` with differnt
|
| 36 |
+
attributes and the :meth:`transform` method.
|
| 37 |
+
"""
|
| 38 |
+
def __init__(
|
| 39 |
+
self,
|
| 40 |
+
image: np.ndarray,
|
| 41 |
+
*,
|
| 42 |
+
boxes = None,
|
| 43 |
+
seg_info= None,
|
| 44 |
+
):
|
| 45 |
+
"""
|
| 46 |
+
Args:
|
| 47 |
+
image: (H,W) or (H,W,C) ndarray of type uint8 in range [0, 255], or
|
| 48 |
+
floating point in range [0, 1] or [0, 255].
|
| 49 |
+
boxes: (N,4) ndarray of float32. It represents the instance bounding boxes
|
| 50 |
+
of N instances. Each is in XYXY format in unit of absolute coordinates.
|
| 51 |
+
sem_seg: (H,W) ndarray of type uint8. Each element is an integer label of pixel.
|
| 52 |
+
"""
|
| 53 |
+
_check_img_dtype(image)
|
| 54 |
+
self.image = image
|
| 55 |
+
self.boxes = boxes
|
| 56 |
+
self.seg_info = seg_info
|
| 57 |
+
|
| 58 |
+
def transform(self, tfm: Transform) -> None:
|
| 59 |
+
"""
|
| 60 |
+
In-place transform all attributes of this class.
|
| 61 |
+
"""
|
| 62 |
+
self.image = tfm.apply_image(self.image)
|
| 63 |
+
if self.boxes is not None:
|
| 64 |
+
self.boxes = tfm.apply_box(self.boxes)
|
| 65 |
+
if self.seg_info is not None:
|
| 66 |
+
assert type(self.seg_info) == dict, "seg_info is dictionary"
|
| 67 |
+
for key, value in self.seg_info.items():
|
| 68 |
+
self.seg_info[key] = tfm.apply_segmentation(value)
|
MaskClustering/third_party/Entity/Entity/EntitySeg/entityseg/data/__init__.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .datasets import *
|
| 2 |
+
from .dataset_mapper import DatasetMapper
|
MaskClustering/third_party/Entity/Entity/EntitySeg/entityseg/data/dataset_mapper.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
| 2 |
+
import copy
|
| 3 |
+
import logging
|
| 4 |
+
import numpy as np
|
| 5 |
+
import torch.nn.functional as F
|
| 6 |
+
from typing import List, Optional, Union
|
| 7 |
+
import torch
|
| 8 |
+
import os
|
| 9 |
+
import pdb
|
| 10 |
+
import cv2
|
| 11 |
+
|
| 12 |
+
from detectron2.config import configurable
|
| 13 |
+
from detectron2.data import detection_utils as utils
|
| 14 |
+
from detectron2.data import transforms as T
|
| 15 |
+
|
| 16 |
+
from .Auginput import ItemAugInput
|
| 17 |
+
|
| 18 |
+
from panopticapi.utils import rgb2id, id2rgb
|
| 19 |
+
|
| 20 |
+
"""
|
| 21 |
+
This file contains the default mapping that's applied to "dataset dicts".
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
__all__ = ["DatasetMapper"]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def filter_empty_instances(instances, by_box=True, by_mask=True, box_threshold=1e-5):
|
| 28 |
+
"""
|
| 29 |
+
Filter out empty instances in an `Instances` object.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
instances (Instances):
|
| 33 |
+
by_box (bool): whether to filter out instances with empty boxes
|
| 34 |
+
by_mask (bool): whether to filter out instances with empty masks
|
| 35 |
+
box_threshold (float): minimum width and height to be considered non-empty
|
| 36 |
+
|
| 37 |
+
Returns:
|
| 38 |
+
Instances: the filtered instances.
|
| 39 |
+
"""
|
| 40 |
+
assert by_box or by_mask
|
| 41 |
+
r = []
|
| 42 |
+
if by_box:
|
| 43 |
+
r.append(instances.gt_boxes.nonempty(threshold=box_threshold))
|
| 44 |
+
if instances.has("gt_masks") and by_mask:
|
| 45 |
+
r.append(instances.gt_masks.nonempty())
|
| 46 |
+
|
| 47 |
+
# TODO: can also filter visible keypoints
|
| 48 |
+
|
| 49 |
+
if not r:
|
| 50 |
+
return instances
|
| 51 |
+
m = r[0]
|
| 52 |
+
for x in r[1:]:
|
| 53 |
+
m = m & x
|
| 54 |
+
return instances[m], m
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class DatasetMapper:
|
| 58 |
+
"""
|
| 59 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 60 |
+
and map it into a format used by the model.
|
| 61 |
+
|
| 62 |
+
This is the default callable to be used to map your dataset dict into training data.
|
| 63 |
+
You may need to follow it to implement your own one for customized logic,
|
| 64 |
+
such as a different way to read or transform images.
|
| 65 |
+
See :doc:`/tutorials/data_loading` for details.
|
| 66 |
+
|
| 67 |
+
The callable currently does the following:
|
| 68 |
+
|
| 69 |
+
1. Read the image from "file_name"
|
| 70 |
+
2. Applies cropping/geometric transforms to the image and annotations
|
| 71 |
+
3. Prepare data and annotations to Tensor and :class:`Instances`
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
@configurable
|
| 75 |
+
def __init__(
|
| 76 |
+
self,
|
| 77 |
+
is_train: bool,
|
| 78 |
+
*,
|
| 79 |
+
augmentations: List[Union[T.Augmentation, T.Transform]],
|
| 80 |
+
image_format: str
|
| 81 |
+
):
|
| 82 |
+
"""
|
| 83 |
+
NOTE: this interface is experimental.
|
| 84 |
+
|
| 85 |
+
Args:
|
| 86 |
+
is_train: whether it's used in training or inference
|
| 87 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 88 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 89 |
+
use_instance_mask: whether to process instance segmentation annotations, if available
|
| 90 |
+
use_keypoint: whether to process keypoint annotations if available
|
| 91 |
+
instance_mask_format: one of "polygon" or "bitmask". Process instance segmentation
|
| 92 |
+
masks into this format.
|
| 93 |
+
keypoint_hflip_indices: see :func:`detection_utils.create_keypoint_hflip_indices`
|
| 94 |
+
precomputed_proposal_topk: if given, will load pre-computed
|
| 95 |
+
proposals from dataset_dict and keep the top k proposals for each image.
|
| 96 |
+
recompute_boxes: whether to overwrite bounding box annotations
|
| 97 |
+
by computing tight bounding boxes from instance mask annotations.
|
| 98 |
+
"""
|
| 99 |
+
# fmt: off
|
| 100 |
+
self.is_train = is_train
|
| 101 |
+
self.augmentations = augmentations
|
| 102 |
+
self.image_format = image_format
|
| 103 |
+
# fmt: on
|
| 104 |
+
logger = logging.getLogger(__name__)
|
| 105 |
+
logger.info("Augmentations used in training: " + str(augmentations))
|
| 106 |
+
|
| 107 |
+
@classmethod
|
| 108 |
+
def from_config(cls, cfg, is_train: bool = True):
|
| 109 |
+
augs = utils.build_augmentation(cfg, is_train)
|
| 110 |
+
if cfg.INPUT.CROP.ENABLED and is_train:
|
| 111 |
+
augs.insert(0, T.RandomCrop(cfg.INPUT.CROP.TYPE, cfg.INPUT.CROP.SIZE))
|
| 112 |
+
recompute_boxes = cfg.MODEL.MASK_ON
|
| 113 |
+
else:
|
| 114 |
+
recompute_boxes = False
|
| 115 |
+
|
| 116 |
+
ret = {
|
| 117 |
+
"is_train": is_train,
|
| 118 |
+
"augmentations": augs,
|
| 119 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 120 |
+
}
|
| 121 |
+
return ret
|
| 122 |
+
|
| 123 |
+
def __call__(self, dataset_dict):
|
| 124 |
+
"""
|
| 125 |
+
Args:
|
| 126 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 127 |
+
|
| 128 |
+
Returns:
|
| 129 |
+
dict: a format that builtin models in detectron2 accept
|
| 130 |
+
"""
|
| 131 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 132 |
+
# USER: Write your own image loading if it's not from a file
|
| 133 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.image_format)
|
| 134 |
+
utils.check_image_size(dataset_dict, image)
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
name = dataset_dict["file_name"].split("/")[-1].split(".")[0]
|
| 138 |
+
|
| 139 |
+
if self.is_train:
|
| 140 |
+
panoptic_annotation_path = os.path.join("datasets/coco/entity_train2017", name+".npz")
|
| 141 |
+
else:
|
| 142 |
+
panoptic_annotation_path = os.path.join("datasets/coco/entity_val2017", name+".npz")
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
panoptic_semantic_map = np.load(panoptic_annotation_path)
|
| 146 |
+
# x1,y1,x2,y2,category,thing_or_stuff,instance_id
|
| 147 |
+
bounding_boxes = panoptic_semantic_map["bounding_box"].astype(np.float)
|
| 148 |
+
|
| 149 |
+
info_map = panoptic_semantic_map["map"]
|
| 150 |
+
instance_map = info_map[0]
|
| 151 |
+
semantic_map = info_map[1]
|
| 152 |
+
# instance_map = torch.tensor(instance_map).long()
|
| 153 |
+
num_instances = len(dataset_dict["annotations"])
|
| 154 |
+
|
| 155 |
+
seg_info = {"instance_map": instance_map,
|
| 156 |
+
"semantic_map": semantic_map}
|
| 157 |
+
|
| 158 |
+
aug_input = ItemAugInput(image, seg_info=seg_info)
|
| 159 |
+
transforms = aug_input.apply_augmentations(self.augmentations)
|
| 160 |
+
|
| 161 |
+
image = aug_input.image
|
| 162 |
+
instance_map = aug_input.seg_info["instance_map"].copy()
|
| 163 |
+
semantic_map = aug_input.seg_info["semantic_map"]
|
| 164 |
+
|
| 165 |
+
image_shape = image.shape[:2] # h, w
|
| 166 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 167 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 168 |
+
# Therefore it's important to use torch.Tensor.
|
| 169 |
+
dataset_dict["image"] = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 170 |
+
new_anns = dataset_dict.pop("annotations")
|
| 171 |
+
new_anns = [obj for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 172 |
+
# assert len(new_anns) == bounding_boxes.shape[0], print("{}:{}".format(len(new_anns), bounding_boxes.shape[0]))
|
| 173 |
+
isthing_list = []
|
| 174 |
+
instance_id_list = []
|
| 175 |
+
for i in range(len(new_anns)):
|
| 176 |
+
x1, y1, x2, y2, category, thing, instance_id = bounding_boxes[i]
|
| 177 |
+
x1 = int(x1)
|
| 178 |
+
y1 = int(y1)
|
| 179 |
+
x2 = int(x2)
|
| 180 |
+
y2 = int(y2)
|
| 181 |
+
w = x2 - x1
|
| 182 |
+
h = y2 - y1
|
| 183 |
+
new_anns[i]["bbox"] = [x1, y1, w, h]
|
| 184 |
+
new_anns[i]["category_id"] = int(category)
|
| 185 |
+
isthing_list.append(int(thing))
|
| 186 |
+
instance_id_list.append(int(instance_id))
|
| 187 |
+
|
| 188 |
+
isthing_list = torch.tensor(isthing_list, dtype=torch.int64)
|
| 189 |
+
instance_id_list = torch.tensor(instance_id_list, dtype=torch.int64)
|
| 190 |
+
|
| 191 |
+
# annos = [utils.transform_instance_annotations(obj, transforms, image_shape) for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 192 |
+
annos = [utils.transform_instance_annotations(obj, transforms, image_shape) for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 193 |
+
instances = utils.annotations_to_instances(annos, image_shape, mask_format="bitmask")
|
| 194 |
+
instances.instanceid = instance_id_list
|
| 195 |
+
|
| 196 |
+
instances, select = filter_empty_instances(instances)
|
| 197 |
+
|
| 198 |
+
dataset_dict["instances"] = instances
|
| 199 |
+
dataset_dict["instance_map"] = torch.as_tensor(np.ascontiguousarray(instance_map))
|
| 200 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entity/EntitySeg/entityseg/data/datasets.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
| 2 |
+
import os
|
| 3 |
+
import pdb
|
| 4 |
+
|
| 5 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 6 |
+
from detectron2.data.datasets.builtin_meta import COCO_CATEGORIES, _get_builtin_metadata
|
| 7 |
+
from detectron2.data.datasets import load_coco_json, register_coco_instances
|
| 8 |
+
import torchvision
|
| 9 |
+
|
| 10 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 11 |
+
|
| 12 |
+
SPLITS = {}
|
| 13 |
+
SPLITS["coco_2017_train_entity"] = ("coco/train2017", "coco/annotations/entity_train2017.json")
|
| 14 |
+
SPLITS["coco_2017_val_entity"] = ("coco/val2017", "coco/annotations/entity_val2017.json")
|
| 15 |
+
|
| 16 |
+
def _get_coco_trans_meta():
|
| 17 |
+
oc2nc_map = {category['id']: [cid, category["isthing"], category["name"], category["color"]] for cid, category in enumerate(COCO_CATEGORIES)}
|
| 18 |
+
NEW_COCO_CATEGORIES = []
|
| 19 |
+
for key, value in oc2nc_map.items():
|
| 20 |
+
new_info = {"id": value[0], "isthing": value[1], "name": value[2], "color": value[3]}
|
| 21 |
+
NEW_COCO_CATEGORIES.append(new_info)
|
| 22 |
+
|
| 23 |
+
thing_ids = [k["id"] for k in NEW_COCO_CATEGORIES]
|
| 24 |
+
thing_colors = [k["color"] for k in NEW_COCO_CATEGORIES]
|
| 25 |
+
thing_classes = [k["name"] for k in NEW_COCO_CATEGORIES]
|
| 26 |
+
thing_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(thing_ids)}
|
| 27 |
+
ret = {
|
| 28 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 29 |
+
"thing_classes": thing_classes,
|
| 30 |
+
"thing_colors": thing_colors,
|
| 31 |
+
}
|
| 32 |
+
return ret
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
for key, (image_root, json_file) in SPLITS.items():
|
| 36 |
+
register_coco_instances(key,
|
| 37 |
+
_get_coco_trans_meta(),
|
| 38 |
+
os.path.join(_root, json_file) if "://" not in json_file else json_file,
|
| 39 |
+
os.path.join(_root, image_root)
|
| 40 |
+
)
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/Auginput.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pprint
|
| 4 |
+
from abc import ABCMeta, abstractmethod
|
| 5 |
+
from typing import List, Optional, Tuple, Union
|
| 6 |
+
from fvcore.transforms.transform import Transform, TransformList
|
| 7 |
+
from detectron2.data.transforms import AugInput
|
| 8 |
+
from detectron2.data.transforms.augmentation import _check_img_dtype
|
| 9 |
+
|
| 10 |
+
class ItemAugInput(AugInput):
|
| 11 |
+
"""
|
| 12 |
+
A standard implementation of :class:`AugInput` for the majority of use cases.
|
| 13 |
+
This class provides the following standard attributes that are common to use by
|
| 14 |
+
Augmentation (augmentation policies). These are chosen because most
|
| 15 |
+
:class:`Augmentation` won't need anything more to define a augmentation policy.
|
| 16 |
+
After applying augmentations to these special attributes, the returned transforms
|
| 17 |
+
can then be used to transform other data structures that users have.
|
| 18 |
+
|
| 19 |
+
Attributes:
|
| 20 |
+
image (ndarray): image in HW or HWC format. The meaning of C is up to users
|
| 21 |
+
boxes (ndarray or None): Nx4 boxes in XYXY_ABS mode
|
| 22 |
+
sem_seg (ndarray or None): HxW semantic segmentation mask
|
| 23 |
+
|
| 24 |
+
Examples:
|
| 25 |
+
::
|
| 26 |
+
input = StandardAugInput(image, boxes=boxes)
|
| 27 |
+
tfms = input.apply_augmentations(list_of_augmentations)
|
| 28 |
+
transformed_image = input.image
|
| 29 |
+
transformed_boxes = input.boxes
|
| 30 |
+
transformed_other_data = tfms.apply_other(other_data)
|
| 31 |
+
|
| 32 |
+
An extended project that works with new data types may require augmentation
|
| 33 |
+
policies that need more inputs. An algorithm may need to transform inputs
|
| 34 |
+
in a way different from the standard approach defined in this class. In those
|
| 35 |
+
situations, users can implement new subclasses of :class:`AugInput` with differnt
|
| 36 |
+
attributes and the :meth:`transform` method.
|
| 37 |
+
"""
|
| 38 |
+
def __init__(
|
| 39 |
+
self,
|
| 40 |
+
image: np.ndarray,
|
| 41 |
+
*,
|
| 42 |
+
boxes = None,
|
| 43 |
+
seg_info= None,
|
| 44 |
+
):
|
| 45 |
+
"""
|
| 46 |
+
Args:
|
| 47 |
+
image: (H,W) or (H,W,C) ndarray of type uint8 in range [0, 255], or
|
| 48 |
+
floating point in range [0, 1] or [0, 255].
|
| 49 |
+
boxes: (N,4) ndarray of float32. It represents the instance bounding boxes
|
| 50 |
+
of N instances. Each is in XYXY format in unit of absolute coordinates.
|
| 51 |
+
sem_seg: (H,W) ndarray of type uint8. Each element is an integer label of pixel.
|
| 52 |
+
"""
|
| 53 |
+
_check_img_dtype(image)
|
| 54 |
+
self.image = image
|
| 55 |
+
self.boxes = boxes
|
| 56 |
+
self.seg_info = seg_info
|
| 57 |
+
|
| 58 |
+
def transform(self, tfm: Transform) -> None:
|
| 59 |
+
"""
|
| 60 |
+
In-place transform all attributes of this class.
|
| 61 |
+
"""
|
| 62 |
+
self.image = tfm.apply_image(self.image)
|
| 63 |
+
if self.boxes is not None:
|
| 64 |
+
self.boxes = tfm.apply_box(self.boxes)
|
| 65 |
+
if self.seg_info is not None:
|
| 66 |
+
assert type(self.seg_info) == dict, "seg_info is dictionary"
|
| 67 |
+
for key, value in self.seg_info.items():
|
| 68 |
+
self.seg_info[key] = tfm.apply_segmentation(value)
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .datasets import *
|
| 2 |
+
from .dataset_mapper import DatasetMapper
|
| 3 |
+
from .coco_instance_new_baseline_dataset_mapper import COCOInstanceNewBaselineDatasetMapper
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/__init__.py
ADDED
|
File without changes
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/__init__.py
ADDED
|
File without changes
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/box_level_augs.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import random
|
| 3 |
+
import numpy as np
|
| 4 |
+
from detectron2.augmentations.box_level_augs.color_augs import color_aug_func
|
| 5 |
+
from detectron2.augmentations.box_level_augs.geometric_augs import geometric_aug_func
|
| 6 |
+
|
| 7 |
+
pixel_mean = [103.530, 116.280, 123.675]
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _box_sample_prob(bbox, scale_ratios_splits, box_prob=0.3):
|
| 11 |
+
scale_ratios, scale_splits = scale_ratios_splits
|
| 12 |
+
|
| 13 |
+
ratios = np.array(scale_ratios)
|
| 14 |
+
ratios = ratios / ratios.sum()
|
| 15 |
+
area = (bbox[2] - bbox[0]) * (bbox[3] - bbox[1])
|
| 16 |
+
if area == 0:
|
| 17 |
+
return 0
|
| 18 |
+
if area < scale_splits[0]:
|
| 19 |
+
scale_ratio = ratios[0]
|
| 20 |
+
elif area < scale_splits[1]:
|
| 21 |
+
scale_ratio = ratios[1]
|
| 22 |
+
else:
|
| 23 |
+
scale_ratio = ratios[2]
|
| 24 |
+
return box_prob * scale_ratio
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _box_aug_per_img(img, target, aug_type=None, scale_ratios=None, scale_splits=None, img_prob=0.1, box_prob=0.3, level=1):
|
| 28 |
+
if random.random() > img_prob:
|
| 29 |
+
return img, target
|
| 30 |
+
img_mean = torch.Tensor(pixel_mean).reshape(3,1,1).to(img.device)
|
| 31 |
+
img = img + img_mean
|
| 32 |
+
img /= 255.0
|
| 33 |
+
bboxes = target['gt_boxes']
|
| 34 |
+
|
| 35 |
+
tag = 'prob' if aug_type in geometric_aug_func else 'area'
|
| 36 |
+
scale_ratios_splits = [scale_ratios[tag], scale_splits]
|
| 37 |
+
if scale_ratios is None:
|
| 38 |
+
box_sample_prob = [box_prob] * len(bboxes.tensor)
|
| 39 |
+
else:
|
| 40 |
+
box_sample_prob = [_box_sample_prob(bbox, scale_ratios_splits, box_prob=box_prob) for bbox in bboxes.tensor]
|
| 41 |
+
|
| 42 |
+
if aug_type in color_aug_func:
|
| 43 |
+
img_aug = color_aug_func[aug_type](img, level, bboxes, [scale_ratios['area'], scale_splits], box_sample_prob)
|
| 44 |
+
elif aug_type in geometric_aug_func:
|
| 45 |
+
img_aug, target = geometric_aug_func[aug_type](img, level, target, box_sample_prob)
|
| 46 |
+
else:
|
| 47 |
+
raise ValueError('Unknown box-level augmentation function %s.' % (aug_type))
|
| 48 |
+
|
| 49 |
+
tensor = img_aug*255.0-img_mean
|
| 50 |
+
|
| 51 |
+
return tensor, target
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class Box_augs(object):
|
| 55 |
+
def __init__(self, box_augs_dict, max_iters, scale_splits, box_prob=0.3):
|
| 56 |
+
self.max_iters = max_iters
|
| 57 |
+
self.box_prob = box_prob
|
| 58 |
+
self.scale_splits = scale_splits
|
| 59 |
+
self.policies = box_augs_dict['policies']
|
| 60 |
+
self.scale_ratios = box_augs_dict['scale_ratios']
|
| 61 |
+
|
| 62 |
+
def __call__(self, tensor, target, iteration):
|
| 63 |
+
iter_ratio = float(iteration) / self.max_iters
|
| 64 |
+
sub_policy = random.choice(self.policies)
|
| 65 |
+
tensor, _ = _box_aug_per_img(tensor, target, aug_type=sub_policy[0][0], scale_ratios=self.scale_ratios, scale_splits=self.scale_splits, img_prob=sub_policy[0][1] * iter_ratio, box_prob=self.box_prob, level=sub_policy[0][2])
|
| 66 |
+
tensor_out, target_out = _box_aug_per_img(tensor, target, aug_type=sub_policy[1][0], scale_ratios=self.scale_ratios, scale_splits=self.scale_splits, img_prob=sub_policy[1][1] * iter_ratio, box_prob=self.box_prob, level=sub_policy[1][2])
|
| 67 |
+
|
| 68 |
+
return tensor_out, target_out
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/color_augs.py
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import torch
|
| 3 |
+
import torch.nn.functional as F
|
| 4 |
+
from detectron2.augmentations.box_level_augs.gaussian_maps import _merge_gaussian
|
| 5 |
+
|
| 6 |
+
_MAX_LEVEL = 10.0
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def blend(image1, image2, factor):
|
| 10 |
+
"""Blend image1 and image2 using 'factor'.
|
| 11 |
+
Factor can be above 0.0. A value of 0.0 means only image1 is used.
|
| 12 |
+
A value of 1.0 means only image2 is used. A value between 0.0 and
|
| 13 |
+
1.0 means we linearly interpolate the pixel values between the two
|
| 14 |
+
images. A value greater than 1.0 "extrapolates" the difference
|
| 15 |
+
between the two pixel values, and we clip the results to values
|
| 16 |
+
between 0 and 1.0.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
if factor == 0.0:
|
| 20 |
+
return image1
|
| 21 |
+
if factor == 1.0:
|
| 22 |
+
return image2
|
| 23 |
+
|
| 24 |
+
difference = image2 - image1
|
| 25 |
+
scaled = factor * difference
|
| 26 |
+
|
| 27 |
+
# Do addition in float.
|
| 28 |
+
temp = image1 + scaled
|
| 29 |
+
|
| 30 |
+
# Interpolate
|
| 31 |
+
if factor > 0.0 and factor < 1.0:
|
| 32 |
+
# Interpolation means we always stay within 0 and 255.
|
| 33 |
+
return temp
|
| 34 |
+
|
| 35 |
+
# Extrapolate:
|
| 36 |
+
#
|
| 37 |
+
# We need to clip and then cast.
|
| 38 |
+
return torch.clamp(temp, 0.0, 1.0)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def solarize(image, threshold=0.5):
|
| 42 |
+
# For each pixel in the image, select the pixel
|
| 43 |
+
# if the value is less than the threshold.
|
| 44 |
+
# Otherwise, subtract 255 from the pixel.
|
| 45 |
+
return torch.where(image <= threshold, image, 1.0 - image)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def solarize_add(image, addition=0, threshold=0.5):
|
| 49 |
+
# For each pixel in the image less than threshold
|
| 50 |
+
# we add 'addition' amount to it and then clip the
|
| 51 |
+
# pixel value to be between 0 and 255. The value
|
| 52 |
+
# of 'addition' is between -128 and 128.
|
| 53 |
+
added_image = image + addition
|
| 54 |
+
added_image = torch.clamp(added_image, 0.0, 1.0)
|
| 55 |
+
return torch.where(image <= threshold, added_image, image)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def rgb2gray(rgb):
|
| 59 |
+
gray = rgb[0] * 0.2989 + rgb[1] * 0.5870 + rgb[2] * 0.1140
|
| 60 |
+
gray = gray.unsqueeze(0).repeat((3, 1, 1))
|
| 61 |
+
return gray
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def color(img, factor):
|
| 65 |
+
"""Equivalent of PIL Color."""
|
| 66 |
+
if img.shape[0] == 0 or img.shape[1] == 0:
|
| 67 |
+
return img
|
| 68 |
+
|
| 69 |
+
degenerate = rgb2gray(img)
|
| 70 |
+
return blend(degenerate, img, factor)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def contrast(img, factor):
|
| 74 |
+
dtype = img.dtype if torch.is_floating_point(img) else torch.float32
|
| 75 |
+
mean = torch.mean(rgb2gray(img).to(dtype), dim=(-3, -2, -1), keepdim=True)
|
| 76 |
+
return blend(mean, img, max(factor, 1e-6))
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def brightness(image, factor):
|
| 80 |
+
"""Equivalent of PIL Brightness."""
|
| 81 |
+
degenerate = torch.zeros(image.shape)
|
| 82 |
+
return blend(degenerate, image, factor)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def sharpness(image, factor):
|
| 86 |
+
"""Implements Sharpness function from PIL using TF ops."""
|
| 87 |
+
if image.shape[0] == 0 or image.shape[1] == 0:
|
| 88 |
+
return image
|
| 89 |
+
channels = image.shape[0]
|
| 90 |
+
kernel = torch.Tensor([[1, 1, 1], [1, 5, 1], [1, 1, 1]]).reshape(1, 1, 3, 3) / 13.0
|
| 91 |
+
kernel = kernel.repeat((3, 1, 1, 1))
|
| 92 |
+
image_newaxis = image.unsqueeze(0)
|
| 93 |
+
image_pad = F.pad(image_newaxis, (1, 1, 1, 1), mode='reflect')
|
| 94 |
+
degenerate = F.conv2d(image_pad, weight=kernel, groups=channels).squeeze(0)
|
| 95 |
+
return blend(degenerate, image, factor)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def equalize(image):
|
| 99 |
+
"""Implements Equalize function from PIL using PyTorch ops based on:
|
| 100 |
+
https://github.com/tensorflow/tpu/blob/master/models/official/efficientnet/autoaugment.py#L352"""
|
| 101 |
+
image = image * 255
|
| 102 |
+
|
| 103 |
+
def scale_channel(im, c):
|
| 104 |
+
"""Scale the data in the channel to implement equalize."""
|
| 105 |
+
im = im[c, :, :]
|
| 106 |
+
# Compute the histogram of the image channel.
|
| 107 |
+
histo = torch.histc(im, bins=256, min=0, max=255) # .type(torch.int32)
|
| 108 |
+
# For the purposes of computing the step, filter out the nonzeros.
|
| 109 |
+
nonzero_histo = torch.reshape(histo[histo != 0], [-1])
|
| 110 |
+
step = (torch.sum(nonzero_histo) - nonzero_histo[-1]) // 255
|
| 111 |
+
|
| 112 |
+
def build_lut(histo, step):
|
| 113 |
+
# Compute the cumulative sum, shifting by step // 2
|
| 114 |
+
# and then normalization by step.
|
| 115 |
+
lut = (torch.cumsum(histo, 0) + (step // 2)) // step
|
| 116 |
+
# Shift lut, prepending with 0.
|
| 117 |
+
lut = torch.cat([torch.zeros(1), lut[:-1]])
|
| 118 |
+
# Clip the counts to be in range. This is done
|
| 119 |
+
# in the C code for image.point.
|
| 120 |
+
return torch.clamp(lut, 0, 255)
|
| 121 |
+
|
| 122 |
+
# If step is zero, return the original image. Otherwise, build
|
| 123 |
+
# lut from the full histogram and step and then index from it.
|
| 124 |
+
if step == 0:
|
| 125 |
+
result = im
|
| 126 |
+
else:
|
| 127 |
+
# can't index using 2d index. Have to flatten and then reshape
|
| 128 |
+
result = torch.gather(build_lut(histo, step), 0, im.flatten().long())
|
| 129 |
+
result = result.reshape_as(im)
|
| 130 |
+
|
| 131 |
+
return result # .type(torch.uint8)
|
| 132 |
+
|
| 133 |
+
# Assumes RGB for now. Scales each channel independently
|
| 134 |
+
# and then stacks the result.
|
| 135 |
+
s1 = scale_channel(image, 0)
|
| 136 |
+
s2 = scale_channel(image, 1)
|
| 137 |
+
s3 = scale_channel(image, 2)
|
| 138 |
+
image = torch.stack([s1, s2, s3], 0) / 255.0
|
| 139 |
+
return image
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def autocontrast(image):
|
| 143 |
+
"""Implements Autocontrast function from PIL using TF ops.
|
| 144 |
+
Args:
|
| 145 |
+
image: A 3D uint8 tensor.
|
| 146 |
+
Returns:
|
| 147 |
+
The image after it has had autocontrast applied to it and will be of type
|
| 148 |
+
uint8.
|
| 149 |
+
"""
|
| 150 |
+
|
| 151 |
+
def scale_channel(image):
|
| 152 |
+
"""Scale the 2D image using the autocontrast rule."""
|
| 153 |
+
# A possibly cheaper version can be done using cumsum/unique_with_counts
|
| 154 |
+
# over the histogram values, rather than iterating over the entire image.
|
| 155 |
+
# to compute mins and maxes.
|
| 156 |
+
lo = torch.min(image)
|
| 157 |
+
hi = torch.max(image)
|
| 158 |
+
|
| 159 |
+
# Scale the image, making the lowest value 0 and the highest value 1.
|
| 160 |
+
def scale_values(im):
|
| 161 |
+
scale = 1.0 / (hi - lo)
|
| 162 |
+
offset = -lo * scale
|
| 163 |
+
im = im * scale + offset
|
| 164 |
+
im = torch.clamp(im, 0.0, 1.0)
|
| 165 |
+
return im
|
| 166 |
+
|
| 167 |
+
if hi > lo:
|
| 168 |
+
result = scale_values(image)
|
| 169 |
+
else:
|
| 170 |
+
result = image
|
| 171 |
+
|
| 172 |
+
return result
|
| 173 |
+
|
| 174 |
+
# Assumes RGB for now. Scales each channel independently
|
| 175 |
+
# and then stacks the result.
|
| 176 |
+
s1 = scale_channel(image[0, :, :])
|
| 177 |
+
s2 = scale_channel(image[1, :, :])
|
| 178 |
+
s3 = scale_channel(image[2, :, :])
|
| 179 |
+
image = torch.stack([s1, s2, s3], 0)
|
| 180 |
+
return image
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def posterize(image, bits):
|
| 184 |
+
"""Equivalent of PIL Posterize."""
|
| 185 |
+
image *= 255
|
| 186 |
+
image = image.long()
|
| 187 |
+
shift = bits # 8 - bits
|
| 188 |
+
image_rightshift = image >> shift
|
| 189 |
+
image_leftshift = image_rightshift << shift
|
| 190 |
+
image_leftshift = image_leftshift.float() / 255.0
|
| 191 |
+
return image_leftshift
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def _color_aug_func(img, img_aug, bboxes, scale_ratios_splits, box_sample_probs):
|
| 195 |
+
scale_ratios, scale_splits = scale_ratios_splits
|
| 196 |
+
boxes = [bbox for i, bbox in enumerate(bboxes.tensor) if random.random() < box_sample_probs[i]]
|
| 197 |
+
img_aug = _merge_gaussian(img, img_aug, boxes, scale_ratios, scale_splits)
|
| 198 |
+
return img_aug
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
color_aug_func = {
|
| 202 |
+
'AutoContrast': lambda x, level, target, scale_ratios_splits, box_sample_probs: _color_aug_func(x, autocontrast(x), target, scale_ratios_splits, box_sample_probs),
|
| 203 |
+
'Equalize': lambda x, leve, target, scale_ratios_splits, box_sample_probs: _color_aug_func(x, equalize(x), target, scale_ratios_splits, box_sample_probs),
|
| 204 |
+
'SolarizeAdd': lambda x, level, target, scale_ratios_splits, box_sample_probs: _color_aug_func(x, solarize_add(x, level / _MAX_LEVEL * 0.4296875), target, scale_ratios_splits, box_sample_probs),
|
| 205 |
+
'Color': lambda x, level, target, scale_ratios_splits, box_sample_probs: _color_aug_func(x, color(x, level / _MAX_LEVEL * 1.8 + 0.1), target, scale_ratios_splits, box_sample_probs),
|
| 206 |
+
'Contrast': lambda x, level, target, scale_ratios_splits, box_sample_probs: _color_aug_func(x, contrast(x, level / _MAX_LEVEL * 1.8 + 0.1), target, scale_ratios_splits, box_sample_probs),
|
| 207 |
+
'Brightness': lambda x, level, target, scale_ratios_splits, box_sample_probs: _color_aug_func(x, brightness(x, level / _MAX_LEVEL * 1.8 + 0.1), target, scale_ratios_splits, box_sample_probs),
|
| 208 |
+
'Sharpness': lambda x, level, target, scale_ratios_splits, box_sample_probs: _color_aug_func(x, sharpness(x, level /_MAX_LEVEL * 1.8 + 0.1), target, scale_ratios_splits, box_sample_probs), }
|
| 209 |
+
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/gaussian_maps.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def _gaussian_map(img, boxes, scale_splits=None, scale_ratios=None):
|
| 6 |
+
g_maps = torch.zeros(*img.shape[1:]).to(img.device)
|
| 7 |
+
height, width = img.shape[1], img.shape[2]
|
| 8 |
+
|
| 9 |
+
x_range = torch.arange(0, height, 1).to(img.device)
|
| 10 |
+
y_range = torch.arange(0, width, 1).to(img.device)
|
| 11 |
+
xx, yy = torch.meshgrid(x_range, y_range)
|
| 12 |
+
pos = torch.empty(xx.shape + (2,)).to(img.device)
|
| 13 |
+
pos[:, :, 0] = xx
|
| 14 |
+
pos[:, :, 1] = yy
|
| 15 |
+
|
| 16 |
+
for j, box in enumerate(boxes):
|
| 17 |
+
y1, x1, y2, x2 = box
|
| 18 |
+
x, y, h, w = x1, y1, x2 - x1, y2 - y1
|
| 19 |
+
mean_torch = torch.tensor([x + h // 2, y + w // 2]).to(img.device)
|
| 20 |
+
if scale_ratios is None:
|
| 21 |
+
scale_ratio = 1.0
|
| 22 |
+
else:
|
| 23 |
+
ratio_list = [0.2, 0.4, 0.6, 0.8, 1.0, 2, 4, 6, 8, 10]
|
| 24 |
+
if h * w < scale_splits[0]:
|
| 25 |
+
scale_ratio = ratio_list[scale_ratios[0]] * scale_splits[0] / (h * w)
|
| 26 |
+
elif h * w < scale_splits[1]:
|
| 27 |
+
scale_ratio = ratio_list[scale_ratios[1]] * (scale_splits[0] + scale_splits[1]) / 2.0 / (h * w)
|
| 28 |
+
elif h * w < scale_splits[2]:
|
| 29 |
+
scale_ratio = ratio_list[scale_ratios[2]] * scale_splits[2] / (h * w)
|
| 30 |
+
else:
|
| 31 |
+
scale_ratio = ratio_list[scale_ratios[2]]
|
| 32 |
+
|
| 33 |
+
r_var = (scale_ratio * height * width / (2 * math.pi)) ** 0.5
|
| 34 |
+
var_x = torch.tensor([(h / height) * r_var], dtype=torch.float32).to(img.device)
|
| 35 |
+
var_y = torch.tensor([(w / width) * r_var], dtype=torch.float32).to(img.device)
|
| 36 |
+
g_map = torch.exp(
|
| 37 |
+
-(((xx.float() - mean_torch[0]) ** 2 / (2.0 * var_x ** 2) + (yy.float() - mean_torch[1]) ** 2 / (
|
| 38 |
+
2.0 * var_y ** 2)))).to(
|
| 39 |
+
img.device)
|
| 40 |
+
g_maps += g_map
|
| 41 |
+
return g_maps
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _merge_gaussian(img, img_aug, boxes, scale_ratios, scale_splits):
|
| 45 |
+
g_maps = _gaussian_map(img, boxes, scale_splits, scale_ratios)
|
| 46 |
+
out = img * (1 - g_maps) + img_aug * g_maps
|
| 47 |
+
return out
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/box_level_augs/geometric_augs.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
import random
|
| 3 |
+
import torch
|
| 4 |
+
import torchvision.transforms as transforms
|
| 5 |
+
import numpy as np
|
| 6 |
+
from detectron2.augmentations.box_level_augs.gaussian_maps import _gaussian_map
|
| 7 |
+
from detectron2.structures.boxes import Boxes
|
| 8 |
+
from detectron2.structures.masks import PolygonMasks
|
| 9 |
+
|
| 10 |
+
_MAX_LEVEL = 10.0
|
| 11 |
+
pixel_mean = [103.530, 116.280, 123.675]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def scale_area(box, height, width, scale_ratio=1.0):
|
| 15 |
+
y1, x1, y2, x2 = box
|
| 16 |
+
h, w = x2 - x1, y2 - y1
|
| 17 |
+
h_new, w_new = h * scale_ratio, w * scale_ratio
|
| 18 |
+
x1, y1 = max(x1 + h / 2 - h_new / 2, 0), max(y1 + w / 2 - w_new / 2, 0)
|
| 19 |
+
x2, y2 = min(x1 + h_new, height), min(y1 + w_new, width)
|
| 20 |
+
box_new = torch.Tensor([y1, x1, y2, x2])
|
| 21 |
+
return box_new
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _geometric_aug_func(x, target, angle=0, translate=(0, 0), scale=1, shear=(0, 0), hflip=False, boxes_sample_prob=[], scale_ratio=1.0):
|
| 25 |
+
use_mask = ('gt_masks' in target)
|
| 26 |
+
|
| 27 |
+
boxes_and_labels = [(target['gt_boxes'].tensor[i], target['gt_classes'][i], target['gt_masks'].polygons[i] if use_mask else None) for i in range(len(target['gt_boxes'])) if random.random() < boxes_sample_prob[i]]
|
| 28 |
+
boxes = [b_and_l[0] for b_and_l in boxes_and_labels]
|
| 29 |
+
labels = [b_and_l[1] for b_and_l in boxes_and_labels]
|
| 30 |
+
masks = [b_and_l[2] for b_and_l in boxes_and_labels]
|
| 31 |
+
|
| 32 |
+
if random.random()<0.5:
|
| 33 |
+
angle *= -1
|
| 34 |
+
translate = (-translate[0], -translate[1])
|
| 35 |
+
shear = (-shear[0], -shear[1])
|
| 36 |
+
|
| 37 |
+
translate = (0, 0)
|
| 38 |
+
height, width = x.shape[1], x.shape[2]
|
| 39 |
+
|
| 40 |
+
x_crops = []
|
| 41 |
+
boxes_crops = []
|
| 42 |
+
boxes_new = []
|
| 43 |
+
labels_new = []
|
| 44 |
+
masks_new = []
|
| 45 |
+
for i, box in enumerate(boxes):
|
| 46 |
+
box_crop = scale_area(box, height, width, scale_ratio)
|
| 47 |
+
y1, x1, y2, x2 = box_crop.long()
|
| 48 |
+
|
| 49 |
+
x_crop = x[:, x1:x2, y1:y2]
|
| 50 |
+
boxes_crops.append(box_crop)
|
| 51 |
+
|
| 52 |
+
if x1>=x2 or y1>=y2:
|
| 53 |
+
x_crops.append(x_crop)
|
| 54 |
+
continue
|
| 55 |
+
|
| 56 |
+
if hflip:
|
| 57 |
+
x_crop = x_crop.flip(-1)
|
| 58 |
+
elif translate[0] + translate[1] != 0:
|
| 59 |
+
offset_y = (y2 + translate[0]).clamp(0, width).long().tolist() - y2
|
| 60 |
+
offset_x = (x2 + translate[1]).clamp(0, height).long().tolist() - x2
|
| 61 |
+
if offset_x!=0 or offset_y!=0:
|
| 62 |
+
offset = [offset_y, offset_x]
|
| 63 |
+
boxes_new.append(box + torch.Tensor(offset*2))
|
| 64 |
+
labels_new.append(labels[i])
|
| 65 |
+
if use_mask:
|
| 66 |
+
polys = masks[i]
|
| 67 |
+
polys_out = []
|
| 68 |
+
for poly in polys:
|
| 69 |
+
poly_new = copy.deepcopy(poly)
|
| 70 |
+
poly_new[0::2] = poly_new[0::2] + offset_y
|
| 71 |
+
poly_new[1::2] = poly_new[1::2] + offset_x
|
| 72 |
+
polys_out.append(poly_new)
|
| 73 |
+
masks_new.append(polys_out)
|
| 74 |
+
else:
|
| 75 |
+
x_crop = transforms.functional.to_pil_image(x_crop.cpu())
|
| 76 |
+
x_crop = transforms.functional.affine(x_crop, angle, translate, scale, shear, resample=2, fillcolor=tuple([int(i) for i in pixel_mean]))
|
| 77 |
+
x_crop = transforms.functional.to_tensor(x_crop).to(x.device)
|
| 78 |
+
x_crops.append(x_crop)
|
| 79 |
+
y = _transform(x, x_crops, boxes_crops, translate)
|
| 80 |
+
|
| 81 |
+
if translate[0] + translate[1] != 0 and len(boxes_new)>0:
|
| 82 |
+
target['gt_boxes'] = Boxes(torch.cat((target['gt_boxes'], torch.stack(boxes_new))))
|
| 83 |
+
target['gt_classes'] = torch.cat((target['gt_classes'], torch.Tensor(labels_new).long()))
|
| 84 |
+
if use_mask:
|
| 85 |
+
target['gt_masks'] = PolygonMasks(target['gt_masks'].polygons + masks_new)
|
| 86 |
+
|
| 87 |
+
return y, target
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def _transform(x, x_crops, boxes_crops, translate=(0, 0)):
|
| 91 |
+
y = copy.deepcopy(x)
|
| 92 |
+
height, width = x.shape[1], x.shape[2]
|
| 93 |
+
|
| 94 |
+
for i, box in enumerate(boxes_crops):
|
| 95 |
+
y1_c, x1_c, y2_c, x2_c = boxes_crops[i].long()
|
| 96 |
+
|
| 97 |
+
y1_c = (y1_c + translate[0]).clamp(0, width).long().tolist()
|
| 98 |
+
x1_c = (x1_c + translate[1]).clamp(0, height).long().tolist()
|
| 99 |
+
y2_c = (y2_c + translate[0]).clamp(0, width).long().tolist()
|
| 100 |
+
x2_c = (x2_c + translate[1]).clamp(0, height).long().tolist()
|
| 101 |
+
|
| 102 |
+
y_crop = copy.deepcopy(y[:, x1_c:x2_c, y1_c:y2_c])
|
| 103 |
+
x_crop = x_crops[i][:, :y_crop.shape[1], :y_crop.shape[2]]
|
| 104 |
+
|
| 105 |
+
if y_crop.shape[1] * y_crop.shape[2] == 0:
|
| 106 |
+
continue
|
| 107 |
+
|
| 108 |
+
g_maps = _gaussian_map(x_crop, [[0, 0, y_crop.shape[2], y_crop.shape[1]]])
|
| 109 |
+
_, _h, _w = y[:, x1_c:x2_c, y1_c:y2_c].shape
|
| 110 |
+
y[:, x1_c:x1_c+x_crop.shape[1], y1_c:y1_c+x_crop.shape[2]] = g_maps * x_crop + (1 - g_maps) * y_crop[:, :x_crop.shape[1], :x_crop.shape[2]]
|
| 111 |
+
return y
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
geometric_aug_func = {
|
| 115 |
+
'hflip': lambda x, level, target, boxes_sample_probs: _geometric_aug_func(x, target, hflip=True, boxes_sample_prob=boxes_sample_probs), #, scale_ratio=scale_ratio), # no parameters
|
| 116 |
+
'rotate': lambda x, level, target, boxes_sample_probs: _geometric_aug_func(x, target, level / _MAX_LEVEL * 30, boxes_sample_prob=boxes_sample_probs), #, scale_ratio=scale_ratio),
|
| 117 |
+
'shearX': lambda x, level, target, boxes_sample_probs: _geometric_aug_func(x, target, shear=(level / _MAX_LEVEL * 15, 0), boxes_sample_prob=boxes_sample_probs), #, scale_ratio=scale_ratio),
|
| 118 |
+
'shearY': lambda x, level, target, boxes_sample_probs: _geometric_aug_func(x, target, shear=(0, level / _MAX_LEVEL * 15), boxes_sample_prob=boxes_sample_probs), #, scale_ratio=scale_ratio),
|
| 119 |
+
'translateX': lambda x, level, target, boxes_sample_probs: _geometric_aug_func(x, target, translate=(level / _MAX_LEVEL * 120.0, 0), boxes_sample_prob=boxes_sample_probs), #, scale_ratio=scale_ratio),
|
| 120 |
+
'translateY': lambda x, level, target, boxes_sample_probs: _geometric_aug_func(x, target, translate=(0, level / _MAX_LEVEL * 120.0), boxes_sample_prob=boxes_sample_probs)} #, scale_ratio=scale_ratio),}
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/image_level_augs/img_level_augs.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import numpy as np
|
| 3 |
+
from detectron2.augmentations.image_level_augs.zoom_in import Zoom_in
|
| 4 |
+
from detectron2.augmentations.image_level_augs.zoom_out import Zoom_out
|
| 5 |
+
from detectron2.augmentations.image_level_augs.scale_jitter import scale_jitter
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Img_augs(object):
|
| 9 |
+
def __init__(self, img_augs_dict):
|
| 10 |
+
self.zoom_in_prob = img_augs_dict['zoom_in']['prob']
|
| 11 |
+
self.zoom_out_prob = img_augs_dict['zoom_out']['prob']
|
| 12 |
+
|
| 13 |
+
zoom_in_ratio_range = np.linspace(1.0, 1.5, 11)[1:]
|
| 14 |
+
zoom_out_ratio_range = np.linspace(1.0, 0.5, 11)[1:]
|
| 15 |
+
|
| 16 |
+
self.Zoom_in = Zoom_in(ratio=zoom_in_ratio_range[img_augs_dict['zoom_in']['level']])
|
| 17 |
+
self.Zoom_out = Zoom_out(ratio=zoom_out_ratio_range[img_augs_dict['zoom_out']['level']])
|
| 18 |
+
|
| 19 |
+
def __call__(self, tensor, target):
|
| 20 |
+
|
| 21 |
+
if random.random() < self.zoom_in_prob:
|
| 22 |
+
tensor_out, target_out = self.Zoom_in(tensor=tensor, target=target)
|
| 23 |
+
elif random.random() < self.zoom_in_prob + self.zoom_out_prob:
|
| 24 |
+
tensor_out, target_out = self.Zoom_out(tensor=tensor, target=target)
|
| 25 |
+
else:
|
| 26 |
+
tensor_out, target_out = tensor, target
|
| 27 |
+
|
| 28 |
+
jitter_factor = random.sample(np.linspace(0.75, 1.25, 5).tolist(), 1)[0]
|
| 29 |
+
tensor_out, target_out, _ = scale_jitter(tensor_out, target_out, jitter_factor)
|
| 30 |
+
|
| 31 |
+
return tensor_out, target_out
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/image_level_augs/scale_jitter.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
import torch
|
| 3 |
+
from detectron2.structures.boxes import Boxes
|
| 4 |
+
from detectron2.structures.masks import PolygonMasks
|
| 5 |
+
|
| 6 |
+
def scale_jitter(tensor, target, jitter_factor, jitter_size=None, mask=None):
|
| 7 |
+
if jitter_size is None:
|
| 8 |
+
_, h, w = tensor.shape
|
| 9 |
+
new_h, new_w = int(h * jitter_factor), int(w * jitter_factor)
|
| 10 |
+
jitter_factor_x = jitter_factor_y = jitter_factor
|
| 11 |
+
else:
|
| 12 |
+
new_h, new_w = jitter_size
|
| 13 |
+
_, h, w = tensor.shape
|
| 14 |
+
jitter_factor_y, jitter_factor_x = new_h/h, new_w/w
|
| 15 |
+
tensor_out = torch.nn.functional.interpolate(tensor.unsqueeze(0), size=(new_h, new_w), mode='nearest').squeeze(0)
|
| 16 |
+
target_out = copy.deepcopy(target)
|
| 17 |
+
target_mask = []
|
| 18 |
+
|
| 19 |
+
if 'gt_masks' in target:
|
| 20 |
+
mask = target['gt_masks']
|
| 21 |
+
|
| 22 |
+
if mask is not None:
|
| 23 |
+
for polys in mask.polygons:
|
| 24 |
+
new_polys = copy.deepcopy(polys)
|
| 25 |
+
for p in new_polys:
|
| 26 |
+
p[0::2] *= jitter_factor_x
|
| 27 |
+
p[1::2] *= jitter_factor_y
|
| 28 |
+
target_mask.append(new_polys)
|
| 29 |
+
|
| 30 |
+
if isinstance(target, dict):
|
| 31 |
+
target_out['gt_boxes'].scale(jitter_factor_x, jitter_factor_y)
|
| 32 |
+
if 'gt_masks' in target:
|
| 33 |
+
target_out['gt_masks'] = PolygonMasks(target_mask)
|
| 34 |
+
elif isinstance(target, Boxes):
|
| 35 |
+
target_out.scale(jitter_factor_x, jitter_factor_y)
|
| 36 |
+
else:
|
| 37 |
+
raise ValueError('Unsupported target %s'%str(target))
|
| 38 |
+
|
| 39 |
+
return tensor_out, target_out, target_mask
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def _crop_boxes(gt_boxes, crop_box):
|
| 43 |
+
xmin, ymin, xmax, ymax = gt_boxes.tensor.split(1, dim=-1)
|
| 44 |
+
|
| 45 |
+
assert torch.isfinite(gt_boxes.tensor).all(), "Box tensor contains infinite or NaN!"
|
| 46 |
+
|
| 47 |
+
w, h = crop_box[2] - crop_box[0], crop_box[3] - crop_box[1]
|
| 48 |
+
cropped_xmin = (xmin - crop_box[0]).clamp(min=0, max=w)
|
| 49 |
+
cropped_ymin = (ymin - crop_box[1]).clamp(min=0, max=h)
|
| 50 |
+
cropped_xmax = (xmax - crop_box[0]).clamp(min=0, max=w)
|
| 51 |
+
cropped_ymax = (ymax - crop_box[1]).clamp(min=0, max=h)
|
| 52 |
+
|
| 53 |
+
cropped_box = torch.cat((cropped_xmin, cropped_ymin, cropped_xmax, cropped_ymax), dim=-1)
|
| 54 |
+
gt_boxes.tensor = cropped_box
|
| 55 |
+
return gt_boxes
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/image_level_augs/zoom_in.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
import torch
|
| 3 |
+
import numpy as np
|
| 4 |
+
from detectron2.structures.masks import PolygonMasks
|
| 5 |
+
from detectron2.augmentations.image_level_augs.scale_jitter import scale_jitter, _crop_boxes
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Zoom_in(object):
|
| 9 |
+
def __init__(self, ratio=1.0, iou_threshold=0.5):
|
| 10 |
+
self.ratio = ratio
|
| 11 |
+
self.iou_threshold = iou_threshold
|
| 12 |
+
|
| 13 |
+
def __call__(self, tensor, target):
|
| 14 |
+
if self.ratio <= 1.0:
|
| 15 |
+
return tensor, target
|
| 16 |
+
bbox = target['gt_boxes']
|
| 17 |
+
classes = target['gt_classes']
|
| 18 |
+
|
| 19 |
+
h, w = tensor.shape[1], tensor.shape[2]
|
| 20 |
+
new_h, new_w = int(h * self.ratio), int(w * self.ratio)
|
| 21 |
+
|
| 22 |
+
use_mask = ('gt_masks' in target)
|
| 23 |
+
|
| 24 |
+
original_bbox = copy.deepcopy(bbox)
|
| 25 |
+
enlarged_tensor, enlarged_bbox, enlarged_mask = scale_jitter(tensor, bbox, self.ratio, mask=target['gt_masks'] if use_mask else None)
|
| 26 |
+
original_enlarged_bbox = copy.deepcopy(enlarged_bbox)
|
| 27 |
+
|
| 28 |
+
crop_x, crop_y = np.random.randint(0, new_h - h), np.random.randint(0, new_w - w)
|
| 29 |
+
crop_box = (crop_y, crop_x, crop_y + w, crop_x + h)
|
| 30 |
+
cropped_tensor = enlarged_tensor[:, crop_box[1]:crop_box[3], crop_box[0]:crop_box[2]]
|
| 31 |
+
cropped_bbox = _crop_boxes(enlarged_bbox, crop_box)
|
| 32 |
+
ious = cropped_bbox.area() / original_enlarged_bbox.area()
|
| 33 |
+
inds = ious >= self.iou_threshold
|
| 34 |
+
cropped_bbox = cropped_bbox[inds]
|
| 35 |
+
cropped_classes = classes[inds]
|
| 36 |
+
|
| 37 |
+
if len(cropped_bbox) > 0:
|
| 38 |
+
tensor_out = cropped_tensor
|
| 39 |
+
target_out = {'gt_boxes': cropped_bbox, 'gt_classes': cropped_classes}
|
| 40 |
+
else:
|
| 41 |
+
tensor_out = tensor
|
| 42 |
+
target_out = {'gt_boxes': original_bbox, 'gt_classes': classes}
|
| 43 |
+
|
| 44 |
+
if use_mask:
|
| 45 |
+
cropped_masks = []
|
| 46 |
+
for j, polys in enumerate(enlarged_mask):
|
| 47 |
+
poly_out = []
|
| 48 |
+
for poly in polys:
|
| 49 |
+
if len(cropped_bbox) > 0:
|
| 50 |
+
poly_new = copy.deepcopy(poly)
|
| 51 |
+
poly_new[0::2] = poly_new[0::2] - crop_y
|
| 52 |
+
poly_new[1::2] = poly_new[1::2] - crop_x
|
| 53 |
+
poly_out.append(poly_new)
|
| 54 |
+
else:
|
| 55 |
+
poly_out.append(poly)
|
| 56 |
+
if len(cropped_bbox) == 0:
|
| 57 |
+
cropped_masks.append(poly_out)
|
| 58 |
+
elif inds[j]:
|
| 59 |
+
cropped_masks.append(poly_out)
|
| 60 |
+
target_out['gt_masks'] = PolygonMasks(cropped_masks)
|
| 61 |
+
if len(target_out['gt_boxes']) > len(target_out['gt_masks']):
|
| 62 |
+
from IPython import embed; embed()
|
| 63 |
+
|
| 64 |
+
return tensor_out, target_out
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/image_level_augs/zoom_out.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
import math
|
| 3 |
+
import torch
|
| 4 |
+
import random
|
| 5 |
+
import numpy as np
|
| 6 |
+
from detectron2.structures.boxes import Boxes
|
| 7 |
+
from detectron2.structures.masks import PolygonMasks
|
| 8 |
+
from detectron2.augmentations.image_level_augs.scale_jitter import scale_jitter
|
| 9 |
+
from detectron2.augmentations.vis import _vis
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class Zoom_out(object):
|
| 13 |
+
def __init__(self, ratio=1.0, img_pool_size=10, iou_threshold=0.5, size_divisible=2):
|
| 14 |
+
self.ratio = ratio
|
| 15 |
+
self.img_pool = []
|
| 16 |
+
self.img_pool_size = img_pool_size
|
| 17 |
+
self.iou_threshold =iou_threshold
|
| 18 |
+
self.size_divisible = size_divisible
|
| 19 |
+
|
| 20 |
+
def __call__(self, tensor, target):
|
| 21 |
+
if self.ratio >= 1.0:
|
| 22 |
+
return tensor, target
|
| 23 |
+
|
| 24 |
+
self.img_pool.append({'tensor': tensor, 'target': target})
|
| 25 |
+
|
| 26 |
+
if len(self.img_pool) > self.img_pool_size:
|
| 27 |
+
self.img_pool.pop(0)
|
| 28 |
+
|
| 29 |
+
if len(self.img_pool) < 4:
|
| 30 |
+
return tensor, target
|
| 31 |
+
|
| 32 |
+
use_mask = ('gt_masks' in target)
|
| 33 |
+
|
| 34 |
+
bbox = target['gt_boxes']
|
| 35 |
+
classes = target['gt_classes']
|
| 36 |
+
masks = target['gt_masks'] if use_mask else None
|
| 37 |
+
|
| 38 |
+
c, h, w = tensor.shape
|
| 39 |
+
h = int(math.ceil(h / self.size_divisible) * self.size_divisible)
|
| 40 |
+
w = int(math.ceil(w / self.size_divisible) * self.size_divisible)
|
| 41 |
+
|
| 42 |
+
new_h, new_w = int(self.ratio * h), int(self.ratio * w)
|
| 43 |
+
in_tensor, in_bbox, in_mask = scale_jitter(tensor, bbox, self.ratio, (new_h, new_w), masks)
|
| 44 |
+
|
| 45 |
+
pad_imgs = random.sample(self.img_pool, 3)
|
| 46 |
+
pad_tensors, pad_bboxes, pad_masks = [], [], []
|
| 47 |
+
for img in pad_imgs:
|
| 48 |
+
pad_tensor, pad_bbox, pad_mask = scale_jitter(img['tensor'], img['target']['gt_boxes'], self.ratio, (new_h, new_w), img['target']['gt_masks'] if use_mask else None)
|
| 49 |
+
pad_tensors.append(pad_tensor)
|
| 50 |
+
pad_bboxes.append(pad_bbox)
|
| 51 |
+
pad_masks.append(pad_mask)
|
| 52 |
+
|
| 53 |
+
crop_boxes = [(new_h, w-new_w), (h-new_h, new_w), (h-new_h, w-new_w)]
|
| 54 |
+
|
| 55 |
+
tensor_out = in_tensor.new(*(c, h, w)).zero_()
|
| 56 |
+
tensor_out[:c, :new_h, :new_w].copy_(in_tensor)
|
| 57 |
+
tensor_out[:c, :new_h, new_w:].copy_(pad_tensors[0][:c, :crop_boxes[0][0], :crop_boxes[0][1]])
|
| 58 |
+
tensor_out[:c, new_h:, :new_w].copy_(pad_tensors[1][:c, :crop_boxes[1][0], :crop_boxes[1][1]])
|
| 59 |
+
tensor_out[:c, new_h:, new_w:].copy_(pad_tensors[2][:c, :crop_boxes[2][0], :crop_boxes[2][1]])
|
| 60 |
+
|
| 61 |
+
crop_bboxes, crop_classes, crop_masks = [], [], []
|
| 62 |
+
for i, pad_bbox in enumerate(pad_bboxes):
|
| 63 |
+
crop_bbox = copy.deepcopy(pad_bbox)
|
| 64 |
+
crop_bbox.clip(crop_boxes[i])
|
| 65 |
+
ious = crop_bbox.area() / pad_bbox.area()
|
| 66 |
+
inds = ious >= self.iou_threshold
|
| 67 |
+
crop_bbox = crop_bbox[inds]
|
| 68 |
+
crop_bboxes.append(crop_bbox)
|
| 69 |
+
crop_classes.append(pad_imgs[i]['target']['gt_classes'][inds])
|
| 70 |
+
if use_mask:
|
| 71 |
+
crop_masks.append([mask for j, mask in enumerate(pad_masks[i]) if inds[j]])
|
| 72 |
+
|
| 73 |
+
offsets_box = [torch.Tensor([0.0,0.0,0.0,0.0]), torch.Tensor([new_w, 0.0, new_w, 0.0]), torch.Tensor([0.0, new_h, 0.0, new_h]), torch.Tensor([new_w, new_h, new_w, new_h])]
|
| 74 |
+
offsets_mask = [[0.0, 0.0], [0.0, new_w], [new_h, 0], [new_h, new_w]]
|
| 75 |
+
bbox_out = Boxes(torch.cat([target.tensor + offsets_box[i] for i, target in enumerate([in_bbox] + crop_bboxes)], dim=0))
|
| 76 |
+
classes_out = torch.cat([classes] + crop_classes, dim=0)
|
| 77 |
+
target_out = {'gt_boxes': bbox_out, 'gt_classes': classes_out}
|
| 78 |
+
|
| 79 |
+
if use_mask:
|
| 80 |
+
masks_out = []
|
| 81 |
+
for i, crop_mask in enumerate([in_mask]+crop_masks):
|
| 82 |
+
mask_out = []
|
| 83 |
+
for polys in crop_mask:
|
| 84 |
+
poly_out = []
|
| 85 |
+
for poly in polys:
|
| 86 |
+
poly_new = copy.deepcopy(poly)
|
| 87 |
+
poly_new[0::2] = poly_new[0::2] + offsets_mask[i][1]
|
| 88 |
+
poly_new[1::2] = poly_new[1::2] + offsets_mask[i][0]
|
| 89 |
+
poly_out.append(poly_new)
|
| 90 |
+
mask_out.append(poly_out)
|
| 91 |
+
|
| 92 |
+
masks_out += mask_out
|
| 93 |
+
masks_out = PolygonMasks(masks_out)
|
| 94 |
+
target_out['gt_masks'] = masks_out
|
| 95 |
+
|
| 96 |
+
return tensor_out, target_out
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/scale_aware_aug.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
import torch
|
| 3 |
+
import torchvision
|
| 4 |
+
from detectron2.augmentations.image_level_augs.img_level_augs import Img_augs
|
| 5 |
+
from detectron2.augmentations.box_level_augs.box_level_augs import Box_augs
|
| 6 |
+
from detectron2.augmentations.box_level_augs.color_augs import color_aug_func
|
| 7 |
+
from detectron2.augmentations.box_level_augs.geometric_augs import geometric_aug_func
|
| 8 |
+
from detectron2.utils.comm import get_world_size
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class SA_Aug(object):
|
| 12 |
+
def __init__(self, cfg):
|
| 13 |
+
autoaug_list = cfg.AUTOAUG.LIST
|
| 14 |
+
num_policies = cfg.AUTOAUG.NUM_SUBPOLICIES
|
| 15 |
+
max_iters = cfg.SOLVER.MAX_ITER
|
| 16 |
+
scale_splits = cfg.AUTOAUG.SCALE_SPLITS
|
| 17 |
+
box_prob = cfg.AUTOAUG.BOX_PROB
|
| 18 |
+
|
| 19 |
+
img_aug_list = autoaug_list[:4]
|
| 20 |
+
img_augs_dict = {'zoom_out':{'prob':img_aug_list[0]*0.05, 'level':img_aug_list[1]},
|
| 21 |
+
'zoom_in':{'prob':img_aug_list[2]*0.05, 'level':img_aug_list[3]}}
|
| 22 |
+
self.img_augs = Img_augs(img_augs_dict=img_augs_dict)
|
| 23 |
+
|
| 24 |
+
box_aug_list = autoaug_list[4:]
|
| 25 |
+
color_aug_types = list(color_aug_func.keys())
|
| 26 |
+
geometric_aug_types = list(geometric_aug_func.keys())
|
| 27 |
+
policies = []
|
| 28 |
+
for i in range(num_policies):
|
| 29 |
+
_start_pos = i * 6
|
| 30 |
+
sub_policy = [(color_aug_types[box_aug_list[_start_pos+0]%len(color_aug_types)], box_aug_list[_start_pos+1]* 0.1, box_aug_list[_start_pos+2], ), # box_color policy
|
| 31 |
+
(geometric_aug_types[box_aug_list[_start_pos+3]%len(geometric_aug_types)], box_aug_list[_start_pos+4]* 0.1, box_aug_list[_start_pos+5])] # box_geometric policy
|
| 32 |
+
policies.append(sub_policy)
|
| 33 |
+
|
| 34 |
+
_start_pos = num_policies * 6
|
| 35 |
+
scale_ratios = {'area': [box_aug_list[_start_pos+0], box_aug_list[_start_pos+1], box_aug_list[_start_pos+2]],
|
| 36 |
+
'prob': [box_aug_list[_start_pos+3], box_aug_list[_start_pos+4], box_aug_list[_start_pos+5]]}
|
| 37 |
+
|
| 38 |
+
box_augs_dict = {'policies': policies, 'scale_ratios': scale_ratios}
|
| 39 |
+
|
| 40 |
+
self.box_augs = Box_augs(box_augs_dict=box_augs_dict, max_iters=max_iters, scale_splits=scale_splits, box_prob=box_prob)
|
| 41 |
+
self.max_iters = max_iters
|
| 42 |
+
|
| 43 |
+
self.count = 0
|
| 44 |
+
self.start_iter = cfg.AUTOAUG.START_ITER
|
| 45 |
+
num_gpus = get_world_size()
|
| 46 |
+
self.batch_size = cfg.SOLVER.IMS_PER_BATCH // num_gpus
|
| 47 |
+
self.num_workers = cfg.DATALOADER.NUM_WORKERS
|
| 48 |
+
if self.num_workers==0:
|
| 49 |
+
self.num_workers += 1
|
| 50 |
+
|
| 51 |
+
def __call__(self, dataset_dict):
|
| 52 |
+
tensor = dataset_dict['image']
|
| 53 |
+
target = dataset_dict['instances']._fields
|
| 54 |
+
iteration = self.count // self.batch_size * self.num_workers
|
| 55 |
+
tensor_out, target_out = self.img_augs(tensor, target)
|
| 56 |
+
tensor_out, target_out = self.box_augs(tensor_out, target_out, iteration=self.start_iter + iteration)
|
| 57 |
+
self.count += 1
|
| 58 |
+
|
| 59 |
+
dataset_dict['image'] = tensor_out
|
| 60 |
+
dataset_dict['instances']._image_size = tensor_out.shape[1:]
|
| 61 |
+
dataset_dict['instances']._fields = target_out
|
| 62 |
+
|
| 63 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/augmentations/vis.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import copy
|
| 2 |
+
import torch
|
| 3 |
+
import torchvision
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def _vis(tensor, boxes, iteration=0, prex=''):
|
| 7 |
+
|
| 8 |
+
a = torch.clone(tensor)
|
| 9 |
+
width = 3
|
| 10 |
+
for box in boxes:
|
| 11 |
+
y1, x1, y2, x2 = int(box[0]), int(box[1]), int(box[2]), int(box[3])
|
| 12 |
+
patch = copy.deepcopy(a[:,x1+width:x2-width, y1+width:y2-width])
|
| 13 |
+
a[:,x1:x2,y1:y2] = torch.Tensor([1, 0, 0]).reshape(1, 3, 1, 1)
|
| 14 |
+
a[:,x1+width:x2-width, y1+width:y2-width] = patch
|
| 15 |
+
|
| 16 |
+
inv_idx = torch.arange(a.shape[0]-1,-1,-1).long().tolist()
|
| 17 |
+
torchvision.utils.save_image(a[inv_idx].float(), '%s_tensor_%d.jpg'%(prex, iteration), normalize=True)
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/coco_instance_new_baseline_dataset_mapper.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# Modified by Bowen Cheng from https://github.com/facebookresearch/detr/blob/master/d2/detr/dataset_mapper.py
|
| 3 |
+
import copy
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from detectron2.config import configurable
|
| 10 |
+
from detectron2.data import detection_utils as utils
|
| 11 |
+
from detectron2.data import transforms as T
|
| 12 |
+
from detectron2.data.transforms import TransformGen
|
| 13 |
+
from detectron2.structures import BitMasks, Instances
|
| 14 |
+
|
| 15 |
+
from pycocotools import mask as coco_mask
|
| 16 |
+
|
| 17 |
+
__all__ = ["COCOInstanceNewBaselineDatasetMapper"]
|
| 18 |
+
|
| 19 |
+
def convert_coco_poly_to_mask(segmentations, height, width):
|
| 20 |
+
masks = []
|
| 21 |
+
for polygons in segmentations:
|
| 22 |
+
rles = coco_mask.frPyObjects(polygons, height, width)
|
| 23 |
+
mask = coco_mask.decode(rles)
|
| 24 |
+
if len(mask.shape) < 3:
|
| 25 |
+
mask = mask[..., None]
|
| 26 |
+
mask = torch.as_tensor(mask, dtype=torch.uint8)
|
| 27 |
+
mask = mask.any(dim=2)
|
| 28 |
+
masks.append(mask)
|
| 29 |
+
if masks:
|
| 30 |
+
masks = torch.stack(masks, dim=0)
|
| 31 |
+
else:
|
| 32 |
+
masks = torch.zeros((0, height, width), dtype=torch.uint8)
|
| 33 |
+
return masks
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def build_transform_gen(cfg, is_train):
|
| 37 |
+
"""
|
| 38 |
+
Create a list of default :class:`Augmentation` from config.
|
| 39 |
+
Now it includes resizing and flipping.
|
| 40 |
+
Returns:
|
| 41 |
+
list[Augmentation]
|
| 42 |
+
"""
|
| 43 |
+
assert is_train, "Only support training augmentation"
|
| 44 |
+
image_size = cfg.INPUT.IMAGE_SIZE
|
| 45 |
+
min_scale = cfg.INPUT.MIN_SCALE
|
| 46 |
+
max_scale = cfg.INPUT.MAX_SCALE
|
| 47 |
+
|
| 48 |
+
augmentation = []
|
| 49 |
+
|
| 50 |
+
if cfg.INPUT.RANDOM_FLIP != "none":
|
| 51 |
+
augmentation.append(
|
| 52 |
+
T.RandomFlip(
|
| 53 |
+
horizontal=cfg.INPUT.RANDOM_FLIP == "horizontal",
|
| 54 |
+
vertical=cfg.INPUT.RANDOM_FLIP == "vertical",
|
| 55 |
+
)
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
augmentation.extend([
|
| 59 |
+
T.ResizeScale(
|
| 60 |
+
min_scale=min_scale, max_scale=max_scale, target_height=image_size, target_width=image_size
|
| 61 |
+
),
|
| 62 |
+
T.FixedSizeCrop(crop_size=(image_size, image_size)),
|
| 63 |
+
])
|
| 64 |
+
|
| 65 |
+
return augmentation
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# This is specifically designed for the COCO dataset.
|
| 69 |
+
class COCOInstanceNewBaselineDatasetMapper:
|
| 70 |
+
"""
|
| 71 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 72 |
+
and map it into a format used by MaskFormer.
|
| 73 |
+
|
| 74 |
+
This dataset mapper applies the same transformation as DETR for COCO panoptic segmentation.
|
| 75 |
+
|
| 76 |
+
The callable currently does the following:
|
| 77 |
+
|
| 78 |
+
1. Read the image from "file_name"
|
| 79 |
+
2. Applies geometric transforms to the image and annotation
|
| 80 |
+
3. Find and applies suitable cropping to the image and annotation
|
| 81 |
+
4. Prepare image and annotation to Tensors
|
| 82 |
+
"""
|
| 83 |
+
|
| 84 |
+
@configurable
|
| 85 |
+
def __init__(
|
| 86 |
+
self,
|
| 87 |
+
is_train=True,
|
| 88 |
+
*,
|
| 89 |
+
tfm_gens,
|
| 90 |
+
image_format,
|
| 91 |
+
):
|
| 92 |
+
"""
|
| 93 |
+
NOTE: this interface is experimental.
|
| 94 |
+
Args:
|
| 95 |
+
is_train: for training or inference
|
| 96 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 97 |
+
tfm_gens: data augmentation
|
| 98 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 99 |
+
"""
|
| 100 |
+
self.tfm_gens = tfm_gens
|
| 101 |
+
logging.getLogger(__name__).info(
|
| 102 |
+
"[COCOInstanceNewBaselineDatasetMapper] Full TransformGens used in training: {}".format(str(self.tfm_gens))
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
self.img_format = image_format
|
| 106 |
+
self.is_train = is_train
|
| 107 |
+
|
| 108 |
+
@classmethod
|
| 109 |
+
def from_config(cls, cfg, is_train=True):
|
| 110 |
+
# Build augmentation
|
| 111 |
+
tfm_gens = build_transform_gen(cfg, is_train)
|
| 112 |
+
|
| 113 |
+
ret = {
|
| 114 |
+
"is_train": is_train,
|
| 115 |
+
"tfm_gens": tfm_gens,
|
| 116 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 117 |
+
}
|
| 118 |
+
return ret
|
| 119 |
+
|
| 120 |
+
def __call__(self, dataset_dict):
|
| 121 |
+
"""
|
| 122 |
+
Args:
|
| 123 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 124 |
+
|
| 125 |
+
Returns:
|
| 126 |
+
dict: a format that builtin models in detectron2 accept
|
| 127 |
+
"""
|
| 128 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 129 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
|
| 130 |
+
utils.check_image_size(dataset_dict, image)
|
| 131 |
+
|
| 132 |
+
# TODO: get padding mask
|
| 133 |
+
# by feeding a "segmentation mask" to the same transforms
|
| 134 |
+
padding_mask = np.ones(image.shape[:2])
|
| 135 |
+
|
| 136 |
+
image, transforms = T.apply_transform_gens(self.tfm_gens, image)
|
| 137 |
+
# the crop transformation has default padding value 0 for segmentation
|
| 138 |
+
padding_mask = transforms.apply_segmentation(padding_mask)
|
| 139 |
+
padding_mask = ~ padding_mask.astype(bool)
|
| 140 |
+
|
| 141 |
+
image_shape = image.shape[:2] # h, w
|
| 142 |
+
|
| 143 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 144 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 145 |
+
# Therefore it's important to use torch.Tensor.
|
| 146 |
+
dataset_dict["image"] = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 147 |
+
dataset_dict["padding_mask"] = torch.as_tensor(np.ascontiguousarray(padding_mask))
|
| 148 |
+
|
| 149 |
+
if not self.is_train:
|
| 150 |
+
# USER: Modify this if you want to keep them for some reason.
|
| 151 |
+
dataset_dict.pop("annotations", None)
|
| 152 |
+
return dataset_dict
|
| 153 |
+
|
| 154 |
+
if "annotations" in dataset_dict:
|
| 155 |
+
# USER: Modify this if you want to keep them for some reason.
|
| 156 |
+
for anno in dataset_dict["annotations"]:
|
| 157 |
+
# Let's always keep mask
|
| 158 |
+
# if not self.mask_on:
|
| 159 |
+
# anno.pop("segmentation", None)
|
| 160 |
+
anno.pop("keypoints", None)
|
| 161 |
+
|
| 162 |
+
# USER: Implement additional transformations if you have other types of data
|
| 163 |
+
annos = [
|
| 164 |
+
utils.transform_instance_annotations(obj, transforms, image_shape)
|
| 165 |
+
for obj in dataset_dict.pop("annotations")
|
| 166 |
+
if obj.get("iscrowd", 0) == 0
|
| 167 |
+
]
|
| 168 |
+
# NOTE: does not support BitMask due to augmentation
|
| 169 |
+
# Current BitMask cannot handle empty objects
|
| 170 |
+
instances = utils.annotations_to_instances(annos, image_shape, mask_format="bitmask")
|
| 171 |
+
# After transforms such as cropping are applied, the bounding box may no longer
|
| 172 |
+
# tightly bound the object. As an example, imagine a triangle object
|
| 173 |
+
# [(0,0), (2,0), (0,2)] cropped by a box [(1,0),(2,2)] (XYXY format). The tight
|
| 174 |
+
# bounding box of the cropped triangle should be [(1,0),(2,1)], which is not equal to
|
| 175 |
+
# the intersection of original bounding box and the cropping box.
|
| 176 |
+
instances.gt_boxes = instances.gt_masks.get_bounding_boxes()
|
| 177 |
+
# Need to filter empty instances first (due to augmentation)
|
| 178 |
+
instances = utils.filter_empty_instances(instances)
|
| 179 |
+
# Generate masks from polygon
|
| 180 |
+
h, w = instances.image_size
|
| 181 |
+
# image_size_xyxy = torch.as_tensor([w, h, w, h], dtype=torch.float)
|
| 182 |
+
if hasattr(instances, 'gt_masks'):
|
| 183 |
+
gt_masks = instances.gt_masks.tensor
|
| 184 |
+
# gt_masks = convert_coco_poly_to_mask(gt_masks.polygons, h, w)
|
| 185 |
+
instances.gt_masks = gt_masks
|
| 186 |
+
dataset_dict["instances"] = instances
|
| 187 |
+
|
| 188 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/dataset_mapper.py
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
| 2 |
+
import copy
|
| 3 |
+
import logging
|
| 4 |
+
import numpy as np
|
| 5 |
+
import torch.nn.functional as F
|
| 6 |
+
from typing import List, Optional, Union
|
| 7 |
+
import torch
|
| 8 |
+
import os
|
| 9 |
+
import pdb
|
| 10 |
+
import logging
|
| 11 |
+
import cv2
|
| 12 |
+
|
| 13 |
+
from detectron2.config import configurable
|
| 14 |
+
from detectron2.data import detection_utils as utils
|
| 15 |
+
from detectron2.data import transforms as T
|
| 16 |
+
|
| 17 |
+
from .Auginput import ItemAugInput
|
| 18 |
+
from detectron2.augmentations.scale_aware_aug import SA_Aug
|
| 19 |
+
|
| 20 |
+
from panopticapi.utils import rgb2id, id2rgb
|
| 21 |
+
|
| 22 |
+
"""
|
| 23 |
+
This file contains the default mapping that's applied to "dataset dicts".
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
__all__ = ["DatasetMapper"]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def filter_empty_instances(instances, by_box=True, by_mask=True, box_threshold=1e-5):
|
| 30 |
+
"""
|
| 31 |
+
Filter out empty instances in an `Instances` object.
|
| 32 |
+
|
| 33 |
+
Args:
|
| 34 |
+
instances (Instances):
|
| 35 |
+
by_box (bool): whether to filter out instances with empty boxes
|
| 36 |
+
by_mask (bool): whether to filter out instances with empty masks
|
| 37 |
+
box_threshold (float): minimum width and height to be considered non-empty
|
| 38 |
+
|
| 39 |
+
Returns:
|
| 40 |
+
Instances: the filtered instances.
|
| 41 |
+
"""
|
| 42 |
+
assert by_box or by_mask
|
| 43 |
+
r = []
|
| 44 |
+
if by_box:
|
| 45 |
+
r.append(instances.gt_boxes.nonempty(threshold=box_threshold))
|
| 46 |
+
if instances.has("gt_masks") and by_mask:
|
| 47 |
+
r.append(instances.gt_masks.nonempty())
|
| 48 |
+
|
| 49 |
+
# TODO: can also filter visible keypoints
|
| 50 |
+
|
| 51 |
+
if not r:
|
| 52 |
+
return instances
|
| 53 |
+
m = r[0]
|
| 54 |
+
for x in r[1:]:
|
| 55 |
+
m = m & x
|
| 56 |
+
return instances[m], m
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class DatasetMapper:
|
| 60 |
+
"""
|
| 61 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 62 |
+
and map it into a format used by the model.
|
| 63 |
+
|
| 64 |
+
This is the default callable to be used to map your dataset dict into training data.
|
| 65 |
+
You may need to follow it to implement your own one for customized logic,
|
| 66 |
+
such as a different way to read or transform images.
|
| 67 |
+
See :doc:`/tutorials/data_loading` for details.
|
| 68 |
+
|
| 69 |
+
The callable currently does the following:
|
| 70 |
+
|
| 71 |
+
1. Read the image from "file_name"
|
| 72 |
+
2. Applies cropping/geometric transforms to the image and annotations
|
| 73 |
+
3. Prepare data and annotations to Tensor and :class:`Instances`
|
| 74 |
+
"""
|
| 75 |
+
|
| 76 |
+
@configurable
|
| 77 |
+
def __init__(
|
| 78 |
+
self,
|
| 79 |
+
is_train: bool,
|
| 80 |
+
*,
|
| 81 |
+
augmentations: List[Union[T.Augmentation, T.Transform]],
|
| 82 |
+
image_format: str,
|
| 83 |
+
aug=None,
|
| 84 |
+
):
|
| 85 |
+
"""
|
| 86 |
+
NOTE: this interface is experimental.
|
| 87 |
+
|
| 88 |
+
Args:
|
| 89 |
+
is_train: whether it's used in training or inference
|
| 90 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 91 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 92 |
+
use_instance_mask: whether to process instance segmentation annotations, if available
|
| 93 |
+
use_keypoint: whether to process keypoint annotations if available
|
| 94 |
+
instance_mask_format: one of "polygon" or "bitmask". Process instance segmentation
|
| 95 |
+
masks into this format.
|
| 96 |
+
keypoint_hflip_indices: see :func:`detection_utils.create_keypoint_hflip_indices`
|
| 97 |
+
precomputed_proposal_topk: if given, will load pre-computed
|
| 98 |
+
proposals from dataset_dict and keep the top k proposals for each image.
|
| 99 |
+
recompute_boxes: whether to overwrite bounding box annotations
|
| 100 |
+
by computing tight bounding boxes from instance mask annotations.
|
| 101 |
+
"""
|
| 102 |
+
# fmt: off
|
| 103 |
+
self.is_train = is_train
|
| 104 |
+
self.augmentations = augmentations
|
| 105 |
+
self.image_format = image_format
|
| 106 |
+
self.aug = aug
|
| 107 |
+
# fmt: on
|
| 108 |
+
logger = logging.getLogger(__name__)
|
| 109 |
+
logger.info("Augmentations used in training: " + str(augmentations))
|
| 110 |
+
logger.info("use autoaug:{}".format(self.aug))
|
| 111 |
+
|
| 112 |
+
@classmethod
|
| 113 |
+
def from_config(cls, cfg, is_train: bool = True):
|
| 114 |
+
augs = utils.build_augmentation(cfg, is_train)
|
| 115 |
+
if cfg.INPUT.CROP.ENABLED and is_train:
|
| 116 |
+
augs.insert(0, T.RandomCrop(cfg.INPUT.CROP.TYPE, cfg.INPUT.CROP.SIZE))
|
| 117 |
+
recompute_boxes = cfg.MODEL.MASK_ON
|
| 118 |
+
else:
|
| 119 |
+
recompute_boxes = False
|
| 120 |
+
|
| 121 |
+
ret = {
|
| 122 |
+
"is_train": is_train,
|
| 123 |
+
"augmentations": augs,
|
| 124 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 125 |
+
}
|
| 126 |
+
ret["aug"] = SA_Aug(cfg) if cfg.AUTOAUG.USE and is_train else None
|
| 127 |
+
return ret
|
| 128 |
+
|
| 129 |
+
def __call__(self, dataset_dict):
|
| 130 |
+
"""
|
| 131 |
+
Args:
|
| 132 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 133 |
+
|
| 134 |
+
Returns:
|
| 135 |
+
dict: a format that builtin models in detectron2 accept
|
| 136 |
+
"""
|
| 137 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 138 |
+
# USER: Write your own image loading if it's not from a file
|
| 139 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.image_format)
|
| 140 |
+
utils.check_image_size(dataset_dict, image)
|
| 141 |
+
name = dataset_dict["file_name"].split("/")[-1].split(".")[0]
|
| 142 |
+
|
| 143 |
+
if self.is_train:
|
| 144 |
+
if "coco" in dataset_dict["file_name"]:
|
| 145 |
+
panoptic_annotation_path = os.path.join("datasets/coco/entity_train2017", name+".npz")
|
| 146 |
+
if not os.path.exists(panoptic_annotation_path):
|
| 147 |
+
panoptic_annotation_path = os.path.join("datasets/coco/entity_unlabeled", name+".npz")
|
| 148 |
+
elif "ade20k" in dataset_dict["file_name"]:
|
| 149 |
+
panoptic_annotation_path = os.path.join("datasets/ade20k/panoptic_semantic_training", name+".npz")
|
| 150 |
+
elif "city" in dataset_dict["file_name"]:
|
| 151 |
+
panoptic_annotation_path = os.path.join("datasets/city/cityscapes_panoptic_new_train", name+".npz")
|
| 152 |
+
elif "places" in dataset_dict["file_name"]:
|
| 153 |
+
name = dataset_dict["file_name"].split("data_large/")[-1]
|
| 154 |
+
name = name.replace("/","_").replace(".jpg",".npz")
|
| 155 |
+
panoptic_annotation_path = os.path.join("datasets/places/gt_npz/",name)
|
| 156 |
+
elif "openimage" in dataset_dict["file_name"]:
|
| 157 |
+
name = dataset_dict["file_name"].split("data/")[-1]
|
| 158 |
+
name = name.split(".")[0] + ".npz"
|
| 159 |
+
if os.path.exists(os.path.join("datasets/openimage/gt_npz_1/", name)):
|
| 160 |
+
panoptic_annotation_path = os.path.join("datasets/openimage/gt_npz_1/", name)
|
| 161 |
+
else:
|
| 162 |
+
panoptic_annotation_path = os.path.join("datasets/openimage/gt_npz_2/", name)
|
| 163 |
+
else:
|
| 164 |
+
if "coco" in dataset_dict["file_name"]:
|
| 165 |
+
panoptic_annotation_path = os.path.join("datasets/coco/entity_val2017", name+".npz")
|
| 166 |
+
elif "ade20k" in dataset_dict["file_name"]:
|
| 167 |
+
panoptic_annotation_path = os.path.join("datasets/ade20k/panoptic_semantic_validation", name+".npz")
|
| 168 |
+
elif "city" in dataset_dict["file_name"]:
|
| 169 |
+
panoptic_annotation_path = os.path.join("datasets/city/cityscapes_panoptic_new_val", name+".npz")
|
| 170 |
+
|
| 171 |
+
panoptic_semantic_map = np.load(panoptic_annotation_path)
|
| 172 |
+
bounding_boxes = panoptic_semantic_map["bounding_box"].astype(np.float)
|
| 173 |
+
|
| 174 |
+
info_map = panoptic_semantic_map["map"]
|
| 175 |
+
instance_map = info_map[0]
|
| 176 |
+
semantic_map = info_map[1]
|
| 177 |
+
height, width = instance_map.shape
|
| 178 |
+
# instance_map = torch.tensor(instance_map).long()
|
| 179 |
+
num_instances = len(dataset_dict["annotations"])
|
| 180 |
+
|
| 181 |
+
seg_info = {"instance_map": instance_map,
|
| 182 |
+
"semantic_map": semantic_map}
|
| 183 |
+
|
| 184 |
+
aug_input = ItemAugInput(image, seg_info=seg_info)
|
| 185 |
+
transforms = aug_input.apply_augmentations(self.augmentations)
|
| 186 |
+
|
| 187 |
+
image = aug_input.image
|
| 188 |
+
instance_map = aug_input.seg_info["instance_map"].copy()
|
| 189 |
+
semantic_map = aug_input.seg_info["semantic_map"]
|
| 190 |
+
|
| 191 |
+
image_shape = image.shape[:2] # h, w
|
| 192 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 193 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 194 |
+
# Therefore it's important to use torch.Tensor.
|
| 195 |
+
dataset_dict["image"] = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 196 |
+
new_anns = dataset_dict.pop("annotations")
|
| 197 |
+
new_anns = [obj for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 198 |
+
# assert len(new_anns) == bounding_boxes.shape[0], print("{}:{}".format(len(new_anns), bounding_boxes.shape[0]))
|
| 199 |
+
isthing_list = []
|
| 200 |
+
instance_id_list = []
|
| 201 |
+
for i in range(len(new_anns)):
|
| 202 |
+
try:
|
| 203 |
+
x1, y1, x2, y2, category, thing, instance_id = bounding_boxes[i][:7]
|
| 204 |
+
except:
|
| 205 |
+
print(bounding_boxes)
|
| 206 |
+
print(new_anns)
|
| 207 |
+
x1 = int(x1)
|
| 208 |
+
y1 = int(y1)
|
| 209 |
+
x2 = int(x2)
|
| 210 |
+
y2 = int(y2)
|
| 211 |
+
# assert (x1<x2 and y1<y2 and x1>=0 and y1>=0 and y2<height and x2<width), "failed! The file name is {}".format(dataset_dict["file_name"])
|
| 212 |
+
w = x2 - x1
|
| 213 |
+
h = y2 - y1
|
| 214 |
+
new_anns[i]["bbox"] = [x1, y1, w, h]
|
| 215 |
+
new_anns[i]["category_id"] = int(category)
|
| 216 |
+
isthing_list.append(int(thing))
|
| 217 |
+
instance_id_list.append(int(instance_id))
|
| 218 |
+
|
| 219 |
+
# new_new_anns = new_anns[valid]
|
| 220 |
+
|
| 221 |
+
isthing_list = torch.tensor(isthing_list, dtype=torch.int64)
|
| 222 |
+
instance_id_list = torch.tensor(instance_id_list, dtype=torch.int64)
|
| 223 |
+
|
| 224 |
+
# annos = [utils.transform_instance_annotations(obj, transforms, image_shape) for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 225 |
+
annos = [utils.transform_instance_annotations(obj, transforms, image_shape) for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 226 |
+
instances = utils.annotations_to_instances(annos, image_shape, mask_format="bitmask")
|
| 227 |
+
instances.instanceid = instance_id_list
|
| 228 |
+
|
| 229 |
+
instances, select = filter_empty_instances(instances)
|
| 230 |
+
dataset_dict["instances"] = instances
|
| 231 |
+
dataset_dict["instance_map"] = torch.as_tensor(np.ascontiguousarray(instance_map))
|
| 232 |
+
if self.is_train and not self.aug is None:
|
| 233 |
+
dataset_dict = self.aug(dataset_dict)
|
| 234 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/dataset_mapper_only_det.py
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
| 2 |
+
import copy
|
| 3 |
+
import logging
|
| 4 |
+
import numpy as np
|
| 5 |
+
import torch.nn.functional as F
|
| 6 |
+
from typing import List, Optional, Union
|
| 7 |
+
import torch
|
| 8 |
+
import os
|
| 9 |
+
import pdb
|
| 10 |
+
import logging
|
| 11 |
+
import cv2
|
| 12 |
+
|
| 13 |
+
from detectron2.config import configurable
|
| 14 |
+
from detectron2.data import detection_utils as utils
|
| 15 |
+
from detectron2.data import transforms as T
|
| 16 |
+
from detectron2.augmentations.scale_aware_aug import SA_Aug
|
| 17 |
+
|
| 18 |
+
from .Auginput import ItemAugInput
|
| 19 |
+
|
| 20 |
+
from panopticapi.utils import rgb2id, id2rgb
|
| 21 |
+
|
| 22 |
+
"""
|
| 23 |
+
This file contains the default mapping that's applied to "dataset dicts".
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
__all__ = ["DatasetMapper"]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def filter_empty_instances(instances, by_box=True, by_mask=True, box_threshold=1e-5):
|
| 30 |
+
"""
|
| 31 |
+
Filter out empty instances in an `Instances` object.
|
| 32 |
+
|
| 33 |
+
Args:
|
| 34 |
+
instances (Instances):
|
| 35 |
+
by_box (bool): whether to filter out instances with empty boxes
|
| 36 |
+
by_mask (bool): whether to filter out instances with empty masks
|
| 37 |
+
box_threshold (float): minimum width and height to be considered non-empty
|
| 38 |
+
|
| 39 |
+
Returns:
|
| 40 |
+
Instances: the filtered instances.
|
| 41 |
+
"""
|
| 42 |
+
assert by_box or by_mask
|
| 43 |
+
r = []
|
| 44 |
+
if by_box:
|
| 45 |
+
r.append(instances.gt_boxes.nonempty(threshold=box_threshold))
|
| 46 |
+
if instances.has("gt_masks") and by_mask:
|
| 47 |
+
r.append(instances.gt_masks.nonempty())
|
| 48 |
+
|
| 49 |
+
# TODO: can also filter visible keypoints
|
| 50 |
+
|
| 51 |
+
if not r:
|
| 52 |
+
return instances
|
| 53 |
+
m = r[0]
|
| 54 |
+
for x in r[1:]:
|
| 55 |
+
m = m & x
|
| 56 |
+
return instances[m], m
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class DatasetMapperOnlyDet:
|
| 60 |
+
"""
|
| 61 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 62 |
+
and map it into a format used by the model.
|
| 63 |
+
|
| 64 |
+
This is the default callable to be used to map your dataset dict into training data.
|
| 65 |
+
You may need to follow it to implement your own one for customized logic,
|
| 66 |
+
such as a different way to read or transform images.
|
| 67 |
+
See :doc:`/tutorials/data_loading` for details.
|
| 68 |
+
|
| 69 |
+
The callable currently does the following:
|
| 70 |
+
|
| 71 |
+
1. Read the image from "file_name"
|
| 72 |
+
2. Applies cropping/geometric transforms to the image and annotations
|
| 73 |
+
3. Prepare data and annotations to Tensor and :class:`Instances`
|
| 74 |
+
"""
|
| 75 |
+
|
| 76 |
+
@configurable
|
| 77 |
+
def __init__(
|
| 78 |
+
self,
|
| 79 |
+
is_train: bool,
|
| 80 |
+
*,
|
| 81 |
+
augmentations: List[Union[T.Augmentation, T.Transform]],
|
| 82 |
+
image_format: str
|
| 83 |
+
):
|
| 84 |
+
"""
|
| 85 |
+
NOTE: this interface is experimental.
|
| 86 |
+
|
| 87 |
+
Args:
|
| 88 |
+
is_train: whether it's used in training or inference
|
| 89 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 90 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 91 |
+
use_instance_mask: whether to process instance segmentation annotations, if available
|
| 92 |
+
use_keypoint: whether to process keypoint annotations if available
|
| 93 |
+
instance_mask_format: one of "polygon" or "bitmask". Process instance segmentation
|
| 94 |
+
masks into this format.
|
| 95 |
+
keypoint_hflip_indices: see :func:`detection_utils.create_keypoint_hflip_indices`
|
| 96 |
+
precomputed_proposal_topk: if given, will load pre-computed
|
| 97 |
+
proposals from dataset_dict and keep the top k proposals for each image.
|
| 98 |
+
recompute_boxes: whether to overwrite bounding box annotations
|
| 99 |
+
by computing tight bounding boxes from instance mask annotations.
|
| 100 |
+
"""
|
| 101 |
+
# fmt: off
|
| 102 |
+
self.is_train = is_train
|
| 103 |
+
self.augmentations = augmentations
|
| 104 |
+
self.image_format = image_format
|
| 105 |
+
# fmt: on
|
| 106 |
+
logger = logging.getLogger(__name__)
|
| 107 |
+
logger.info("Augmentations used in training: " + str(augmentations))
|
| 108 |
+
|
| 109 |
+
@classmethod
|
| 110 |
+
def from_config(cls, cfg, is_train: bool = True):
|
| 111 |
+
augs = utils.build_augmentation(cfg, is_train)
|
| 112 |
+
if cfg.INPUT.CROP.ENABLED and is_train:
|
| 113 |
+
augs.insert(0, T.RandomCrop(cfg.INPUT.CROP.TYPE, cfg.INPUT.CROP.SIZE))
|
| 114 |
+
recompute_boxes = cfg.MODEL.MASK_ON
|
| 115 |
+
else:
|
| 116 |
+
recompute_boxes = False
|
| 117 |
+
|
| 118 |
+
ret = {
|
| 119 |
+
"is_train": is_train,
|
| 120 |
+
"augmentations": augs,
|
| 121 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 122 |
+
}
|
| 123 |
+
return ret
|
| 124 |
+
|
| 125 |
+
def __call__(self, dataset_dict):
|
| 126 |
+
"""
|
| 127 |
+
Args:
|
| 128 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 129 |
+
|
| 130 |
+
Returns:
|
| 131 |
+
dict: a format that builtin models in detectron2 accept
|
| 132 |
+
"""
|
| 133 |
+
# logger = logging.getLogger(__name__)
|
| 134 |
+
# logger.info(dataset_dict["file_name"])
|
| 135 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 136 |
+
# USER: Write your own image loading if it's not from a file
|
| 137 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.image_format)
|
| 138 |
+
utils.check_image_size(dataset_dict, image)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
name = dataset_dict["file_name"].split("/")[-1].split(".")[0]
|
| 142 |
+
# print(name)
|
| 143 |
+
# print(dataset_dict["file_name"])
|
| 144 |
+
# import pdb
|
| 145 |
+
# pdb.set_trace()
|
| 146 |
+
if self.is_train:
|
| 147 |
+
if "coco" in dataset_dict["file_name"]:
|
| 148 |
+
panoptic_annotation_path = os.path.join("datasets/coco/entity_train2017", name+".npz")
|
| 149 |
+
if not os.path.exists(panoptic_annotation_path):
|
| 150 |
+
panoptic_annotation_path = os.path.join("datasets/coco/entity_unlabeled", name+".npz")
|
| 151 |
+
elif "ade20k" in dataset_dict["file_name"]:
|
| 152 |
+
panoptic_annotation_path = os.path.join("datasets/ade20k/panoptic_semantic_training", name+".npz")
|
| 153 |
+
elif "city" in dataset_dict["file_name"]:
|
| 154 |
+
panoptic_annotation_path = os.path.join("datasets/city/cityscapes_panoptic_new_train", name+".npz")
|
| 155 |
+
elif "places" in dataset_dict["file_name"]:
|
| 156 |
+
# print(dataset_dict["file_name"])
|
| 157 |
+
name = dataset_dict["file_name"].split("data_large/")[-1]
|
| 158 |
+
name = name.replace("/","_").replace(".jpg",".npz")
|
| 159 |
+
panoptic_annotation_path = os.path.join("datasets/places/gt_npz/",name)
|
| 160 |
+
elif "openimage" in dataset_dict["file_name"]:
|
| 161 |
+
# print(dataset_dict["file_name"])
|
| 162 |
+
name = dataset_dict["file_name"].split("data/")[-1]
|
| 163 |
+
name = name.split(".")[0] + ".npz"
|
| 164 |
+
if os.path.exists(os.path.join("datasets/openimage/gt_npz_1/", name)):
|
| 165 |
+
panoptic_annotation_path = os.path.join("datasets/openimage/gt_npz_1/", name)
|
| 166 |
+
else:
|
| 167 |
+
panoptic_annotation_path = os.path.join("datasets/openimage/gt_npz_2/", name)
|
| 168 |
+
else:
|
| 169 |
+
if "coco" in dataset_dict["file_name"]:
|
| 170 |
+
panoptic_annotation_path = os.path.join("datasets/coco/entity_val2017", name+".npz")
|
| 171 |
+
elif "ade20k" in dataset_dict["file_name"]:
|
| 172 |
+
panoptic_annotation_path = os.path.join("datasets/ade20k/panoptic_semantic_validation", name+".npz")
|
| 173 |
+
elif "city" in dataset_dict["file_name"]:
|
| 174 |
+
panoptic_annotation_path = os.path.join("datasets/city/cityscapes_panoptic_new_val", name+".npz")
|
| 175 |
+
|
| 176 |
+
panoptic_semantic_map = np.load(panoptic_annotation_path)
|
| 177 |
+
# x1,y1,x2,y2,category,thing_or_stuff,instance_id
|
| 178 |
+
bounding_boxes = panoptic_semantic_map["bounding_box"].astype(np.float)
|
| 179 |
+
|
| 180 |
+
info_map = panoptic_semantic_map["map"]
|
| 181 |
+
instance_map = info_map[0]
|
| 182 |
+
semantic_map = info_map[1]
|
| 183 |
+
height, width = instance_map.shape
|
| 184 |
+
# instance_map = torch.tensor(instance_map).long()
|
| 185 |
+
num_instances = len(dataset_dict["annotations"])
|
| 186 |
+
|
| 187 |
+
seg_info = {"instance_map": instance_map,
|
| 188 |
+
"semantic_map": semantic_map}
|
| 189 |
+
|
| 190 |
+
aug_input = ItemAugInput(image, seg_info=seg_info)
|
| 191 |
+
transforms = aug_input.apply_augmentations(self.augmentations)
|
| 192 |
+
|
| 193 |
+
image = aug_input.image
|
| 194 |
+
instance_map = aug_input.seg_info["instance_map"].copy()
|
| 195 |
+
semantic_map = aug_input.seg_info["semantic_map"]
|
| 196 |
+
|
| 197 |
+
image_shape = image.shape[:2] # h, w
|
| 198 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 199 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 200 |
+
# Therefore it's important to use torch.Tensor.
|
| 201 |
+
dataset_dict["image"] = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 202 |
+
new_anns = dataset_dict.pop("annotations")
|
| 203 |
+
new_anns = [obj for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 204 |
+
# assert len(new_anns) == bounding_boxes.shape[0], print("{}:{}".format(len(new_anns), bounding_boxes.shape[0]))
|
| 205 |
+
isthing_list = []
|
| 206 |
+
instance_id_list = []
|
| 207 |
+
for i in range(len(new_anns)):
|
| 208 |
+
x1, y1, x2, y2, category, thing, instance_id = bounding_boxes[i][:7]
|
| 209 |
+
x1 = int(x1)
|
| 210 |
+
y1 = int(y1)
|
| 211 |
+
x2 = int(x2)
|
| 212 |
+
y2 = int(y2)
|
| 213 |
+
# assert (x1<x2 and y1<y2 and x1>=0 and y1>=0 and y2<height and x2<width), "failed! The file name is {}".format(dataset_dict["file_name"])
|
| 214 |
+
w = x2 - x1
|
| 215 |
+
h = y2 - y1
|
| 216 |
+
new_anns[i]["bbox"] = [x1, y1, w, h]
|
| 217 |
+
new_anns[i]["category_id"] = int(category)
|
| 218 |
+
isthing_list.append(int(thing))
|
| 219 |
+
instance_id_list.append(int(instance_id))
|
| 220 |
+
|
| 221 |
+
# new_new_anns = new_anns[valid]
|
| 222 |
+
|
| 223 |
+
isthing_list = torch.tensor(isthing_list, dtype=torch.int64)
|
| 224 |
+
instance_id_list = torch.tensor(instance_id_list, dtype=torch.int64)
|
| 225 |
+
|
| 226 |
+
# annos = [utils.transform_instance_annotations(obj, transforms, image_shape) for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 227 |
+
annos = [utils.transform_instance_annotations(obj, transforms, image_shape) for obj in new_anns if obj.get("iscrowd", 0) == 0]
|
| 228 |
+
instances = utils.annotations_to_instances(annos, image_shape, mask_format="bitmask")
|
| 229 |
+
instances.instanceid = instance_id_list
|
| 230 |
+
|
| 231 |
+
instances, select = filter_empty_instances(instances)
|
| 232 |
+
dataset_dict["instances"] = Instances
|
| 233 |
+
|
| 234 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entity/EntitySegRLE/entityseg/data/datasets.py
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
| 2 |
+
import os
|
| 3 |
+
import pdb
|
| 4 |
+
|
| 5 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 6 |
+
from detectron2.data.datasets.builtin_meta import COCO_CATEGORIES, _get_builtin_metadata
|
| 7 |
+
from detectron2.data.datasets import load_coco_json, register_coco_instances
|
| 8 |
+
import torchvision
|
| 9 |
+
|
| 10 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 11 |
+
|
| 12 |
+
SPLITS = {}
|
| 13 |
+
SPLITS["coco_2017_train_entity"] = ("coco/train2017", "coco/annotations/entity_train2017.json")
|
| 14 |
+
SPLITS["coco_2017_val_entity"] = ("coco/val2017", "coco/annotations/entity_val2017.json")
|
| 15 |
+
SPLITS["coco_2017_unlabeled_enity"] = ("coco/unlabel2017", "coco/annotations/entity_unlabel2017.json")
|
| 16 |
+
SPLITS["coco_2017_val_entity_rle"] = ("coco/val2017", "coco/annotations/entity_val2017.json")
|
| 17 |
+
SPLITS["coco_2017_train_entity_rle"] = ("coco/train2017", "coco/annotations/entity_train2017_RLE.json")
|
| 18 |
+
|
| 19 |
+
for i in [0,1,3]:
|
| 20 |
+
SPLITS["places_{}_10_train_entity".format(i)] = ("places/data_large", "places/annotations/annotations_unlabeled_{}_10.json".format(i))
|
| 21 |
+
|
| 22 |
+
for i in [2,4,5,6,7,8,9]:
|
| 23 |
+
SPLITS["places_{}_10_train_entity".format(i)] = ("places/data_large", "places/annotations/annotations_unlabeled_{}_10_new.json".format(i))
|
| 24 |
+
|
| 25 |
+
for i in [0,1,2,3,4,5,6,7,8,9]:
|
| 26 |
+
SPLITS["openimage_{}_10_train_entity".format(i)] = ("openimage/data", "openimage/annotations/annotations_unlabeled_{}_10.json".format(i))
|
| 27 |
+
|
| 28 |
+
def _get_coco_trans_meta():
|
| 29 |
+
oc2nc_map = {category['id']: [cid, category["isthing"], category["name"], category["color"]] for cid, category in enumerate(COCO_CATEGORIES)}
|
| 30 |
+
NEW_COCO_CATEGORIES = []
|
| 31 |
+
for key, value in oc2nc_map.items():
|
| 32 |
+
new_info = {"id": value[0], "isthing": value[1], "name": value[2], "color": value[3]}
|
| 33 |
+
NEW_COCO_CATEGORIES.append(new_info)
|
| 34 |
+
|
| 35 |
+
thing_ids = [k["id"] for k in NEW_COCO_CATEGORIES]
|
| 36 |
+
thing_colors = [k["color"] for k in NEW_COCO_CATEGORIES]
|
| 37 |
+
thing_classes = [k["name"] for k in NEW_COCO_CATEGORIES]
|
| 38 |
+
thing_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(thing_ids)}
|
| 39 |
+
ret = {
|
| 40 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 41 |
+
"thing_classes": thing_classes,
|
| 42 |
+
"thing_colors": thing_colors,
|
| 43 |
+
}
|
| 44 |
+
return ret
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
for key, (image_root, json_file) in SPLITS.items():
|
| 48 |
+
register_coco_instances(key,
|
| 49 |
+
_get_coco_trans_meta(),
|
| 50 |
+
os.path.join(_root, json_file) if "://" not in json_file else json_file,
|
| 51 |
+
os.path.join(_root, image_root)
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
ADE20K_CATEGORIES = [
|
| 55 |
+
{"color":[220,20,60], "isthing": 1, "id": 1, "name": "wall"},
|
| 56 |
+
{"color":[119,11,32], "isthing": 1, "id": 2, "name": "building"},
|
| 57 |
+
{"color":[0,0,142], "isthing": 1, "id": 3, "name": "sky"},
|
| 58 |
+
{"color":[0,0,230], "isthing": 1, "id": 4, "name": "floor"},
|
| 59 |
+
{"color":[106,0,228], "isthing": 1, "id": 5, "name": "tree"},
|
| 60 |
+
{"color":[0,60,100], "isthing": 1, "id": 6, "name": "ceiling"},
|
| 61 |
+
{"color":[0,80,100], "isthing": 1, "id": 7, "name": "road"},
|
| 62 |
+
{"color":[0,0,70], "isthing": 1, "id": 8, "name": "bed "},
|
| 63 |
+
{"color":[0,0,192], "isthing": 1, "id": 9, "name": "windowpane"},
|
| 64 |
+
{"color":[250,170,30], "isthing": 1, "id": 10, "name": "grass"},
|
| 65 |
+
{"color":[100,170,30], "isthing": 1, "id": 11, "name": "cabinet"},
|
| 66 |
+
{"color":[220,220,0], "isthing": 1, "id": 12, "name": "sidewalk"},
|
| 67 |
+
{"color":[175,116,175], "isthing": 1, "id": 13, "name": "person"},
|
| 68 |
+
{"color":[250,0,30], "isthing": 1, "id": 14, "name": "earth"},
|
| 69 |
+
{"color":[165,42,42], "isthing": 1, "id": 15, "name": "door"},
|
| 70 |
+
{"color":[255,77,255], "isthing": 1, "id": 16, "name": "table"},
|
| 71 |
+
{"color":[0,226,252], "isthing": 1, "id": 17, "name": "mountain"},
|
| 72 |
+
{"color":[182,182,255], "isthing": 1, "id": 18, "name": "plant"},
|
| 73 |
+
{"color":[0,82,0], "isthing": 1, "id": 19, "name": "curtain"},
|
| 74 |
+
{"color":[120,166,157], "isthing": 1, "id": 20, "name": "chair"},
|
| 75 |
+
{"color":[110,76,0], "isthing": 1, "id": 21, "name": "car"},
|
| 76 |
+
{"color":[174,57,255], "isthing": 1, "id": 22 , "name": "water"},
|
| 77 |
+
{"color":[199,100,0], "isthing": 1, "id": 23, "name": "painting"},
|
| 78 |
+
{"color":[72,0,118], "isthing": 1, "id": 24 , "name": "sofa"},
|
| 79 |
+
{"color":[255,179,240], "isthing": 1, "id": 25 , "name": "shelf"},
|
| 80 |
+
{"color":[0,125,92], "isthing": 1, "id": 26 , "name": "house"},
|
| 81 |
+
{"color":[209,0,151], "isthing": 1, "id": 27 , "name": "sea"},
|
| 82 |
+
{"color":[188,208,182], "isthing": 1, "id": 28, "name": "mirror"},
|
| 83 |
+
{"color":[0,220,176], "isthing": 1, "id": 29, "name": "rug"},
|
| 84 |
+
{"color":[255,99,164], "isthing": 1, "id": 30, "name": "field"},
|
| 85 |
+
{"color":[92,0,73], "isthing": 1, "id": 31, "name": "armchair"},
|
| 86 |
+
{"color":[133,129,255], "isthing": 1, "id": 32, "name": "seat"},
|
| 87 |
+
{"color":[78,180,255], "isthing": 1, "id": 33, "name": "fence"},
|
| 88 |
+
{"color":[0,228,0], "isthing": 1, "id": 34, "name": "desk"},
|
| 89 |
+
{"color":[174,255,243], "isthing": 1, "id": 35, "name": "rock"},
|
| 90 |
+
{"color":[45,89,255], "isthing": 1, "id": 36, "name": "wardrobe"},
|
| 91 |
+
{"color":[134,134,103], "isthing": 1, "id": 37, "name": "lamp"},
|
| 92 |
+
{"color":[145,148,174], "isthing": 1, "id": 38, "name": "bathtub"},
|
| 93 |
+
{"color":[255,208,186], "isthing": 1, "id": 39, "name": "railing"},
|
| 94 |
+
{"color":[197,226,255], "isthing": 1, "id": 40, "name": "cushion"},
|
| 95 |
+
{"color":[171,134,1], "isthing": 1, "id": 41, "name": "base"},
|
| 96 |
+
{"color":[109,63,54], "isthing": 1, "id": 42, "name": "box"},
|
| 97 |
+
{"color":[207,138,255], "isthing": 1, "id": 43, "name": "column"},
|
| 98 |
+
{"color":[151,0,95], "isthing": 1, "id": 44, "name": "signboard"},
|
| 99 |
+
{"color":[9,80,61], "isthing": 1, "id": 45, "name": "chest of drawers"},
|
| 100 |
+
{"color":[84,105,51], "isthing": 1, "id": 46, "name": "counter"},
|
| 101 |
+
{"color":[74,65,105], "isthing": 1, "id": 47, "name": "sand"},
|
| 102 |
+
{"color":[166,196,102], "isthing": 1, "id": 48, "name": "sink"},
|
| 103 |
+
{"color":[208,195,210], "isthing": 1, "id": 49, "name": "skyscraper"},
|
| 104 |
+
{"color":[255,109,65], "isthing": 1, "id": 50, "name": "fireplace"},
|
| 105 |
+
{"color":[0,143,149], "isthing": 1, "id": 51, "name": "refrigerator"},
|
| 106 |
+
{"color":[179,0,194], "isthing": 1, "id": 52, "name": "grandstand"},
|
| 107 |
+
{"color":[209,99,106], "isthing": 1, "id": 53, "name": "path"},
|
| 108 |
+
{"color":[5,121,0], "isthing": 1, "id": 54, "name": "stairs"},
|
| 109 |
+
{"color":[227,255,205], "isthing": 1, "id": 55, "name": "runway"},
|
| 110 |
+
{"color":[147,186,208], "isthing": 1, "id": 56, "name": "case"},
|
| 111 |
+
{"color":[153,69,1], "isthing": 1, "id": 57, "name": "pool table"},
|
| 112 |
+
{"color":[3,95,161], "isthing": 1, "id": 58, "name": "pillow"},
|
| 113 |
+
{"color":[163,255,0], "isthing": 1, "id": 59, "name": "screen door"},
|
| 114 |
+
{"color":[119,0,170], "isthing": 1, "id": 60, "name": "stairway"},
|
| 115 |
+
{"color":[0,182,199], "isthing": 1, "id": 61, "name": "river"},
|
| 116 |
+
{"color":[0,165,120], "isthing": 1, "id": 62, "name": "bridge"},
|
| 117 |
+
{"color":[183,130,88], "isthing": 1, "id": 63, "name": "bookcase"},
|
| 118 |
+
{"color":[95,32,0], "isthing": 1, "id": 64, "name": "blind"},
|
| 119 |
+
{"color":[130,114,135], "isthing": 1, "id": 65, "name": "coffee table"},
|
| 120 |
+
{"color":[110,129,133], "isthing": 1, "id": 66, "name": "toilet"},
|
| 121 |
+
{"color":[166,74,118], "isthing": 1, "id": 67, "name": "flower"},
|
| 122 |
+
{"color":[219,142,185], "isthing": 1, "id": 68, "name": "book"},
|
| 123 |
+
{"color":[79,210,114], "isthing": 1, "id": 69, "name": "hill"},
|
| 124 |
+
{"color":[178,90,62], "isthing": 1, "id": 70, "name": "bench"},
|
| 125 |
+
{"color":[65,70,15], "isthing": 1, "id": 71, "name": "countertop"},
|
| 126 |
+
{"color":[127,167,115], "isthing": 1, "id": 72, "name": "stove"},
|
| 127 |
+
{"color":[59,105,106], "isthing": 1, "id": 73, "name": "palm"},
|
| 128 |
+
{"color":[142,108,45], "isthing": 1, "id": 74, "name": "kitchen island"},
|
| 129 |
+
{"color":[196,172,0], "isthing": 1, "id": 75, "name": "computer"},
|
| 130 |
+
{"color":[95,54,80], "isthing": 1, "id": 76, "name": "swivel chair"},
|
| 131 |
+
{"color":[128,76,255], "isthing": 1, "id": 77, "name": "boat"},
|
| 132 |
+
{"color":[201,57,1], "isthing": 1, "id": 78, "name": "bar"},
|
| 133 |
+
{"color":[246,0,122], "isthing": 1, "id": 79, "name": "arcade machine"},
|
| 134 |
+
{"color":[191,162,208], "isthing": 1, "id": 80, "name": "hovel"},
|
| 135 |
+
{"color":[255,255,128], "isthing": 1, "id": 81, "name": "bus"},
|
| 136 |
+
{"color":[147,211,203], "isthing": 1, "id": 82, "name": "towel"},
|
| 137 |
+
{"color":[150,100,100], "isthing": 1, "id": 83, "name": "light"},
|
| 138 |
+
{"color":[168,171,172], "isthing": 1, "id": 84, "name": "truck"},
|
| 139 |
+
{"color":[146,112,198], "isthing": 1, "id": 85, "name": "tower"},
|
| 140 |
+
{"color":[210,170,100], "isthing": 1, "id": 86, "name": "chandelier"},
|
| 141 |
+
{"color":[92,136,89], "isthing": 1, "id": 87, "name": "awning"},
|
| 142 |
+
{"color":[218,88,184], "isthing": 1, "id": 88, "name": "streetlight"},
|
| 143 |
+
{"color":[241,129,0], "isthing": 1, "id": 89, "name": "booth"},
|
| 144 |
+
{"color":[217,17,255], "isthing": 1, "id": 90, "name": "television receiver"},
|
| 145 |
+
{"color":[124,74,181], "isthing": 1, "id": 91, "name": "airplane"},
|
| 146 |
+
{"color":[70,70,70], "isthing": 1, "id": 92, "name": "dirt track"},
|
| 147 |
+
{"color":[255,228,255], "isthing": 1, "id": 93, "name": "apparel"},
|
| 148 |
+
{"color":[154,208,0], "isthing": 1, "id": 94, "name": "pole"},
|
| 149 |
+
{"color":[193,0,92], "isthing": 1, "id": 95, "name": "land"},
|
| 150 |
+
{"color":[76,91,113], "isthing": 1, "id": 96, "name": "bannister"},
|
| 151 |
+
{"color":[255,180,195], "isthing": 1, "id": 97, "name": "escalator"},
|
| 152 |
+
{"color":[106,154,176], "isthing": 1, "id": 98, "name": "ottoman"},
|
| 153 |
+
{"color":[230,150,140], "isthing": 1, "id": 99, "name": "bottle"},
|
| 154 |
+
{"color":[60,143,255], "isthing": 1, "id": 100, "name": "buffet"},
|
| 155 |
+
{"color":[128,64,128], "isthing": 1, "id": 101, "name": "poster"},
|
| 156 |
+
{"color":[92,82,55], "isthing": 1, "id": 102, "name": "stage"},
|
| 157 |
+
{"color":[254,212,124], "isthing": 1, "id": 103, "name": "van"},
|
| 158 |
+
{"color":[73,77,174], "isthing": 1, "id": 104, "name": "ship"},
|
| 159 |
+
{"color":[255,160,98], "isthing": 1, "id": 105, "name": "fountain"},
|
| 160 |
+
{"color":[255,255,255], "isthing": 1, "id": 106, "name": "conveyer belt"},
|
| 161 |
+
{"color":[104,84,109], "isthing": 1, "id": 107, "name": "canopy"},
|
| 162 |
+
{"color":[169,164,131], "isthing": 1, "id": 108, "name": "washer"},
|
| 163 |
+
{"color":[225,199,255], "isthing": 1, "id": 109, "name": "plaything"},
|
| 164 |
+
{"color":[137,54,74], "isthing": 1, "id": 110, "name": "swimming pool"},
|
| 165 |
+
{"color":[135,158,223], "isthing": 1, "id": 111, "name": "stool"},
|
| 166 |
+
{"color":[7,246,231], "isthing": 1, "id": 112, "name": "barrel"},
|
| 167 |
+
{"color":[107,255,200], "isthing": 1, "id": 113, "name": "basket"},
|
| 168 |
+
{"color":[58,41,149], "isthing": 1, "id": 114, "name": "waterfall"},
|
| 169 |
+
{"color":[183,121,142], "isthing": 1, "id": 115, "name": "tent"},
|
| 170 |
+
{"color":[255,73,97], "isthing": 1, "id": 116, "name": "bag"},
|
| 171 |
+
{"color":[107,142,35], "isthing": 1, "id": 117, "name": "minibike"},
|
| 172 |
+
{"color":[190,153,153], "isthing": 1, "id": 118, "name": "cradle"},
|
| 173 |
+
{"color":[146,139,141], "isthing": 1, "id": 119, "name": "oven"},
|
| 174 |
+
{"color":[70,130,180], "isthing": 1, "id": 120, "name": "ball"},
|
| 175 |
+
{"color":[134,199,156], "isthing": 1, "id": 121, "name": "food"},
|
| 176 |
+
{"color":[209,226,140], "isthing": 1, "id": 122, "name": "step"},
|
| 177 |
+
{"color":[96,36,108], "isthing": 1, "id": 123, "name": "tank"},
|
| 178 |
+
{"color":[96,96,96], "isthing": 1, "id": 124, "name": "trade name"},
|
| 179 |
+
{"color":[64,170,64], "isthing": 1, "id": 125, "name": "microwave"},
|
| 180 |
+
{"color":[152,251,152], "isthing": 1, "id": 126, "name": "pot"},
|
| 181 |
+
{"color":[208,229,228], "isthing": 1, "id": 127, "name": "animal"},
|
| 182 |
+
{"color":[206,186,171], "isthing": 1, "id": 128, "name": "bicycle"},
|
| 183 |
+
{"color":[152,161,64], "isthing": 1, "id": 129, "name": "lake"},
|
| 184 |
+
{"color":[116,112,0], "isthing": 1, "id": 130, "name": "dishwasher"},
|
| 185 |
+
{"color":[0,114,143], "isthing": 1, "id": 131, "name": "screen"},
|
| 186 |
+
{"color":[102,102,156], "isthing": 1, "id": 132, "name": "blanket"},
|
| 187 |
+
{"color":[220,20,60], "isthing": 1, "id": 133, "name": "sculpture"},
|
| 188 |
+
{"color":[119,11,32], "isthing": 1, "id": 134, "name": "hood"},
|
| 189 |
+
{"color":[0,0,142], "isthing": 1, "id": 135, "name": "sconce"},
|
| 190 |
+
{"color":[0,0,230], "isthing": 1, "id": 136, "name": "vase"},
|
| 191 |
+
{"color":[106,0,228], "isthing": 1, "id": 137, "name": "traffic light"},
|
| 192 |
+
{"color":[0,60,100], "isthing": 1, "id": 138, "name": "tray"},
|
| 193 |
+
{"color":[0,80,100], "isthing": 1, "id": 139, "name": "ashcan"},
|
| 194 |
+
{"color":[0,0,70], "isthing": 1, "id": 140, "name": "fan"},
|
| 195 |
+
{"color":[0,0,192], "isthing": 1, "id": 141, "name": "pier"},
|
| 196 |
+
{"color":[250,170,30], "isthing": 1, "id": 142, "name": "crt screen"},
|
| 197 |
+
{"color":[100,170,30], "isthing": 1, "id": 143, "name": "plate"},
|
| 198 |
+
{"color":[220,220,0], "isthing": 1, "id": 144, "name": "monitor"},
|
| 199 |
+
{"color":[175,116,175], "isthing": 1, "id": 145, "name": "bulletin board"},
|
| 200 |
+
{"color":[250,0,30], "isthing": 1, "id": 146, "name": "shower"},
|
| 201 |
+
{"color":[165,42,42], "isthing": 1, "id": 147, "name": "radiator"},
|
| 202 |
+
{"color":[255,77,255], "isthing": 1, "id": 148, "name": "glass"},
|
| 203 |
+
{"color":[0,226,252], "isthing": 1, "id": 149, "name": "clock"},
|
| 204 |
+
{"color":[182,182,255], "isthing": 1, "id": 150, "name": "flag"},
|
| 205 |
+
]
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def _get_ade20k_trans_meta():
|
| 209 |
+
oc2nc_map = {category['id']: [cid, category["isthing"], category["name"], category["color"]] for cid, category in enumerate(ADE20K_CATEGORIES)}
|
| 210 |
+
# transformed info
|
| 211 |
+
NEW_ADE20K_CATEGORIES = []
|
| 212 |
+
for key, value in oc2nc_map.items():
|
| 213 |
+
new_info = {"id": value[0], "isthing": value[1], "name": value[2], "color": value[3]}
|
| 214 |
+
NEW_ADE20K_CATEGORIES.append(new_info)
|
| 215 |
+
|
| 216 |
+
thing_ids = [k["id"] for k in NEW_ADE20K_CATEGORIES]
|
| 217 |
+
thing_colors = [k["color"] for k in NEW_ADE20K_CATEGORIES]
|
| 218 |
+
thing_classes = [k["name"] for k in NEW_ADE20K_CATEGORIES]
|
| 219 |
+
|
| 220 |
+
thing_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(thing_ids)}
|
| 221 |
+
|
| 222 |
+
ret = {
|
| 223 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 224 |
+
"thing_classes": thing_classes,
|
| 225 |
+
"thing_colors": thing_colors,
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
return ret
|
| 229 |
+
|
| 230 |
+
SPLITS_ADE = {}
|
| 231 |
+
SPLITS_ADE["ade20k_train_entity"] = ("ade20k/train", "ade20k/annotations/ade20k_instances_training.json")
|
| 232 |
+
SPLITS_ADE["ade20k_val_entity"] = ("ade20k/val", "ade20k/annotations/ade20k_instances_validation.json")
|
| 233 |
+
|
| 234 |
+
for key, (image_root, json_file) in SPLITS_ADE.items():
|
| 235 |
+
register_coco_instances(key,
|
| 236 |
+
_get_ade20k_trans_meta(),
|
| 237 |
+
os.path.join(_root, json_file) if "://" not in json_file else json_file,
|
| 238 |
+
os.path.join(_root, image_root)
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
CITYSCAPES_CATEGORIES = [
|
| 242 |
+
{"color":[220,20,60], "isthing": 0, "id": 1, "name": "road"},
|
| 243 |
+
{"color":[119,11,32], "isthing": 0, "id": 2, "name": "sidewalk"},
|
| 244 |
+
{"color":[0,0,142], "isthing": 0, "id": 3, "name": "building"},
|
| 245 |
+
{"color":[0,0,230], "isthing": 0, "id": 4, "name": "wall"},
|
| 246 |
+
{"color":[106,0,228], "isthing": 0, "id": 5, "name": "fence"},
|
| 247 |
+
{"color":[0,60,100], "isthing": 0, "id": 6, "name": "pole"},
|
| 248 |
+
{"color":[0,80,100], "isthing": 0, "id": 7, "name": "traffic light"},
|
| 249 |
+
{"color":[0,0,70], "isthing": 0, "id": 8, "name": "traffic sign"},
|
| 250 |
+
{"color":[0,0,192], "isthing": 0, "id": 9, "name": "vegetation"},
|
| 251 |
+
{"color":[250,170,30], "isthing": 0, "id": 10, "name": "terrain"},
|
| 252 |
+
{"color":[100,170,30], "isthing": 0, "id": 11, "name": "sky"},
|
| 253 |
+
{"color":[220,220,0], "isthing": 1, "id": 12, "name": "person"},
|
| 254 |
+
{"color":[175,116,175], "isthing": 1, "id": 13, "name": "rider"},
|
| 255 |
+
{"color":[250,0,30], "isthing": 1, "id": 14, "name": "car"},
|
| 256 |
+
{"color":[165,42,42], "isthing": 1, "id": 15, "name": "truck"},
|
| 257 |
+
{"color":[255,77,255], "isthing": 1, "id": 16, "name": "bus"},
|
| 258 |
+
{"color":[0,226,252], "isthing": 1, "id": 17, "name": "train"},
|
| 259 |
+
{"color":[182,182,255], "isthing": 1, "id": 18, "name": "motorcycle"},
|
| 260 |
+
{"color":[0,82,0], "isthing": 1, "id": 19, "name": "bicycle"},
|
| 261 |
+
]
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
def _get_cityscapes_trans_meta():
|
| 265 |
+
oc2nc_map = {category['id']: [cid, category["isthing"], category["name"], category["color"]] for cid, category in enumerate(CITYSCAPES_CATEGORIES)}
|
| 266 |
+
# transformed info
|
| 267 |
+
NEW_CITY_CATEGORIES = []
|
| 268 |
+
for key, value in oc2nc_map.items():
|
| 269 |
+
new_info = {"id": value[0], "isthing": value[1], "name": value[2], "color": value[3]}
|
| 270 |
+
NEW_CITY_CATEGORIES.append(new_info)
|
| 271 |
+
|
| 272 |
+
thing_ids = [k["id"] for k in NEW_CITY_CATEGORIES]
|
| 273 |
+
thing_colors = [k["color"] for k in NEW_CITY_CATEGORIES]
|
| 274 |
+
thing_classes = [k["name"] for k in NEW_CITY_CATEGORIES]
|
| 275 |
+
|
| 276 |
+
thing_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(thing_ids)}
|
| 277 |
+
|
| 278 |
+
ret = {
|
| 279 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 280 |
+
"thing_classes": thing_classes,
|
| 281 |
+
"thing_colors": thing_colors,
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
return ret
|
| 285 |
+
|
| 286 |
+
SPLITS_CITY = {}
|
| 287 |
+
SPLITS_CITY["city_train_entity"] = ("city/images/train", "city/annotations/cityscapes_panoptic_new_train.json")
|
| 288 |
+
SPLITS_CITY["city_val_entity"] = ("city/images/val", "city/annotations/cityscapes_panoptic_new_val.json")
|
| 289 |
+
|
| 290 |
+
for key, (image_root, json_file) in SPLITS_CITY.items():
|
| 291 |
+
register_coco_instances(key,
|
| 292 |
+
_get_cityscapes_trans_meta(),
|
| 293 |
+
os.path.join(_root, json_file) if "://" not in json_file else json_file,
|
| 294 |
+
os.path.join(_root, image_root)
|
| 295 |
+
)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/__init__.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
from . import datasets
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/coco_instance_new_baseline_dataset_mapper.py
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# Modified by Bowen Cheng from https://github.com/facebookresearch/detr/blob/master/d2/detr/dataset_mapper.py
|
| 3 |
+
import copy
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from detectron2.config import configurable
|
| 10 |
+
from detectron2.data import detection_utils as utils
|
| 11 |
+
from detectron2.data import transforms as T
|
| 12 |
+
from detectron2.data.transforms import TransformGen
|
| 13 |
+
from detectron2.structures import BitMasks, Instances
|
| 14 |
+
|
| 15 |
+
from pycocotools import mask as coco_mask
|
| 16 |
+
from PIL import ImageFile
|
| 17 |
+
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
| 18 |
+
|
| 19 |
+
__all__ = ["COCOInstanceNewBaselineDatasetMapper"]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def convert_coco_poly_to_mask(segmentations, height, width):
|
| 23 |
+
masks = []
|
| 24 |
+
for polygons in segmentations:
|
| 25 |
+
rles = coco_mask.frPyObjects(polygons, height, width)
|
| 26 |
+
mask = coco_mask.decode(rles)
|
| 27 |
+
if len(mask.shape) < 3:
|
| 28 |
+
mask = mask[..., None]
|
| 29 |
+
mask = torch.as_tensor(mask, dtype=torch.uint8)
|
| 30 |
+
mask = mask.any(dim=2)
|
| 31 |
+
masks.append(mask)
|
| 32 |
+
if masks:
|
| 33 |
+
masks = torch.stack(masks, dim=0)
|
| 34 |
+
else:
|
| 35 |
+
masks = torch.zeros((0, height, width), dtype=torch.uint8)
|
| 36 |
+
return masks
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def build_transform_gen(cfg, is_train):
|
| 40 |
+
"""
|
| 41 |
+
Create a list of default :class:`Augmentation` from config.
|
| 42 |
+
Now it includes resizing and flipping.
|
| 43 |
+
Returns:
|
| 44 |
+
list[Augmentation]
|
| 45 |
+
"""
|
| 46 |
+
assert is_train, "Only support training augmentation"
|
| 47 |
+
image_size = cfg.INPUT.IMAGE_SIZE
|
| 48 |
+
min_scale = cfg.INPUT.MIN_SCALE
|
| 49 |
+
max_scale = cfg.INPUT.MAX_SCALE
|
| 50 |
+
|
| 51 |
+
augmentation = []
|
| 52 |
+
|
| 53 |
+
if cfg.INPUT.RANDOM_FLIP != "none":
|
| 54 |
+
augmentation.append(
|
| 55 |
+
T.RandomFlip(
|
| 56 |
+
horizontal=cfg.INPUT.RANDOM_FLIP == "horizontal",
|
| 57 |
+
vertical=cfg.INPUT.RANDOM_FLIP == "vertical",
|
| 58 |
+
)
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
augmentation.extend([
|
| 62 |
+
T.ResizeScale(
|
| 63 |
+
min_scale=min_scale, max_scale=max_scale, target_height=image_size, target_width=image_size
|
| 64 |
+
),
|
| 65 |
+
T.FixedSizeCrop(crop_size=(image_size, image_size)),
|
| 66 |
+
])
|
| 67 |
+
|
| 68 |
+
return augmentation
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
# This is specifically designed for the COCO dataset.
|
| 72 |
+
class COCOInstanceNewBaselineDatasetMapper:
|
| 73 |
+
"""
|
| 74 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 75 |
+
and map it into a format used by MaskFormer.
|
| 76 |
+
|
| 77 |
+
This dataset mapper applies the same transformation as DETR for COCO panoptic segmentation.
|
| 78 |
+
|
| 79 |
+
The callable currently does the following:
|
| 80 |
+
|
| 81 |
+
1. Read the image from "file_name"
|
| 82 |
+
2. Applies geometric transforms to the image and annotation
|
| 83 |
+
3. Find and applies suitable cropping to the image and annotation
|
| 84 |
+
4. Prepare image and annotation to Tensors
|
| 85 |
+
"""
|
| 86 |
+
|
| 87 |
+
@configurable
|
| 88 |
+
def __init__(
|
| 89 |
+
self,
|
| 90 |
+
is_train=True,
|
| 91 |
+
*,
|
| 92 |
+
tfm_gens,
|
| 93 |
+
image_format,
|
| 94 |
+
mask_format,
|
| 95 |
+
):
|
| 96 |
+
"""
|
| 97 |
+
NOTE: this interface is experimental.
|
| 98 |
+
Args:
|
| 99 |
+
is_train: for training or inference
|
| 100 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 101 |
+
tfm_gens: data augmentation
|
| 102 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 103 |
+
"""
|
| 104 |
+
self.tfm_gens = tfm_gens
|
| 105 |
+
logging.getLogger(__name__).info(
|
| 106 |
+
"[COCOInstanceNewBaselineDatasetMapper] Full TransformGens used in training: {}".format(str(self.tfm_gens))
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
self.img_format = image_format
|
| 110 |
+
self.mask_format = mask_format
|
| 111 |
+
self.is_train = is_train
|
| 112 |
+
|
| 113 |
+
@classmethod
|
| 114 |
+
def from_config(cls, cfg, is_train=True):
|
| 115 |
+
# Build augmentation
|
| 116 |
+
tfm_gens = build_transform_gen(cfg, is_train)
|
| 117 |
+
|
| 118 |
+
ret = {
|
| 119 |
+
"is_train": is_train,
|
| 120 |
+
"tfm_gens": tfm_gens,
|
| 121 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 122 |
+
"mask_format": cfg.INPUT.MASK_FORMAT,
|
| 123 |
+
}
|
| 124 |
+
return ret
|
| 125 |
+
|
| 126 |
+
def __call__(self, dataset_dict):
|
| 127 |
+
"""
|
| 128 |
+
Args:
|
| 129 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 130 |
+
|
| 131 |
+
Returns:
|
| 132 |
+
dict: a format that builtin models in detectron2 accept
|
| 133 |
+
"""
|
| 134 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 135 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
|
| 136 |
+
utils.check_image_size(dataset_dict, image)
|
| 137 |
+
|
| 138 |
+
# TODO: get padding mask
|
| 139 |
+
# by feeding a "segmentation mask" to the same transforms
|
| 140 |
+
padding_mask = np.ones(image.shape[:2])
|
| 141 |
+
|
| 142 |
+
image, transforms = T.apply_transform_gens(self.tfm_gens, image)
|
| 143 |
+
# the crop transformation has default padding value 0 for segmentation
|
| 144 |
+
padding_mask = transforms.apply_segmentation(padding_mask)
|
| 145 |
+
padding_mask = ~ padding_mask.astype(bool)
|
| 146 |
+
|
| 147 |
+
image_shape = image.shape[:2] # h, w
|
| 148 |
+
|
| 149 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 150 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 151 |
+
# Therefore it's important to use torch.Tensor.
|
| 152 |
+
dataset_dict["image"] = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 153 |
+
dataset_dict["padding_mask"] = torch.as_tensor(np.ascontiguousarray(padding_mask))
|
| 154 |
+
|
| 155 |
+
if not self.is_train:
|
| 156 |
+
# USER: Modify this if you want to keep them for some reason.
|
| 157 |
+
dataset_dict.pop("annotations", None)
|
| 158 |
+
return dataset_dict
|
| 159 |
+
|
| 160 |
+
if "annotations" in dataset_dict:
|
| 161 |
+
# USER: Modify this if you want to keep them for some reason.
|
| 162 |
+
for anno in dataset_dict["annotations"]:
|
| 163 |
+
# Let's always keep mask
|
| 164 |
+
# if not self.mask_on:
|
| 165 |
+
# anno.pop("segmentation", None)
|
| 166 |
+
anno.pop("keypoints", None)
|
| 167 |
+
|
| 168 |
+
# USER: Implement additional transformations if you have other types of data
|
| 169 |
+
annos = [
|
| 170 |
+
utils.transform_instance_annotations(obj, transforms, image_shape)
|
| 171 |
+
for obj in dataset_dict.pop("annotations")
|
| 172 |
+
if obj.get("iscrowd", 0) == 0
|
| 173 |
+
]
|
| 174 |
+
# NOTE: does not support BitMask due to augmentation
|
| 175 |
+
# Current BitMask cannot handle empty objects
|
| 176 |
+
instances = utils.annotations_to_instances(annos, image_shape, mask_format=self.mask_format)
|
| 177 |
+
# After transforms such as cropping are applied, the bounding box may no longer
|
| 178 |
+
# tightly bound the object. As an example, imagine a triangle object
|
| 179 |
+
# [(0,0), (2,0), (0,2)] cropped by a box [(1,0),(2,2)] (XYXY format). The tight
|
| 180 |
+
# bounding box of the cropped triangle should be [(1,0),(2,1)], which is not equal to
|
| 181 |
+
# the intersection of original bounding box and the cropping box.
|
| 182 |
+
instances.gt_boxes = instances.gt_masks.get_bounding_boxes()
|
| 183 |
+
# Need to filter empty instances first (due to augmentation)
|
| 184 |
+
instances = utils.filter_empty_instances(instances)
|
| 185 |
+
# Generate masks from polygon
|
| 186 |
+
h, w = instances.image_size
|
| 187 |
+
# image_size_xyxy = torch.as_tensor([w, h, w, h], dtype=torch.float)
|
| 188 |
+
if hasattr(instances, 'gt_masks'):
|
| 189 |
+
gt_masks = instances.gt_masks
|
| 190 |
+
if self.mask_format == "polygons":
|
| 191 |
+
gt_masks = convert_coco_poly_to_mask(gt_masks.polygons, h, w)
|
| 192 |
+
else:
|
| 193 |
+
gt_masks = gt_masks.tensor
|
| 194 |
+
instances.gt_masks = gt_masks
|
| 195 |
+
dataset_dict["instances"] = instances
|
| 196 |
+
|
| 197 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/coco_panoptic_new_baseline_dataset_mapper.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# Modified by Bowen Cheng from https://github.com/facebookresearch/detr/blob/master/d2/detr/dataset_mapper.py
|
| 3 |
+
import copy
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from detectron2.config import configurable
|
| 10 |
+
from detectron2.data import detection_utils as utils
|
| 11 |
+
from detectron2.data import transforms as T
|
| 12 |
+
from detectron2.data.transforms import TransformGen
|
| 13 |
+
from detectron2.structures import BitMasks, Boxes, Instances
|
| 14 |
+
|
| 15 |
+
__all__ = ["COCOPanopticNewBaselineDatasetMapper"]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def build_transform_gen(cfg, is_train):
|
| 19 |
+
"""
|
| 20 |
+
Create a list of default :class:`Augmentation` from config.
|
| 21 |
+
Now it includes resizing and flipping.
|
| 22 |
+
Returns:
|
| 23 |
+
list[Augmentation]
|
| 24 |
+
"""
|
| 25 |
+
assert is_train, "Only support training augmentation"
|
| 26 |
+
image_size = cfg.INPUT.IMAGE_SIZE
|
| 27 |
+
min_scale = cfg.INPUT.MIN_SCALE
|
| 28 |
+
max_scale = cfg.INPUT.MAX_SCALE
|
| 29 |
+
|
| 30 |
+
augmentation = []
|
| 31 |
+
|
| 32 |
+
if cfg.INPUT.RANDOM_FLIP != "none":
|
| 33 |
+
augmentation.append(
|
| 34 |
+
T.RandomFlip(
|
| 35 |
+
horizontal=cfg.INPUT.RANDOM_FLIP == "horizontal",
|
| 36 |
+
vertical=cfg.INPUT.RANDOM_FLIP == "vertical",
|
| 37 |
+
)
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
augmentation.extend([
|
| 41 |
+
T.ResizeScale(
|
| 42 |
+
min_scale=min_scale, max_scale=max_scale, target_height=image_size, target_width=image_size
|
| 43 |
+
),
|
| 44 |
+
T.FixedSizeCrop(crop_size=(image_size, image_size)),
|
| 45 |
+
])
|
| 46 |
+
|
| 47 |
+
return augmentation
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# This is specifically designed for the COCO dataset.
|
| 51 |
+
class COCOPanopticNewBaselineDatasetMapper:
|
| 52 |
+
"""
|
| 53 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 54 |
+
and map it into a format used by MaskFormer.
|
| 55 |
+
|
| 56 |
+
This dataset mapper applies the same transformation as DETR for COCO panoptic segmentation.
|
| 57 |
+
|
| 58 |
+
The callable currently does the following:
|
| 59 |
+
|
| 60 |
+
1. Read the image from "file_name"
|
| 61 |
+
2. Applies geometric transforms to the image and annotation
|
| 62 |
+
3. Find and applies suitable cropping to the image and annotation
|
| 63 |
+
4. Prepare image and annotation to Tensors
|
| 64 |
+
"""
|
| 65 |
+
|
| 66 |
+
@configurable
|
| 67 |
+
def __init__(
|
| 68 |
+
self,
|
| 69 |
+
is_train=True,
|
| 70 |
+
*,
|
| 71 |
+
tfm_gens,
|
| 72 |
+
image_format,
|
| 73 |
+
):
|
| 74 |
+
"""
|
| 75 |
+
NOTE: this interface is experimental.
|
| 76 |
+
Args:
|
| 77 |
+
is_train: for training or inference
|
| 78 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 79 |
+
crop_gen: crop augmentation
|
| 80 |
+
tfm_gens: data augmentation
|
| 81 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 82 |
+
"""
|
| 83 |
+
self.tfm_gens = tfm_gens
|
| 84 |
+
logging.getLogger(__name__).info(
|
| 85 |
+
"[COCOPanopticNewBaselineDatasetMapper] Full TransformGens used in training: {}".format(
|
| 86 |
+
str(self.tfm_gens)
|
| 87 |
+
)
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
self.img_format = image_format
|
| 91 |
+
self.is_train = is_train
|
| 92 |
+
|
| 93 |
+
@classmethod
|
| 94 |
+
def from_config(cls, cfg, is_train=True):
|
| 95 |
+
# Build augmentation
|
| 96 |
+
tfm_gens = build_transform_gen(cfg, is_train)
|
| 97 |
+
|
| 98 |
+
ret = {
|
| 99 |
+
"is_train": is_train,
|
| 100 |
+
"tfm_gens": tfm_gens,
|
| 101 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 102 |
+
}
|
| 103 |
+
return ret
|
| 104 |
+
|
| 105 |
+
def __call__(self, dataset_dict):
|
| 106 |
+
"""
|
| 107 |
+
Args:
|
| 108 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 109 |
+
|
| 110 |
+
Returns:
|
| 111 |
+
dict: a format that builtin models in detectron2 accept
|
| 112 |
+
"""
|
| 113 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 114 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
|
| 115 |
+
utils.check_image_size(dataset_dict, image)
|
| 116 |
+
|
| 117 |
+
image, transforms = T.apply_transform_gens(self.tfm_gens, image)
|
| 118 |
+
image_shape = image.shape[:2] # h, w
|
| 119 |
+
|
| 120 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 121 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 122 |
+
# Therefore it's important to use torch.Tensor.
|
| 123 |
+
dataset_dict["image"] = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 124 |
+
|
| 125 |
+
if not self.is_train:
|
| 126 |
+
# USER: Modify this if you want to keep them for some reason.
|
| 127 |
+
dataset_dict.pop("annotations", None)
|
| 128 |
+
return dataset_dict
|
| 129 |
+
|
| 130 |
+
if "pan_seg_file_name" in dataset_dict:
|
| 131 |
+
pan_seg_gt = utils.read_image(dataset_dict.pop("pan_seg_file_name"), "RGB")
|
| 132 |
+
segments_info = dataset_dict["segments_info"]
|
| 133 |
+
|
| 134 |
+
# apply the same transformation to panoptic segmentation
|
| 135 |
+
pan_seg_gt = transforms.apply_segmentation(pan_seg_gt)
|
| 136 |
+
|
| 137 |
+
from panopticapi.utils import rgb2id
|
| 138 |
+
|
| 139 |
+
pan_seg_gt = rgb2id(pan_seg_gt)
|
| 140 |
+
|
| 141 |
+
instances = Instances(image_shape)
|
| 142 |
+
classes = []
|
| 143 |
+
masks = []
|
| 144 |
+
for segment_info in segments_info:
|
| 145 |
+
class_id = segment_info["category_id"]
|
| 146 |
+
if not segment_info["iscrowd"]:
|
| 147 |
+
classes.append(class_id)
|
| 148 |
+
masks.append(pan_seg_gt == segment_info["id"])
|
| 149 |
+
|
| 150 |
+
classes = np.array(classes)
|
| 151 |
+
instances.gt_classes = torch.tensor(classes, dtype=torch.int64)
|
| 152 |
+
if len(masks) == 0:
|
| 153 |
+
# Some image does not have annotation (all ignored)
|
| 154 |
+
instances.gt_masks = torch.zeros((0, pan_seg_gt.shape[-2], pan_seg_gt.shape[-1]))
|
| 155 |
+
instances.gt_boxes = Boxes(torch.zeros((0, 4)))
|
| 156 |
+
else:
|
| 157 |
+
masks = BitMasks(
|
| 158 |
+
torch.stack([torch.from_numpy(np.ascontiguousarray(x.copy())) for x in masks])
|
| 159 |
+
)
|
| 160 |
+
instances.gt_masks = masks.tensor
|
| 161 |
+
instances.gt_boxes = masks.get_bounding_boxes()
|
| 162 |
+
|
| 163 |
+
dataset_dict["instances"] = instances
|
| 164 |
+
|
| 165 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/crop_augmentations.py
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 3 |
+
"""
|
| 4 |
+
Implement many useful :class:`Augmentation`.
|
| 5 |
+
"""
|
| 6 |
+
import numpy as np
|
| 7 |
+
import sys
|
| 8 |
+
from typing import Tuple
|
| 9 |
+
from PIL import Image
|
| 10 |
+
import random
|
| 11 |
+
|
| 12 |
+
from fvcore.transforms.transform import NoOpTransform, Transform
|
| 13 |
+
|
| 14 |
+
from detectron2.data.transforms.augmentation import Augmentation
|
| 15 |
+
import pdb
|
| 16 |
+
import math
|
| 17 |
+
|
| 18 |
+
import logging
|
| 19 |
+
import numpy as np
|
| 20 |
+
import pycocotools.mask as mask_util
|
| 21 |
+
import torch
|
| 22 |
+
from PIL import Image
|
| 23 |
+
from collections import defaultdict
|
| 24 |
+
import copy
|
| 25 |
+
from detectron2.data import transforms as T
|
| 26 |
+
from detectron2.structures import (
|
| 27 |
+
BitMasks,
|
| 28 |
+
Boxes,
|
| 29 |
+
BoxMode,
|
| 30 |
+
Instances,
|
| 31 |
+
Keypoints,
|
| 32 |
+
PolygonMasks,
|
| 33 |
+
RotatedBoxes,
|
| 34 |
+
polygons_to_bitmask,
|
| 35 |
+
)
|
| 36 |
+
from detectron2.utils.file_io import PathManager
|
| 37 |
+
|
| 38 |
+
__all__ = [
|
| 39 |
+
"BatchResizeShortestEdge",
|
| 40 |
+
"EntityCrop",
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
class BatchResizeTransform(Transform):
|
| 44 |
+
"""
|
| 45 |
+
Resize the image to a target size.
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
def __init__(self, h, w, new_h, new_w, interp=None):
|
| 49 |
+
"""
|
| 50 |
+
Args:
|
| 51 |
+
h, w (int): original image size
|
| 52 |
+
new_h, new_w (int): new image size
|
| 53 |
+
interp: PIL interpolation methods, defaults to bilinear.
|
| 54 |
+
"""
|
| 55 |
+
# TODO decide on PIL vs opencv
|
| 56 |
+
super().__init__()
|
| 57 |
+
if interp is None:
|
| 58 |
+
interp = Image.BILINEAR
|
| 59 |
+
self._set_attributes(locals())
|
| 60 |
+
|
| 61 |
+
def apply_image(self, imgs, interp=None):
|
| 62 |
+
dim_num = len(imgs.shape)
|
| 63 |
+
assert dim_num == 4
|
| 64 |
+
interp_method = interp if interp is not None else self.interp
|
| 65 |
+
resized_imgs = []
|
| 66 |
+
for img in imgs:
|
| 67 |
+
if len(img.shape) > 2 and img.shape[2] == 1:
|
| 68 |
+
pil_image = Image.fromarray(img[:, :, 0], mode="L")
|
| 69 |
+
else:
|
| 70 |
+
pil_image = Image.fromarray(img)
|
| 71 |
+
pil_image = pil_image.resize((self.new_w, self.new_h), interp_method)
|
| 72 |
+
ret = np.asarray(pil_image)
|
| 73 |
+
if len(img.shape) > 2 and img.shape[2] == 1:
|
| 74 |
+
ret = np.expand_dims(ret, -1)
|
| 75 |
+
resized_imgs.append(ret)
|
| 76 |
+
resized_imgs = np.stack(resized_imgs)
|
| 77 |
+
return resized_imgs
|
| 78 |
+
|
| 79 |
+
def apply_coords(self, coords):
|
| 80 |
+
coords[:, 0] = coords[:, 0] * (self.new_w * 1.0 / self.w)
|
| 81 |
+
coords[:, 1] = coords[:, 1] * (self.new_h * 1.0 / self.h)
|
| 82 |
+
return coords
|
| 83 |
+
|
| 84 |
+
def apply_box(self, boxes):
|
| 85 |
+
boxes = boxes[0]
|
| 86 |
+
new_boxes = super(BatchResizeTransform, self).apply_box(boxes[:,:4])
|
| 87 |
+
boxes[...,:4] = new_boxes
|
| 88 |
+
return boxes[None]
|
| 89 |
+
|
| 90 |
+
def apply_segmentation(self, segmentation):
|
| 91 |
+
if len(segmentation.shape)==3:
|
| 92 |
+
segmentation = segmentation[..., None]
|
| 93 |
+
segmentation = self.apply_image(segmentation, interp=Image.NEAREST)
|
| 94 |
+
segmentation = segmentation[..., 0]
|
| 95 |
+
else:
|
| 96 |
+
segmentation = self.apply_image(segmentation, interp=Image.NEAREST)
|
| 97 |
+
return segmentation
|
| 98 |
+
|
| 99 |
+
class EntityCropTransform(Transform):
|
| 100 |
+
"""
|
| 101 |
+
Consectively crop the images
|
| 102 |
+
"""
|
| 103 |
+
def __init__(self, crop_axises, crop_indexes):
|
| 104 |
+
super().__init__()
|
| 105 |
+
self._set_attributes(locals())
|
| 106 |
+
|
| 107 |
+
def apply_image(self, img):
|
| 108 |
+
"""
|
| 109 |
+
Args:
|
| 110 |
+
img (ndarray): of shape NxHxWxC, or HxWxC or HxW. The array can be
|
| 111 |
+
of type uint8 in range [0, 255], or floating point in range
|
| 112 |
+
[0, 1] or [0, 255]
|
| 113 |
+
returns:
|
| 114 |
+
ndarray: cropped images
|
| 115 |
+
"""
|
| 116 |
+
dim_num = len(img.shape)
|
| 117 |
+
imgs = []
|
| 118 |
+
|
| 119 |
+
for crop_axis in self.crop_axises:
|
| 120 |
+
x0, y0, x1, y1 = crop_axis
|
| 121 |
+
if dim_num <= 3:
|
| 122 |
+
crop_img = img[y0:y1, x0:x1]
|
| 123 |
+
else:
|
| 124 |
+
crop_img = img[..., y0:y1, x0:x1, :]
|
| 125 |
+
imgs.append(crop_img)
|
| 126 |
+
|
| 127 |
+
if dim_num <= 3:
|
| 128 |
+
imgs = np.stack(imgs, axis=0)
|
| 129 |
+
else:
|
| 130 |
+
imgs = np.concatenate(imgs, axis=0)
|
| 131 |
+
return imgs
|
| 132 |
+
|
| 133 |
+
def apply_coords(self, coords: np.ndarray, x0, y0):
|
| 134 |
+
coords[:, 0] -= x0
|
| 135 |
+
coords[:, 1] -= y0
|
| 136 |
+
return coords
|
| 137 |
+
|
| 138 |
+
def apply_box(self, box: np.ndarray) -> np.ndarray:
|
| 139 |
+
"""
|
| 140 |
+
box: Nx4, [x0, y0, x1, y1]
|
| 141 |
+
"""
|
| 142 |
+
idxs = np.array([(0, 1), (2, 1), (0, 3), (2, 3)]).flatten()
|
| 143 |
+
coords = np.asarray(box).reshape(-1, 4)[:, idxs].reshape(-1, 2)
|
| 144 |
+
split_boxes = []
|
| 145 |
+
crop_ws, crop_hs = [], []
|
| 146 |
+
for crop_axis in self.crop_axises:
|
| 147 |
+
startw, starth, endw, endh = crop_axis
|
| 148 |
+
coords_new = self.apply_coords(copy.deepcopy(coords), startw, starth).reshape((-1, 4, 2))
|
| 149 |
+
minxy = coords_new.min(axis=1)
|
| 150 |
+
maxxy = coords_new.max(axis=1)
|
| 151 |
+
trans_boxes = np.concatenate((minxy, maxxy), axis=1)
|
| 152 |
+
|
| 153 |
+
crop_ws.append(endw-startw)
|
| 154 |
+
crop_hs.append(endh-starth)
|
| 155 |
+
split_boxes.append(trans_boxes)
|
| 156 |
+
split_boxes = np.stack(split_boxes, axis=1)
|
| 157 |
+
### clip to the image boundary
|
| 158 |
+
## assert each crop size is equal
|
| 159 |
+
for crop_index, (crop_w, crop_h) in enumerate(zip(crop_ws, crop_hs)):
|
| 160 |
+
assert crop_w == crop_ws[0], "crop width is not equal, crop_{}: {}, crop_0: {}".format(crop_index, crop_w, crop_ws[0])
|
| 161 |
+
assert crop_h == crop_hs[0], "crop height is not equal, crop_{}: {}, crop_0: {}".format(crop_index, crop_h, crop_hs[0])
|
| 162 |
+
crop_w = crop_ws[0]
|
| 163 |
+
crop_h = crop_hs[0]
|
| 164 |
+
# pdb.set_trace()
|
| 165 |
+
split_boxes[...,0::2] = np.clip(split_boxes[...,0::2], 0, crop_w)
|
| 166 |
+
split_boxes[...,1::2] = np.clip(split_boxes[...,1::2], 0, crop_h)
|
| 167 |
+
valid_inds = (split_boxes[...,2]>split_boxes[...,0]) & (split_boxes[...,3]>split_boxes[...,1])
|
| 168 |
+
split_infos = np.concatenate((split_boxes, valid_inds[...,None]), axis=-1)
|
| 169 |
+
return split_infos
|
| 170 |
+
|
| 171 |
+
class BatchResizeShortestEdge(Augmentation):
|
| 172 |
+
"""
|
| 173 |
+
Scale the shorter edge to the given size, with a limit of `max_size` on the longer edge.
|
| 174 |
+
If `max_size` is reached, then downscale so that the longer edge does not exceed max_size.
|
| 175 |
+
"""
|
| 176 |
+
|
| 177 |
+
def __init__(
|
| 178 |
+
self, short_edge_length, max_size=sys.maxsize, sample_style="range", interp=Image.BILINEAR
|
| 179 |
+
):
|
| 180 |
+
"""
|
| 181 |
+
Args:
|
| 182 |
+
short_edge_length (list[int]): If ``sample_style=="range"``,
|
| 183 |
+
a [min, max] interval from which to sample the shortest edge length.
|
| 184 |
+
If ``sample_style=="choice"``, a list of shortest edge lengths to sample from.
|
| 185 |
+
max_size (int): maximum allowed longest edge length.
|
| 186 |
+
sample_style (str): either "range" or "choice".
|
| 187 |
+
"""
|
| 188 |
+
super().__init__()
|
| 189 |
+
assert sample_style in ["range", "choice"], sample_style
|
| 190 |
+
|
| 191 |
+
self.is_range = sample_style == "range"
|
| 192 |
+
if isinstance(short_edge_length, int):
|
| 193 |
+
short_edge_length = (short_edge_length, short_edge_length)
|
| 194 |
+
if self.is_range:
|
| 195 |
+
assert len(short_edge_length) == 2, (
|
| 196 |
+
"short_edge_length must be two values using 'range' sample style."
|
| 197 |
+
f" Got {short_edge_length}!"
|
| 198 |
+
)
|
| 199 |
+
self._init(locals())
|
| 200 |
+
|
| 201 |
+
def get_transform(self, image):
|
| 202 |
+
dim_num = len(image.shape)
|
| 203 |
+
assert dim_num == 4, "the tensor should be in [B, H, W, C]"
|
| 204 |
+
h, w = image.shape[1:3]
|
| 205 |
+
if self.is_range:
|
| 206 |
+
size = np.random.randint(self.short_edge_length[0], self.short_edge_length[1] + 1)
|
| 207 |
+
else:
|
| 208 |
+
size = np.random.choice(self.short_edge_length)
|
| 209 |
+
if size == 0:
|
| 210 |
+
return NoOpTransform()
|
| 211 |
+
|
| 212 |
+
scale = size * 1.0 / min(h, w)
|
| 213 |
+
if h < w:
|
| 214 |
+
newh, neww = size, scale * w
|
| 215 |
+
else:
|
| 216 |
+
newh, neww = scale * h, size
|
| 217 |
+
if max(newh, neww) > self.max_size:
|
| 218 |
+
scale = self.max_size * 1.0 / max(newh, neww)
|
| 219 |
+
newh = newh * scale
|
| 220 |
+
neww = neww * scale
|
| 221 |
+
neww = int(neww + 0.5)
|
| 222 |
+
newh = int(newh + 0.5)
|
| 223 |
+
return BatchResizeTransform(h, w, newh, neww, self.interp)
|
| 224 |
+
|
| 225 |
+
class EntityCrop(Augmentation):
|
| 226 |
+
def __init__(self, crop_ratio, stride_ratio, sample_num, is_train):
|
| 227 |
+
super().__init__()
|
| 228 |
+
self._init(locals())
|
| 229 |
+
|
| 230 |
+
def get_transform(self, image):
|
| 231 |
+
h, w = image.shape[:2]
|
| 232 |
+
crop_axises, crop_indexes = self.get_crop_axises((h, w))
|
| 233 |
+
transform = EntityCropTransform(crop_axises, crop_indexes)
|
| 234 |
+
return transform
|
| 235 |
+
|
| 236 |
+
def get_crop_axises(self, image_size):
|
| 237 |
+
h, w = image_size
|
| 238 |
+
crop_w = int(self.crop_ratio*w)
|
| 239 |
+
crop_h = int(self.crop_ratio*h)
|
| 240 |
+
# if self.is_train:
|
| 241 |
+
stride_w = int(self.stride_ratio*w)
|
| 242 |
+
stride_h = int(self.stride_ratio*h)
|
| 243 |
+
# pdb.set_trace()
|
| 244 |
+
|
| 245 |
+
crop_axises = []
|
| 246 |
+
for starth in range(0, h, stride_h):
|
| 247 |
+
for startw in range(0, w, stride_w):
|
| 248 |
+
endh = min(starth+crop_h, h)
|
| 249 |
+
endw = min(startw+crop_w, w)
|
| 250 |
+
starth = int(endh-crop_h)
|
| 251 |
+
startw = int(endw-crop_w)
|
| 252 |
+
crop_axises.append([startw, starth, endw, endh])
|
| 253 |
+
if self.is_train:
|
| 254 |
+
crop_indexes = random.sample([i for i in range(len(crop_axises))], self.sample_num)
|
| 255 |
+
crop_axises = [crop_axises[i] for i in crop_indexes]
|
| 256 |
+
else:
|
| 257 |
+
crop_indexes = [i for i in range(self.sample_num)]
|
| 258 |
+
# left_upper = [0, 0, crop_w, crop_h]
|
| 259 |
+
# right_upper = [w-crop_w, 0, w, crop_h]
|
| 260 |
+
# left_bottom = [0, h-crop_h, crop_w, h]
|
| 261 |
+
# right_bottom = [w-crop_w, h-crop_h, w, h]
|
| 262 |
+
|
| 263 |
+
# crop_axises = [left_upper, right_upper, left_bottom, right_bottom]
|
| 264 |
+
# crop_indexes = [0,1,2,3]
|
| 265 |
+
assert len(crop_axises)==len(crop_indexes)
|
| 266 |
+
return crop_axises, crop_indexes
|
| 267 |
+
|
| 268 |
+
def transform_instance_annotations_crop(
|
| 269 |
+
annotation, transforms, image_size, *, keypoint_hflip_indices=None
|
| 270 |
+
):
|
| 271 |
+
"""
|
| 272 |
+
Apply transforms to box, segmentation and keypoints annotations of a single instance.
|
| 273 |
+
|
| 274 |
+
It will use `transforms.apply_box` for the box, and
|
| 275 |
+
`transforms.apply_coords` for segmentation polygons & keypoints.
|
| 276 |
+
If you need anything more specially designed for each data structure,
|
| 277 |
+
you'll need to implement your own version of this function or the transforms.
|
| 278 |
+
|
| 279 |
+
Args:
|
| 280 |
+
annotation (dict): dict of instance annotations for a single instance.
|
| 281 |
+
It will be modified in-place.
|
| 282 |
+
transforms (TransformList or list[Transform]):
|
| 283 |
+
image_size (tuple): the height, width of the transformed image
|
| 284 |
+
keypoint_hflip_indices (ndarray[int]): see `create_keypoint_hflip_indices`.
|
| 285 |
+
|
| 286 |
+
Returns:
|
| 287 |
+
dict:
|
| 288 |
+
the same input dict with fields "bbox", "segmentation", "keypoints"
|
| 289 |
+
transformed according to `transforms`.
|
| 290 |
+
The "bbox_mode" field will be set to XYXY_ABS.
|
| 291 |
+
"""
|
| 292 |
+
if isinstance(transforms, (tuple, list)):
|
| 293 |
+
transforms = T.TransformList(transforms)
|
| 294 |
+
# bbox is 1d (per-instance bounding box)
|
| 295 |
+
bbox = BoxMode.convert(annotation["bbox"], annotation["bbox_mode"], BoxMode.XYXY_ABS)
|
| 296 |
+
|
| 297 |
+
# clip transformed bbox to image size
|
| 298 |
+
bboxes_info = transforms.apply_box(np.array([bbox]))[0].clip(min=0)
|
| 299 |
+
annotation["bbox"] = np.minimum(bbox, list(image_size + image_size)[::-1])
|
| 300 |
+
annotation["bbox"] = bboxes_info[...,:4]
|
| 301 |
+
annotation["bbox_mode"] = BoxMode.XYXY_ABS
|
| 302 |
+
annotation["bbox_valid"] = bboxes_info[...,4]
|
| 303 |
+
for transform_type in transforms:
|
| 304 |
+
if isinstance(transform_type, EntityCropTransform):
|
| 305 |
+
annotation["crop_axises"] = transform_type.crop_axises
|
| 306 |
+
annotation["crop_indexes"] = transform_type.crop_indexes
|
| 307 |
+
|
| 308 |
+
if "segmentation" in annotation:
|
| 309 |
+
segm = annotation["segmentation"]
|
| 310 |
+
assert isinstance(segm, dict), "requiring segmentation encoding -> RLE"
|
| 311 |
+
# RLE
|
| 312 |
+
mask = mask_util.decode(segm)
|
| 313 |
+
mask = transforms.apply_segmentation(mask)
|
| 314 |
+
annotation["segmentation"] = mask
|
| 315 |
+
return annotation
|
| 316 |
+
|
| 317 |
+
def annotations_to_instances_crop(annos, image_size, mask_format="polygon", return_indexes=False):
|
| 318 |
+
"""
|
| 319 |
+
Create an :class:`Instances` object used by the models,
|
| 320 |
+
from instance annotations in the dataset dict.
|
| 321 |
+
|
| 322 |
+
Args:
|
| 323 |
+
annos (list[dict]): a list of instance annotations in one image, each
|
| 324 |
+
element for one instance.
|
| 325 |
+
image_size (tuple): height, width
|
| 326 |
+
|
| 327 |
+
Returns:
|
| 328 |
+
Instances:
|
| 329 |
+
It will contain fields "gt_boxes", "gt_classes",
|
| 330 |
+
"gt_masks", "gt_keypoints", if they can be obtained from `annos`.
|
| 331 |
+
This is the format that builtin models expect.
|
| 332 |
+
"""
|
| 333 |
+
###
|
| 334 |
+
all_boxes = []
|
| 335 |
+
all_boxes_valid = []
|
| 336 |
+
all_classes = []
|
| 337 |
+
all_segmentations = []
|
| 338 |
+
all_iscrowds = []
|
| 339 |
+
# pdb.set_trace()
|
| 340 |
+
annos_num = len(annos)
|
| 341 |
+
patches_num = len(annos[0]["bbox"])
|
| 342 |
+
for ann_index, obj in enumerate(annos):
|
| 343 |
+
for split_index in range(len(obj["bbox"])):
|
| 344 |
+
all_boxes.append(BoxMode.convert(obj["bbox"][split_index], obj["bbox_mode"], BoxMode.XYXY_ABS))
|
| 345 |
+
all_boxes_valid.append(obj["bbox_valid"][split_index])
|
| 346 |
+
all_classes.append(obj["category_id"])
|
| 347 |
+
all_segmentations.append(obj["segmentation"][split_index])
|
| 348 |
+
all_iscrowds.append(obj["iscrowd"])
|
| 349 |
+
# print("ann_index:{}, split_index:{}".format(ann_index, split_index))
|
| 350 |
+
|
| 351 |
+
new_targets = []
|
| 352 |
+
crop_axises = annos[0]["crop_axises"]
|
| 353 |
+
# pdb.set_trace()
|
| 354 |
+
crop_size = (crop_axises[0][3], crop_axises[0][2])
|
| 355 |
+
crop_axises = torch.tensor(crop_axises)
|
| 356 |
+
|
| 357 |
+
for split_index in range(patches_num):
|
| 358 |
+
new_targets.append(Instances(crop_size))
|
| 359 |
+
# pdb.set_trace()
|
| 360 |
+
## boxes
|
| 361 |
+
new_targets[-1].gt_boxes = Boxes(all_boxes[split_index::patches_num])
|
| 362 |
+
new_targets[-1].gt_boxes_valid = torch.tensor(all_boxes_valid[split_index::patches_num], dtype=torch.int64)
|
| 363 |
+
## categories
|
| 364 |
+
new_targets[-1].gt_classes = torch.tensor(all_classes[split_index::patches_num], dtype=torch.int64)
|
| 365 |
+
|
| 366 |
+
## masks
|
| 367 |
+
if "segmentation" in annos[0]:
|
| 368 |
+
new_targets[-1].gt_masks = BitMasks(torch.stack([torch.from_numpy(np.ascontiguousarray(x)) for x in all_segmentations[split_index::patches_num]]))
|
| 369 |
+
|
| 370 |
+
# pdb.set_trace()
|
| 371 |
+
if return_indexes:
|
| 372 |
+
return new_targets, crop_axises, annos[0]["crop_indexes"]
|
| 373 |
+
else:
|
| 374 |
+
return new_targets, crop_axises
|
| 375 |
+
|
| 376 |
+
class EntityCascadedCrop(Augmentation):
|
| 377 |
+
def __init__(self, crop_ratio, stride_ratio, sample_num, cascade_num, is_train):
|
| 378 |
+
super().__init__()
|
| 379 |
+
self._init(locals())
|
| 380 |
+
|
| 381 |
+
def get_transform(self, image):
|
| 382 |
+
h, w = image.shape[:2]
|
| 383 |
+
crop_axises, crop_indexes = self.get_crop_axises((h, w))
|
| 384 |
+
transform = EntityCropTransform(crop_axises, crop_indexes)
|
| 385 |
+
return transform
|
| 386 |
+
|
| 387 |
+
def get_crop_axises(self, image_size):
|
| 388 |
+
h, w = image_size
|
| 389 |
+
# for i in range(self.cascade_num):
|
| 390 |
+
# crop_w = int((self.crop_ratio**(i+1))*w)
|
| 391 |
+
# crop_h = int((self.crop_ratio**(i+1))*h)
|
| 392 |
+
# stride_w = int((self.stride_ratio**(i+1))*w)
|
| 393 |
+
# stride_h = int((self.stride_ratio**(i+1))*h)
|
| 394 |
+
# crop_axises = []
|
| 395 |
+
# if i==0:
|
| 396 |
+
|
| 397 |
+
# for starth in range(0, )
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
crop_axises = []
|
| 401 |
+
for starth in range(0, h, stride_h):
|
| 402 |
+
for startw in range(0, w, stride_w):
|
| 403 |
+
endh = min(starth+crop_h, h)
|
| 404 |
+
endw = min(startw+crop_w, w)
|
| 405 |
+
starth = int(endh-crop_h)
|
| 406 |
+
startw = int(endw-crop_w)
|
| 407 |
+
crop_axises.append([startw, starth, endw, endh])
|
| 408 |
+
if self.is_train:
|
| 409 |
+
crop_indexes = random.sample([i for i in range(len(crop_axises))], self.sample_num)
|
| 410 |
+
crop_axises = [crop_axises[i] for i in crop_indexes]
|
| 411 |
+
else:
|
| 412 |
+
crop_indexes = [i for i in range(self.sample_num)]
|
| 413 |
+
# left_upper = [0, 0, crop_w, crop_h]
|
| 414 |
+
# right_upper = [w-crop_w, 0, w, crop_h]
|
| 415 |
+
# left_bottom = [0, h-crop_h, crop_w, h]
|
| 416 |
+
# right_bottom = [w-crop_w, h-crop_h, w, h]
|
| 417 |
+
|
| 418 |
+
# crop_axises = [left_upper, right_upper, left_bottom, right_bottom]
|
| 419 |
+
# crop_indexes = [0,1,2,3]
|
| 420 |
+
assert len(crop_axises)==len(crop_indexes)
|
| 421 |
+
return crop_axises, crop_indexes
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/entity_crop_dataset_mapper.py
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import copy
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
import pycocotools.mask as mask_util
|
| 7 |
+
import torch
|
| 8 |
+
import random
|
| 9 |
+
from torch.nn import functional as F
|
| 10 |
+
|
| 11 |
+
from detectron2.config import configurable
|
| 12 |
+
from detectron2.data import detection_utils as utils
|
| 13 |
+
from detectron2.data import transforms as T
|
| 14 |
+
from detectron2.projects.point_rend import ColorAugSSDTransform
|
| 15 |
+
from detectron2.structures import BitMasks, Instances, polygons_to_bitmask
|
| 16 |
+
|
| 17 |
+
from .crop_augmentations import BatchResizeShortestEdge, EntityCrop, EntityCropTransform, transform_instance_annotations_crop, annotations_to_instances_crop
|
| 18 |
+
|
| 19 |
+
import copy
|
| 20 |
+
import pdb
|
| 21 |
+
|
| 22 |
+
__all__ = ["EntityCropDatasetMapper"]
|
| 23 |
+
|
| 24 |
+
def empty_instances_indexes(
|
| 25 |
+
instances, by_box=True, by_mask=True, box_threshold=1e-5, return_mask=False
|
| 26 |
+
):
|
| 27 |
+
"""
|
| 28 |
+
Filter out empty instances in an `Instances` object.
|
| 29 |
+
|
| 30 |
+
Args:
|
| 31 |
+
instances (Instances):
|
| 32 |
+
by_box (bool): whether to filter out instances with empty boxes
|
| 33 |
+
by_mask (bool): whether to filter out instances with empty masks
|
| 34 |
+
box_threshold (float): minimum width and height to be considered non-empty
|
| 35 |
+
return_mask (bool): whether to return boolean mask of filtered instances
|
| 36 |
+
|
| 37 |
+
Returns:
|
| 38 |
+
Instances: the filtered instances.
|
| 39 |
+
tensor[bool], optional: boolean mask of filtered instances
|
| 40 |
+
"""
|
| 41 |
+
assert by_box or by_mask
|
| 42 |
+
r = []
|
| 43 |
+
if by_box:
|
| 44 |
+
r.append(instances.gt_boxes.nonempty(threshold=box_threshold))
|
| 45 |
+
if instances.has("gt_masks") and by_mask:
|
| 46 |
+
r.append(instances.gt_masks.nonempty())
|
| 47 |
+
|
| 48 |
+
# TODO: can also filter visible keypoints
|
| 49 |
+
|
| 50 |
+
if not r:
|
| 51 |
+
return instances
|
| 52 |
+
m = r[0]
|
| 53 |
+
for x in r[1:]:
|
| 54 |
+
m = m & x
|
| 55 |
+
return m
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class EntityCropDatasetMapper:
|
| 59 |
+
"""
|
| 60 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 61 |
+
and map it into a format used by MaskFormer for instance segmentation.
|
| 62 |
+
|
| 63 |
+
The callable currently does the following:
|
| 64 |
+
|
| 65 |
+
1. Read the image from "file_name"
|
| 66 |
+
2. Applies geometric transforms to the image and annotation
|
| 67 |
+
3. Find and applies suitable cropping to the image and annotation
|
| 68 |
+
4. Prepare image and annotation to Tensors
|
| 69 |
+
"""
|
| 70 |
+
|
| 71 |
+
@configurable
|
| 72 |
+
def __init__(
|
| 73 |
+
self,
|
| 74 |
+
is_train=True,
|
| 75 |
+
*,
|
| 76 |
+
cfg,
|
| 77 |
+
image_format,
|
| 78 |
+
instance_mask_format,
|
| 79 |
+
size_divisibility,
|
| 80 |
+
):
|
| 81 |
+
"""
|
| 82 |
+
NOTE: this interface is experimental.
|
| 83 |
+
Args:
|
| 84 |
+
is_train: for training or inference
|
| 85 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 86 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 87 |
+
size_divisibility: pad image size to be divisible by this value
|
| 88 |
+
"""
|
| 89 |
+
self.is_train = is_train
|
| 90 |
+
self.cfg = cfg
|
| 91 |
+
|
| 92 |
+
self.img_format = image_format
|
| 93 |
+
self.instance_mask_format = instance_mask_format
|
| 94 |
+
self.size_divisibility = size_divisibility
|
| 95 |
+
|
| 96 |
+
def generate_augs(self):
|
| 97 |
+
## make sure the shortest side and flip for both full image and crops
|
| 98 |
+
if self.is_train:
|
| 99 |
+
shortest_side = np.random.choice(self.cfg.INPUT.MIN_SIZE_TRAIN)
|
| 100 |
+
flip_flag = (random.random() >= 0.5)
|
| 101 |
+
else:
|
| 102 |
+
shortest_side = np.random.choice([self.cfg.INPUT.MIN_SIZE_TEST])
|
| 103 |
+
flip_flag = False
|
| 104 |
+
|
| 105 |
+
augs = [
|
| 106 |
+
T.RandomFlip(
|
| 107 |
+
1.0 if flip_flag else 0.0,
|
| 108 |
+
horizontal=self.cfg.INPUT.RANDOM_FLIP == "horizontal",
|
| 109 |
+
vertical=self.cfg.INPUT.RANDOM_FLIP == "vertical",
|
| 110 |
+
),
|
| 111 |
+
|
| 112 |
+
T.ResizeShortestEdge(
|
| 113 |
+
(shortest_side,),
|
| 114 |
+
self.cfg.INPUT.MAX_SIZE_TRAIN if self.is_train else self.cfg.INPUT.MAX_SIZE_TEST,
|
| 115 |
+
self.cfg.INPUT.MIN_SIZE_TRAIN_SAMPLING,
|
| 116 |
+
),
|
| 117 |
+
|
| 118 |
+
]
|
| 119 |
+
if self.cfg.INPUT.COLOR_AUG_SSD:
|
| 120 |
+
augs.append(ColorAugSSDTransform(img_format=self.cfg.INPUT.FORMAT))
|
| 121 |
+
|
| 122 |
+
# Build original image augmentation
|
| 123 |
+
crop_augs = []
|
| 124 |
+
crop_augs.append(T.RandomFlip(
|
| 125 |
+
1.0 if flip_flag else 0.0,
|
| 126 |
+
horizontal=self.cfg.INPUT.RANDOM_FLIP == "horizontal",
|
| 127 |
+
vertical=self.cfg.INPUT.RANDOM_FLIP == "vertical",
|
| 128 |
+
))
|
| 129 |
+
entity_crops = EntityCrop(self.cfg.ENTITY.CROP_AREA_RATIO,
|
| 130 |
+
self.cfg.ENTITY.CROP_STRIDE_RATIO,
|
| 131 |
+
self.cfg.ENTITY.CROP_SAMPLE_NUM_TRAIN if self.is_train else self.cfg.ENTITY.CROP_SAMPLE_NUM_TEST,
|
| 132 |
+
self.is_train)
|
| 133 |
+
crop_augs.append(entity_crops)
|
| 134 |
+
|
| 135 |
+
entity_resize = BatchResizeShortestEdge((shortest_side,), self.cfg.INPUT.MAX_SIZE_TRAIN, self.cfg.INPUT.MIN_SIZE_TRAIN_SAMPLING)
|
| 136 |
+
crop_augs.append(entity_resize)
|
| 137 |
+
crop_augs = T.AugmentationList(crop_augs)
|
| 138 |
+
return augs, crop_augs
|
| 139 |
+
|
| 140 |
+
@classmethod
|
| 141 |
+
def from_config(cls, cfg, is_train=True):
|
| 142 |
+
ret = {
|
| 143 |
+
"is_train": is_train,
|
| 144 |
+
"cfg": cfg,
|
| 145 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 146 |
+
"instance_mask_format": cfg.INPUT.MASK_FORMAT,
|
| 147 |
+
"size_divisibility": cfg.INPUT.SIZE_DIVISIBILITY,
|
| 148 |
+
}
|
| 149 |
+
return ret
|
| 150 |
+
|
| 151 |
+
def __call__(self, dataset_dict):
|
| 152 |
+
"""
|
| 153 |
+
Args:
|
| 154 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 155 |
+
Returns:
|
| 156 |
+
dict: a format that builtin models in detectron2 accept
|
| 157 |
+
"""
|
| 158 |
+
# assert self.is_train, "MaskFormerPanopticDatasetMapper should only be used for training!"
|
| 159 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 160 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
|
| 161 |
+
utils.check_image_size(dataset_dict, image)
|
| 162 |
+
|
| 163 |
+
tfm_gens, crop_augs = self.generate_augs()
|
| 164 |
+
### original images
|
| 165 |
+
aug_input_ori = T.AugInput(copy.deepcopy(image))
|
| 166 |
+
aug_input_ori, transforms_ori = T.apply_transform_gens(tfm_gens, aug_input_ori)
|
| 167 |
+
image_ori = aug_input_ori.image
|
| 168 |
+
dataset_dict["image"] = torch.as_tensor(np.ascontiguousarray(image_ori.transpose(2, 0, 1)))
|
| 169 |
+
|
| 170 |
+
#### crop images
|
| 171 |
+
aug_input_crop = T.AugInput(copy.deepcopy(image))
|
| 172 |
+
transforms_crop = crop_augs(aug_input_crop)
|
| 173 |
+
image_crop = aug_input_crop.image
|
| 174 |
+
assert len(image_crop.shape)==4, "the image shape must be [N, H, W, C]"
|
| 175 |
+
dataset_dict["image_crop"] = torch.as_tensor(np.ascontiguousarray(image_crop.transpose(0, 3, 1, 2)))
|
| 176 |
+
|
| 177 |
+
#### transform instnace masks of original images
|
| 178 |
+
annos_ori = [utils.transform_instance_annotations(obj, transforms_ori, image_ori.shape[:2]) for obj in copy.deepcopy(dataset_dict["annotations"]) if obj.get("iscrowd", 0) == 0]
|
| 179 |
+
image_shape = image_ori.shape[:2]
|
| 180 |
+
if self.is_train:
|
| 181 |
+
instances_ori = utils.annotations_to_instances(annos_ori, image_shape, mask_format=self.instance_mask_format)
|
| 182 |
+
gt_valid = empty_instances_indexes(instances_ori).int()
|
| 183 |
+
instances_ori.gt_boxes_valid = gt_valid
|
| 184 |
+
dataset_dict["instances"] = instances_ori
|
| 185 |
+
|
| 186 |
+
#### transform instnace masks of crop images
|
| 187 |
+
assert len(image_crop.shape)==4, "the image shape must be [N, H, W, C]"
|
| 188 |
+
image_shape = image_crop.shape[1:3] # h, w
|
| 189 |
+
if self.is_train:
|
| 190 |
+
annos_crop = [transform_instance_annotations_crop(obj, transforms_crop, image_shape) for obj in copy.deepcopy(dataset_dict["annotations"]) if obj.get("iscrowd", 0) == 0]
|
| 191 |
+
patch_instances, crop_ori_size, crop_indexes = annotations_to_instances_crop(annos_crop, image_shape, mask_format=self.instance_mask_format, return_indexes=True)
|
| 192 |
+
for patch_instance in patch_instances:
|
| 193 |
+
gt_valid = empty_instances_indexes(patch_instance).int()
|
| 194 |
+
patch_instance.gt_boxes_valid = gt_valid
|
| 195 |
+
dataset_dict["instances_crop"] = patch_instances
|
| 196 |
+
dataset_dict["crop_region"] = crop_ori_size
|
| 197 |
+
dataset_dict["crop_indexes"] = crop_indexes
|
| 198 |
+
else:
|
| 199 |
+
for transform_type in transforms_crop:
|
| 200 |
+
if isinstance(transform_type, EntityCropTransform):
|
| 201 |
+
crop_axises = transform_type.crop_axises
|
| 202 |
+
crop_indexes = transform_type.crop_indexes
|
| 203 |
+
dataset_dict["crop_region"] = torch.tensor(crop_axises)
|
| 204 |
+
dataset_dict["crop_indexes"] = crop_indexes
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
dataset_dict.pop("annotations")
|
| 208 |
+
|
| 209 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/mask_former_instance_dataset_mapper.py
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import copy
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
import pycocotools.mask as mask_util
|
| 7 |
+
import torch
|
| 8 |
+
from torch.nn import functional as F
|
| 9 |
+
|
| 10 |
+
from detectron2.config import configurable
|
| 11 |
+
from detectron2.data import detection_utils as utils
|
| 12 |
+
from detectron2.data import transforms as T
|
| 13 |
+
from detectron2.projects.point_rend import ColorAugSSDTransform
|
| 14 |
+
from detectron2.structures import BitMasks, Instances, polygons_to_bitmask
|
| 15 |
+
|
| 16 |
+
__all__ = ["MaskFormerInstanceDatasetMapper"]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class MaskFormerInstanceDatasetMapper:
|
| 20 |
+
"""
|
| 21 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 22 |
+
and map it into a format used by MaskFormer for instance segmentation.
|
| 23 |
+
|
| 24 |
+
The callable currently does the following:
|
| 25 |
+
|
| 26 |
+
1. Read the image from "file_name"
|
| 27 |
+
2. Applies geometric transforms to the image and annotation
|
| 28 |
+
3. Find and applies suitable cropping to the image and annotation
|
| 29 |
+
4. Prepare image and annotation to Tensors
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
@configurable
|
| 33 |
+
def __init__(
|
| 34 |
+
self,
|
| 35 |
+
is_train=True,
|
| 36 |
+
*,
|
| 37 |
+
augmentations,
|
| 38 |
+
image_format,
|
| 39 |
+
size_divisibility,
|
| 40 |
+
):
|
| 41 |
+
"""
|
| 42 |
+
NOTE: this interface is experimental.
|
| 43 |
+
Args:
|
| 44 |
+
is_train: for training or inference
|
| 45 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 46 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 47 |
+
size_divisibility: pad image size to be divisible by this value
|
| 48 |
+
"""
|
| 49 |
+
self.is_train = is_train
|
| 50 |
+
self.tfm_gens = augmentations
|
| 51 |
+
self.img_format = image_format
|
| 52 |
+
self.size_divisibility = size_divisibility
|
| 53 |
+
|
| 54 |
+
logger = logging.getLogger(__name__)
|
| 55 |
+
mode = "training" if is_train else "inference"
|
| 56 |
+
logger.info(f"[{self.__class__.__name__}] Augmentations used in {mode}: {augmentations}")
|
| 57 |
+
|
| 58 |
+
@classmethod
|
| 59 |
+
def from_config(cls, cfg, is_train=True):
|
| 60 |
+
# Build augmentation
|
| 61 |
+
augs = [
|
| 62 |
+
T.ResizeShortestEdge(
|
| 63 |
+
cfg.INPUT.MIN_SIZE_TRAIN,
|
| 64 |
+
cfg.INPUT.MAX_SIZE_TRAIN,
|
| 65 |
+
cfg.INPUT.MIN_SIZE_TRAIN_SAMPLING,
|
| 66 |
+
)
|
| 67 |
+
]
|
| 68 |
+
if cfg.INPUT.CROP.ENABLED:
|
| 69 |
+
augs.append(
|
| 70 |
+
T.RandomCrop(
|
| 71 |
+
cfg.INPUT.CROP.TYPE,
|
| 72 |
+
cfg.INPUT.CROP.SIZE,
|
| 73 |
+
)
|
| 74 |
+
)
|
| 75 |
+
if cfg.INPUT.COLOR_AUG_SSD:
|
| 76 |
+
augs.append(ColorAugSSDTransform(img_format=cfg.INPUT.FORMAT))
|
| 77 |
+
augs.append(T.RandomFlip())
|
| 78 |
+
|
| 79 |
+
ret = {
|
| 80 |
+
"is_train": is_train,
|
| 81 |
+
"augmentations": augs,
|
| 82 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 83 |
+
"size_divisibility": cfg.INPUT.SIZE_DIVISIBILITY,
|
| 84 |
+
}
|
| 85 |
+
return ret
|
| 86 |
+
|
| 87 |
+
def __call__(self, dataset_dict):
|
| 88 |
+
"""
|
| 89 |
+
Args:
|
| 90 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 91 |
+
|
| 92 |
+
Returns:
|
| 93 |
+
dict: a format that builtin models in detectron2 accept
|
| 94 |
+
"""
|
| 95 |
+
assert self.is_train, "MaskFormerPanopticDatasetMapper should only be used for training!"
|
| 96 |
+
|
| 97 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 98 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
|
| 99 |
+
utils.check_image_size(dataset_dict, image)
|
| 100 |
+
|
| 101 |
+
aug_input = T.AugInput(image)
|
| 102 |
+
aug_input, transforms = T.apply_transform_gens(self.tfm_gens, aug_input)
|
| 103 |
+
image = aug_input.image
|
| 104 |
+
|
| 105 |
+
# transform instnace masks
|
| 106 |
+
assert "annotations" in dataset_dict
|
| 107 |
+
for anno in dataset_dict["annotations"]:
|
| 108 |
+
anno.pop("keypoints", None)
|
| 109 |
+
|
| 110 |
+
annos = [
|
| 111 |
+
utils.transform_instance_annotations(obj, transforms, image.shape[:2])
|
| 112 |
+
for obj in dataset_dict.pop("annotations")
|
| 113 |
+
if obj.get("iscrowd", 0) == 0
|
| 114 |
+
]
|
| 115 |
+
|
| 116 |
+
if len(annos):
|
| 117 |
+
assert "segmentation" in annos[0]
|
| 118 |
+
segms = [obj["segmentation"] for obj in annos]
|
| 119 |
+
masks = []
|
| 120 |
+
for segm in segms:
|
| 121 |
+
if isinstance(segm, list):
|
| 122 |
+
# polygon
|
| 123 |
+
masks.append(polygons_to_bitmask(segm, *image.shape[:2]))
|
| 124 |
+
elif isinstance(segm, dict):
|
| 125 |
+
# COCO RLE
|
| 126 |
+
masks.append(mask_util.decode(segm))
|
| 127 |
+
elif isinstance(segm, np.ndarray):
|
| 128 |
+
assert segm.ndim == 2, "Expect segmentation of 2 dimensions, got {}.".format(
|
| 129 |
+
segm.ndim
|
| 130 |
+
)
|
| 131 |
+
# mask array
|
| 132 |
+
masks.append(segm)
|
| 133 |
+
else:
|
| 134 |
+
raise ValueError(
|
| 135 |
+
"Cannot convert segmentation of type '{}' to BitMasks!"
|
| 136 |
+
"Supported types are: polygons as list[list[float] or ndarray],"
|
| 137 |
+
" COCO-style RLE as a dict, or a binary segmentation mask "
|
| 138 |
+
" in a 2D numpy array of shape HxW.".format(type(segm))
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
# Pad image and segmentation label here!
|
| 142 |
+
image = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 143 |
+
masks = [torch.from_numpy(np.ascontiguousarray(x)) for x in masks]
|
| 144 |
+
|
| 145 |
+
classes = [int(obj["category_id"]) for obj in annos]
|
| 146 |
+
classes = torch.tensor(classes, dtype=torch.int64)
|
| 147 |
+
|
| 148 |
+
if self.size_divisibility > 0:
|
| 149 |
+
image_size = (image.shape[-2], image.shape[-1])
|
| 150 |
+
padding_size = [
|
| 151 |
+
0,
|
| 152 |
+
self.size_divisibility - image_size[1],
|
| 153 |
+
0,
|
| 154 |
+
self.size_divisibility - image_size[0],
|
| 155 |
+
]
|
| 156 |
+
# pad image
|
| 157 |
+
image = F.pad(image, padding_size, value=128).contiguous()
|
| 158 |
+
# pad mask
|
| 159 |
+
masks = [F.pad(x, padding_size, value=0).contiguous() for x in masks]
|
| 160 |
+
|
| 161 |
+
image_shape = (image.shape[-2], image.shape[-1]) # h, w
|
| 162 |
+
|
| 163 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 164 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 165 |
+
# Therefore it's important to use torch.Tensor.
|
| 166 |
+
dataset_dict["image"] = image
|
| 167 |
+
|
| 168 |
+
# Prepare per-category binary masks
|
| 169 |
+
instances = Instances(image_shape)
|
| 170 |
+
instances.gt_classes = classes
|
| 171 |
+
if len(masks) == 0:
|
| 172 |
+
# Some image does not have annotation (all ignored)
|
| 173 |
+
instances.gt_masks = torch.zeros((0, image.shape[-2], image.shape[-1]))
|
| 174 |
+
else:
|
| 175 |
+
masks = BitMasks(torch.stack(masks))
|
| 176 |
+
instances.gt_masks = masks.tensor
|
| 177 |
+
|
| 178 |
+
dataset_dict["instances"] = instances
|
| 179 |
+
|
| 180 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/mask_former_panoptic_dataset_mapper.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import copy
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
import torch
|
| 7 |
+
from torch.nn import functional as F
|
| 8 |
+
|
| 9 |
+
from detectron2.config import configurable
|
| 10 |
+
from detectron2.data import detection_utils as utils
|
| 11 |
+
from detectron2.data import transforms as T
|
| 12 |
+
from detectron2.structures import BitMasks, Instances
|
| 13 |
+
|
| 14 |
+
from .mask_former_semantic_dataset_mapper import MaskFormerSemanticDatasetMapper
|
| 15 |
+
|
| 16 |
+
__all__ = ["MaskFormerPanopticDatasetMapper"]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class MaskFormerPanopticDatasetMapper(MaskFormerSemanticDatasetMapper):
|
| 20 |
+
"""
|
| 21 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 22 |
+
and map it into a format used by MaskFormer for panoptic segmentation.
|
| 23 |
+
|
| 24 |
+
The callable currently does the following:
|
| 25 |
+
|
| 26 |
+
1. Read the image from "file_name"
|
| 27 |
+
2. Applies geometric transforms to the image and annotation
|
| 28 |
+
3. Find and applies suitable cropping to the image and annotation
|
| 29 |
+
4. Prepare image and annotation to Tensors
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
@configurable
|
| 33 |
+
def __init__(
|
| 34 |
+
self,
|
| 35 |
+
is_train=True,
|
| 36 |
+
*,
|
| 37 |
+
augmentations,
|
| 38 |
+
image_format,
|
| 39 |
+
ignore_label,
|
| 40 |
+
size_divisibility,
|
| 41 |
+
):
|
| 42 |
+
"""
|
| 43 |
+
NOTE: this interface is experimental.
|
| 44 |
+
Args:
|
| 45 |
+
is_train: for training or inference
|
| 46 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 47 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 48 |
+
ignore_label: the label that is ignored to evaluation
|
| 49 |
+
size_divisibility: pad image size to be divisible by this value
|
| 50 |
+
"""
|
| 51 |
+
super().__init__(
|
| 52 |
+
is_train,
|
| 53 |
+
augmentations=augmentations,
|
| 54 |
+
image_format=image_format,
|
| 55 |
+
ignore_label=ignore_label,
|
| 56 |
+
size_divisibility=size_divisibility,
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
def __call__(self, dataset_dict):
|
| 60 |
+
"""
|
| 61 |
+
Args:
|
| 62 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 63 |
+
|
| 64 |
+
Returns:
|
| 65 |
+
dict: a format that builtin models in detectron2 accept
|
| 66 |
+
"""
|
| 67 |
+
assert self.is_train, "MaskFormerPanopticDatasetMapper should only be used for training!"
|
| 68 |
+
|
| 69 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 70 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
|
| 71 |
+
utils.check_image_size(dataset_dict, image)
|
| 72 |
+
|
| 73 |
+
# semantic segmentation
|
| 74 |
+
if "sem_seg_file_name" in dataset_dict:
|
| 75 |
+
# PyTorch transformation not implemented for uint16, so converting it to double first
|
| 76 |
+
sem_seg_gt = utils.read_image(dataset_dict.pop("sem_seg_file_name")).astype("double")
|
| 77 |
+
else:
|
| 78 |
+
sem_seg_gt = None
|
| 79 |
+
|
| 80 |
+
# panoptic segmentation
|
| 81 |
+
if "pan_seg_file_name" in dataset_dict:
|
| 82 |
+
pan_seg_gt = utils.read_image(dataset_dict.pop("pan_seg_file_name"), "RGB")
|
| 83 |
+
segments_info = dataset_dict["segments_info"]
|
| 84 |
+
else:
|
| 85 |
+
pan_seg_gt = None
|
| 86 |
+
segments_info = None
|
| 87 |
+
|
| 88 |
+
if pan_seg_gt is None:
|
| 89 |
+
raise ValueError(
|
| 90 |
+
"Cannot find 'pan_seg_file_name' for panoptic segmentation dataset {}.".format(
|
| 91 |
+
dataset_dict["file_name"]
|
| 92 |
+
)
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
aug_input = T.AugInput(image, sem_seg=sem_seg_gt)
|
| 96 |
+
aug_input, transforms = T.apply_transform_gens(self.tfm_gens, aug_input)
|
| 97 |
+
image = aug_input.image
|
| 98 |
+
if sem_seg_gt is not None:
|
| 99 |
+
sem_seg_gt = aug_input.sem_seg
|
| 100 |
+
|
| 101 |
+
# apply the same transformation to panoptic segmentation
|
| 102 |
+
pan_seg_gt = transforms.apply_segmentation(pan_seg_gt)
|
| 103 |
+
|
| 104 |
+
from panopticapi.utils import rgb2id
|
| 105 |
+
|
| 106 |
+
pan_seg_gt = rgb2id(pan_seg_gt)
|
| 107 |
+
|
| 108 |
+
# Pad image and segmentation label here!
|
| 109 |
+
image = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 110 |
+
if sem_seg_gt is not None:
|
| 111 |
+
sem_seg_gt = torch.as_tensor(sem_seg_gt.astype("long"))
|
| 112 |
+
pan_seg_gt = torch.as_tensor(pan_seg_gt.astype("long"))
|
| 113 |
+
|
| 114 |
+
if self.size_divisibility > 0:
|
| 115 |
+
image_size = (image.shape[-2], image.shape[-1])
|
| 116 |
+
padding_size = [
|
| 117 |
+
0,
|
| 118 |
+
self.size_divisibility - image_size[1],
|
| 119 |
+
0,
|
| 120 |
+
self.size_divisibility - image_size[0],
|
| 121 |
+
]
|
| 122 |
+
image = F.pad(image, padding_size, value=128).contiguous()
|
| 123 |
+
if sem_seg_gt is not None:
|
| 124 |
+
sem_seg_gt = F.pad(sem_seg_gt, padding_size, value=self.ignore_label).contiguous()
|
| 125 |
+
pan_seg_gt = F.pad(
|
| 126 |
+
pan_seg_gt, padding_size, value=0
|
| 127 |
+
).contiguous() # 0 is the VOID panoptic label
|
| 128 |
+
|
| 129 |
+
image_shape = (image.shape[-2], image.shape[-1]) # h, w
|
| 130 |
+
|
| 131 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 132 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 133 |
+
# Therefore it's important to use torch.Tensor.
|
| 134 |
+
dataset_dict["image"] = image
|
| 135 |
+
if sem_seg_gt is not None:
|
| 136 |
+
dataset_dict["sem_seg"] = sem_seg_gt.long()
|
| 137 |
+
|
| 138 |
+
if "annotations" in dataset_dict:
|
| 139 |
+
raise ValueError("Pemantic segmentation dataset should not have 'annotations'.")
|
| 140 |
+
|
| 141 |
+
# Prepare per-category binary masks
|
| 142 |
+
pan_seg_gt = pan_seg_gt.numpy()
|
| 143 |
+
instances = Instances(image_shape)
|
| 144 |
+
classes = []
|
| 145 |
+
masks = []
|
| 146 |
+
for segment_info in segments_info:
|
| 147 |
+
class_id = segment_info["category_id"]
|
| 148 |
+
if not segment_info["iscrowd"]:
|
| 149 |
+
classes.append(class_id)
|
| 150 |
+
masks.append(pan_seg_gt == segment_info["id"])
|
| 151 |
+
|
| 152 |
+
classes = np.array(classes)
|
| 153 |
+
instances.gt_classes = torch.tensor(classes, dtype=torch.int64)
|
| 154 |
+
if len(masks) == 0:
|
| 155 |
+
# Some image does not have annotation (all ignored)
|
| 156 |
+
instances.gt_masks = torch.zeros((0, pan_seg_gt.shape[-2], pan_seg_gt.shape[-1]))
|
| 157 |
+
else:
|
| 158 |
+
masks = BitMasks(
|
| 159 |
+
torch.stack([torch.from_numpy(np.ascontiguousarray(x.copy())) for x in masks])
|
| 160 |
+
)
|
| 161 |
+
instances.gt_masks = masks.tensor
|
| 162 |
+
|
| 163 |
+
dataset_dict["instances"] = instances
|
| 164 |
+
|
| 165 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/dataset_mappers/mask_former_semantic_dataset_mapper.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import copy
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
import torch
|
| 7 |
+
from torch.nn import functional as F
|
| 8 |
+
|
| 9 |
+
from detectron2.config import configurable
|
| 10 |
+
from detectron2.data import MetadataCatalog
|
| 11 |
+
from detectron2.data import detection_utils as utils
|
| 12 |
+
from detectron2.data import transforms as T
|
| 13 |
+
from detectron2.projects.point_rend import ColorAugSSDTransform
|
| 14 |
+
from detectron2.structures import BitMasks, Instances
|
| 15 |
+
|
| 16 |
+
__all__ = ["MaskFormerSemanticDatasetMapper"]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class MaskFormerSemanticDatasetMapper:
|
| 20 |
+
"""
|
| 21 |
+
A callable which takes a dataset dict in Detectron2 Dataset format,
|
| 22 |
+
and map it into a format used by MaskFormer for semantic segmentation.
|
| 23 |
+
|
| 24 |
+
The callable currently does the following:
|
| 25 |
+
|
| 26 |
+
1. Read the image from "file_name"
|
| 27 |
+
2. Applies geometric transforms to the image and annotation
|
| 28 |
+
3. Find and applies suitable cropping to the image and annotation
|
| 29 |
+
4. Prepare image and annotation to Tensors
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
@configurable
|
| 33 |
+
def __init__(
|
| 34 |
+
self,
|
| 35 |
+
is_train=True,
|
| 36 |
+
*,
|
| 37 |
+
augmentations,
|
| 38 |
+
image_format,
|
| 39 |
+
ignore_label,
|
| 40 |
+
size_divisibility,
|
| 41 |
+
):
|
| 42 |
+
"""
|
| 43 |
+
NOTE: this interface is experimental.
|
| 44 |
+
Args:
|
| 45 |
+
is_train: for training or inference
|
| 46 |
+
augmentations: a list of augmentations or deterministic transforms to apply
|
| 47 |
+
image_format: an image format supported by :func:`detection_utils.read_image`.
|
| 48 |
+
ignore_label: the label that is ignored to evaluation
|
| 49 |
+
size_divisibility: pad image size to be divisible by this value
|
| 50 |
+
"""
|
| 51 |
+
self.is_train = is_train
|
| 52 |
+
self.tfm_gens = augmentations
|
| 53 |
+
self.img_format = image_format
|
| 54 |
+
self.ignore_label = ignore_label
|
| 55 |
+
self.size_divisibility = size_divisibility
|
| 56 |
+
|
| 57 |
+
logger = logging.getLogger(__name__)
|
| 58 |
+
mode = "training" if is_train else "inference"
|
| 59 |
+
logger.info(f"[{self.__class__.__name__}] Augmentations used in {mode}: {augmentations}")
|
| 60 |
+
|
| 61 |
+
@classmethod
|
| 62 |
+
def from_config(cls, cfg, is_train=True):
|
| 63 |
+
# Build augmentation
|
| 64 |
+
augs = [
|
| 65 |
+
T.ResizeShortestEdge(
|
| 66 |
+
cfg.INPUT.MIN_SIZE_TRAIN,
|
| 67 |
+
cfg.INPUT.MAX_SIZE_TRAIN,
|
| 68 |
+
cfg.INPUT.MIN_SIZE_TRAIN_SAMPLING,
|
| 69 |
+
)
|
| 70 |
+
]
|
| 71 |
+
if cfg.INPUT.CROP.ENABLED:
|
| 72 |
+
augs.append(
|
| 73 |
+
T.RandomCrop_CategoryAreaConstraint(
|
| 74 |
+
cfg.INPUT.CROP.TYPE,
|
| 75 |
+
cfg.INPUT.CROP.SIZE,
|
| 76 |
+
cfg.INPUT.CROP.SINGLE_CATEGORY_MAX_AREA,
|
| 77 |
+
cfg.MODEL.SEM_SEG_HEAD.IGNORE_VALUE,
|
| 78 |
+
)
|
| 79 |
+
)
|
| 80 |
+
if cfg.INPUT.COLOR_AUG_SSD:
|
| 81 |
+
augs.append(ColorAugSSDTransform(img_format=cfg.INPUT.FORMAT))
|
| 82 |
+
augs.append(T.RandomFlip())
|
| 83 |
+
|
| 84 |
+
# Assume always applies to the training set.
|
| 85 |
+
dataset_names = cfg.DATASETS.TRAIN
|
| 86 |
+
meta = MetadataCatalog.get(dataset_names[0])
|
| 87 |
+
ignore_label = meta.ignore_label
|
| 88 |
+
|
| 89 |
+
ret = {
|
| 90 |
+
"is_train": is_train,
|
| 91 |
+
"augmentations": augs,
|
| 92 |
+
"image_format": cfg.INPUT.FORMAT,
|
| 93 |
+
"ignore_label": ignore_label,
|
| 94 |
+
"size_divisibility": cfg.INPUT.SIZE_DIVISIBILITY,
|
| 95 |
+
}
|
| 96 |
+
return ret
|
| 97 |
+
|
| 98 |
+
def __call__(self, dataset_dict):
|
| 99 |
+
"""
|
| 100 |
+
Args:
|
| 101 |
+
dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
|
| 102 |
+
|
| 103 |
+
Returns:
|
| 104 |
+
dict: a format that builtin models in detectron2 accept
|
| 105 |
+
"""
|
| 106 |
+
assert self.is_train, "MaskFormerSemanticDatasetMapper should only be used for training!"
|
| 107 |
+
|
| 108 |
+
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
|
| 109 |
+
image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
|
| 110 |
+
utils.check_image_size(dataset_dict, image)
|
| 111 |
+
|
| 112 |
+
if "sem_seg_file_name" in dataset_dict:
|
| 113 |
+
# PyTorch transformation not implemented for uint16, so converting it to double first
|
| 114 |
+
sem_seg_gt = utils.read_image(dataset_dict.pop("sem_seg_file_name")).astype("double")
|
| 115 |
+
else:
|
| 116 |
+
sem_seg_gt = None
|
| 117 |
+
|
| 118 |
+
if sem_seg_gt is None:
|
| 119 |
+
raise ValueError(
|
| 120 |
+
"Cannot find 'sem_seg_file_name' for semantic segmentation dataset {}.".format(
|
| 121 |
+
dataset_dict["file_name"]
|
| 122 |
+
)
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
aug_input = T.AugInput(image, sem_seg=sem_seg_gt)
|
| 126 |
+
aug_input, transforms = T.apply_transform_gens(self.tfm_gens, aug_input)
|
| 127 |
+
image = aug_input.image
|
| 128 |
+
sem_seg_gt = aug_input.sem_seg
|
| 129 |
+
|
| 130 |
+
# Pad image and segmentation label here!
|
| 131 |
+
image = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
|
| 132 |
+
if sem_seg_gt is not None:
|
| 133 |
+
sem_seg_gt = torch.as_tensor(sem_seg_gt.astype("long"))
|
| 134 |
+
|
| 135 |
+
if self.size_divisibility > 0:
|
| 136 |
+
image_size = (image.shape[-2], image.shape[-1])
|
| 137 |
+
padding_size = [
|
| 138 |
+
0,
|
| 139 |
+
self.size_divisibility - image_size[1],
|
| 140 |
+
0,
|
| 141 |
+
self.size_divisibility - image_size[0],
|
| 142 |
+
]
|
| 143 |
+
image = F.pad(image, padding_size, value=128).contiguous()
|
| 144 |
+
if sem_seg_gt is not None:
|
| 145 |
+
sem_seg_gt = F.pad(sem_seg_gt, padding_size, value=self.ignore_label).contiguous()
|
| 146 |
+
|
| 147 |
+
image_shape = (image.shape[-2], image.shape[-1]) # h, w
|
| 148 |
+
|
| 149 |
+
# Pytorch's dataloader is efficient on torch.Tensor due to shared-memory,
|
| 150 |
+
# but not efficient on large generic data structures due to the use of pickle & mp.Queue.
|
| 151 |
+
# Therefore it's important to use torch.Tensor.
|
| 152 |
+
dataset_dict["image"] = image
|
| 153 |
+
|
| 154 |
+
if sem_seg_gt is not None:
|
| 155 |
+
dataset_dict["sem_seg"] = sem_seg_gt.long()
|
| 156 |
+
|
| 157 |
+
if "annotations" in dataset_dict:
|
| 158 |
+
raise ValueError("Semantic segmentation dataset should not have 'annotations'.")
|
| 159 |
+
|
| 160 |
+
# Prepare per-category binary masks
|
| 161 |
+
if sem_seg_gt is not None:
|
| 162 |
+
sem_seg_gt = sem_seg_gt.numpy()
|
| 163 |
+
instances = Instances(image_shape)
|
| 164 |
+
classes = np.unique(sem_seg_gt)
|
| 165 |
+
# remove ignored region
|
| 166 |
+
classes = classes[classes != self.ignore_label]
|
| 167 |
+
instances.gt_classes = torch.tensor(classes, dtype=torch.int64)
|
| 168 |
+
|
| 169 |
+
masks = []
|
| 170 |
+
for class_id in classes:
|
| 171 |
+
masks.append(sem_seg_gt == class_id)
|
| 172 |
+
|
| 173 |
+
if len(masks) == 0:
|
| 174 |
+
# Some image does not have annotation (all ignored)
|
| 175 |
+
instances.gt_masks = torch.zeros((0, sem_seg_gt.shape[-2], sem_seg_gt.shape[-1]))
|
| 176 |
+
else:
|
| 177 |
+
masks = BitMasks(
|
| 178 |
+
torch.stack([torch.from_numpy(np.ascontiguousarray(x.copy())) for x in masks])
|
| 179 |
+
)
|
| 180 |
+
instances.gt_masks = masks.tensor
|
| 181 |
+
|
| 182 |
+
dataset_dict["instances"] = instances
|
| 183 |
+
|
| 184 |
+
return dataset_dict
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
from . import (
|
| 3 |
+
register_ade20k_full,
|
| 4 |
+
register_ade20k_panoptic,
|
| 5 |
+
register_coco_stuff_10k,
|
| 6 |
+
register_mapillary_vistas,
|
| 7 |
+
register_coco_panoptic_annos_semseg,
|
| 8 |
+
register_ade20k_instance,
|
| 9 |
+
register_mapillary_vistas_panoptic,
|
| 10 |
+
register_entityv2_entity,
|
| 11 |
+
register_entityv2_instances,
|
| 12 |
+
register_entityv2_panoptic_350,
|
| 13 |
+
register_entityv2_semseg_150,
|
| 14 |
+
)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_ade20k_full.py
ADDED
|
@@ -0,0 +1,964 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 5 |
+
from detectron2.data.datasets import load_sem_seg
|
| 6 |
+
|
| 7 |
+
ADE20K_SEM_SEG_FULL_CATEGORIES = [
|
| 8 |
+
{"name": "wall", "id": 2978, "trainId": 0},
|
| 9 |
+
{"name": "building, edifice", "id": 312, "trainId": 1},
|
| 10 |
+
{"name": "sky", "id": 2420, "trainId": 2},
|
| 11 |
+
{"name": "tree", "id": 2855, "trainId": 3},
|
| 12 |
+
{"name": "road, route", "id": 2131, "trainId": 4},
|
| 13 |
+
{"name": "floor, flooring", "id": 976, "trainId": 5},
|
| 14 |
+
{"name": "ceiling", "id": 447, "trainId": 6},
|
| 15 |
+
{"name": "bed", "id": 165, "trainId": 7},
|
| 16 |
+
{"name": "sidewalk, pavement", "id": 2377, "trainId": 8},
|
| 17 |
+
{"name": "earth, ground", "id": 838, "trainId": 9},
|
| 18 |
+
{"name": "cabinet", "id": 350, "trainId": 10},
|
| 19 |
+
{"name": "person, individual, someone, somebody, mortal, soul", "id": 1831, "trainId": 11},
|
| 20 |
+
{"name": "grass", "id": 1125, "trainId": 12},
|
| 21 |
+
{"name": "windowpane, window", "id": 3055, "trainId": 13},
|
| 22 |
+
{"name": "car, auto, automobile, machine, motorcar", "id": 401, "trainId": 14},
|
| 23 |
+
{"name": "mountain, mount", "id": 1610, "trainId": 15},
|
| 24 |
+
{"name": "plant, flora, plant life", "id": 1910, "trainId": 16},
|
| 25 |
+
{"name": "table", "id": 2684, "trainId": 17},
|
| 26 |
+
{"name": "chair", "id": 471, "trainId": 18},
|
| 27 |
+
{"name": "curtain, drape, drapery, mantle, pall", "id": 687, "trainId": 19},
|
| 28 |
+
{"name": "door", "id": 774, "trainId": 20},
|
| 29 |
+
{"name": "sofa, couch, lounge", "id": 2473, "trainId": 21},
|
| 30 |
+
{"name": "sea", "id": 2264, "trainId": 22},
|
| 31 |
+
{"name": "painting, picture", "id": 1735, "trainId": 23},
|
| 32 |
+
{"name": "water", "id": 2994, "trainId": 24},
|
| 33 |
+
{"name": "mirror", "id": 1564, "trainId": 25},
|
| 34 |
+
{"name": "house", "id": 1276, "trainId": 26},
|
| 35 |
+
{"name": "rug, carpet, carpeting", "id": 2178, "trainId": 27},
|
| 36 |
+
{"name": "shelf", "id": 2329, "trainId": 28},
|
| 37 |
+
{"name": "armchair", "id": 57, "trainId": 29},
|
| 38 |
+
{"name": "fence, fencing", "id": 907, "trainId": 30},
|
| 39 |
+
{"name": "field", "id": 913, "trainId": 31},
|
| 40 |
+
{"name": "lamp", "id": 1395, "trainId": 32},
|
| 41 |
+
{"name": "rock, stone", "id": 2138, "trainId": 33},
|
| 42 |
+
{"name": "seat", "id": 2272, "trainId": 34},
|
| 43 |
+
{"name": "river", "id": 2128, "trainId": 35},
|
| 44 |
+
{"name": "desk", "id": 724, "trainId": 36},
|
| 45 |
+
{"name": "bathtub, bathing tub, bath, tub", "id": 155, "trainId": 37},
|
| 46 |
+
{"name": "railing, rail", "id": 2053, "trainId": 38},
|
| 47 |
+
{"name": "signboard, sign", "id": 2380, "trainId": 39},
|
| 48 |
+
{"name": "cushion", "id": 689, "trainId": 40},
|
| 49 |
+
{"name": "path", "id": 1788, "trainId": 41},
|
| 50 |
+
{"name": "work surface", "id": 3087, "trainId": 42},
|
| 51 |
+
{"name": "stairs, steps", "id": 2530, "trainId": 43},
|
| 52 |
+
{"name": "column, pillar", "id": 581, "trainId": 44},
|
| 53 |
+
{"name": "sink", "id": 2388, "trainId": 45},
|
| 54 |
+
{"name": "wardrobe, closet, press", "id": 2985, "trainId": 46},
|
| 55 |
+
{"name": "snow", "id": 2454, "trainId": 47},
|
| 56 |
+
{"name": "refrigerator, icebox", "id": 2096, "trainId": 48},
|
| 57 |
+
{"name": "base, pedestal, stand", "id": 137, "trainId": 49},
|
| 58 |
+
{"name": "bridge, span", "id": 294, "trainId": 50},
|
| 59 |
+
{"name": "blind, screen", "id": 212, "trainId": 51},
|
| 60 |
+
{"name": "runway", "id": 2185, "trainId": 52},
|
| 61 |
+
{"name": "cliff, drop, drop-off", "id": 524, "trainId": 53},
|
| 62 |
+
{"name": "sand", "id": 2212, "trainId": 54},
|
| 63 |
+
{"name": "fireplace, hearth, open fireplace", "id": 943, "trainId": 55},
|
| 64 |
+
{"name": "pillow", "id": 1869, "trainId": 56},
|
| 65 |
+
{"name": "screen door, screen", "id": 2251, "trainId": 57},
|
| 66 |
+
{"name": "toilet, can, commode, crapper, pot, potty, stool, throne", "id": 2793, "trainId": 58},
|
| 67 |
+
{"name": "skyscraper", "id": 2423, "trainId": 59},
|
| 68 |
+
{"name": "grandstand, covered stand", "id": 1121, "trainId": 60},
|
| 69 |
+
{"name": "box", "id": 266, "trainId": 61},
|
| 70 |
+
{"name": "pool table, billiard table, snooker table", "id": 1948, "trainId": 62},
|
| 71 |
+
{"name": "palm, palm tree", "id": 1744, "trainId": 63},
|
| 72 |
+
{"name": "double door", "id": 783, "trainId": 64},
|
| 73 |
+
{"name": "coffee table, cocktail table", "id": 571, "trainId": 65},
|
| 74 |
+
{"name": "counter", "id": 627, "trainId": 66},
|
| 75 |
+
{"name": "countertop", "id": 629, "trainId": 67},
|
| 76 |
+
{"name": "chest of drawers, chest, bureau, dresser", "id": 491, "trainId": 68},
|
| 77 |
+
{"name": "kitchen island", "id": 1374, "trainId": 69},
|
| 78 |
+
{"name": "boat", "id": 223, "trainId": 70},
|
| 79 |
+
{"name": "waterfall, falls", "id": 3016, "trainId": 71},
|
| 80 |
+
{
|
| 81 |
+
"name": "stove, kitchen stove, range, kitchen range, cooking stove",
|
| 82 |
+
"id": 2598,
|
| 83 |
+
"trainId": 72,
|
| 84 |
+
},
|
| 85 |
+
{"name": "flower", "id": 978, "trainId": 73},
|
| 86 |
+
{"name": "bookcase", "id": 239, "trainId": 74},
|
| 87 |
+
{"name": "controls", "id": 608, "trainId": 75},
|
| 88 |
+
{"name": "book", "id": 236, "trainId": 76},
|
| 89 |
+
{"name": "stairway, staircase", "id": 2531, "trainId": 77},
|
| 90 |
+
{"name": "streetlight, street lamp", "id": 2616, "trainId": 78},
|
| 91 |
+
{
|
| 92 |
+
"name": "computer, computing machine, computing device, data processor, electronic computer, information processing system",
|
| 93 |
+
"id": 591,
|
| 94 |
+
"trainId": 79,
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"name": "bus, autobus, coach, charabanc, double-decker, jitney, motorbus, motorcoach, omnibus, passenger vehicle",
|
| 98 |
+
"id": 327,
|
| 99 |
+
"trainId": 80,
|
| 100 |
+
},
|
| 101 |
+
{"name": "swivel chair", "id": 2679, "trainId": 81},
|
| 102 |
+
{"name": "light, light source", "id": 1451, "trainId": 82},
|
| 103 |
+
{"name": "bench", "id": 181, "trainId": 83},
|
| 104 |
+
{"name": "case, display case, showcase, vitrine", "id": 420, "trainId": 84},
|
| 105 |
+
{"name": "towel", "id": 2821, "trainId": 85},
|
| 106 |
+
{"name": "fountain", "id": 1023, "trainId": 86},
|
| 107 |
+
{"name": "embankment", "id": 855, "trainId": 87},
|
| 108 |
+
{
|
| 109 |
+
"name": "television receiver, television, television set, tv, tv set, idiot box, boob tube, telly, goggle box",
|
| 110 |
+
"id": 2733,
|
| 111 |
+
"trainId": 88,
|
| 112 |
+
},
|
| 113 |
+
{"name": "van", "id": 2928, "trainId": 89},
|
| 114 |
+
{"name": "hill", "id": 1240, "trainId": 90},
|
| 115 |
+
{"name": "awning, sunshade, sunblind", "id": 77, "trainId": 91},
|
| 116 |
+
{"name": "poster, posting, placard, notice, bill, card", "id": 1969, "trainId": 92},
|
| 117 |
+
{"name": "truck, motortruck", "id": 2880, "trainId": 93},
|
| 118 |
+
{"name": "airplane, aeroplane, plane", "id": 14, "trainId": 94},
|
| 119 |
+
{"name": "pole", "id": 1936, "trainId": 95},
|
| 120 |
+
{"name": "tower", "id": 2828, "trainId": 96},
|
| 121 |
+
{"name": "court", "id": 631, "trainId": 97},
|
| 122 |
+
{"name": "ball", "id": 103, "trainId": 98},
|
| 123 |
+
{
|
| 124 |
+
"name": "aircraft carrier, carrier, flattop, attack aircraft carrier",
|
| 125 |
+
"id": 3144,
|
| 126 |
+
"trainId": 99,
|
| 127 |
+
},
|
| 128 |
+
{"name": "buffet, counter, sideboard", "id": 308, "trainId": 100},
|
| 129 |
+
{"name": "hovel, hut, hutch, shack, shanty", "id": 1282, "trainId": 101},
|
| 130 |
+
{"name": "apparel, wearing apparel, dress, clothes", "id": 38, "trainId": 102},
|
| 131 |
+
{"name": "minibike, motorbike", "id": 1563, "trainId": 103},
|
| 132 |
+
{"name": "animal, animate being, beast, brute, creature, fauna", "id": 29, "trainId": 104},
|
| 133 |
+
{"name": "chandelier, pendant, pendent", "id": 480, "trainId": 105},
|
| 134 |
+
{"name": "step, stair", "id": 2569, "trainId": 106},
|
| 135 |
+
{"name": "booth, cubicle, stall, kiosk", "id": 247, "trainId": 107},
|
| 136 |
+
{"name": "bicycle, bike, wheel, cycle", "id": 187, "trainId": 108},
|
| 137 |
+
{"name": "doorframe, doorcase", "id": 778, "trainId": 109},
|
| 138 |
+
{"name": "sconce", "id": 2243, "trainId": 110},
|
| 139 |
+
{"name": "pond", "id": 1941, "trainId": 111},
|
| 140 |
+
{"name": "trade name, brand name, brand, marque", "id": 2833, "trainId": 112},
|
| 141 |
+
{"name": "bannister, banister, balustrade, balusters, handrail", "id": 120, "trainId": 113},
|
| 142 |
+
{"name": "bag", "id": 95, "trainId": 114},
|
| 143 |
+
{"name": "traffic light, traffic signal, stoplight", "id": 2836, "trainId": 115},
|
| 144 |
+
{"name": "gazebo", "id": 1087, "trainId": 116},
|
| 145 |
+
{"name": "escalator, moving staircase, moving stairway", "id": 868, "trainId": 117},
|
| 146 |
+
{"name": "land, ground, soil", "id": 1401, "trainId": 118},
|
| 147 |
+
{"name": "board, plank", "id": 220, "trainId": 119},
|
| 148 |
+
{"name": "arcade machine", "id": 47, "trainId": 120},
|
| 149 |
+
{"name": "eiderdown, duvet, continental quilt", "id": 843, "trainId": 121},
|
| 150 |
+
{"name": "bar", "id": 123, "trainId": 122},
|
| 151 |
+
{"name": "stall, stand, sales booth", "id": 2537, "trainId": 123},
|
| 152 |
+
{"name": "playground", "id": 1927, "trainId": 124},
|
| 153 |
+
{"name": "ship", "id": 2337, "trainId": 125},
|
| 154 |
+
{"name": "ottoman, pouf, pouffe, puff, hassock", "id": 1702, "trainId": 126},
|
| 155 |
+
{
|
| 156 |
+
"name": "ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin",
|
| 157 |
+
"id": 64,
|
| 158 |
+
"trainId": 127,
|
| 159 |
+
},
|
| 160 |
+
{"name": "bottle", "id": 249, "trainId": 128},
|
| 161 |
+
{"name": "cradle", "id": 642, "trainId": 129},
|
| 162 |
+
{"name": "pot, flowerpot", "id": 1981, "trainId": 130},
|
| 163 |
+
{
|
| 164 |
+
"name": "conveyer belt, conveyor belt, conveyer, conveyor, transporter",
|
| 165 |
+
"id": 609,
|
| 166 |
+
"trainId": 131,
|
| 167 |
+
},
|
| 168 |
+
{"name": "train, railroad train", "id": 2840, "trainId": 132},
|
| 169 |
+
{"name": "stool", "id": 2586, "trainId": 133},
|
| 170 |
+
{"name": "lake", "id": 1393, "trainId": 134},
|
| 171 |
+
{"name": "tank, storage tank", "id": 2704, "trainId": 135},
|
| 172 |
+
{"name": "ice, water ice", "id": 1304, "trainId": 136},
|
| 173 |
+
{"name": "basket, handbasket", "id": 146, "trainId": 137},
|
| 174 |
+
{"name": "manhole", "id": 1494, "trainId": 138},
|
| 175 |
+
{"name": "tent, collapsible shelter", "id": 2739, "trainId": 139},
|
| 176 |
+
{"name": "canopy", "id": 389, "trainId": 140},
|
| 177 |
+
{"name": "microwave, microwave oven", "id": 1551, "trainId": 141},
|
| 178 |
+
{"name": "barrel, cask", "id": 131, "trainId": 142},
|
| 179 |
+
{"name": "dirt track", "id": 738, "trainId": 143},
|
| 180 |
+
{"name": "beam", "id": 161, "trainId": 144},
|
| 181 |
+
{"name": "dishwasher, dish washer, dishwashing machine", "id": 747, "trainId": 145},
|
| 182 |
+
{"name": "plate", "id": 1919, "trainId": 146},
|
| 183 |
+
{"name": "screen, crt screen", "id": 3109, "trainId": 147},
|
| 184 |
+
{"name": "ruins", "id": 2179, "trainId": 148},
|
| 185 |
+
{"name": "washer, automatic washer, washing machine", "id": 2989, "trainId": 149},
|
| 186 |
+
{"name": "blanket, cover", "id": 206, "trainId": 150},
|
| 187 |
+
{"name": "plaything, toy", "id": 1930, "trainId": 151},
|
| 188 |
+
{"name": "food, solid food", "id": 1002, "trainId": 152},
|
| 189 |
+
{"name": "screen, silver screen, projection screen", "id": 2254, "trainId": 153},
|
| 190 |
+
{"name": "oven", "id": 1708, "trainId": 154},
|
| 191 |
+
{"name": "stage", "id": 2526, "trainId": 155},
|
| 192 |
+
{"name": "beacon, lighthouse, beacon light, pharos", "id": 160, "trainId": 156},
|
| 193 |
+
{"name": "umbrella", "id": 2901, "trainId": 157},
|
| 194 |
+
{"name": "sculpture", "id": 2262, "trainId": 158},
|
| 195 |
+
{"name": "aqueduct", "id": 44, "trainId": 159},
|
| 196 |
+
{"name": "container", "id": 597, "trainId": 160},
|
| 197 |
+
{"name": "scaffolding, staging", "id": 2235, "trainId": 161},
|
| 198 |
+
{"name": "hood, exhaust hood", "id": 1260, "trainId": 162},
|
| 199 |
+
{"name": "curb, curbing, kerb", "id": 682, "trainId": 163},
|
| 200 |
+
{"name": "roller coaster", "id": 2151, "trainId": 164},
|
| 201 |
+
{"name": "horse, equus caballus", "id": 3107, "trainId": 165},
|
| 202 |
+
{"name": "catwalk", "id": 432, "trainId": 166},
|
| 203 |
+
{"name": "glass, drinking glass", "id": 1098, "trainId": 167},
|
| 204 |
+
{"name": "vase", "id": 2932, "trainId": 168},
|
| 205 |
+
{"name": "central reservation", "id": 461, "trainId": 169},
|
| 206 |
+
{"name": "carousel", "id": 410, "trainId": 170},
|
| 207 |
+
{"name": "radiator", "id": 2046, "trainId": 171},
|
| 208 |
+
{"name": "closet", "id": 533, "trainId": 172},
|
| 209 |
+
{"name": "machine", "id": 1481, "trainId": 173},
|
| 210 |
+
{"name": "pier, wharf, wharfage, dock", "id": 1858, "trainId": 174},
|
| 211 |
+
{"name": "fan", "id": 894, "trainId": 175},
|
| 212 |
+
{"name": "inflatable bounce game", "id": 1322, "trainId": 176},
|
| 213 |
+
{"name": "pitch", "id": 1891, "trainId": 177},
|
| 214 |
+
{"name": "paper", "id": 1756, "trainId": 178},
|
| 215 |
+
{"name": "arcade, colonnade", "id": 49, "trainId": 179},
|
| 216 |
+
{"name": "hot tub", "id": 1272, "trainId": 180},
|
| 217 |
+
{"name": "helicopter", "id": 1229, "trainId": 181},
|
| 218 |
+
{"name": "tray", "id": 2850, "trainId": 182},
|
| 219 |
+
{"name": "partition, divider", "id": 1784, "trainId": 183},
|
| 220 |
+
{"name": "vineyard", "id": 2962, "trainId": 184},
|
| 221 |
+
{"name": "bowl", "id": 259, "trainId": 185},
|
| 222 |
+
{"name": "bullring", "id": 319, "trainId": 186},
|
| 223 |
+
{"name": "flag", "id": 954, "trainId": 187},
|
| 224 |
+
{"name": "pot", "id": 1974, "trainId": 188},
|
| 225 |
+
{"name": "footbridge, overcrossing, pedestrian bridge", "id": 1013, "trainId": 189},
|
| 226 |
+
{"name": "shower", "id": 2356, "trainId": 190},
|
| 227 |
+
{"name": "bag, traveling bag, travelling bag, grip, suitcase", "id": 97, "trainId": 191},
|
| 228 |
+
{"name": "bulletin board, notice board", "id": 318, "trainId": 192},
|
| 229 |
+
{"name": "confessional booth", "id": 592, "trainId": 193},
|
| 230 |
+
{"name": "trunk, tree trunk, bole", "id": 2885, "trainId": 194},
|
| 231 |
+
{"name": "forest", "id": 1017, "trainId": 195},
|
| 232 |
+
{"name": "elevator door", "id": 851, "trainId": 196},
|
| 233 |
+
{"name": "laptop, laptop computer", "id": 1407, "trainId": 197},
|
| 234 |
+
{"name": "instrument panel", "id": 1332, "trainId": 198},
|
| 235 |
+
{"name": "bucket, pail", "id": 303, "trainId": 199},
|
| 236 |
+
{"name": "tapestry, tapis", "id": 2714, "trainId": 200},
|
| 237 |
+
{"name": "platform", "id": 1924, "trainId": 201},
|
| 238 |
+
{"name": "jacket", "id": 1346, "trainId": 202},
|
| 239 |
+
{"name": "gate", "id": 1081, "trainId": 203},
|
| 240 |
+
{"name": "monitor, monitoring device", "id": 1583, "trainId": 204},
|
| 241 |
+
{
|
| 242 |
+
"name": "telephone booth, phone booth, call box, telephone box, telephone kiosk",
|
| 243 |
+
"id": 2727,
|
| 244 |
+
"trainId": 205,
|
| 245 |
+
},
|
| 246 |
+
{"name": "spotlight, spot", "id": 2509, "trainId": 206},
|
| 247 |
+
{"name": "ring", "id": 2123, "trainId": 207},
|
| 248 |
+
{"name": "control panel", "id": 602, "trainId": 208},
|
| 249 |
+
{"name": "blackboard, chalkboard", "id": 202, "trainId": 209},
|
| 250 |
+
{"name": "air conditioner, air conditioning", "id": 10, "trainId": 210},
|
| 251 |
+
{"name": "chest", "id": 490, "trainId": 211},
|
| 252 |
+
{"name": "clock", "id": 530, "trainId": 212},
|
| 253 |
+
{"name": "sand dune", "id": 2213, "trainId": 213},
|
| 254 |
+
{"name": "pipe, pipage, piping", "id": 1884, "trainId": 214},
|
| 255 |
+
{"name": "vault", "id": 2934, "trainId": 215},
|
| 256 |
+
{"name": "table football", "id": 2687, "trainId": 216},
|
| 257 |
+
{"name": "cannon", "id": 387, "trainId": 217},
|
| 258 |
+
{"name": "swimming pool, swimming bath, natatorium", "id": 2668, "trainId": 218},
|
| 259 |
+
{"name": "fluorescent, fluorescent fixture", "id": 982, "trainId": 219},
|
| 260 |
+
{"name": "statue", "id": 2547, "trainId": 220},
|
| 261 |
+
{
|
| 262 |
+
"name": "loudspeaker, speaker, speaker unit, loudspeaker system, speaker system",
|
| 263 |
+
"id": 1474,
|
| 264 |
+
"trainId": 221,
|
| 265 |
+
},
|
| 266 |
+
{"name": "exhibitor", "id": 877, "trainId": 222},
|
| 267 |
+
{"name": "ladder", "id": 1391, "trainId": 223},
|
| 268 |
+
{"name": "carport", "id": 414, "trainId": 224},
|
| 269 |
+
{"name": "dam", "id": 698, "trainId": 225},
|
| 270 |
+
{"name": "pulpit", "id": 2019, "trainId": 226},
|
| 271 |
+
{"name": "skylight, fanlight", "id": 2422, "trainId": 227},
|
| 272 |
+
{"name": "water tower", "id": 3010, "trainId": 228},
|
| 273 |
+
{"name": "grill, grille, grillwork", "id": 1139, "trainId": 229},
|
| 274 |
+
{"name": "display board", "id": 753, "trainId": 230},
|
| 275 |
+
{"name": "pane, pane of glass, window glass", "id": 1747, "trainId": 231},
|
| 276 |
+
{"name": "rubbish, trash, scrap", "id": 2175, "trainId": 232},
|
| 277 |
+
{"name": "ice rink", "id": 1301, "trainId": 233},
|
| 278 |
+
{"name": "fruit", "id": 1033, "trainId": 234},
|
| 279 |
+
{"name": "patio", "id": 1789, "trainId": 235},
|
| 280 |
+
{"name": "vending machine", "id": 2939, "trainId": 236},
|
| 281 |
+
{"name": "telephone, phone, telephone set", "id": 2730, "trainId": 237},
|
| 282 |
+
{"name": "net", "id": 1652, "trainId": 238},
|
| 283 |
+
{
|
| 284 |
+
"name": "backpack, back pack, knapsack, packsack, rucksack, haversack",
|
| 285 |
+
"id": 90,
|
| 286 |
+
"trainId": 239,
|
| 287 |
+
},
|
| 288 |
+
{"name": "jar", "id": 1349, "trainId": 240},
|
| 289 |
+
{"name": "track", "id": 2830, "trainId": 241},
|
| 290 |
+
{"name": "magazine", "id": 1485, "trainId": 242},
|
| 291 |
+
{"name": "shutter", "id": 2370, "trainId": 243},
|
| 292 |
+
{"name": "roof", "id": 2155, "trainId": 244},
|
| 293 |
+
{"name": "banner, streamer", "id": 118, "trainId": 245},
|
| 294 |
+
{"name": "landfill", "id": 1402, "trainId": 246},
|
| 295 |
+
{"name": "post", "id": 1957, "trainId": 247},
|
| 296 |
+
{"name": "altarpiece, reredos", "id": 3130, "trainId": 248},
|
| 297 |
+
{"name": "hat, chapeau, lid", "id": 1197, "trainId": 249},
|
| 298 |
+
{"name": "arch, archway", "id": 52, "trainId": 250},
|
| 299 |
+
{"name": "table game", "id": 2688, "trainId": 251},
|
| 300 |
+
{"name": "bag, handbag, pocketbook, purse", "id": 96, "trainId": 252},
|
| 301 |
+
{"name": "document, written document, papers", "id": 762, "trainId": 253},
|
| 302 |
+
{"name": "dome", "id": 772, "trainId": 254},
|
| 303 |
+
{"name": "pier", "id": 1857, "trainId": 255},
|
| 304 |
+
{"name": "shanties", "id": 2315, "trainId": 256},
|
| 305 |
+
{"name": "forecourt", "id": 1016, "trainId": 257},
|
| 306 |
+
{"name": "crane", "id": 643, "trainId": 258},
|
| 307 |
+
{"name": "dog, domestic dog, canis familiaris", "id": 3105, "trainId": 259},
|
| 308 |
+
{"name": "piano, pianoforte, forte-piano", "id": 1849, "trainId": 260},
|
| 309 |
+
{"name": "drawing", "id": 791, "trainId": 261},
|
| 310 |
+
{"name": "cabin", "id": 349, "trainId": 262},
|
| 311 |
+
{
|
| 312 |
+
"name": "ad, advertisement, advertizement, advertising, advertizing, advert",
|
| 313 |
+
"id": 6,
|
| 314 |
+
"trainId": 263,
|
| 315 |
+
},
|
| 316 |
+
{"name": "amphitheater, amphitheatre, coliseum", "id": 3114, "trainId": 264},
|
| 317 |
+
{"name": "monument", "id": 1587, "trainId": 265},
|
| 318 |
+
{"name": "henhouse", "id": 1233, "trainId": 266},
|
| 319 |
+
{"name": "cockpit", "id": 559, "trainId": 267},
|
| 320 |
+
{"name": "heater, warmer", "id": 1223, "trainId": 268},
|
| 321 |
+
{"name": "windmill, aerogenerator, wind generator", "id": 3049, "trainId": 269},
|
| 322 |
+
{"name": "pool", "id": 1943, "trainId": 270},
|
| 323 |
+
{"name": "elevator, lift", "id": 853, "trainId": 271},
|
| 324 |
+
{"name": "decoration, ornament, ornamentation", "id": 709, "trainId": 272},
|
| 325 |
+
{"name": "labyrinth", "id": 1390, "trainId": 273},
|
| 326 |
+
{"name": "text, textual matter", "id": 2748, "trainId": 274},
|
| 327 |
+
{"name": "printer", "id": 2007, "trainId": 275},
|
| 328 |
+
{"name": "mezzanine, first balcony", "id": 1546, "trainId": 276},
|
| 329 |
+
{"name": "mattress", "id": 1513, "trainId": 277},
|
| 330 |
+
{"name": "straw", "id": 2600, "trainId": 278},
|
| 331 |
+
{"name": "stalls", "id": 2538, "trainId": 279},
|
| 332 |
+
{"name": "patio, terrace", "id": 1790, "trainId": 280},
|
| 333 |
+
{"name": "billboard, hoarding", "id": 194, "trainId": 281},
|
| 334 |
+
{"name": "bus stop", "id": 326, "trainId": 282},
|
| 335 |
+
{"name": "trouser, pant", "id": 2877, "trainId": 283},
|
| 336 |
+
{"name": "console table, console", "id": 594, "trainId": 284},
|
| 337 |
+
{"name": "rack", "id": 2036, "trainId": 285},
|
| 338 |
+
{"name": "notebook", "id": 1662, "trainId": 286},
|
| 339 |
+
{"name": "shrine", "id": 2366, "trainId": 287},
|
| 340 |
+
{"name": "pantry", "id": 1754, "trainId": 288},
|
| 341 |
+
{"name": "cart", "id": 418, "trainId": 289},
|
| 342 |
+
{"name": "steam shovel", "id": 2553, "trainId": 290},
|
| 343 |
+
{"name": "porch", "id": 1951, "trainId": 291},
|
| 344 |
+
{"name": "postbox, mailbox, letter box", "id": 1963, "trainId": 292},
|
| 345 |
+
{"name": "figurine, statuette", "id": 918, "trainId": 293},
|
| 346 |
+
{"name": "recycling bin", "id": 2086, "trainId": 294},
|
| 347 |
+
{"name": "folding screen", "id": 997, "trainId": 295},
|
| 348 |
+
{"name": "telescope", "id": 2731, "trainId": 296},
|
| 349 |
+
{"name": "deck chair, beach chair", "id": 704, "trainId": 297},
|
| 350 |
+
{"name": "kennel", "id": 1365, "trainId": 298},
|
| 351 |
+
{"name": "coffee maker", "id": 569, "trainId": 299},
|
| 352 |
+
{"name": "altar, communion table, lord's table", "id": 3108, "trainId": 300},
|
| 353 |
+
{"name": "fish", "id": 948, "trainId": 301},
|
| 354 |
+
{"name": "easel", "id": 839, "trainId": 302},
|
| 355 |
+
{"name": "artificial golf green", "id": 63, "trainId": 303},
|
| 356 |
+
{"name": "iceberg", "id": 1305, "trainId": 304},
|
| 357 |
+
{"name": "candlestick, candle holder", "id": 378, "trainId": 305},
|
| 358 |
+
{"name": "shower stall, shower bath", "id": 2362, "trainId": 306},
|
| 359 |
+
{"name": "television stand", "id": 2734, "trainId": 307},
|
| 360 |
+
{
|
| 361 |
+
"name": "wall socket, wall plug, electric outlet, electrical outlet, outlet, electric receptacle",
|
| 362 |
+
"id": 2982,
|
| 363 |
+
"trainId": 308,
|
| 364 |
+
},
|
| 365 |
+
{"name": "skeleton", "id": 2398, "trainId": 309},
|
| 366 |
+
{"name": "grand piano, grand", "id": 1119, "trainId": 310},
|
| 367 |
+
{"name": "candy, confect", "id": 382, "trainId": 311},
|
| 368 |
+
{"name": "grille door", "id": 1141, "trainId": 312},
|
| 369 |
+
{"name": "pedestal, plinth, footstall", "id": 1805, "trainId": 313},
|
| 370 |
+
{"name": "jersey, t-shirt, tee shirt", "id": 3102, "trainId": 314},
|
| 371 |
+
{"name": "shoe", "id": 2341, "trainId": 315},
|
| 372 |
+
{"name": "gravestone, headstone, tombstone", "id": 1131, "trainId": 316},
|
| 373 |
+
{"name": "shanty", "id": 2316, "trainId": 317},
|
| 374 |
+
{"name": "structure", "id": 2626, "trainId": 318},
|
| 375 |
+
{"name": "rocking chair, rocker", "id": 3104, "trainId": 319},
|
| 376 |
+
{"name": "bird", "id": 198, "trainId": 320},
|
| 377 |
+
{"name": "place mat", "id": 1896, "trainId": 321},
|
| 378 |
+
{"name": "tomb", "id": 2800, "trainId": 322},
|
| 379 |
+
{"name": "big top", "id": 190, "trainId": 323},
|
| 380 |
+
{"name": "gas pump, gasoline pump, petrol pump, island dispenser", "id": 3131, "trainId": 324},
|
| 381 |
+
{"name": "lockers", "id": 1463, "trainId": 325},
|
| 382 |
+
{"name": "cage", "id": 357, "trainId": 326},
|
| 383 |
+
{"name": "finger", "id": 929, "trainId": 327},
|
| 384 |
+
{"name": "bleachers", "id": 209, "trainId": 328},
|
| 385 |
+
{"name": "ferris wheel", "id": 912, "trainId": 329},
|
| 386 |
+
{"name": "hairdresser chair", "id": 1164, "trainId": 330},
|
| 387 |
+
{"name": "mat", "id": 1509, "trainId": 331},
|
| 388 |
+
{"name": "stands", "id": 2539, "trainId": 332},
|
| 389 |
+
{"name": "aquarium, fish tank, marine museum", "id": 3116, "trainId": 333},
|
| 390 |
+
{"name": "streetcar, tram, tramcar, trolley, trolley car", "id": 2615, "trainId": 334},
|
| 391 |
+
{"name": "napkin, table napkin, serviette", "id": 1644, "trainId": 335},
|
| 392 |
+
{"name": "dummy", "id": 818, "trainId": 336},
|
| 393 |
+
{"name": "booklet, brochure, folder, leaflet, pamphlet", "id": 242, "trainId": 337},
|
| 394 |
+
{"name": "sand trap", "id": 2217, "trainId": 338},
|
| 395 |
+
{"name": "shop, store", "id": 2347, "trainId": 339},
|
| 396 |
+
{"name": "table cloth", "id": 2686, "trainId": 340},
|
| 397 |
+
{"name": "service station", "id": 2300, "trainId": 341},
|
| 398 |
+
{"name": "coffin", "id": 572, "trainId": 342},
|
| 399 |
+
{"name": "drawer", "id": 789, "trainId": 343},
|
| 400 |
+
{"name": "cages", "id": 358, "trainId": 344},
|
| 401 |
+
{"name": "slot machine, coin machine", "id": 2443, "trainId": 345},
|
| 402 |
+
{"name": "balcony", "id": 101, "trainId": 346},
|
| 403 |
+
{"name": "volleyball court", "id": 2969, "trainId": 347},
|
| 404 |
+
{"name": "table tennis", "id": 2692, "trainId": 348},
|
| 405 |
+
{"name": "control table", "id": 606, "trainId": 349},
|
| 406 |
+
{"name": "shirt", "id": 2339, "trainId": 350},
|
| 407 |
+
{"name": "merchandise, ware, product", "id": 1533, "trainId": 351},
|
| 408 |
+
{"name": "railway", "id": 2060, "trainId": 352},
|
| 409 |
+
{"name": "parterre", "id": 1782, "trainId": 353},
|
| 410 |
+
{"name": "chimney", "id": 495, "trainId": 354},
|
| 411 |
+
{"name": "can, tin, tin can", "id": 371, "trainId": 355},
|
| 412 |
+
{"name": "tanks", "id": 2707, "trainId": 356},
|
| 413 |
+
{"name": "fabric, cloth, material, textile", "id": 889, "trainId": 357},
|
| 414 |
+
{"name": "alga, algae", "id": 3156, "trainId": 358},
|
| 415 |
+
{"name": "system", "id": 2683, "trainId": 359},
|
| 416 |
+
{"name": "map", "id": 1499, "trainId": 360},
|
| 417 |
+
{"name": "greenhouse", "id": 1135, "trainId": 361},
|
| 418 |
+
{"name": "mug", "id": 1619, "trainId": 362},
|
| 419 |
+
{"name": "barbecue", "id": 125, "trainId": 363},
|
| 420 |
+
{"name": "trailer", "id": 2838, "trainId": 364},
|
| 421 |
+
{"name": "toilet tissue, toilet paper, bathroom tissue", "id": 2792, "trainId": 365},
|
| 422 |
+
{"name": "organ", "id": 1695, "trainId": 366},
|
| 423 |
+
{"name": "dishrag, dishcloth", "id": 746, "trainId": 367},
|
| 424 |
+
{"name": "island", "id": 1343, "trainId": 368},
|
| 425 |
+
{"name": "keyboard", "id": 1370, "trainId": 369},
|
| 426 |
+
{"name": "trench", "id": 2858, "trainId": 370},
|
| 427 |
+
{"name": "basket, basketball hoop, hoop", "id": 145, "trainId": 371},
|
| 428 |
+
{"name": "steering wheel, wheel", "id": 2565, "trainId": 372},
|
| 429 |
+
{"name": "pitcher, ewer", "id": 1892, "trainId": 373},
|
| 430 |
+
{"name": "goal", "id": 1103, "trainId": 374},
|
| 431 |
+
{"name": "bread, breadstuff, staff of life", "id": 286, "trainId": 375},
|
| 432 |
+
{"name": "beds", "id": 170, "trainId": 376},
|
| 433 |
+
{"name": "wood", "id": 3073, "trainId": 377},
|
| 434 |
+
{"name": "file cabinet", "id": 922, "trainId": 378},
|
| 435 |
+
{"name": "newspaper, paper", "id": 1655, "trainId": 379},
|
| 436 |
+
{"name": "motorboat", "id": 1602, "trainId": 380},
|
| 437 |
+
{"name": "rope", "id": 2160, "trainId": 381},
|
| 438 |
+
{"name": "guitar", "id": 1151, "trainId": 382},
|
| 439 |
+
{"name": "rubble", "id": 2176, "trainId": 383},
|
| 440 |
+
{"name": "scarf", "id": 2239, "trainId": 384},
|
| 441 |
+
{"name": "barrels", "id": 132, "trainId": 385},
|
| 442 |
+
{"name": "cap", "id": 394, "trainId": 386},
|
| 443 |
+
{"name": "leaves", "id": 1424, "trainId": 387},
|
| 444 |
+
{"name": "control tower", "id": 607, "trainId": 388},
|
| 445 |
+
{"name": "dashboard", "id": 700, "trainId": 389},
|
| 446 |
+
{"name": "bandstand", "id": 116, "trainId": 390},
|
| 447 |
+
{"name": "lectern", "id": 1425, "trainId": 391},
|
| 448 |
+
{"name": "switch, electric switch, electrical switch", "id": 2676, "trainId": 392},
|
| 449 |
+
{"name": "baseboard, mopboard, skirting board", "id": 141, "trainId": 393},
|
| 450 |
+
{"name": "shower room", "id": 2360, "trainId": 394},
|
| 451 |
+
{"name": "smoke", "id": 2449, "trainId": 395},
|
| 452 |
+
{"name": "faucet, spigot", "id": 897, "trainId": 396},
|
| 453 |
+
{"name": "bulldozer", "id": 317, "trainId": 397},
|
| 454 |
+
{"name": "saucepan", "id": 2228, "trainId": 398},
|
| 455 |
+
{"name": "shops", "id": 2351, "trainId": 399},
|
| 456 |
+
{"name": "meter", "id": 1543, "trainId": 400},
|
| 457 |
+
{"name": "crevasse", "id": 656, "trainId": 401},
|
| 458 |
+
{"name": "gear", "id": 1088, "trainId": 402},
|
| 459 |
+
{"name": "candelabrum, candelabra", "id": 373, "trainId": 403},
|
| 460 |
+
{"name": "sofa bed", "id": 2472, "trainId": 404},
|
| 461 |
+
{"name": "tunnel", "id": 2892, "trainId": 405},
|
| 462 |
+
{"name": "pallet", "id": 1740, "trainId": 406},
|
| 463 |
+
{"name": "wire, conducting wire", "id": 3067, "trainId": 407},
|
| 464 |
+
{"name": "kettle, boiler", "id": 1367, "trainId": 408},
|
| 465 |
+
{"name": "bidet", "id": 188, "trainId": 409},
|
| 466 |
+
{
|
| 467 |
+
"name": "baby buggy, baby carriage, carriage, perambulator, pram, stroller, go-cart, pushchair, pusher",
|
| 468 |
+
"id": 79,
|
| 469 |
+
"trainId": 410,
|
| 470 |
+
},
|
| 471 |
+
{"name": "music stand", "id": 1633, "trainId": 411},
|
| 472 |
+
{"name": "pipe, tube", "id": 1885, "trainId": 412},
|
| 473 |
+
{"name": "cup", "id": 677, "trainId": 413},
|
| 474 |
+
{"name": "parking meter", "id": 1779, "trainId": 414},
|
| 475 |
+
{"name": "ice hockey rink", "id": 1297, "trainId": 415},
|
| 476 |
+
{"name": "shelter", "id": 2334, "trainId": 416},
|
| 477 |
+
{"name": "weeds", "id": 3027, "trainId": 417},
|
| 478 |
+
{"name": "temple", "id": 2735, "trainId": 418},
|
| 479 |
+
{"name": "patty, cake", "id": 1791, "trainId": 419},
|
| 480 |
+
{"name": "ski slope", "id": 2405, "trainId": 420},
|
| 481 |
+
{"name": "panel", "id": 1748, "trainId": 421},
|
| 482 |
+
{"name": "wallet", "id": 2983, "trainId": 422},
|
| 483 |
+
{"name": "wheel", "id": 3035, "trainId": 423},
|
| 484 |
+
{"name": "towel rack, towel horse", "id": 2824, "trainId": 424},
|
| 485 |
+
{"name": "roundabout", "id": 2168, "trainId": 425},
|
| 486 |
+
{"name": "canister, cannister, tin", "id": 385, "trainId": 426},
|
| 487 |
+
{"name": "rod", "id": 2148, "trainId": 427},
|
| 488 |
+
{"name": "soap dispenser", "id": 2465, "trainId": 428},
|
| 489 |
+
{"name": "bell", "id": 175, "trainId": 429},
|
| 490 |
+
{"name": "canvas", "id": 390, "trainId": 430},
|
| 491 |
+
{"name": "box office, ticket office, ticket booth", "id": 268, "trainId": 431},
|
| 492 |
+
{"name": "teacup", "id": 2722, "trainId": 432},
|
| 493 |
+
{"name": "trellis", "id": 2857, "trainId": 433},
|
| 494 |
+
{"name": "workbench", "id": 3088, "trainId": 434},
|
| 495 |
+
{"name": "valley, vale", "id": 2926, "trainId": 435},
|
| 496 |
+
{"name": "toaster", "id": 2782, "trainId": 436},
|
| 497 |
+
{"name": "knife", "id": 1378, "trainId": 437},
|
| 498 |
+
{"name": "podium", "id": 1934, "trainId": 438},
|
| 499 |
+
{"name": "ramp", "id": 2072, "trainId": 439},
|
| 500 |
+
{"name": "tumble dryer", "id": 2889, "trainId": 440},
|
| 501 |
+
{"name": "fireplug, fire hydrant, plug", "id": 944, "trainId": 441},
|
| 502 |
+
{"name": "gym shoe, sneaker, tennis shoe", "id": 1158, "trainId": 442},
|
| 503 |
+
{"name": "lab bench", "id": 1383, "trainId": 443},
|
| 504 |
+
{"name": "equipment", "id": 867, "trainId": 444},
|
| 505 |
+
{"name": "rocky formation", "id": 2145, "trainId": 445},
|
| 506 |
+
{"name": "plastic", "id": 1915, "trainId": 446},
|
| 507 |
+
{"name": "calendar", "id": 361, "trainId": 447},
|
| 508 |
+
{"name": "caravan", "id": 402, "trainId": 448},
|
| 509 |
+
{"name": "check-in-desk", "id": 482, "trainId": 449},
|
| 510 |
+
{"name": "ticket counter", "id": 2761, "trainId": 450},
|
| 511 |
+
{"name": "brush", "id": 300, "trainId": 451},
|
| 512 |
+
{"name": "mill", "id": 1554, "trainId": 452},
|
| 513 |
+
{"name": "covered bridge", "id": 636, "trainId": 453},
|
| 514 |
+
{"name": "bowling alley", "id": 260, "trainId": 454},
|
| 515 |
+
{"name": "hanger", "id": 1186, "trainId": 455},
|
| 516 |
+
{"name": "excavator", "id": 871, "trainId": 456},
|
| 517 |
+
{"name": "trestle", "id": 2859, "trainId": 457},
|
| 518 |
+
{"name": "revolving door", "id": 2103, "trainId": 458},
|
| 519 |
+
{"name": "blast furnace", "id": 208, "trainId": 459},
|
| 520 |
+
{"name": "scale, weighing machine", "id": 2236, "trainId": 460},
|
| 521 |
+
{"name": "projector", "id": 2012, "trainId": 461},
|
| 522 |
+
{"name": "soap", "id": 2462, "trainId": 462},
|
| 523 |
+
{"name": "locker", "id": 1462, "trainId": 463},
|
| 524 |
+
{"name": "tractor", "id": 2832, "trainId": 464},
|
| 525 |
+
{"name": "stretcher", "id": 2617, "trainId": 465},
|
| 526 |
+
{"name": "frame", "id": 1024, "trainId": 466},
|
| 527 |
+
{"name": "grating", "id": 1129, "trainId": 467},
|
| 528 |
+
{"name": "alembic", "id": 18, "trainId": 468},
|
| 529 |
+
{"name": "candle, taper, wax light", "id": 376, "trainId": 469},
|
| 530 |
+
{"name": "barrier", "id": 134, "trainId": 470},
|
| 531 |
+
{"name": "cardboard", "id": 407, "trainId": 471},
|
| 532 |
+
{"name": "cave", "id": 434, "trainId": 472},
|
| 533 |
+
{"name": "puddle", "id": 2017, "trainId": 473},
|
| 534 |
+
{"name": "tarp", "id": 2717, "trainId": 474},
|
| 535 |
+
{"name": "price tag", "id": 2005, "trainId": 475},
|
| 536 |
+
{"name": "watchtower", "id": 2993, "trainId": 476},
|
| 537 |
+
{"name": "meters", "id": 1545, "trainId": 477},
|
| 538 |
+
{
|
| 539 |
+
"name": "light bulb, lightbulb, bulb, incandescent lamp, electric light, electric-light bulb",
|
| 540 |
+
"id": 1445,
|
| 541 |
+
"trainId": 478,
|
| 542 |
+
},
|
| 543 |
+
{"name": "tracks", "id": 2831, "trainId": 479},
|
| 544 |
+
{"name": "hair dryer", "id": 1161, "trainId": 480},
|
| 545 |
+
{"name": "skirt", "id": 2411, "trainId": 481},
|
| 546 |
+
{"name": "viaduct", "id": 2949, "trainId": 482},
|
| 547 |
+
{"name": "paper towel", "id": 1769, "trainId": 483},
|
| 548 |
+
{"name": "coat", "id": 552, "trainId": 484},
|
| 549 |
+
{"name": "sheet", "id": 2327, "trainId": 485},
|
| 550 |
+
{"name": "fire extinguisher, extinguisher, asphyxiator", "id": 939, "trainId": 486},
|
| 551 |
+
{"name": "water wheel", "id": 3013, "trainId": 487},
|
| 552 |
+
{"name": "pottery, clayware", "id": 1986, "trainId": 488},
|
| 553 |
+
{"name": "magazine rack", "id": 1486, "trainId": 489},
|
| 554 |
+
{"name": "teapot", "id": 2723, "trainId": 490},
|
| 555 |
+
{"name": "microphone, mike", "id": 1549, "trainId": 491},
|
| 556 |
+
{"name": "support", "id": 2649, "trainId": 492},
|
| 557 |
+
{"name": "forklift", "id": 1020, "trainId": 493},
|
| 558 |
+
{"name": "canyon", "id": 392, "trainId": 494},
|
| 559 |
+
{"name": "cash register, register", "id": 422, "trainId": 495},
|
| 560 |
+
{"name": "leaf, leafage, foliage", "id": 1419, "trainId": 496},
|
| 561 |
+
{"name": "remote control, remote", "id": 2099, "trainId": 497},
|
| 562 |
+
{"name": "soap dish", "id": 2464, "trainId": 498},
|
| 563 |
+
{"name": "windshield, windscreen", "id": 3058, "trainId": 499},
|
| 564 |
+
{"name": "cat", "id": 430, "trainId": 500},
|
| 565 |
+
{"name": "cue, cue stick, pool cue, pool stick", "id": 675, "trainId": 501},
|
| 566 |
+
{"name": "vent, venthole, vent-hole, blowhole", "id": 2941, "trainId": 502},
|
| 567 |
+
{"name": "videos", "id": 2955, "trainId": 503},
|
| 568 |
+
{"name": "shovel", "id": 2355, "trainId": 504},
|
| 569 |
+
{"name": "eaves", "id": 840, "trainId": 505},
|
| 570 |
+
{"name": "antenna, aerial, transmitting aerial", "id": 32, "trainId": 506},
|
| 571 |
+
{"name": "shipyard", "id": 2338, "trainId": 507},
|
| 572 |
+
{"name": "hen, biddy", "id": 1232, "trainId": 508},
|
| 573 |
+
{"name": "traffic cone", "id": 2834, "trainId": 509},
|
| 574 |
+
{"name": "washing machines", "id": 2991, "trainId": 510},
|
| 575 |
+
{"name": "truck crane", "id": 2879, "trainId": 511},
|
| 576 |
+
{"name": "cds", "id": 444, "trainId": 512},
|
| 577 |
+
{"name": "niche", "id": 1657, "trainId": 513},
|
| 578 |
+
{"name": "scoreboard", "id": 2246, "trainId": 514},
|
| 579 |
+
{"name": "briefcase", "id": 296, "trainId": 515},
|
| 580 |
+
{"name": "boot", "id": 245, "trainId": 516},
|
| 581 |
+
{"name": "sweater, jumper", "id": 2661, "trainId": 517},
|
| 582 |
+
{"name": "hay", "id": 1202, "trainId": 518},
|
| 583 |
+
{"name": "pack", "id": 1714, "trainId": 519},
|
| 584 |
+
{"name": "bottle rack", "id": 251, "trainId": 520},
|
| 585 |
+
{"name": "glacier", "id": 1095, "trainId": 521},
|
| 586 |
+
{"name": "pergola", "id": 1828, "trainId": 522},
|
| 587 |
+
{"name": "building materials", "id": 311, "trainId": 523},
|
| 588 |
+
{"name": "television camera", "id": 2732, "trainId": 524},
|
| 589 |
+
{"name": "first floor", "id": 947, "trainId": 525},
|
| 590 |
+
{"name": "rifle", "id": 2115, "trainId": 526},
|
| 591 |
+
{"name": "tennis table", "id": 2738, "trainId": 527},
|
| 592 |
+
{"name": "stadium", "id": 2525, "trainId": 528},
|
| 593 |
+
{"name": "safety belt", "id": 2194, "trainId": 529},
|
| 594 |
+
{"name": "cover", "id": 634, "trainId": 530},
|
| 595 |
+
{"name": "dish rack", "id": 740, "trainId": 531},
|
| 596 |
+
{"name": "synthesizer", "id": 2682, "trainId": 532},
|
| 597 |
+
{"name": "pumpkin", "id": 2020, "trainId": 533},
|
| 598 |
+
{"name": "gutter", "id": 1156, "trainId": 534},
|
| 599 |
+
{"name": "fruit stand", "id": 1036, "trainId": 535},
|
| 600 |
+
{"name": "ice floe, floe", "id": 1295, "trainId": 536},
|
| 601 |
+
{"name": "handle, grip, handgrip, hold", "id": 1181, "trainId": 537},
|
| 602 |
+
{"name": "wheelchair", "id": 3037, "trainId": 538},
|
| 603 |
+
{"name": "mousepad, mouse mat", "id": 1614, "trainId": 539},
|
| 604 |
+
{"name": "diploma", "id": 736, "trainId": 540},
|
| 605 |
+
{"name": "fairground ride", "id": 893, "trainId": 541},
|
| 606 |
+
{"name": "radio", "id": 2047, "trainId": 542},
|
| 607 |
+
{"name": "hotplate", "id": 1274, "trainId": 543},
|
| 608 |
+
{"name": "junk", "id": 1361, "trainId": 544},
|
| 609 |
+
{"name": "wheelbarrow", "id": 3036, "trainId": 545},
|
| 610 |
+
{"name": "stream", "id": 2606, "trainId": 546},
|
| 611 |
+
{"name": "toll plaza", "id": 2797, "trainId": 547},
|
| 612 |
+
{"name": "punching bag", "id": 2022, "trainId": 548},
|
| 613 |
+
{"name": "trough", "id": 2876, "trainId": 549},
|
| 614 |
+
{"name": "throne", "id": 2758, "trainId": 550},
|
| 615 |
+
{"name": "chair desk", "id": 472, "trainId": 551},
|
| 616 |
+
{"name": "weighbridge", "id": 3028, "trainId": 552},
|
| 617 |
+
{"name": "extractor fan", "id": 882, "trainId": 553},
|
| 618 |
+
{"name": "hanging clothes", "id": 1189, "trainId": 554},
|
| 619 |
+
{"name": "dish, dish aerial, dish antenna, saucer", "id": 743, "trainId": 555},
|
| 620 |
+
{"name": "alarm clock, alarm", "id": 3122, "trainId": 556},
|
| 621 |
+
{"name": "ski lift", "id": 2401, "trainId": 557},
|
| 622 |
+
{"name": "chain", "id": 468, "trainId": 558},
|
| 623 |
+
{"name": "garage", "id": 1061, "trainId": 559},
|
| 624 |
+
{"name": "mechanical shovel", "id": 1523, "trainId": 560},
|
| 625 |
+
{"name": "wine rack", "id": 3059, "trainId": 561},
|
| 626 |
+
{"name": "tramway", "id": 2843, "trainId": 562},
|
| 627 |
+
{"name": "treadmill", "id": 2853, "trainId": 563},
|
| 628 |
+
{"name": "menu", "id": 1529, "trainId": 564},
|
| 629 |
+
{"name": "block", "id": 214, "trainId": 565},
|
| 630 |
+
{"name": "well", "id": 3032, "trainId": 566},
|
| 631 |
+
{"name": "witness stand", "id": 3071, "trainId": 567},
|
| 632 |
+
{"name": "branch", "id": 277, "trainId": 568},
|
| 633 |
+
{"name": "duck", "id": 813, "trainId": 569},
|
| 634 |
+
{"name": "casserole", "id": 426, "trainId": 570},
|
| 635 |
+
{"name": "frying pan", "id": 1039, "trainId": 571},
|
| 636 |
+
{"name": "desk organizer", "id": 727, "trainId": 572},
|
| 637 |
+
{"name": "mast", "id": 1508, "trainId": 573},
|
| 638 |
+
{"name": "spectacles, specs, eyeglasses, glasses", "id": 2490, "trainId": 574},
|
| 639 |
+
{"name": "service elevator", "id": 2299, "trainId": 575},
|
| 640 |
+
{"name": "dollhouse", "id": 768, "trainId": 576},
|
| 641 |
+
{"name": "hammock", "id": 1172, "trainId": 577},
|
| 642 |
+
{"name": "clothes hanging", "id": 537, "trainId": 578},
|
| 643 |
+
{"name": "photocopier", "id": 1847, "trainId": 579},
|
| 644 |
+
{"name": "notepad", "id": 1664, "trainId": 580},
|
| 645 |
+
{"name": "golf cart", "id": 1110, "trainId": 581},
|
| 646 |
+
{"name": "footpath", "id": 1014, "trainId": 582},
|
| 647 |
+
{"name": "cross", "id": 662, "trainId": 583},
|
| 648 |
+
{"name": "baptismal font", "id": 121, "trainId": 584},
|
| 649 |
+
{"name": "boiler", "id": 227, "trainId": 585},
|
| 650 |
+
{"name": "skip", "id": 2410, "trainId": 586},
|
| 651 |
+
{"name": "rotisserie", "id": 2165, "trainId": 587},
|
| 652 |
+
{"name": "tables", "id": 2696, "trainId": 588},
|
| 653 |
+
{"name": "water mill", "id": 3005, "trainId": 589},
|
| 654 |
+
{"name": "helmet", "id": 1231, "trainId": 590},
|
| 655 |
+
{"name": "cover curtain", "id": 635, "trainId": 591},
|
| 656 |
+
{"name": "brick", "id": 292, "trainId": 592},
|
| 657 |
+
{"name": "table runner", "id": 2690, "trainId": 593},
|
| 658 |
+
{"name": "ashtray", "id": 65, "trainId": 594},
|
| 659 |
+
{"name": "street box", "id": 2607, "trainId": 595},
|
| 660 |
+
{"name": "stick", "id": 2574, "trainId": 596},
|
| 661 |
+
{"name": "hangers", "id": 1188, "trainId": 597},
|
| 662 |
+
{"name": "cells", "id": 456, "trainId": 598},
|
| 663 |
+
{"name": "urinal", "id": 2913, "trainId": 599},
|
| 664 |
+
{"name": "centerpiece", "id": 459, "trainId": 600},
|
| 665 |
+
{"name": "portable fridge", "id": 1955, "trainId": 601},
|
| 666 |
+
{"name": "dvds", "id": 827, "trainId": 602},
|
| 667 |
+
{"name": "golf club", "id": 1111, "trainId": 603},
|
| 668 |
+
{"name": "skirting board", "id": 2412, "trainId": 604},
|
| 669 |
+
{"name": "water cooler", "id": 2997, "trainId": 605},
|
| 670 |
+
{"name": "clipboard", "id": 528, "trainId": 606},
|
| 671 |
+
{"name": "camera, photographic camera", "id": 366, "trainId": 607},
|
| 672 |
+
{"name": "pigeonhole", "id": 1863, "trainId": 608},
|
| 673 |
+
{"name": "chips", "id": 500, "trainId": 609},
|
| 674 |
+
{"name": "food processor", "id": 1001, "trainId": 610},
|
| 675 |
+
{"name": "post box", "id": 1958, "trainId": 611},
|
| 676 |
+
{"name": "lid", "id": 1441, "trainId": 612},
|
| 677 |
+
{"name": "drum", "id": 809, "trainId": 613},
|
| 678 |
+
{"name": "blender", "id": 210, "trainId": 614},
|
| 679 |
+
{"name": "cave entrance", "id": 435, "trainId": 615},
|
| 680 |
+
{"name": "dental chair", "id": 718, "trainId": 616},
|
| 681 |
+
{"name": "obelisk", "id": 1674, "trainId": 617},
|
| 682 |
+
{"name": "canoe", "id": 388, "trainId": 618},
|
| 683 |
+
{"name": "mobile", "id": 1572, "trainId": 619},
|
| 684 |
+
{"name": "monitors", "id": 1584, "trainId": 620},
|
| 685 |
+
{"name": "pool ball", "id": 1944, "trainId": 621},
|
| 686 |
+
{"name": "cue rack", "id": 674, "trainId": 622},
|
| 687 |
+
{"name": "baggage carts", "id": 99, "trainId": 623},
|
| 688 |
+
{"name": "shore", "id": 2352, "trainId": 624},
|
| 689 |
+
{"name": "fork", "id": 1019, "trainId": 625},
|
| 690 |
+
{"name": "paper filer", "id": 1763, "trainId": 626},
|
| 691 |
+
{"name": "bicycle rack", "id": 185, "trainId": 627},
|
| 692 |
+
{"name": "coat rack", "id": 554, "trainId": 628},
|
| 693 |
+
{"name": "garland", "id": 1066, "trainId": 629},
|
| 694 |
+
{"name": "sports bag", "id": 2508, "trainId": 630},
|
| 695 |
+
{"name": "fish tank", "id": 951, "trainId": 631},
|
| 696 |
+
{"name": "towel dispenser", "id": 2822, "trainId": 632},
|
| 697 |
+
{"name": "carriage", "id": 415, "trainId": 633},
|
| 698 |
+
{"name": "brochure", "id": 297, "trainId": 634},
|
| 699 |
+
{"name": "plaque", "id": 1914, "trainId": 635},
|
| 700 |
+
{"name": "stringer", "id": 2619, "trainId": 636},
|
| 701 |
+
{"name": "iron", "id": 1338, "trainId": 637},
|
| 702 |
+
{"name": "spoon", "id": 2505, "trainId": 638},
|
| 703 |
+
{"name": "flag pole", "id": 955, "trainId": 639},
|
| 704 |
+
{"name": "toilet brush", "id": 2786, "trainId": 640},
|
| 705 |
+
{"name": "book stand", "id": 238, "trainId": 641},
|
| 706 |
+
{"name": "water faucet, water tap, tap, hydrant", "id": 3000, "trainId": 642},
|
| 707 |
+
{"name": "ticket office", "id": 2763, "trainId": 643},
|
| 708 |
+
{"name": "broom", "id": 299, "trainId": 644},
|
| 709 |
+
{"name": "dvd", "id": 822, "trainId": 645},
|
| 710 |
+
{"name": "ice bucket", "id": 1288, "trainId": 646},
|
| 711 |
+
{"name": "carapace, shell, cuticle, shield", "id": 3101, "trainId": 647},
|
| 712 |
+
{"name": "tureen", "id": 2894, "trainId": 648},
|
| 713 |
+
{"name": "folders", "id": 992, "trainId": 649},
|
| 714 |
+
{"name": "chess", "id": 489, "trainId": 650},
|
| 715 |
+
{"name": "root", "id": 2157, "trainId": 651},
|
| 716 |
+
{"name": "sewing machine", "id": 2309, "trainId": 652},
|
| 717 |
+
{"name": "model", "id": 1576, "trainId": 653},
|
| 718 |
+
{"name": "pen", "id": 1810, "trainId": 654},
|
| 719 |
+
{"name": "violin", "id": 2964, "trainId": 655},
|
| 720 |
+
{"name": "sweatshirt", "id": 2662, "trainId": 656},
|
| 721 |
+
{"name": "recycling materials", "id": 2087, "trainId": 657},
|
| 722 |
+
{"name": "mitten", "id": 1569, "trainId": 658},
|
| 723 |
+
{"name": "chopping board, cutting board", "id": 503, "trainId": 659},
|
| 724 |
+
{"name": "mask", "id": 1505, "trainId": 660},
|
| 725 |
+
{"name": "log", "id": 1468, "trainId": 661},
|
| 726 |
+
{"name": "mouse, computer mouse", "id": 1613, "trainId": 662},
|
| 727 |
+
{"name": "grill", "id": 1138, "trainId": 663},
|
| 728 |
+
{"name": "hole", "id": 1256, "trainId": 664},
|
| 729 |
+
{"name": "target", "id": 2715, "trainId": 665},
|
| 730 |
+
{"name": "trash bag", "id": 2846, "trainId": 666},
|
| 731 |
+
{"name": "chalk", "id": 477, "trainId": 667},
|
| 732 |
+
{"name": "sticks", "id": 2576, "trainId": 668},
|
| 733 |
+
{"name": "balloon", "id": 108, "trainId": 669},
|
| 734 |
+
{"name": "score", "id": 2245, "trainId": 670},
|
| 735 |
+
{"name": "hair spray", "id": 1162, "trainId": 671},
|
| 736 |
+
{"name": "roll", "id": 2149, "trainId": 672},
|
| 737 |
+
{"name": "runner", "id": 2183, "trainId": 673},
|
| 738 |
+
{"name": "engine", "id": 858, "trainId": 674},
|
| 739 |
+
{"name": "inflatable glove", "id": 1324, "trainId": 675},
|
| 740 |
+
{"name": "games", "id": 1055, "trainId": 676},
|
| 741 |
+
{"name": "pallets", "id": 1741, "trainId": 677},
|
| 742 |
+
{"name": "baskets", "id": 149, "trainId": 678},
|
| 743 |
+
{"name": "coop", "id": 615, "trainId": 679},
|
| 744 |
+
{"name": "dvd player", "id": 825, "trainId": 680},
|
| 745 |
+
{"name": "rocking horse", "id": 2143, "trainId": 681},
|
| 746 |
+
{"name": "buckets", "id": 304, "trainId": 682},
|
| 747 |
+
{"name": "bread rolls", "id": 283, "trainId": 683},
|
| 748 |
+
{"name": "shawl", "id": 2322, "trainId": 684},
|
| 749 |
+
{"name": "watering can", "id": 3017, "trainId": 685},
|
| 750 |
+
{"name": "spotlights", "id": 2510, "trainId": 686},
|
| 751 |
+
{"name": "post-it", "id": 1960, "trainId": 687},
|
| 752 |
+
{"name": "bowls", "id": 265, "trainId": 688},
|
| 753 |
+
{"name": "security camera", "id": 2282, "trainId": 689},
|
| 754 |
+
{"name": "runner cloth", "id": 2184, "trainId": 690},
|
| 755 |
+
{"name": "lock", "id": 1461, "trainId": 691},
|
| 756 |
+
{"name": "alarm, warning device, alarm system", "id": 3113, "trainId": 692},
|
| 757 |
+
{"name": "side", "id": 2372, "trainId": 693},
|
| 758 |
+
{"name": "roulette", "id": 2166, "trainId": 694},
|
| 759 |
+
{"name": "bone", "id": 232, "trainId": 695},
|
| 760 |
+
{"name": "cutlery", "id": 693, "trainId": 696},
|
| 761 |
+
{"name": "pool balls", "id": 1945, "trainId": 697},
|
| 762 |
+
{"name": "wheels", "id": 3039, "trainId": 698},
|
| 763 |
+
{"name": "spice rack", "id": 2494, "trainId": 699},
|
| 764 |
+
{"name": "plant pots", "id": 1908, "trainId": 700},
|
| 765 |
+
{"name": "towel ring", "id": 2827, "trainId": 701},
|
| 766 |
+
{"name": "bread box", "id": 280, "trainId": 702},
|
| 767 |
+
{"name": "video", "id": 2950, "trainId": 703},
|
| 768 |
+
{"name": "funfair", "id": 1044, "trainId": 704},
|
| 769 |
+
{"name": "breads", "id": 288, "trainId": 705},
|
| 770 |
+
{"name": "tripod", "id": 2863, "trainId": 706},
|
| 771 |
+
{"name": "ironing board", "id": 1342, "trainId": 707},
|
| 772 |
+
{"name": "skimmer", "id": 2409, "trainId": 708},
|
| 773 |
+
{"name": "hollow", "id": 1258, "trainId": 709},
|
| 774 |
+
{"name": "scratching post", "id": 2249, "trainId": 710},
|
| 775 |
+
{"name": "tricycle", "id": 2862, "trainId": 711},
|
| 776 |
+
{"name": "file box", "id": 920, "trainId": 712},
|
| 777 |
+
{"name": "mountain pass", "id": 1607, "trainId": 713},
|
| 778 |
+
{"name": "tombstones", "id": 2802, "trainId": 714},
|
| 779 |
+
{"name": "cooker", "id": 610, "trainId": 715},
|
| 780 |
+
{"name": "card game, cards", "id": 3129, "trainId": 716},
|
| 781 |
+
{"name": "golf bag", "id": 1108, "trainId": 717},
|
| 782 |
+
{"name": "towel paper", "id": 2823, "trainId": 718},
|
| 783 |
+
{"name": "chaise lounge", "id": 476, "trainId": 719},
|
| 784 |
+
{"name": "sun", "id": 2641, "trainId": 720},
|
| 785 |
+
{"name": "toilet paper holder", "id": 2788, "trainId": 721},
|
| 786 |
+
{"name": "rake", "id": 2070, "trainId": 722},
|
| 787 |
+
{"name": "key", "id": 1368, "trainId": 723},
|
| 788 |
+
{"name": "umbrella stand", "id": 2903, "trainId": 724},
|
| 789 |
+
{"name": "dartboard", "id": 699, "trainId": 725},
|
| 790 |
+
{"name": "transformer", "id": 2844, "trainId": 726},
|
| 791 |
+
{"name": "fireplace utensils", "id": 942, "trainId": 727},
|
| 792 |
+
{"name": "sweatshirts", "id": 2663, "trainId": 728},
|
| 793 |
+
{
|
| 794 |
+
"name": "cellular telephone, cellular phone, cellphone, cell, mobile phone",
|
| 795 |
+
"id": 457,
|
| 796 |
+
"trainId": 729,
|
| 797 |
+
},
|
| 798 |
+
{"name": "tallboy", "id": 2701, "trainId": 730},
|
| 799 |
+
{"name": "stapler", "id": 2540, "trainId": 731},
|
| 800 |
+
{"name": "sauna", "id": 2231, "trainId": 732},
|
| 801 |
+
{"name": "test tube", "id": 2746, "trainId": 733},
|
| 802 |
+
{"name": "palette", "id": 1738, "trainId": 734},
|
| 803 |
+
{"name": "shopping carts", "id": 2350, "trainId": 735},
|
| 804 |
+
{"name": "tools", "id": 2808, "trainId": 736},
|
| 805 |
+
{"name": "push button, push, button", "id": 2025, "trainId": 737},
|
| 806 |
+
{"name": "star", "id": 2541, "trainId": 738},
|
| 807 |
+
{"name": "roof rack", "id": 2156, "trainId": 739},
|
| 808 |
+
{"name": "barbed wire", "id": 126, "trainId": 740},
|
| 809 |
+
{"name": "spray", "id": 2512, "trainId": 741},
|
| 810 |
+
{"name": "ear", "id": 831, "trainId": 742},
|
| 811 |
+
{"name": "sponge", "id": 2503, "trainId": 743},
|
| 812 |
+
{"name": "racket", "id": 2039, "trainId": 744},
|
| 813 |
+
{"name": "tins", "id": 2774, "trainId": 745},
|
| 814 |
+
{"name": "eyeglasses", "id": 886, "trainId": 746},
|
| 815 |
+
{"name": "file", "id": 919, "trainId": 747},
|
| 816 |
+
{"name": "scarfs", "id": 2240, "trainId": 748},
|
| 817 |
+
{"name": "sugar bowl", "id": 2636, "trainId": 749},
|
| 818 |
+
{"name": "flip flop", "id": 963, "trainId": 750},
|
| 819 |
+
{"name": "headstones", "id": 1218, "trainId": 751},
|
| 820 |
+
{"name": "laptop bag", "id": 1406, "trainId": 752},
|
| 821 |
+
{"name": "leash", "id": 1420, "trainId": 753},
|
| 822 |
+
{"name": "climbing frame", "id": 526, "trainId": 754},
|
| 823 |
+
{"name": "suit hanger", "id": 2639, "trainId": 755},
|
| 824 |
+
{"name": "floor spotlight", "id": 975, "trainId": 756},
|
| 825 |
+
{"name": "plate rack", "id": 1921, "trainId": 757},
|
| 826 |
+
{"name": "sewer", "id": 2305, "trainId": 758},
|
| 827 |
+
{"name": "hard drive", "id": 1193, "trainId": 759},
|
| 828 |
+
{"name": "sprinkler", "id": 2517, "trainId": 760},
|
| 829 |
+
{"name": "tools box", "id": 2809, "trainId": 761},
|
| 830 |
+
{"name": "necklace", "id": 1647, "trainId": 762},
|
| 831 |
+
{"name": "bulbs", "id": 314, "trainId": 763},
|
| 832 |
+
{"name": "steel industry", "id": 2560, "trainId": 764},
|
| 833 |
+
{"name": "club", "id": 545, "trainId": 765},
|
| 834 |
+
{"name": "jack", "id": 1345, "trainId": 766},
|
| 835 |
+
{"name": "door bars", "id": 775, "trainId": 767},
|
| 836 |
+
{
|
| 837 |
+
"name": "control panel, instrument panel, control board, board, panel",
|
| 838 |
+
"id": 603,
|
| 839 |
+
"trainId": 768,
|
| 840 |
+
},
|
| 841 |
+
{"name": "hairbrush", "id": 1163, "trainId": 769},
|
| 842 |
+
{"name": "napkin holder", "id": 1641, "trainId": 770},
|
| 843 |
+
{"name": "office", "id": 1678, "trainId": 771},
|
| 844 |
+
{"name": "smoke detector", "id": 2450, "trainId": 772},
|
| 845 |
+
{"name": "utensils", "id": 2915, "trainId": 773},
|
| 846 |
+
{"name": "apron", "id": 42, "trainId": 774},
|
| 847 |
+
{"name": "scissors", "id": 2242, "trainId": 775},
|
| 848 |
+
{"name": "terminal", "id": 2741, "trainId": 776},
|
| 849 |
+
{"name": "grinder", "id": 1143, "trainId": 777},
|
| 850 |
+
{"name": "entry phone", "id": 862, "trainId": 778},
|
| 851 |
+
{"name": "newspaper stand", "id": 1654, "trainId": 779},
|
| 852 |
+
{"name": "pepper shaker", "id": 1826, "trainId": 780},
|
| 853 |
+
{"name": "onions", "id": 1689, "trainId": 781},
|
| 854 |
+
{
|
| 855 |
+
"name": "central processing unit, cpu, c p u , central processor, processor, mainframe",
|
| 856 |
+
"id": 3124,
|
| 857 |
+
"trainId": 782,
|
| 858 |
+
},
|
| 859 |
+
{"name": "tape", "id": 2710, "trainId": 783},
|
| 860 |
+
{"name": "bat", "id": 152, "trainId": 784},
|
| 861 |
+
{"name": "coaster", "id": 549, "trainId": 785},
|
| 862 |
+
{"name": "calculator", "id": 360, "trainId": 786},
|
| 863 |
+
{"name": "potatoes", "id": 1982, "trainId": 787},
|
| 864 |
+
{"name": "luggage rack", "id": 1478, "trainId": 788},
|
| 865 |
+
{"name": "salt", "id": 2203, "trainId": 789},
|
| 866 |
+
{"name": "street number", "id": 2612, "trainId": 790},
|
| 867 |
+
{"name": "viewpoint", "id": 2956, "trainId": 791},
|
| 868 |
+
{"name": "sword", "id": 2681, "trainId": 792},
|
| 869 |
+
{"name": "cd", "id": 437, "trainId": 793},
|
| 870 |
+
{"name": "rowing machine", "id": 2171, "trainId": 794},
|
| 871 |
+
{"name": "plug", "id": 1933, "trainId": 795},
|
| 872 |
+
{"name": "andiron, firedog, dog, dog-iron", "id": 3110, "trainId": 796},
|
| 873 |
+
{"name": "pepper", "id": 1824, "trainId": 797},
|
| 874 |
+
{"name": "tongs", "id": 2803, "trainId": 798},
|
| 875 |
+
{"name": "bonfire", "id": 234, "trainId": 799},
|
| 876 |
+
{"name": "dog dish", "id": 764, "trainId": 800},
|
| 877 |
+
{"name": "belt", "id": 177, "trainId": 801},
|
| 878 |
+
{"name": "dumbbells", "id": 817, "trainId": 802},
|
| 879 |
+
{"name": "videocassette recorder, vcr", "id": 3145, "trainId": 803},
|
| 880 |
+
{"name": "hook", "id": 1262, "trainId": 804},
|
| 881 |
+
{"name": "envelopes", "id": 864, "trainId": 805},
|
| 882 |
+
{"name": "shower faucet", "id": 2359, "trainId": 806},
|
| 883 |
+
{"name": "watch", "id": 2992, "trainId": 807},
|
| 884 |
+
{"name": "padlock", "id": 1725, "trainId": 808},
|
| 885 |
+
{"name": "swimming pool ladder", "id": 2667, "trainId": 809},
|
| 886 |
+
{"name": "spanners", "id": 2484, "trainId": 810},
|
| 887 |
+
{"name": "gravy boat", "id": 1133, "trainId": 811},
|
| 888 |
+
{"name": "notice board", "id": 1667, "trainId": 812},
|
| 889 |
+
{"name": "trash bags", "id": 2847, "trainId": 813},
|
| 890 |
+
{"name": "fire alarm", "id": 932, "trainId": 814},
|
| 891 |
+
{"name": "ladle", "id": 1392, "trainId": 815},
|
| 892 |
+
{"name": "stethoscope", "id": 2573, "trainId": 816},
|
| 893 |
+
{"name": "rocket", "id": 2140, "trainId": 817},
|
| 894 |
+
{"name": "funnel", "id": 1046, "trainId": 818},
|
| 895 |
+
{"name": "bowling pins", "id": 264, "trainId": 819},
|
| 896 |
+
{"name": "valve", "id": 2927, "trainId": 820},
|
| 897 |
+
{"name": "thermometer", "id": 2752, "trainId": 821},
|
| 898 |
+
{"name": "cups", "id": 679, "trainId": 822},
|
| 899 |
+
{"name": "spice jar", "id": 2493, "trainId": 823},
|
| 900 |
+
{"name": "night light", "id": 1658, "trainId": 824},
|
| 901 |
+
{"name": "soaps", "id": 2466, "trainId": 825},
|
| 902 |
+
{"name": "games table", "id": 1057, "trainId": 826},
|
| 903 |
+
{"name": "slotted spoon", "id": 2444, "trainId": 827},
|
| 904 |
+
{"name": "reel", "id": 2093, "trainId": 828},
|
| 905 |
+
{"name": "scourer", "id": 2248, "trainId": 829},
|
| 906 |
+
{"name": "sleeping robe", "id": 2432, "trainId": 830},
|
| 907 |
+
{"name": "desk mat", "id": 726, "trainId": 831},
|
| 908 |
+
{"name": "dumbbell", "id": 816, "trainId": 832},
|
| 909 |
+
{"name": "hammer", "id": 1171, "trainId": 833},
|
| 910 |
+
{"name": "tie", "id": 2766, "trainId": 834},
|
| 911 |
+
{"name": "typewriter", "id": 2900, "trainId": 835},
|
| 912 |
+
{"name": "shaker", "id": 2313, "trainId": 836},
|
| 913 |
+
{"name": "cheese dish", "id": 488, "trainId": 837},
|
| 914 |
+
{"name": "sea star", "id": 2265, "trainId": 838},
|
| 915 |
+
{"name": "racquet", "id": 2043, "trainId": 839},
|
| 916 |
+
{"name": "butane gas cylinder", "id": 332, "trainId": 840},
|
| 917 |
+
{"name": "paper weight", "id": 1771, "trainId": 841},
|
| 918 |
+
{"name": "shaving brush", "id": 2320, "trainId": 842},
|
| 919 |
+
{"name": "sunglasses", "id": 2646, "trainId": 843},
|
| 920 |
+
{"name": "gear shift", "id": 1089, "trainId": 844},
|
| 921 |
+
{"name": "towel rail", "id": 2826, "trainId": 845},
|
| 922 |
+
{"name": "adding machine, totalizer, totaliser", "id": 3148, "trainId": 846},
|
| 923 |
+
]
|
| 924 |
+
|
| 925 |
+
|
| 926 |
+
def _get_ade20k_full_meta():
|
| 927 |
+
# Id 0 is reserved for ignore_label, we change ignore_label for 0
|
| 928 |
+
# to 255 in our pre-processing, so all ids are shifted by 1.
|
| 929 |
+
stuff_ids = [k["id"] for k in ADE20K_SEM_SEG_FULL_CATEGORIES]
|
| 930 |
+
assert len(stuff_ids) == 847, len(stuff_ids)
|
| 931 |
+
|
| 932 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 933 |
+
# (in [0, 91], used in models) to ids in the dataset (used for processing results)
|
| 934 |
+
stuff_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(stuff_ids)}
|
| 935 |
+
stuff_classes = [k["name"] for k in ADE20K_SEM_SEG_FULL_CATEGORIES]
|
| 936 |
+
|
| 937 |
+
ret = {
|
| 938 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 939 |
+
"stuff_classes": stuff_classes,
|
| 940 |
+
}
|
| 941 |
+
return ret
|
| 942 |
+
|
| 943 |
+
|
| 944 |
+
def register_all_ade20k_full(root):
|
| 945 |
+
root = os.path.join(root, "ADE20K_2021_17_01")
|
| 946 |
+
meta = _get_ade20k_full_meta()
|
| 947 |
+
for name, dirname in [("train", "training"), ("val", "validation")]:
|
| 948 |
+
image_dir = os.path.join(root, "images_detectron2", dirname)
|
| 949 |
+
gt_dir = os.path.join(root, "annotations_detectron2", dirname)
|
| 950 |
+
name = f"ade20k_full_sem_seg_{name}"
|
| 951 |
+
DatasetCatalog.register(
|
| 952 |
+
name, lambda x=image_dir, y=gt_dir: load_sem_seg(y, x, gt_ext="tif", image_ext="jpg")
|
| 953 |
+
)
|
| 954 |
+
MetadataCatalog.get(name).set(
|
| 955 |
+
stuff_classes=meta["stuff_classes"][:],
|
| 956 |
+
image_root=image_dir,
|
| 957 |
+
sem_seg_root=gt_dir,
|
| 958 |
+
evaluator_type="sem_seg",
|
| 959 |
+
ignore_label=65535, # NOTE: gt is saved in 16-bit TIFF images
|
| 960 |
+
)
|
| 961 |
+
|
| 962 |
+
|
| 963 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 964 |
+
register_all_ade20k_full(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_ade20k_instance.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import json
|
| 3 |
+
import logging
|
| 4 |
+
import numpy as np
|
| 5 |
+
import os
|
| 6 |
+
from PIL import Image
|
| 7 |
+
|
| 8 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 9 |
+
from detectron2.data.datasets.coco import load_coco_json, register_coco_instances
|
| 10 |
+
from detectron2.utils.file_io import PathManager
|
| 11 |
+
|
| 12 |
+
ADE_CATEGORIES = [{'id': 7, 'name': 'bed'}, {'id': 8, 'name': 'windowpane'}, {'id': 10, 'name': 'cabinet'}, {'id': 12, 'name': 'person'}, {'id': 14, 'name': 'door'}, {'id': 15, 'name': 'table'}, {'id': 18, 'name': 'curtain'}, {'id': 19, 'name': 'chair'}, {'id': 20, 'name': 'car'}, {'id': 22, 'name': 'painting'}, {'id': 23, 'name': 'sofa'}, {'id': 24, 'name': 'shelf'}, {'id': 27, 'name': 'mirror'}, {'id': 30, 'name': 'armchair'}, {'id': 31, 'name': 'seat'}, {'id': 32, 'name': 'fence'}, {'id': 33, 'name': 'desk'}, {'id': 35, 'name': 'wardrobe'}, {'id': 36, 'name': 'lamp'}, {'id': 37, 'name': 'bathtub'}, {'id': 38, 'name': 'railing'}, {'id': 39, 'name': 'cushion'}, {'id': 41, 'name': 'box'}, {'id': 42, 'name': 'column'}, {'id': 43, 'name': 'signboard'}, {'id': 44, 'name': 'chest of drawers'}, {'id': 45, 'name': 'counter'}, {'id': 47, 'name': 'sink'}, {'id': 49, 'name': 'fireplace'}, {'id': 50, 'name': 'refrigerator'}, {'id': 53, 'name': 'stairs'}, {'id': 55, 'name': 'case'}, {'id': 56, 'name': 'pool table'}, {'id': 57, 'name': 'pillow'}, {'id': 58, 'name': 'screen door'}, {'id': 62, 'name': 'bookcase'}, {'id': 64, 'name': 'coffee table'}, {'id': 65, 'name': 'toilet'}, {'id': 66, 'name': 'flower'}, {'id': 67, 'name': 'book'}, {'id': 69, 'name': 'bench'}, {'id': 70, 'name': 'countertop'}, {'id': 71, 'name': 'stove'}, {'id': 72, 'name': 'palm'}, {'id': 73, 'name': 'kitchen island'}, {'id': 74, 'name': 'computer'}, {'id': 75, 'name': 'swivel chair'}, {'id': 76, 'name': 'boat'}, {'id': 78, 'name': 'arcade machine'}, {'id': 80, 'name': 'bus'}, {'id': 81, 'name': 'towel'}, {'id': 82, 'name': 'light'}, {'id': 83, 'name': 'truck'}, {'id': 85, 'name': 'chandelier'}, {'id': 86, 'name': 'awning'}, {'id': 87, 'name': 'streetlight'}, {'id': 88, 'name': 'booth'}, {'id': 89, 'name': 'television receiver'}, {'id': 90, 'name': 'airplane'}, {'id': 92, 'name': 'apparel'}, {'id': 93, 'name': 'pole'}, {'id': 95, 'name': 'bannister'}, {'id': 97, 'name': 'ottoman'}, {'id': 98, 'name': 'bottle'}, {'id': 102, 'name': 'van'}, {'id': 103, 'name': 'ship'}, {'id': 104, 'name': 'fountain'}, {'id': 107, 'name': 'washer'}, {'id': 108, 'name': 'plaything'}, {'id': 110, 'name': 'stool'}, {'id': 111, 'name': 'barrel'}, {'id': 112, 'name': 'basket'}, {'id': 115, 'name': 'bag'}, {'id': 116, 'name': 'minibike'}, {'id': 118, 'name': 'oven'}, {'id': 119, 'name': 'ball'}, {'id': 120, 'name': 'food'}, {'id': 121, 'name': 'step'}, {'id': 123, 'name': 'trade name'}, {'id': 124, 'name': 'microwave'}, {'id': 125, 'name': 'pot'}, {'id': 126, 'name': 'animal'}, {'id': 127, 'name': 'bicycle'}, {'id': 129, 'name': 'dishwasher'}, {'id': 130, 'name': 'screen'}, {'id': 132, 'name': 'sculpture'}, {'id': 133, 'name': 'hood'}, {'id': 134, 'name': 'sconce'}, {'id': 135, 'name': 'vase'}, {'id': 136, 'name': 'traffic light'}, {'id': 137, 'name': 'tray'}, {'id': 138, 'name': 'ashcan'}, {'id': 139, 'name': 'fan'}, {'id': 142, 'name': 'plate'}, {'id': 143, 'name': 'monitor'}, {'id': 144, 'name': 'bulletin board'}, {'id': 146, 'name': 'radiator'}, {'id': 147, 'name': 'glass'}, {'id': 148, 'name': 'clock'}, {'id': 149, 'name': 'flag'}]
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
_PREDEFINED_SPLITS = {
|
| 16 |
+
# point annotations without masks
|
| 17 |
+
"ade20k_instance_train": (
|
| 18 |
+
"ADEChallengeData2016/images/training",
|
| 19 |
+
"ADEChallengeData2016/ade20k_instance_train.json",
|
| 20 |
+
),
|
| 21 |
+
"ade20k_instance_val": (
|
| 22 |
+
"ADEChallengeData2016/images/validation",
|
| 23 |
+
"ADEChallengeData2016/ade20k_instance_val.json",
|
| 24 |
+
),
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _get_ade_instances_meta():
|
| 29 |
+
thing_ids = [k["id"] for k in ADE_CATEGORIES]
|
| 30 |
+
assert len(thing_ids) == 100, len(thing_ids)
|
| 31 |
+
# Mapping from the incontiguous ADE category id to an id in [0, 99]
|
| 32 |
+
thing_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(thing_ids)}
|
| 33 |
+
thing_classes = [k["name"] for k in ADE_CATEGORIES]
|
| 34 |
+
ret = {
|
| 35 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 36 |
+
"thing_classes": thing_classes,
|
| 37 |
+
}
|
| 38 |
+
return ret
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def register_all_ade20k_instance(root):
|
| 42 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS.items():
|
| 43 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 44 |
+
register_coco_instances(
|
| 45 |
+
key,
|
| 46 |
+
_get_ade_instances_meta(),
|
| 47 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 48 |
+
os.path.join(root, image_root),
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 53 |
+
register_all_ade20k_instance(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_ade20k_panoptic.py
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 6 |
+
from detectron2.utils.file_io import PathManager
|
| 7 |
+
|
| 8 |
+
ADE20K_150_CATEGORIES = [
|
| 9 |
+
{"color": [120, 120, 120], "id": 0, "isthing": 0, "name": "wall"},
|
| 10 |
+
{"color": [180, 120, 120], "id": 1, "isthing": 0, "name": "building"},
|
| 11 |
+
{"color": [6, 230, 230], "id": 2, "isthing": 0, "name": "sky"},
|
| 12 |
+
{"color": [80, 50, 50], "id": 3, "isthing": 0, "name": "floor"},
|
| 13 |
+
{"color": [4, 200, 3], "id": 4, "isthing": 0, "name": "tree"},
|
| 14 |
+
{"color": [120, 120, 80], "id": 5, "isthing": 0, "name": "ceiling"},
|
| 15 |
+
{"color": [140, 140, 140], "id": 6, "isthing": 0, "name": "road, route"},
|
| 16 |
+
{"color": [204, 5, 255], "id": 7, "isthing": 1, "name": "bed"},
|
| 17 |
+
{"color": [230, 230, 230], "id": 8, "isthing": 1, "name": "window "},
|
| 18 |
+
{"color": [4, 250, 7], "id": 9, "isthing": 0, "name": "grass"},
|
| 19 |
+
{"color": [224, 5, 255], "id": 10, "isthing": 1, "name": "cabinet"},
|
| 20 |
+
{"color": [235, 255, 7], "id": 11, "isthing": 0, "name": "sidewalk, pavement"},
|
| 21 |
+
{"color": [150, 5, 61], "id": 12, "isthing": 1, "name": "person"},
|
| 22 |
+
{"color": [120, 120, 70], "id": 13, "isthing": 0, "name": "earth, ground"},
|
| 23 |
+
{"color": [8, 255, 51], "id": 14, "isthing": 1, "name": "door"},
|
| 24 |
+
{"color": [255, 6, 82], "id": 15, "isthing": 1, "name": "table"},
|
| 25 |
+
{"color": [143, 255, 140], "id": 16, "isthing": 0, "name": "mountain, mount"},
|
| 26 |
+
{"color": [204, 255, 4], "id": 17, "isthing": 0, "name": "plant"},
|
| 27 |
+
{"color": [255, 51, 7], "id": 18, "isthing": 1, "name": "curtain"},
|
| 28 |
+
{"color": [204, 70, 3], "id": 19, "isthing": 1, "name": "chair"},
|
| 29 |
+
{"color": [0, 102, 200], "id": 20, "isthing": 1, "name": "car"},
|
| 30 |
+
{"color": [61, 230, 250], "id": 21, "isthing": 0, "name": "water"},
|
| 31 |
+
{"color": [255, 6, 51], "id": 22, "isthing": 1, "name": "painting, picture"},
|
| 32 |
+
{"color": [11, 102, 255], "id": 23, "isthing": 1, "name": "sofa"},
|
| 33 |
+
{"color": [255, 7, 71], "id": 24, "isthing": 1, "name": "shelf"},
|
| 34 |
+
{"color": [255, 9, 224], "id": 25, "isthing": 0, "name": "house"},
|
| 35 |
+
{"color": [9, 7, 230], "id": 26, "isthing": 0, "name": "sea"},
|
| 36 |
+
{"color": [220, 220, 220], "id": 27, "isthing": 1, "name": "mirror"},
|
| 37 |
+
{"color": [255, 9, 92], "id": 28, "isthing": 0, "name": "rug"},
|
| 38 |
+
{"color": [112, 9, 255], "id": 29, "isthing": 0, "name": "field"},
|
| 39 |
+
{"color": [8, 255, 214], "id": 30, "isthing": 1, "name": "armchair"},
|
| 40 |
+
{"color": [7, 255, 224], "id": 31, "isthing": 1, "name": "seat"},
|
| 41 |
+
{"color": [255, 184, 6], "id": 32, "isthing": 1, "name": "fence"},
|
| 42 |
+
{"color": [10, 255, 71], "id": 33, "isthing": 1, "name": "desk"},
|
| 43 |
+
{"color": [255, 41, 10], "id": 34, "isthing": 0, "name": "rock, stone"},
|
| 44 |
+
{"color": [7, 255, 255], "id": 35, "isthing": 1, "name": "wardrobe, closet, press"},
|
| 45 |
+
{"color": [224, 255, 8], "id": 36, "isthing": 1, "name": "lamp"},
|
| 46 |
+
{"color": [102, 8, 255], "id": 37, "isthing": 1, "name": "tub"},
|
| 47 |
+
{"color": [255, 61, 6], "id": 38, "isthing": 1, "name": "rail"},
|
| 48 |
+
{"color": [255, 194, 7], "id": 39, "isthing": 1, "name": "cushion"},
|
| 49 |
+
{"color": [255, 122, 8], "id": 40, "isthing": 0, "name": "base, pedestal, stand"},
|
| 50 |
+
{"color": [0, 255, 20], "id": 41, "isthing": 1, "name": "box"},
|
| 51 |
+
{"color": [255, 8, 41], "id": 42, "isthing": 1, "name": "column, pillar"},
|
| 52 |
+
{"color": [255, 5, 153], "id": 43, "isthing": 1, "name": "signboard, sign"},
|
| 53 |
+
{
|
| 54 |
+
"color": [6, 51, 255],
|
| 55 |
+
"id": 44,
|
| 56 |
+
"isthing": 1,
|
| 57 |
+
"name": "chest of drawers, chest, bureau, dresser",
|
| 58 |
+
},
|
| 59 |
+
{"color": [235, 12, 255], "id": 45, "isthing": 1, "name": "counter"},
|
| 60 |
+
{"color": [160, 150, 20], "id": 46, "isthing": 0, "name": "sand"},
|
| 61 |
+
{"color": [0, 163, 255], "id": 47, "isthing": 1, "name": "sink"},
|
| 62 |
+
{"color": [140, 140, 140], "id": 48, "isthing": 0, "name": "skyscraper"},
|
| 63 |
+
{"color": [250, 10, 15], "id": 49, "isthing": 1, "name": "fireplace"},
|
| 64 |
+
{"color": [20, 255, 0], "id": 50, "isthing": 1, "name": "refrigerator, icebox"},
|
| 65 |
+
{"color": [31, 255, 0], "id": 51, "isthing": 0, "name": "grandstand, covered stand"},
|
| 66 |
+
{"color": [255, 31, 0], "id": 52, "isthing": 0, "name": "path"},
|
| 67 |
+
{"color": [255, 224, 0], "id": 53, "isthing": 1, "name": "stairs"},
|
| 68 |
+
{"color": [153, 255, 0], "id": 54, "isthing": 0, "name": "runway"},
|
| 69 |
+
{"color": [0, 0, 255], "id": 55, "isthing": 1, "name": "case, display case, showcase, vitrine"},
|
| 70 |
+
{
|
| 71 |
+
"color": [255, 71, 0],
|
| 72 |
+
"id": 56,
|
| 73 |
+
"isthing": 1,
|
| 74 |
+
"name": "pool table, billiard table, snooker table",
|
| 75 |
+
},
|
| 76 |
+
{"color": [0, 235, 255], "id": 57, "isthing": 1, "name": "pillow"},
|
| 77 |
+
{"color": [0, 173, 255], "id": 58, "isthing": 1, "name": "screen door, screen"},
|
| 78 |
+
{"color": [31, 0, 255], "id": 59, "isthing": 0, "name": "stairway, staircase"},
|
| 79 |
+
{"color": [11, 200, 200], "id": 60, "isthing": 0, "name": "river"},
|
| 80 |
+
{"color": [255, 82, 0], "id": 61, "isthing": 0, "name": "bridge, span"},
|
| 81 |
+
{"color": [0, 255, 245], "id": 62, "isthing": 1, "name": "bookcase"},
|
| 82 |
+
{"color": [0, 61, 255], "id": 63, "isthing": 0, "name": "blind, screen"},
|
| 83 |
+
{"color": [0, 255, 112], "id": 64, "isthing": 1, "name": "coffee table"},
|
| 84 |
+
{
|
| 85 |
+
"color": [0, 255, 133],
|
| 86 |
+
"id": 65,
|
| 87 |
+
"isthing": 1,
|
| 88 |
+
"name": "toilet, can, commode, crapper, pot, potty, stool, throne",
|
| 89 |
+
},
|
| 90 |
+
{"color": [255, 0, 0], "id": 66, "isthing": 1, "name": "flower"},
|
| 91 |
+
{"color": [255, 163, 0], "id": 67, "isthing": 1, "name": "book"},
|
| 92 |
+
{"color": [255, 102, 0], "id": 68, "isthing": 0, "name": "hill"},
|
| 93 |
+
{"color": [194, 255, 0], "id": 69, "isthing": 1, "name": "bench"},
|
| 94 |
+
{"color": [0, 143, 255], "id": 70, "isthing": 1, "name": "countertop"},
|
| 95 |
+
{"color": [51, 255, 0], "id": 71, "isthing": 1, "name": "stove"},
|
| 96 |
+
{"color": [0, 82, 255], "id": 72, "isthing": 1, "name": "palm, palm tree"},
|
| 97 |
+
{"color": [0, 255, 41], "id": 73, "isthing": 1, "name": "kitchen island"},
|
| 98 |
+
{"color": [0, 255, 173], "id": 74, "isthing": 1, "name": "computer"},
|
| 99 |
+
{"color": [10, 0, 255], "id": 75, "isthing": 1, "name": "swivel chair"},
|
| 100 |
+
{"color": [173, 255, 0], "id": 76, "isthing": 1, "name": "boat"},
|
| 101 |
+
{"color": [0, 255, 153], "id": 77, "isthing": 0, "name": "bar"},
|
| 102 |
+
{"color": [255, 92, 0], "id": 78, "isthing": 1, "name": "arcade machine"},
|
| 103 |
+
{"color": [255, 0, 255], "id": 79, "isthing": 0, "name": "hovel, hut, hutch, shack, shanty"},
|
| 104 |
+
{"color": [255, 0, 245], "id": 80, "isthing": 1, "name": "bus"},
|
| 105 |
+
{"color": [255, 0, 102], "id": 81, "isthing": 1, "name": "towel"},
|
| 106 |
+
{"color": [255, 173, 0], "id": 82, "isthing": 1, "name": "light"},
|
| 107 |
+
{"color": [255, 0, 20], "id": 83, "isthing": 1, "name": "truck"},
|
| 108 |
+
{"color": [255, 184, 184], "id": 84, "isthing": 0, "name": "tower"},
|
| 109 |
+
{"color": [0, 31, 255], "id": 85, "isthing": 1, "name": "chandelier"},
|
| 110 |
+
{"color": [0, 255, 61], "id": 86, "isthing": 1, "name": "awning, sunshade, sunblind"},
|
| 111 |
+
{"color": [0, 71, 255], "id": 87, "isthing": 1, "name": "street lamp"},
|
| 112 |
+
{"color": [255, 0, 204], "id": 88, "isthing": 1, "name": "booth"},
|
| 113 |
+
{"color": [0, 255, 194], "id": 89, "isthing": 1, "name": "tv"},
|
| 114 |
+
{"color": [0, 255, 82], "id": 90, "isthing": 1, "name": "plane"},
|
| 115 |
+
{"color": [0, 10, 255], "id": 91, "isthing": 0, "name": "dirt track"},
|
| 116 |
+
{"color": [0, 112, 255], "id": 92, "isthing": 1, "name": "clothes"},
|
| 117 |
+
{"color": [51, 0, 255], "id": 93, "isthing": 1, "name": "pole"},
|
| 118 |
+
{"color": [0, 194, 255], "id": 94, "isthing": 0, "name": "land, ground, soil"},
|
| 119 |
+
{
|
| 120 |
+
"color": [0, 122, 255],
|
| 121 |
+
"id": 95,
|
| 122 |
+
"isthing": 1,
|
| 123 |
+
"name": "bannister, banister, balustrade, balusters, handrail",
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"color": [0, 255, 163],
|
| 127 |
+
"id": 96,
|
| 128 |
+
"isthing": 0,
|
| 129 |
+
"name": "escalator, moving staircase, moving stairway",
|
| 130 |
+
},
|
| 131 |
+
{
|
| 132 |
+
"color": [255, 153, 0],
|
| 133 |
+
"id": 97,
|
| 134 |
+
"isthing": 1,
|
| 135 |
+
"name": "ottoman, pouf, pouffe, puff, hassock",
|
| 136 |
+
},
|
| 137 |
+
{"color": [0, 255, 10], "id": 98, "isthing": 1, "name": "bottle"},
|
| 138 |
+
{"color": [255, 112, 0], "id": 99, "isthing": 0, "name": "buffet, counter, sideboard"},
|
| 139 |
+
{
|
| 140 |
+
"color": [143, 255, 0],
|
| 141 |
+
"id": 100,
|
| 142 |
+
"isthing": 0,
|
| 143 |
+
"name": "poster, posting, placard, notice, bill, card",
|
| 144 |
+
},
|
| 145 |
+
{"color": [82, 0, 255], "id": 101, "isthing": 0, "name": "stage"},
|
| 146 |
+
{"color": [163, 255, 0], "id": 102, "isthing": 1, "name": "van"},
|
| 147 |
+
{"color": [255, 235, 0], "id": 103, "isthing": 1, "name": "ship"},
|
| 148 |
+
{"color": [8, 184, 170], "id": 104, "isthing": 1, "name": "fountain"},
|
| 149 |
+
{
|
| 150 |
+
"color": [133, 0, 255],
|
| 151 |
+
"id": 105,
|
| 152 |
+
"isthing": 0,
|
| 153 |
+
"name": "conveyer belt, conveyor belt, conveyer, conveyor, transporter",
|
| 154 |
+
},
|
| 155 |
+
{"color": [0, 255, 92], "id": 106, "isthing": 0, "name": "canopy"},
|
| 156 |
+
{
|
| 157 |
+
"color": [184, 0, 255],
|
| 158 |
+
"id": 107,
|
| 159 |
+
"isthing": 1,
|
| 160 |
+
"name": "washer, automatic washer, washing machine",
|
| 161 |
+
},
|
| 162 |
+
{"color": [255, 0, 31], "id": 108, "isthing": 1, "name": "plaything, toy"},
|
| 163 |
+
{"color": [0, 184, 255], "id": 109, "isthing": 0, "name": "pool"},
|
| 164 |
+
{"color": [0, 214, 255], "id": 110, "isthing": 1, "name": "stool"},
|
| 165 |
+
{"color": [255, 0, 112], "id": 111, "isthing": 1, "name": "barrel, cask"},
|
| 166 |
+
{"color": [92, 255, 0], "id": 112, "isthing": 1, "name": "basket, handbasket"},
|
| 167 |
+
{"color": [0, 224, 255], "id": 113, "isthing": 0, "name": "falls"},
|
| 168 |
+
{"color": [112, 224, 255], "id": 114, "isthing": 0, "name": "tent"},
|
| 169 |
+
{"color": [70, 184, 160], "id": 115, "isthing": 1, "name": "bag"},
|
| 170 |
+
{"color": [163, 0, 255], "id": 116, "isthing": 1, "name": "minibike, motorbike"},
|
| 171 |
+
{"color": [153, 0, 255], "id": 117, "isthing": 0, "name": "cradle"},
|
| 172 |
+
{"color": [71, 255, 0], "id": 118, "isthing": 1, "name": "oven"},
|
| 173 |
+
{"color": [255, 0, 163], "id": 119, "isthing": 1, "name": "ball"},
|
| 174 |
+
{"color": [255, 204, 0], "id": 120, "isthing": 1, "name": "food, solid food"},
|
| 175 |
+
{"color": [255, 0, 143], "id": 121, "isthing": 1, "name": "step, stair"},
|
| 176 |
+
{"color": [0, 255, 235], "id": 122, "isthing": 0, "name": "tank, storage tank"},
|
| 177 |
+
{"color": [133, 255, 0], "id": 123, "isthing": 1, "name": "trade name"},
|
| 178 |
+
{"color": [255, 0, 235], "id": 124, "isthing": 1, "name": "microwave"},
|
| 179 |
+
{"color": [245, 0, 255], "id": 125, "isthing": 1, "name": "pot"},
|
| 180 |
+
{"color": [255, 0, 122], "id": 126, "isthing": 1, "name": "animal"},
|
| 181 |
+
{"color": [255, 245, 0], "id": 127, "isthing": 1, "name": "bicycle"},
|
| 182 |
+
{"color": [10, 190, 212], "id": 128, "isthing": 0, "name": "lake"},
|
| 183 |
+
{"color": [214, 255, 0], "id": 129, "isthing": 1, "name": "dishwasher"},
|
| 184 |
+
{"color": [0, 204, 255], "id": 130, "isthing": 1, "name": "screen"},
|
| 185 |
+
{"color": [20, 0, 255], "id": 131, "isthing": 0, "name": "blanket, cover"},
|
| 186 |
+
{"color": [255, 255, 0], "id": 132, "isthing": 1, "name": "sculpture"},
|
| 187 |
+
{"color": [0, 153, 255], "id": 133, "isthing": 1, "name": "hood, exhaust hood"},
|
| 188 |
+
{"color": [0, 41, 255], "id": 134, "isthing": 1, "name": "sconce"},
|
| 189 |
+
{"color": [0, 255, 204], "id": 135, "isthing": 1, "name": "vase"},
|
| 190 |
+
{"color": [41, 0, 255], "id": 136, "isthing": 1, "name": "traffic light"},
|
| 191 |
+
{"color": [41, 255, 0], "id": 137, "isthing": 1, "name": "tray"},
|
| 192 |
+
{"color": [173, 0, 255], "id": 138, "isthing": 1, "name": "trash can"},
|
| 193 |
+
{"color": [0, 245, 255], "id": 139, "isthing": 1, "name": "fan"},
|
| 194 |
+
{"color": [71, 0, 255], "id": 140, "isthing": 0, "name": "pier"},
|
| 195 |
+
{"color": [122, 0, 255], "id": 141, "isthing": 0, "name": "crt screen"},
|
| 196 |
+
{"color": [0, 255, 184], "id": 142, "isthing": 1, "name": "plate"},
|
| 197 |
+
{"color": [0, 92, 255], "id": 143, "isthing": 1, "name": "monitor"},
|
| 198 |
+
{"color": [184, 255, 0], "id": 144, "isthing": 1, "name": "bulletin board"},
|
| 199 |
+
{"color": [0, 133, 255], "id": 145, "isthing": 0, "name": "shower"},
|
| 200 |
+
{"color": [255, 214, 0], "id": 146, "isthing": 1, "name": "radiator"},
|
| 201 |
+
{"color": [25, 194, 194], "id": 147, "isthing": 1, "name": "glass, drinking glass"},
|
| 202 |
+
{"color": [102, 255, 0], "id": 148, "isthing": 1, "name": "clock"},
|
| 203 |
+
{"color": [92, 0, 255], "id": 149, "isthing": 1, "name": "flag"},
|
| 204 |
+
]
|
| 205 |
+
|
| 206 |
+
ADE20k_COLORS = [k["color"] for k in ADE20K_150_CATEGORIES]
|
| 207 |
+
|
| 208 |
+
MetadataCatalog.get("ade20k_sem_seg_train").set(
|
| 209 |
+
stuff_colors=ADE20k_COLORS[:],
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
MetadataCatalog.get("ade20k_sem_seg_val").set(
|
| 213 |
+
stuff_colors=ADE20k_COLORS[:],
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
def load_ade20k_panoptic_json(json_file, image_dir, gt_dir, semseg_dir, meta):
|
| 218 |
+
"""
|
| 219 |
+
Args:
|
| 220 |
+
image_dir (str): path to the raw dataset. e.g., "~/coco/train2017".
|
| 221 |
+
gt_dir (str): path to the raw annotations. e.g., "~/coco/panoptic_train2017".
|
| 222 |
+
json_file (str): path to the json file. e.g., "~/coco/annotations/panoptic_train2017.json".
|
| 223 |
+
Returns:
|
| 224 |
+
list[dict]: a list of dicts in Detectron2 standard format. (See
|
| 225 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ )
|
| 226 |
+
"""
|
| 227 |
+
|
| 228 |
+
def _convert_category_id(segment_info, meta):
|
| 229 |
+
if segment_info["category_id"] in meta["thing_dataset_id_to_contiguous_id"]:
|
| 230 |
+
segment_info["category_id"] = meta["thing_dataset_id_to_contiguous_id"][
|
| 231 |
+
segment_info["category_id"]
|
| 232 |
+
]
|
| 233 |
+
segment_info["isthing"] = True
|
| 234 |
+
else:
|
| 235 |
+
segment_info["category_id"] = meta["stuff_dataset_id_to_contiguous_id"][
|
| 236 |
+
segment_info["category_id"]
|
| 237 |
+
]
|
| 238 |
+
segment_info["isthing"] = False
|
| 239 |
+
return segment_info
|
| 240 |
+
|
| 241 |
+
with PathManager.open(json_file) as f:
|
| 242 |
+
json_info = json.load(f)
|
| 243 |
+
|
| 244 |
+
ret = []
|
| 245 |
+
for ann in json_info["annotations"]:
|
| 246 |
+
image_id = ann["image_id"]
|
| 247 |
+
# TODO: currently we assume image and label has the same filename but
|
| 248 |
+
# different extension, and images have extension ".jpg" for COCO. Need
|
| 249 |
+
# to make image extension a user-provided argument if we extend this
|
| 250 |
+
# function to support other COCO-like datasets.
|
| 251 |
+
image_file = os.path.join(image_dir, os.path.splitext(ann["file_name"])[0] + ".jpg")
|
| 252 |
+
label_file = os.path.join(gt_dir, ann["file_name"])
|
| 253 |
+
sem_label_file = os.path.join(semseg_dir, ann["file_name"])
|
| 254 |
+
segments_info = [_convert_category_id(x, meta) for x in ann["segments_info"]]
|
| 255 |
+
ret.append(
|
| 256 |
+
{
|
| 257 |
+
"file_name": image_file,
|
| 258 |
+
"image_id": image_id,
|
| 259 |
+
"pan_seg_file_name": label_file,
|
| 260 |
+
"sem_seg_file_name": sem_label_file,
|
| 261 |
+
"segments_info": segments_info,
|
| 262 |
+
}
|
| 263 |
+
)
|
| 264 |
+
assert len(ret), f"No images found in {image_dir}!"
|
| 265 |
+
assert PathManager.isfile(ret[0]["file_name"]), ret[0]["file_name"]
|
| 266 |
+
assert PathManager.isfile(ret[0]["pan_seg_file_name"]), ret[0]["pan_seg_file_name"]
|
| 267 |
+
assert PathManager.isfile(ret[0]["sem_seg_file_name"]), ret[0]["sem_seg_file_name"]
|
| 268 |
+
return ret
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def register_ade20k_panoptic(
|
| 272 |
+
name, metadata, image_root, panoptic_root, semantic_root, panoptic_json, instances_json=None
|
| 273 |
+
):
|
| 274 |
+
"""
|
| 275 |
+
Register a "standard" version of ADE20k panoptic segmentation dataset named `name`.
|
| 276 |
+
The dictionaries in this registered dataset follows detectron2's standard format.
|
| 277 |
+
Hence it's called "standard".
|
| 278 |
+
Args:
|
| 279 |
+
name (str): the name that identifies a dataset,
|
| 280 |
+
e.g. "ade20k_panoptic_train"
|
| 281 |
+
metadata (dict): extra metadata associated with this dataset.
|
| 282 |
+
image_root (str): directory which contains all the images
|
| 283 |
+
panoptic_root (str): directory which contains panoptic annotation images in COCO format
|
| 284 |
+
panoptic_json (str): path to the json panoptic annotation file in COCO format
|
| 285 |
+
sem_seg_root (none): not used, to be consistent with
|
| 286 |
+
`register_coco_panoptic_separated`.
|
| 287 |
+
instances_json (str): path to the json instance annotation file
|
| 288 |
+
"""
|
| 289 |
+
panoptic_name = name
|
| 290 |
+
DatasetCatalog.register(
|
| 291 |
+
panoptic_name,
|
| 292 |
+
lambda: load_ade20k_panoptic_json(
|
| 293 |
+
panoptic_json, image_root, panoptic_root, semantic_root, metadata
|
| 294 |
+
),
|
| 295 |
+
)
|
| 296 |
+
MetadataCatalog.get(panoptic_name).set(
|
| 297 |
+
panoptic_root=panoptic_root,
|
| 298 |
+
image_root=image_root,
|
| 299 |
+
panoptic_json=panoptic_json,
|
| 300 |
+
json_file=instances_json,
|
| 301 |
+
evaluator_type="ade20k_panoptic_seg",
|
| 302 |
+
ignore_label=255,
|
| 303 |
+
label_divisor=1000,
|
| 304 |
+
**metadata,
|
| 305 |
+
)
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
_PREDEFINED_SPLITS_ADE20K_PANOPTIC = {
|
| 309 |
+
"ade20k_panoptic_train": (
|
| 310 |
+
"ADEChallengeData2016/images/training",
|
| 311 |
+
"ADEChallengeData2016/ade20k_panoptic_train",
|
| 312 |
+
"ADEChallengeData2016/ade20k_panoptic_train.json",
|
| 313 |
+
"ADEChallengeData2016/annotations_detectron2/training",
|
| 314 |
+
"ADEChallengeData2016/ade20k_instance_train.json",
|
| 315 |
+
),
|
| 316 |
+
"ade20k_panoptic_val": (
|
| 317 |
+
"ADEChallengeData2016/images/validation",
|
| 318 |
+
"ADEChallengeData2016/ade20k_panoptic_val",
|
| 319 |
+
"ADEChallengeData2016/ade20k_panoptic_val.json",
|
| 320 |
+
"ADEChallengeData2016/annotations_detectron2/validation",
|
| 321 |
+
"ADEChallengeData2016/ade20k_instance_val.json",
|
| 322 |
+
),
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def get_metadata():
|
| 327 |
+
meta = {}
|
| 328 |
+
# The following metadata maps contiguous id from [0, #thing categories +
|
| 329 |
+
# #stuff categories) to their names and colors. We have to replica of the
|
| 330 |
+
# same name and color under "thing_*" and "stuff_*" because the current
|
| 331 |
+
# visualization function in D2 handles thing and class classes differently
|
| 332 |
+
# due to some heuristic used in Panoptic FPN. We keep the same naming to
|
| 333 |
+
# enable reusing existing visualization functions.
|
| 334 |
+
thing_classes = [k["name"] for k in ADE20K_150_CATEGORIES if k["isthing"] == 1]
|
| 335 |
+
thing_colors = [k["color"] for k in ADE20K_150_CATEGORIES if k["isthing"] == 1]
|
| 336 |
+
stuff_classes = [k["name"] for k in ADE20K_150_CATEGORIES]
|
| 337 |
+
stuff_colors = [k["color"] for k in ADE20K_150_CATEGORIES]
|
| 338 |
+
|
| 339 |
+
meta["thing_classes"] = thing_classes
|
| 340 |
+
meta["thing_colors"] = thing_colors
|
| 341 |
+
meta["stuff_classes"] = stuff_classes
|
| 342 |
+
meta["stuff_colors"] = stuff_colors
|
| 343 |
+
|
| 344 |
+
# Convert category id for training:
|
| 345 |
+
# category id: like semantic segmentation, it is the class id for each
|
| 346 |
+
# pixel. Since there are some classes not used in evaluation, the category
|
| 347 |
+
# id is not always contiguous and thus we have two set of category ids:
|
| 348 |
+
# - original category id: category id in the original dataset, mainly
|
| 349 |
+
# used for evaluation.
|
| 350 |
+
# - contiguous category id: [0, #classes), in order to train the linear
|
| 351 |
+
# softmax classifier.
|
| 352 |
+
thing_dataset_id_to_contiguous_id = {}
|
| 353 |
+
stuff_dataset_id_to_contiguous_id = {}
|
| 354 |
+
|
| 355 |
+
for i, cat in enumerate(ADE20K_150_CATEGORIES):
|
| 356 |
+
if cat["isthing"]:
|
| 357 |
+
thing_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 358 |
+
# else:
|
| 359 |
+
# stuff_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 360 |
+
|
| 361 |
+
# in order to use sem_seg evaluator
|
| 362 |
+
stuff_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 363 |
+
|
| 364 |
+
meta["thing_dataset_id_to_contiguous_id"] = thing_dataset_id_to_contiguous_id
|
| 365 |
+
meta["stuff_dataset_id_to_contiguous_id"] = stuff_dataset_id_to_contiguous_id
|
| 366 |
+
|
| 367 |
+
return meta
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
def register_all_ade20k_panoptic(root):
|
| 371 |
+
metadata = get_metadata()
|
| 372 |
+
for (
|
| 373 |
+
prefix,
|
| 374 |
+
(image_root, panoptic_root, panoptic_json, semantic_root, instance_json),
|
| 375 |
+
) in _PREDEFINED_SPLITS_ADE20K_PANOPTIC.items():
|
| 376 |
+
# The "standard" version of COCO panoptic segmentation dataset,
|
| 377 |
+
# e.g. used by Panoptic-DeepLab
|
| 378 |
+
register_ade20k_panoptic(
|
| 379 |
+
prefix,
|
| 380 |
+
metadata,
|
| 381 |
+
os.path.join(root, image_root),
|
| 382 |
+
os.path.join(root, panoptic_root),
|
| 383 |
+
os.path.join(root, semantic_root),
|
| 384 |
+
os.path.join(root, panoptic_json),
|
| 385 |
+
os.path.join(root, instance_json),
|
| 386 |
+
)
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 390 |
+
register_all_ade20k_panoptic(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_coco_panoptic_annos_semseg.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 6 |
+
from detectron2.data.datasets import load_sem_seg
|
| 7 |
+
from detectron2.data.datasets.builtin_meta import COCO_CATEGORIES
|
| 8 |
+
from detectron2.utils.file_io import PathManager
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
_PREDEFINED_SPLITS_COCO_PANOPTIC = {
|
| 12 |
+
"coco_2017_train_panoptic": (
|
| 13 |
+
# This is the original panoptic annotation directory
|
| 14 |
+
"coco/panoptic_train2017",
|
| 15 |
+
"coco/annotations/panoptic_train2017.json",
|
| 16 |
+
# This directory contains semantic annotations that are
|
| 17 |
+
# converted from panoptic annotations.
|
| 18 |
+
# It is used by PanopticFPN.
|
| 19 |
+
# You can use the script at detectron2/datasets/prepare_panoptic_fpn.py
|
| 20 |
+
# to create these directories.
|
| 21 |
+
"coco/panoptic_semseg_train2017",
|
| 22 |
+
),
|
| 23 |
+
"coco_2017_val_panoptic": (
|
| 24 |
+
"coco/panoptic_val2017",
|
| 25 |
+
"coco/annotations/panoptic_val2017.json",
|
| 26 |
+
"coco/panoptic_semseg_val2017",
|
| 27 |
+
),
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def get_metadata():
|
| 32 |
+
meta = {}
|
| 33 |
+
# The following metadata maps contiguous id from [0, #thing categories +
|
| 34 |
+
# #stuff categories) to their names and colors. We have to replica of the
|
| 35 |
+
# same name and color under "thing_*" and "stuff_*" because the current
|
| 36 |
+
# visualization function in D2 handles thing and class classes differently
|
| 37 |
+
# due to some heuristic used in Panoptic FPN. We keep the same naming to
|
| 38 |
+
# enable reusing existing visualization functions.
|
| 39 |
+
thing_classes = [k["name"] for k in COCO_CATEGORIES if k["isthing"] == 1]
|
| 40 |
+
thing_colors = [k["color"] for k in COCO_CATEGORIES if k["isthing"] == 1]
|
| 41 |
+
stuff_classes = [k["name"] for k in COCO_CATEGORIES]
|
| 42 |
+
stuff_colors = [k["color"] for k in COCO_CATEGORIES]
|
| 43 |
+
|
| 44 |
+
meta["thing_classes"] = thing_classes
|
| 45 |
+
meta["thing_colors"] = thing_colors
|
| 46 |
+
meta["stuff_classes"] = stuff_classes
|
| 47 |
+
meta["stuff_colors"] = stuff_colors
|
| 48 |
+
|
| 49 |
+
# Convert category id for training:
|
| 50 |
+
# category id: like semantic segmentation, it is the class id for each
|
| 51 |
+
# pixel. Since there are some classes not used in evaluation, the category
|
| 52 |
+
# id is not always contiguous and thus we have two set of category ids:
|
| 53 |
+
# - original category id: category id in the original dataset, mainly
|
| 54 |
+
# used for evaluation.
|
| 55 |
+
# - contiguous category id: [0, #classes), in order to train the linear
|
| 56 |
+
# softmax classifier.
|
| 57 |
+
thing_dataset_id_to_contiguous_id = {}
|
| 58 |
+
stuff_dataset_id_to_contiguous_id = {}
|
| 59 |
+
|
| 60 |
+
for i, cat in enumerate(COCO_CATEGORIES):
|
| 61 |
+
if cat["isthing"]:
|
| 62 |
+
thing_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 63 |
+
# else:
|
| 64 |
+
# stuff_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 65 |
+
|
| 66 |
+
# in order to use sem_seg evaluator
|
| 67 |
+
stuff_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 68 |
+
|
| 69 |
+
meta["thing_dataset_id_to_contiguous_id"] = thing_dataset_id_to_contiguous_id
|
| 70 |
+
meta["stuff_dataset_id_to_contiguous_id"] = stuff_dataset_id_to_contiguous_id
|
| 71 |
+
|
| 72 |
+
return meta
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def load_coco_panoptic_json(json_file, image_dir, gt_dir, semseg_dir, meta):
|
| 76 |
+
"""
|
| 77 |
+
Args:
|
| 78 |
+
image_dir (str): path to the raw dataset. e.g., "~/coco/train2017".
|
| 79 |
+
gt_dir (str): path to the raw annotations. e.g., "~/coco/panoptic_train2017".
|
| 80 |
+
json_file (str): path to the json file. e.g., "~/coco/annotations/panoptic_train2017.json".
|
| 81 |
+
Returns:
|
| 82 |
+
list[dict]: a list of dicts in Detectron2 standard format. (See
|
| 83 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ )
|
| 84 |
+
"""
|
| 85 |
+
|
| 86 |
+
def _convert_category_id(segment_info, meta):
|
| 87 |
+
if segment_info["category_id"] in meta["thing_dataset_id_to_contiguous_id"]:
|
| 88 |
+
segment_info["category_id"] = meta["thing_dataset_id_to_contiguous_id"][
|
| 89 |
+
segment_info["category_id"]
|
| 90 |
+
]
|
| 91 |
+
segment_info["isthing"] = True
|
| 92 |
+
else:
|
| 93 |
+
segment_info["category_id"] = meta["stuff_dataset_id_to_contiguous_id"][
|
| 94 |
+
segment_info["category_id"]
|
| 95 |
+
]
|
| 96 |
+
segment_info["isthing"] = False
|
| 97 |
+
return segment_info
|
| 98 |
+
|
| 99 |
+
with PathManager.open(json_file) as f:
|
| 100 |
+
json_info = json.load(f)
|
| 101 |
+
|
| 102 |
+
ret = []
|
| 103 |
+
for ann in json_info["annotations"]:
|
| 104 |
+
image_id = int(ann["image_id"])
|
| 105 |
+
# TODO: currently we assume image and label has the same filename but
|
| 106 |
+
# different extension, and images have extension ".jpg" for COCO. Need
|
| 107 |
+
# to make image extension a user-provided argument if we extend this
|
| 108 |
+
# function to support other COCO-like datasets.
|
| 109 |
+
image_file = os.path.join(image_dir, os.path.splitext(ann["file_name"])[0] + ".jpg")
|
| 110 |
+
label_file = os.path.join(gt_dir, ann["file_name"])
|
| 111 |
+
sem_label_file = os.path.join(semseg_dir, ann["file_name"])
|
| 112 |
+
segments_info = [_convert_category_id(x, meta) for x in ann["segments_info"]]
|
| 113 |
+
ret.append(
|
| 114 |
+
{
|
| 115 |
+
"file_name": image_file,
|
| 116 |
+
"image_id": image_id,
|
| 117 |
+
"pan_seg_file_name": label_file,
|
| 118 |
+
"sem_seg_file_name": sem_label_file,
|
| 119 |
+
"segments_info": segments_info,
|
| 120 |
+
}
|
| 121 |
+
)
|
| 122 |
+
assert len(ret), f"No images found in {image_dir}!"
|
| 123 |
+
assert PathManager.isfile(ret[0]["file_name"]), ret[0]["file_name"]
|
| 124 |
+
assert PathManager.isfile(ret[0]["pan_seg_file_name"]), ret[0]["pan_seg_file_name"]
|
| 125 |
+
assert PathManager.isfile(ret[0]["sem_seg_file_name"]), ret[0]["sem_seg_file_name"]
|
| 126 |
+
return ret
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def register_coco_panoptic_annos_sem_seg(
|
| 130 |
+
name, metadata, image_root, panoptic_root, panoptic_json, sem_seg_root, instances_json
|
| 131 |
+
):
|
| 132 |
+
panoptic_name = name
|
| 133 |
+
delattr(MetadataCatalog.get(panoptic_name), "thing_classes")
|
| 134 |
+
delattr(MetadataCatalog.get(panoptic_name), "thing_colors")
|
| 135 |
+
MetadataCatalog.get(panoptic_name).set(
|
| 136 |
+
thing_classes=metadata["thing_classes"],
|
| 137 |
+
thing_colors=metadata["thing_colors"],
|
| 138 |
+
# thing_dataset_id_to_contiguous_id=metadata["thing_dataset_id_to_contiguous_id"],
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
# the name is "coco_2017_train_panoptic_with_sem_seg" and "coco_2017_val_panoptic_with_sem_seg"
|
| 142 |
+
semantic_name = name + "_with_sem_seg"
|
| 143 |
+
DatasetCatalog.register(
|
| 144 |
+
semantic_name,
|
| 145 |
+
lambda: load_coco_panoptic_json(panoptic_json, image_root, panoptic_root, sem_seg_root, metadata),
|
| 146 |
+
)
|
| 147 |
+
MetadataCatalog.get(semantic_name).set(
|
| 148 |
+
sem_seg_root=sem_seg_root,
|
| 149 |
+
panoptic_root=panoptic_root,
|
| 150 |
+
image_root=image_root,
|
| 151 |
+
panoptic_json=panoptic_json,
|
| 152 |
+
json_file=instances_json,
|
| 153 |
+
evaluator_type="coco_panoptic_seg",
|
| 154 |
+
ignore_label=255,
|
| 155 |
+
label_divisor=1000,
|
| 156 |
+
**metadata,
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def register_all_coco_panoptic_annos_sem_seg(root):
|
| 161 |
+
for (
|
| 162 |
+
prefix,
|
| 163 |
+
(panoptic_root, panoptic_json, semantic_root),
|
| 164 |
+
) in _PREDEFINED_SPLITS_COCO_PANOPTIC.items():
|
| 165 |
+
prefix_instances = prefix[: -len("_panoptic")]
|
| 166 |
+
instances_meta = MetadataCatalog.get(prefix_instances)
|
| 167 |
+
image_root, instances_json = instances_meta.image_root, instances_meta.json_file
|
| 168 |
+
|
| 169 |
+
register_coco_panoptic_annos_sem_seg(
|
| 170 |
+
prefix,
|
| 171 |
+
get_metadata(),
|
| 172 |
+
image_root,
|
| 173 |
+
os.path.join(root, panoptic_root),
|
| 174 |
+
os.path.join(root, panoptic_json),
|
| 175 |
+
os.path.join(root, semantic_root),
|
| 176 |
+
instances_json,
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 181 |
+
register_all_coco_panoptic_annos_sem_seg(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_coco_stuff_10k.py
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 5 |
+
from detectron2.data.datasets import load_sem_seg
|
| 6 |
+
|
| 7 |
+
COCO_CATEGORIES = [
|
| 8 |
+
{"color": [220, 20, 60], "isthing": 1, "id": 1, "name": "person"},
|
| 9 |
+
{"color": [119, 11, 32], "isthing": 1, "id": 2, "name": "bicycle"},
|
| 10 |
+
{"color": [0, 0, 142], "isthing": 1, "id": 3, "name": "car"},
|
| 11 |
+
{"color": [0, 0, 230], "isthing": 1, "id": 4, "name": "motorcycle"},
|
| 12 |
+
{"color": [106, 0, 228], "isthing": 1, "id": 5, "name": "airplane"},
|
| 13 |
+
{"color": [0, 60, 100], "isthing": 1, "id": 6, "name": "bus"},
|
| 14 |
+
{"color": [0, 80, 100], "isthing": 1, "id": 7, "name": "train"},
|
| 15 |
+
{"color": [0, 0, 70], "isthing": 1, "id": 8, "name": "truck"},
|
| 16 |
+
{"color": [0, 0, 192], "isthing": 1, "id": 9, "name": "boat"},
|
| 17 |
+
{"color": [250, 170, 30], "isthing": 1, "id": 10, "name": "traffic light"},
|
| 18 |
+
{"color": [100, 170, 30], "isthing": 1, "id": 11, "name": "fire hydrant"},
|
| 19 |
+
{"color": [220, 220, 0], "isthing": 1, "id": 13, "name": "stop sign"},
|
| 20 |
+
{"color": [175, 116, 175], "isthing": 1, "id": 14, "name": "parking meter"},
|
| 21 |
+
{"color": [250, 0, 30], "isthing": 1, "id": 15, "name": "bench"},
|
| 22 |
+
{"color": [165, 42, 42], "isthing": 1, "id": 16, "name": "bird"},
|
| 23 |
+
{"color": [255, 77, 255], "isthing": 1, "id": 17, "name": "cat"},
|
| 24 |
+
{"color": [0, 226, 252], "isthing": 1, "id": 18, "name": "dog"},
|
| 25 |
+
{"color": [182, 182, 255], "isthing": 1, "id": 19, "name": "horse"},
|
| 26 |
+
{"color": [0, 82, 0], "isthing": 1, "id": 20, "name": "sheep"},
|
| 27 |
+
{"color": [120, 166, 157], "isthing": 1, "id": 21, "name": "cow"},
|
| 28 |
+
{"color": [110, 76, 0], "isthing": 1, "id": 22, "name": "elephant"},
|
| 29 |
+
{"color": [174, 57, 255], "isthing": 1, "id": 23, "name": "bear"},
|
| 30 |
+
{"color": [199, 100, 0], "isthing": 1, "id": 24, "name": "zebra"},
|
| 31 |
+
{"color": [72, 0, 118], "isthing": 1, "id": 25, "name": "giraffe"},
|
| 32 |
+
{"color": [255, 179, 240], "isthing": 1, "id": 27, "name": "backpack"},
|
| 33 |
+
{"color": [0, 125, 92], "isthing": 1, "id": 28, "name": "umbrella"},
|
| 34 |
+
{"color": [209, 0, 151], "isthing": 1, "id": 31, "name": "handbag"},
|
| 35 |
+
{"color": [188, 208, 182], "isthing": 1, "id": 32, "name": "tie"},
|
| 36 |
+
{"color": [0, 220, 176], "isthing": 1, "id": 33, "name": "suitcase"},
|
| 37 |
+
{"color": [255, 99, 164], "isthing": 1, "id": 34, "name": "frisbee"},
|
| 38 |
+
{"color": [92, 0, 73], "isthing": 1, "id": 35, "name": "skis"},
|
| 39 |
+
{"color": [133, 129, 255], "isthing": 1, "id": 36, "name": "snowboard"},
|
| 40 |
+
{"color": [78, 180, 255], "isthing": 1, "id": 37, "name": "sports ball"},
|
| 41 |
+
{"color": [0, 228, 0], "isthing": 1, "id": 38, "name": "kite"},
|
| 42 |
+
{"color": [174, 255, 243], "isthing": 1, "id": 39, "name": "baseball bat"},
|
| 43 |
+
{"color": [45, 89, 255], "isthing": 1, "id": 40, "name": "baseball glove"},
|
| 44 |
+
{"color": [134, 134, 103], "isthing": 1, "id": 41, "name": "skateboard"},
|
| 45 |
+
{"color": [145, 148, 174], "isthing": 1, "id": 42, "name": "surfboard"},
|
| 46 |
+
{"color": [255, 208, 186], "isthing": 1, "id": 43, "name": "tennis racket"},
|
| 47 |
+
{"color": [197, 226, 255], "isthing": 1, "id": 44, "name": "bottle"},
|
| 48 |
+
{"color": [171, 134, 1], "isthing": 1, "id": 46, "name": "wine glass"},
|
| 49 |
+
{"color": [109, 63, 54], "isthing": 1, "id": 47, "name": "cup"},
|
| 50 |
+
{"color": [207, 138, 255], "isthing": 1, "id": 48, "name": "fork"},
|
| 51 |
+
{"color": [151, 0, 95], "isthing": 1, "id": 49, "name": "knife"},
|
| 52 |
+
{"color": [9, 80, 61], "isthing": 1, "id": 50, "name": "spoon"},
|
| 53 |
+
{"color": [84, 105, 51], "isthing": 1, "id": 51, "name": "bowl"},
|
| 54 |
+
{"color": [74, 65, 105], "isthing": 1, "id": 52, "name": "banana"},
|
| 55 |
+
{"color": [166, 196, 102], "isthing": 1, "id": 53, "name": "apple"},
|
| 56 |
+
{"color": [208, 195, 210], "isthing": 1, "id": 54, "name": "sandwich"},
|
| 57 |
+
{"color": [255, 109, 65], "isthing": 1, "id": 55, "name": "orange"},
|
| 58 |
+
{"color": [0, 143, 149], "isthing": 1, "id": 56, "name": "broccoli"},
|
| 59 |
+
{"color": [179, 0, 194], "isthing": 1, "id": 57, "name": "carrot"},
|
| 60 |
+
{"color": [209, 99, 106], "isthing": 1, "id": 58, "name": "hot dog"},
|
| 61 |
+
{"color": [5, 121, 0], "isthing": 1, "id": 59, "name": "pizza"},
|
| 62 |
+
{"color": [227, 255, 205], "isthing": 1, "id": 60, "name": "donut"},
|
| 63 |
+
{"color": [147, 186, 208], "isthing": 1, "id": 61, "name": "cake"},
|
| 64 |
+
{"color": [153, 69, 1], "isthing": 1, "id": 62, "name": "chair"},
|
| 65 |
+
{"color": [3, 95, 161], "isthing": 1, "id": 63, "name": "couch"},
|
| 66 |
+
{"color": [163, 255, 0], "isthing": 1, "id": 64, "name": "potted plant"},
|
| 67 |
+
{"color": [119, 0, 170], "isthing": 1, "id": 65, "name": "bed"},
|
| 68 |
+
{"color": [0, 182, 199], "isthing": 1, "id": 67, "name": "dining table"},
|
| 69 |
+
{"color": [0, 165, 120], "isthing": 1, "id": 70, "name": "toilet"},
|
| 70 |
+
{"color": [183, 130, 88], "isthing": 1, "id": 72, "name": "tv"},
|
| 71 |
+
{"color": [95, 32, 0], "isthing": 1, "id": 73, "name": "laptop"},
|
| 72 |
+
{"color": [130, 114, 135], "isthing": 1, "id": 74, "name": "mouse"},
|
| 73 |
+
{"color": [110, 129, 133], "isthing": 1, "id": 75, "name": "remote"},
|
| 74 |
+
{"color": [166, 74, 118], "isthing": 1, "id": 76, "name": "keyboard"},
|
| 75 |
+
{"color": [219, 142, 185], "isthing": 1, "id": 77, "name": "cell phone"},
|
| 76 |
+
{"color": [79, 210, 114], "isthing": 1, "id": 78, "name": "microwave"},
|
| 77 |
+
{"color": [178, 90, 62], "isthing": 1, "id": 79, "name": "oven"},
|
| 78 |
+
{"color": [65, 70, 15], "isthing": 1, "id": 80, "name": "toaster"},
|
| 79 |
+
{"color": [127, 167, 115], "isthing": 1, "id": 81, "name": "sink"},
|
| 80 |
+
{"color": [59, 105, 106], "isthing": 1, "id": 82, "name": "refrigerator"},
|
| 81 |
+
{"color": [142, 108, 45], "isthing": 1, "id": 84, "name": "book"},
|
| 82 |
+
{"color": [196, 172, 0], "isthing": 1, "id": 85, "name": "clock"},
|
| 83 |
+
{"color": [95, 54, 80], "isthing": 1, "id": 86, "name": "vase"},
|
| 84 |
+
{"color": [128, 76, 255], "isthing": 1, "id": 87, "name": "scissors"},
|
| 85 |
+
{"color": [201, 57, 1], "isthing": 1, "id": 88, "name": "teddy bear"},
|
| 86 |
+
{"color": [246, 0, 122], "isthing": 1, "id": 89, "name": "hair drier"},
|
| 87 |
+
{"color": [191, 162, 208], "isthing": 1, "id": 90, "name": "toothbrush"},
|
| 88 |
+
{"id": 92, "name": "banner", "supercategory": "textile"},
|
| 89 |
+
{"id": 93, "name": "blanket", "supercategory": "textile"},
|
| 90 |
+
{"id": 94, "name": "branch", "supercategory": "plant"},
|
| 91 |
+
{"id": 95, "name": "bridge", "supercategory": "building"},
|
| 92 |
+
{"id": 96, "name": "building-other", "supercategory": "building"},
|
| 93 |
+
{"id": 97, "name": "bush", "supercategory": "plant"},
|
| 94 |
+
{"id": 98, "name": "cabinet", "supercategory": "furniture-stuff"},
|
| 95 |
+
{"id": 99, "name": "cage", "supercategory": "structural"},
|
| 96 |
+
{"id": 100, "name": "cardboard", "supercategory": "raw-material"},
|
| 97 |
+
{"id": 101, "name": "carpet", "supercategory": "floor"},
|
| 98 |
+
{"id": 102, "name": "ceiling-other", "supercategory": "ceiling"},
|
| 99 |
+
{"id": 103, "name": "ceiling-tile", "supercategory": "ceiling"},
|
| 100 |
+
{"id": 104, "name": "cloth", "supercategory": "textile"},
|
| 101 |
+
{"id": 105, "name": "clothes", "supercategory": "textile"},
|
| 102 |
+
{"id": 106, "name": "clouds", "supercategory": "sky"},
|
| 103 |
+
{"id": 107, "name": "counter", "supercategory": "furniture-stuff"},
|
| 104 |
+
{"id": 108, "name": "cupboard", "supercategory": "furniture-stuff"},
|
| 105 |
+
{"id": 109, "name": "curtain", "supercategory": "textile"},
|
| 106 |
+
{"id": 110, "name": "desk-stuff", "supercategory": "furniture-stuff"},
|
| 107 |
+
{"id": 111, "name": "dirt", "supercategory": "ground"},
|
| 108 |
+
{"id": 112, "name": "door-stuff", "supercategory": "furniture-stuff"},
|
| 109 |
+
{"id": 113, "name": "fence", "supercategory": "structural"},
|
| 110 |
+
{"id": 114, "name": "floor-marble", "supercategory": "floor"},
|
| 111 |
+
{"id": 115, "name": "floor-other", "supercategory": "floor"},
|
| 112 |
+
{"id": 116, "name": "floor-stone", "supercategory": "floor"},
|
| 113 |
+
{"id": 117, "name": "floor-tile", "supercategory": "floor"},
|
| 114 |
+
{"id": 118, "name": "floor-wood", "supercategory": "floor"},
|
| 115 |
+
{"id": 119, "name": "flower", "supercategory": "plant"},
|
| 116 |
+
{"id": 120, "name": "fog", "supercategory": "water"},
|
| 117 |
+
{"id": 121, "name": "food-other", "supercategory": "food-stuff"},
|
| 118 |
+
{"id": 122, "name": "fruit", "supercategory": "food-stuff"},
|
| 119 |
+
{"id": 123, "name": "furniture-other", "supercategory": "furniture-stuff"},
|
| 120 |
+
{"id": 124, "name": "grass", "supercategory": "plant"},
|
| 121 |
+
{"id": 125, "name": "gravel", "supercategory": "ground"},
|
| 122 |
+
{"id": 126, "name": "ground-other", "supercategory": "ground"},
|
| 123 |
+
{"id": 127, "name": "hill", "supercategory": "solid"},
|
| 124 |
+
{"id": 128, "name": "house", "supercategory": "building"},
|
| 125 |
+
{"id": 129, "name": "leaves", "supercategory": "plant"},
|
| 126 |
+
{"id": 130, "name": "light", "supercategory": "furniture-stuff"},
|
| 127 |
+
{"id": 131, "name": "mat", "supercategory": "textile"},
|
| 128 |
+
{"id": 132, "name": "metal", "supercategory": "raw-material"},
|
| 129 |
+
{"id": 133, "name": "mirror-stuff", "supercategory": "furniture-stuff"},
|
| 130 |
+
{"id": 134, "name": "moss", "supercategory": "plant"},
|
| 131 |
+
{"id": 135, "name": "mountain", "supercategory": "solid"},
|
| 132 |
+
{"id": 136, "name": "mud", "supercategory": "ground"},
|
| 133 |
+
{"id": 137, "name": "napkin", "supercategory": "textile"},
|
| 134 |
+
{"id": 138, "name": "net", "supercategory": "structural"},
|
| 135 |
+
{"id": 139, "name": "paper", "supercategory": "raw-material"},
|
| 136 |
+
{"id": 140, "name": "pavement", "supercategory": "ground"},
|
| 137 |
+
{"id": 141, "name": "pillow", "supercategory": "textile"},
|
| 138 |
+
{"id": 142, "name": "plant-other", "supercategory": "plant"},
|
| 139 |
+
{"id": 143, "name": "plastic", "supercategory": "raw-material"},
|
| 140 |
+
{"id": 144, "name": "platform", "supercategory": "ground"},
|
| 141 |
+
{"id": 145, "name": "playingfield", "supercategory": "ground"},
|
| 142 |
+
{"id": 146, "name": "railing", "supercategory": "structural"},
|
| 143 |
+
{"id": 147, "name": "railroad", "supercategory": "ground"},
|
| 144 |
+
{"id": 148, "name": "river", "supercategory": "water"},
|
| 145 |
+
{"id": 149, "name": "road", "supercategory": "ground"},
|
| 146 |
+
{"id": 150, "name": "rock", "supercategory": "solid"},
|
| 147 |
+
{"id": 151, "name": "roof", "supercategory": "building"},
|
| 148 |
+
{"id": 152, "name": "rug", "supercategory": "textile"},
|
| 149 |
+
{"id": 153, "name": "salad", "supercategory": "food-stuff"},
|
| 150 |
+
{"id": 154, "name": "sand", "supercategory": "ground"},
|
| 151 |
+
{"id": 155, "name": "sea", "supercategory": "water"},
|
| 152 |
+
{"id": 156, "name": "shelf", "supercategory": "furniture-stuff"},
|
| 153 |
+
{"id": 157, "name": "sky-other", "supercategory": "sky"},
|
| 154 |
+
{"id": 158, "name": "skyscraper", "supercategory": "building"},
|
| 155 |
+
{"id": 159, "name": "snow", "supercategory": "ground"},
|
| 156 |
+
{"id": 160, "name": "solid-other", "supercategory": "solid"},
|
| 157 |
+
{"id": 161, "name": "stairs", "supercategory": "furniture-stuff"},
|
| 158 |
+
{"id": 162, "name": "stone", "supercategory": "solid"},
|
| 159 |
+
{"id": 163, "name": "straw", "supercategory": "plant"},
|
| 160 |
+
{"id": 164, "name": "structural-other", "supercategory": "structural"},
|
| 161 |
+
{"id": 165, "name": "table", "supercategory": "furniture-stuff"},
|
| 162 |
+
{"id": 166, "name": "tent", "supercategory": "building"},
|
| 163 |
+
{"id": 167, "name": "textile-other", "supercategory": "textile"},
|
| 164 |
+
{"id": 168, "name": "towel", "supercategory": "textile"},
|
| 165 |
+
{"id": 169, "name": "tree", "supercategory": "plant"},
|
| 166 |
+
{"id": 170, "name": "vegetable", "supercategory": "food-stuff"},
|
| 167 |
+
{"id": 171, "name": "wall-brick", "supercategory": "wall"},
|
| 168 |
+
{"id": 172, "name": "wall-concrete", "supercategory": "wall"},
|
| 169 |
+
{"id": 173, "name": "wall-other", "supercategory": "wall"},
|
| 170 |
+
{"id": 174, "name": "wall-panel", "supercategory": "wall"},
|
| 171 |
+
{"id": 175, "name": "wall-stone", "supercategory": "wall"},
|
| 172 |
+
{"id": 176, "name": "wall-tile", "supercategory": "wall"},
|
| 173 |
+
{"id": 177, "name": "wall-wood", "supercategory": "wall"},
|
| 174 |
+
{"id": 178, "name": "water-other", "supercategory": "water"},
|
| 175 |
+
{"id": 179, "name": "waterdrops", "supercategory": "water"},
|
| 176 |
+
{"id": 180, "name": "window-blind", "supercategory": "window"},
|
| 177 |
+
{"id": 181, "name": "window-other", "supercategory": "window"},
|
| 178 |
+
{"id": 182, "name": "wood", "supercategory": "solid"},
|
| 179 |
+
]
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def _get_coco_stuff_meta():
|
| 183 |
+
# Id 0 is reserved for ignore_label, we change ignore_label for 0
|
| 184 |
+
# to 255 in our pre-processing.
|
| 185 |
+
stuff_ids = [k["id"] for k in COCO_CATEGORIES]
|
| 186 |
+
assert len(stuff_ids) == 171, len(stuff_ids)
|
| 187 |
+
|
| 188 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 189 |
+
# (in [0, 91], used in models) to ids in the dataset (used for processing results)
|
| 190 |
+
stuff_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(stuff_ids)}
|
| 191 |
+
stuff_classes = [k["name"] for k in COCO_CATEGORIES]
|
| 192 |
+
|
| 193 |
+
ret = {
|
| 194 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 195 |
+
"stuff_classes": stuff_classes,
|
| 196 |
+
}
|
| 197 |
+
return ret
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def register_all_coco_stuff_10k(root):
|
| 201 |
+
root = os.path.join(root, "coco", "coco_stuff_10k")
|
| 202 |
+
meta = _get_coco_stuff_meta()
|
| 203 |
+
for name, image_dirname, sem_seg_dirname in [
|
| 204 |
+
("train", "images_detectron2/train", "annotations_detectron2/train"),
|
| 205 |
+
("test", "images_detectron2/test", "annotations_detectron2/test"),
|
| 206 |
+
]:
|
| 207 |
+
image_dir = os.path.join(root, image_dirname)
|
| 208 |
+
gt_dir = os.path.join(root, sem_seg_dirname)
|
| 209 |
+
name = f"coco_2017_{name}_stuff_10k_sem_seg"
|
| 210 |
+
DatasetCatalog.register(
|
| 211 |
+
name, lambda x=image_dir, y=gt_dir: load_sem_seg(y, x, gt_ext="png", image_ext="jpg")
|
| 212 |
+
)
|
| 213 |
+
MetadataCatalog.get(name).set(
|
| 214 |
+
image_root=image_dir,
|
| 215 |
+
sem_seg_root=gt_dir,
|
| 216 |
+
evaluator_type="sem_seg",
|
| 217 |
+
ignore_label=255,
|
| 218 |
+
**meta,
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 223 |
+
register_all_coco_stuff_10k(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_entityv2_entity.py
ADDED
|
@@ -0,0 +1,742 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import json
|
| 3 |
+
import logging
|
| 4 |
+
import numpy as np
|
| 5 |
+
import os
|
| 6 |
+
from PIL import Image
|
| 7 |
+
|
| 8 |
+
from detectron2.data.datasets.builtin_meta import COCO_CATEGORIES
|
| 9 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 10 |
+
from detectron2.data.datasets.coco import load_coco_json, register_coco_instances
|
| 11 |
+
from detectron2.utils.file_io import PathManager
|
| 12 |
+
|
| 13 |
+
EntityV2_entity_CATEGORIES = [
|
| 14 |
+
{'supercategory': 'entity', 'id': 0, 'name': 'unknown', 'c_name': '未知物', 'type': 'thing'},
|
| 15 |
+
{'supercategory': 'person', 'id': 1, 'name': 'man', 'c_name': '男人', 'type': 'thing'},
|
| 16 |
+
{'supercategory': 'land_transportation', 'id': 2, 'name': 'car', 'c_name': '小汽车', 'type': 'thing'},
|
| 17 |
+
{'supercategory': 'inanimate_natural_objects', 'id': 3, 'name': 'sky', 'c_name': '天空', 'type': 'stuff'},
|
| 18 |
+
{'supercategory': 'seat_furniture', 'id': 4, 'name': 'chair', 'c_name': '椅子', 'type': 'thing'},
|
| 19 |
+
{'supercategory': 'utility', 'id': 5, 'name': 'utility_ot', 'c_name': '其他工具', 'type': 'thing'},
|
| 20 |
+
{'supercategory': 'non_individual_plants', 'id': 6, 'name': 'tree', 'c_name': '树木', 'type': 'stuff'},
|
| 21 |
+
{'supercategory': 'traffic_facility', 'id': 7, 'name': 'street_light', 'c_name': '路灯', 'type': 'thing'},
|
| 22 |
+
{'supercategory': 'individual_plants', 'id': 8, 'name': 'potted_plants', 'c_name': '盆栽植物', 'type': 'stuff'},
|
| 23 |
+
{'supercategory': 'media', 'id': 9, 'name': 'signboard', 'c_name': '简介牌', 'type': 'thing'},
|
| 24 |
+
{'supercategory': 'facility', 'id': 10, 'name': 'facility_ot', 'c_name': '其他设施类', 'type': 'thing'},
|
| 25 |
+
{'supercategory': 'rigid_container', 'id': 11, 'name': 'rigid_container_ot', 'c_name': '其他定型容器', 'type': 'thing'},
|
| 26 |
+
{'supercategory': 'non_individual_plants', 'id': 12, 'name': 'grass', 'c_name': '草地', 'type': 'stuff'},
|
| 27 |
+
{'supercategory': 'media', 'id': 13, 'name': 'sculpture', 'c_name': '雕塑雕像', 'type': 'thing'},
|
| 28 |
+
{'supercategory': 'media', 'id': 14, 'name': 'book', 'c_name': '书', 'type': 'thing'},
|
| 29 |
+
{'supercategory': 'non_individual_plants', 'id': 15, 'name': 'shrub', 'c_name': '灌木', 'type': 'stuff'},
|
| 30 |
+
{'supercategory': 'rigid_container', 'id': 16, 'name': 'box', 'c_name': '盒子箱子', 'type': 'thing'},
|
| 31 |
+
{'supercategory': 'table', 'id': 17, 'name': 'table_ot', 'c_name': '其他桌子', 'type': 'thing'},
|
| 32 |
+
{'supercategory': 'non-building_houses', 'id': 18, 'name': 'electricpole', 'c_name': '电线杆', 'type': 'stuff'},
|
| 33 |
+
{'supercategory': 'furniture', 'id': 19, 'name': 'noncommon_furniture', 'c_name': '非常用家具', 'type': 'thing'},
|
| 34 |
+
{'supercategory': 'light', 'id': 20, 'name': 'can_light', 'c_name': '筒灯', 'type': 'thing'},
|
| 35 |
+
{'supercategory': 'wall', 'id': 21, 'name': 'concretewall', 'c_name': '水泥墙', 'type': 'stuff'},
|
| 36 |
+
{'supercategory': 'floor_structure', 'id': 22, 'name': 'floor_structure_ot', 'c_name': '其他地面结构', 'type': 'stuff'},
|
| 37 |
+
{'supercategory': 'barrier', 'id': 23, 'name': 'sunk_fence', 'c_name': '矮墙', 'type': 'stuff'},
|
| 38 |
+
{'supercategory': 'media', 'id': 24, 'name': 'painting', 'c_name': '绘画类', 'type': 'thing'},
|
| 39 |
+
{'supercategory': 'building_houses', 'id': 25, 'name': 'house', 'c_name': '房屋', 'type': 'stuff'},
|
| 40 |
+
{'supercategory': 'traffic_facility', 'id': 26, 'name': 'traffic_sign', 'c_name': '交通标志', 'type': 'thing'},
|
| 41 |
+
{'supercategory': 'barrier', 'id': 27, 'name': 'barrier_ot', 'c_name': '其他障碍物', 'type': 'stuff'},
|
| 42 |
+
{'supercategory': 'building_structure', 'id': 28, 'name': 'floor', 'c_name': '地板', 'type': 'stuff'},
|
| 43 |
+
{'supercategory': 'media', 'id': 29, 'name': 'paper', 'c_name': '纸', 'type': 'thing'},
|
| 44 |
+
{'supercategory': 'underwater_vehicle', 'id': 30, 'name': 'boat', 'c_name': '小型船只', 'type': 'thing'},
|
| 45 |
+
{'supercategory': 'entertainment_appliances_ot', 'id': 31, 'name': 'entertainment_appliances_ot', 'c_name': '其他娱乐设施', 'type': 'thing'},
|
| 46 |
+
{'supercategory': 'rigid_container', 'id': 32, 'name': 'bottle', 'c_name': '瓶子', 'type': 'thing'},
|
| 47 |
+
{'supercategory': 'solid', 'id': 33, 'name': 'mountain', 'c_name': '山', 'type': 'stuff'},
|
| 48 |
+
{'supercategory': 'birds', 'id': 34, 'name': 'birds_ot', 'c_name': '其他飞禽', 'type': 'thing'},
|
| 49 |
+
{'supercategory': 'common_furniture', 'id': 35, 'name': 'cushion', 'c_name': '抱枕', 'type': 'thing'},
|
| 50 |
+
{'supercategory': 'building_structure', 'id': 36, 'name': 'pole', 'c_name': '细杆', 'type': 'stuff'},
|
| 51 |
+
{'supercategory': 'cup', 'id': 37, 'name': 'cup_ot', 'c_name': '其他杯子', 'type': 'thing'},
|
| 52 |
+
{'supercategory': 'bag', 'id': 38, 'name': 'backpack', 'c_name': '背包', 'type': 'thing'},
|
| 53 |
+
{'supercategory': 'solid', 'id': 39, 'name': 'soil', 'c_name': '泥土', 'type': 'stuff'},
|
| 54 |
+
{'supercategory': 'barrier', 'id': 40, 'name': 'fence', 'c_name': '栅栏', 'type': 'stuff'},
|
| 55 |
+
{'supercategory': 'non-building_houses', 'id': 41, 'name': 'non-buildinghouse_ot', 'c_name': '其他非建筑房屋', 'type': 'stuff'},
|
| 56 |
+
{'supercategory': 'light', 'id': 42, 'name': 'sconce', 'c_name': '壁灯', 'type': 'thing'},
|
| 57 |
+
{'supercategory': 'fooddrink', 'id': 43, 'name': 'fooddrink_ot', 'c_name': '其他食物饮品', 'type': 'thing'},
|
| 58 |
+
{'supercategory': 'solid', 'id': 44, 'name': 'stone', 'c_name': '小石头', 'type': 'stuff'},
|
| 59 |
+
{'supercategory': 'building_structure', 'id': 45, 'name': 'gutter', 'c_name': '排水沟', 'type': 'stuff'},
|
| 60 |
+
{'supercategory': 'bag', 'id': 46, 'name': 'handbag', 'c_name': '手提包', 'type': 'thing'},
|
| 61 |
+
{'supercategory': 'common_furniture', 'id': 47, 'name': 'decoration', 'c_name': '装饰物', 'type': 'thing'},
|
| 62 |
+
{'supercategory': 'traffic_facility', 'id': 48, 'name': 'electric_wire', 'c_name': '电线电缆', 'type': 'thing'},
|
| 63 |
+
{'supercategory': 'clean_tool', 'id': 49, 'name': 'trash_bin', 'c_name': '垃圾桶', 'type': 'thing'},
|
| 64 |
+
{'supercategory': 'artifical_ground', 'id': 50, 'name': 'road', 'c_name': '马路', 'type': 'stuff'},
|
| 65 |
+
{'supercategory': 'kitchen_tool', 'id': 51, 'name': 'plate', 'c_name': '盘子', 'type': 'thing'},
|
| 66 |
+
{'supercategory': 'drink', 'id': 52, 'name': 'drink_ot', 'c_name': '其他饮品', 'type': 'thing'},
|
| 67 |
+
{'supercategory': 'building_structure', 'id': 53, 'name': 'ceiling', 'c_name': '天花板', 'type': 'stuff'},
|
| 68 |
+
{'supercategory': 'fluid', 'id': 54, 'name': 'sea', 'c_name': '海', 'type': 'stuff'},
|
| 69 |
+
{'supercategory': 'toy', 'id': 55, 'name': 'toy_ot', 'c_name': '其他玩具', 'type': 'thing'},
|
| 70 |
+
{'supercategory': 'media', 'id': 56, 'name': 'pen', 'c_name': '笔', 'type': 'thing'},
|
| 71 |
+
{'supercategory': 'media', 'id': 57, 'name': 'flag', 'c_name': '旗帜', 'type': 'thing'},
|
| 72 |
+
{'supercategory': 'solid', 'id': 58, 'name': 'rock', 'c_name': '岩石', 'type': 'stuff'},
|
| 73 |
+
{'supercategory': 'outdoor_supplies', 'id': 59, 'name': 'outdoor_supplies_ot', 'c_name': '其他户外休闲用品', 'type': 'thing'},
|
| 74 |
+
{'supercategory': 'common_furniture', 'id': 60, 'name': 'curtain', 'c_name': '窗帘', 'type': 'thing'},
|
| 75 |
+
{'supercategory': 'light', 'id': 61, 'name': 'chandilier', 'c_name': '吊灯', 'type': 'thing'},
|
| 76 |
+
{'supercategory': 'fish', 'id': 62, 'name': 'fish_ot', 'c_name': '其他鱼类', 'type': 'thing'},
|
| 77 |
+
{'supercategory': 'building_structure', 'id': 63, 'name': 'window', 'c_name': '窗户', 'type': 'stuff'},
|
| 78 |
+
{'supercategory': 'light', 'id': 64, 'name': 'light_ot', 'c_name': '其他灯', 'type': 'thing'},
|
| 79 |
+
{'supercategory': 'entertainment_appliances', 'id': 65, 'name': 'plugs_and_sockets', 'c_name': '插头插座', 'type': 'thing'},
|
| 80 |
+
{'supercategory': 'outdoor_supplies', 'id': 66, 'name': 'rope', 'c_name': '绳子', 'type': 'thing'},
|
| 81 |
+
{'supercategory': 'building_houses', 'id': 67, 'name': 'building_houses_ot', 'c_name': '其他建筑房屋', 'type': 'stuff'},
|
| 82 |
+
{'supercategory': 'land_transportation', 'id': 68, 'name': 'land_transportation_ot', 'c_name': '其他陆地交通工具', 'type': 'thing'},
|
| 83 |
+
{'supercategory': 'land_transportation', 'id': 69, 'name': 'bicycle', 'c_name': '自行车', 'type': 'thing'},
|
| 84 |
+
{'supercategory': 'seat_furniture', 'id': 70, 'name': 'stool', 'c_name': '凳子', 'type': 'thing'},
|
| 85 |
+
{'supercategory': 'barrier', 'id': 71, 'name': 'wiredfence', 'c_name': '铁丝网栅栏', 'type': 'stuff'},
|
| 86 |
+
{'supercategory': 'kitchen_tool', 'id': 72, 'name': 'kitchen_tool_ot', 'c_name': '其他厨房工具', 'type': 'thing'},
|
| 87 |
+
{'supercategory': 'building_structure', 'id': 73, 'name': 'building_structure_ot', 'c_name': '非建筑结构', 'type': 'stuff'},
|
| 88 |
+
{'supercategory': 'building_houses', 'id': 74, 'name': 'high-rise', 'c_name': '高楼', 'type': 'stuff'},
|
| 89 |
+
{'supercategory': 'blanket_furniture', 'id': 75, 'name': 'mat', 'c_name': '垫子', 'type': 'thing'},
|
| 90 |
+
{'supercategory': 'seat_furniture', 'id': 76, 'name': 'bench', 'c_name': '长凳', 'type': 'thing'},
|
| 91 |
+
{'supercategory': 'non_individual_plants', 'id': 77, 'name': 'nonindividual_plants_ot', 'c_name': '其他非独立植物', 'type': 'stuff'},
|
| 92 |
+
{'supercategory': 'artifical_ground', 'id': 78, 'name': 'sidewalk', 'c_name': '人行道', 'type': 'stuff'},
|
| 93 |
+
{'supercategory': 'media', 'id': 79, 'name': 'billboard', 'c_name': '广告牌', 'type': 'thing'},
|
| 94 |
+
{'supercategory': 'plant_part', 'id': 80, 'name': 'flower', 'c_name': '花', 'type': 'thing'},
|
| 95 |
+
{'supercategory': 'rigid_container', 'id': 81, 'name': 'bowl', 'c_name': '碗', 'type': 'thing'},
|
| 96 |
+
{'supercategory': 'plant_part', 'id': 82, 'name': 'leaf', 'c_name': '树叶', 'type': 'thing'},
|
| 97 |
+
{'supercategory': 'cow', 'id': 83, 'name': 'cow_ot', 'c_name': '其他牛', 'type': 'thing'},
|
| 98 |
+
{'supercategory': 'dessert_snacks', 'id': 84, 'name': 'dessert_snacks_ot', 'c_name': '其他甜点小吃', 'type': 'thing'},
|
| 99 |
+
{'supercategory': 'mammal', 'id': 85, 'name': 'dog', 'c_name': '狗', 'type': 'thing'},
|
| 100 |
+
{'supercategory': 'bag', 'id': 86, 'name': 'bag_ot', 'c_name': '其他包', 'type': 'thing'},
|
| 101 |
+
{'supercategory': 'media', 'id': 87, 'name': 'photo', 'c_name': '照片', 'type': 'thing'},
|
| 102 |
+
{'supercategory': 'bath_tool', 'id': 88, 'name': 'bath_tool_ot', 'c_name': '其他沐浴工具', 'type': 'thing'},
|
| 103 |
+
{'supercategory': 'bath_tool', 'id': 89, 'name': 'towel', 'c_name': '毛巾', 'type': 'thing'},
|
| 104 |
+
{'supercategory': 'building_structure', 'id': 90, 'name': 'step', 'c_name': '台阶', 'type': 'stuff'},
|
| 105 |
+
{'supercategory': 'light', 'id': 91, 'name': 'ceiling_lamp', 'c_name': '吸顶灯', 'type': 'thing'},
|
| 106 |
+
{'supercategory': 'sports_musical', 'id': 92, 'name': 'musical_instrument', 'c_name': '乐器', 'type': 'thing'},
|
| 107 |
+
{'supercategory': 'rigid_container', 'id': 93, 'name': 'barrel', 'c_name': '桶', 'type': 'thing'},
|
| 108 |
+
{'supercategory': 'traffic_facility', 'id': 94, 'name': 'traffic_light', 'c_name': '红绿灯', 'type': 'thing'},
|
| 109 |
+
{'supercategory': 'cup', 'id': 95, 'name': 'wineglass', 'c_name': '酒杯', 'type': 'thing'},
|
| 110 |
+
{'supercategory': 'flexible_container', 'id': 96, 'name': 'plastic_bag', 'c_name': '塑料袋', 'type': 'thing'},
|
| 111 |
+
{'supercategory': 'cloth', 'id': 97, 'name': 'cloth_ot', 'c_name': '其他服饰类', 'type': 'thing'},
|
| 112 |
+
{'supercategory': 'rigid_container', 'id': 98, 'name': 'jar', 'c_name': '玻璃罐', 'type': 'thing'},
|
| 113 |
+
{'supercategory': 'telephone', 'id': 99, 'name': 'mobilephone', 'c_name': '手机', 'type': 'thing'},
|
| 114 |
+
{'supercategory': 'building_structure', 'id': 100, 'name': 'pipe', 'c_name': '管道', 'type': 'stuff'},
|
| 115 |
+
{'supercategory': 'entertainment_appliances', 'id': 101, 'name': 'cable', 'c_name': '连接线', 'type': 'thing'},
|
| 116 |
+
{'supercategory': 'fitness_equipment', 'id': 102, 'name': 'fitness_equipment_ot', 'c_name': '其他健身设备', 'type': 'thing'},
|
| 117 |
+
{'supercategory': 'media', 'id': 103, 'name': 'poster', 'c_name': '海报类', 'type': 'thing'},
|
| 118 |
+
{'supercategory': 'cup', 'id': 104, 'name': 'glass', 'c_name': '玻璃杯', 'type': 'thing'},
|
| 119 |
+
{'supercategory': 'plant_part', 'id': 105, 'name': 'branch', 'c_name': '树枝', 'type': 'thing'},
|
| 120 |
+
{'supercategory': 'repair_tool', 'id': 106, 'name': 'repair_tool_ot', 'c_name': '其他修理工具', 'type': 'thing'},
|
| 121 |
+
{'supercategory': 'beddings', 'id': 107, 'name': 'pillow', 'c_name': '枕头', 'type': 'thing'},
|
| 122 |
+
{'supercategory': 'cabinets', 'id': 108, 'name': 'cabinets_ot', 'c_name': '其他橱柜', 'type': 'thing'},
|
| 123 |
+
{'supercategory': 'fruit', 'id': 109, 'name': 'apple', 'c_name': '苹果', 'type': 'thing'},
|
| 124 |
+
{'supercategory': 'mammal', 'id': 110, 'name': 'sheep', 'c_name': '羊', 'type': 'thing'},
|
| 125 |
+
{'supercategory': 'fluid', 'id': 111, 'name': 'lake', 'c_name': '湖', 'type': 'stuff'},
|
| 126 |
+
{'supercategory': 'doll', 'id': 112, 'name': 'doll_ot', 'c_name': '其他玩偶', 'type': 'thing'},
|
| 127 |
+
{'supercategory': 'fruit', 'id': 113, 'name': 'fruit_ot', 'c_name': '其他水果', 'type': 'thing'},
|
| 128 |
+
{'supercategory': 'solid', 'id': 114, 'name': 'sand', 'c_name': '沙子', 'type': 'stuff'},
|
| 129 |
+
{'supercategory': 'cabinets', 'id': 115, 'name': 'kitchen cabinets', 'c_name': '厨房里的柜子', 'type': 'thing'},
|
| 130 |
+
{'supercategory': 'non-building_houses', 'id': 116, 'name': 'bridge', 'c_name': '桥', 'type': 'stuff'},
|
| 131 |
+
{'supercategory': 'fluid', 'id': 117, 'name': 'river', 'c_name': '河', 'type': 'stuff'},
|
| 132 |
+
{'supercategory': 'plant_part', 'id': 118, 'name': 'trunk', 'c_name': '树干', 'type': 'thing'},
|
| 133 |
+
{'supercategory': 'media', 'id': 119, 'name': 'media_ot', 'c_name': '其他传媒类', 'type': 'thing'},
|
| 134 |
+
{'supercategory': 'wall', 'id': 120, 'name': 'wall_ot', 'c_name': '其他墙', 'type': 'stuff'},
|
| 135 |
+
{'supercategory': 'lab_tool', 'id': 121, 'name': 'candle', 'c_name': '蜡烛', 'type': 'thing'},
|
| 136 |
+
{'supercategory': 'dessert_snacks', 'id': 122, 'name': 'bread', 'c_name': '面包', 'type': 'thing'},
|
| 137 |
+
{'supercategory': 'birds', 'id': 123, 'name': 'duck', 'c_name': '鸭', 'type': 'thing'},
|
| 138 |
+
{'supercategory': 'birds', 'id': 124, 'name': 'pigeon', 'c_name': '鸽子', 'type': 'thing'},
|
| 139 |
+
{'supercategory': 'kitchen_tool', 'id': 125, 'name': 'spoon', 'c_name': '勺子', 'type': 'thing'},
|
| 140 |
+
{'supercategory': 'artifical_ground', 'id': 126, 'name': 'park_ground', 'c_name': '公园地面', 'type': 'stuff'},
|
| 141 |
+
{'supercategory': 'artifical_ground', 'id': 127, 'name': 'artifical_ground_ot', 'c_name': '其他人造地面', 'type': 'stuff'},
|
| 142 |
+
{'supercategory': 'fluid', 'id': 128, 'name': 'fluid_ot', 'c_name': '其他液体', 'type': 'stuff'},
|
| 143 |
+
{'supercategory': 'table', 'id': 129, 'name': 'dining_table', 'c_name': '餐桌', 'type': 'thing'},
|
| 144 |
+
{'supercategory': 'vegetable', 'id': 130, 'name': 'pumkin', 'c_name': '南瓜', 'type': 'thing'},
|
| 145 |
+
{'supercategory': 'fluid', 'id': 131, 'name': 'snow', 'c_name': '雪', 'type': 'stuff'},
|
| 146 |
+
{'supercategory': 'horse', 'id': 132, 'name': 'horse_ot', 'c_name': '其他马', 'type': 'thing'},
|
| 147 |
+
{'supercategory': 'vegetable', 'id': 133, 'name': 'vegetable_ot', 'c_name': '其他蔬菜', 'type': 'thing'},
|
| 148 |
+
{'supercategory': 'flexible_container', 'id': 134, 'name': 'flexible_container_ot', 'c_name': '其他可改变外形的容器', 'type': 'thing'},
|
| 149 |
+
{'supercategory': 'entertainment_appliances', 'id': 135, 'name': 'surveillance_camera', 'c_name': '监控器', 'type': 'thing'},
|
| 150 |
+
{'supercategory': 'land_transportation', 'id': 136, 'name': 'motorbike', 'c_name': '摩托车', 'type': 'thing'},
|
| 151 |
+
{'supercategory': 'sofa', 'id': 137, 'name': 'ordniary_sofa', 'c_name': '普通沙发', 'type': 'thing'},
|
| 152 |
+
{'supercategory': 'building_structure', 'id': 138, 'name': 'banister', 'c_name': '扶手', 'type': 'stuff'},
|
| 153 |
+
{'supercategory': 'entertainment_appliances', 'id': 139, 'name': 'laptop', 'c_name': '笔记本电脑', 'type': 'thing'},
|
| 154 |
+
{'supercategory': 'outdoor_supplies', 'id': 140, 'name': 'umbrella', 'c_name': '雨伞', 'type': 'thing'},
|
| 155 |
+
{'supercategory': 'kitchen_tool', 'id': 141, 'name': 'faucet', 'c_name': '水龙头', 'type': 'thing'},
|
| 156 |
+
{'supercategory': 'mammal', 'id': 142, 'name': 'mammal_ot', 'c_name': '其他哺乳动物', 'type': 'thing'},
|
| 157 |
+
{'supercategory': 'building', 'id': 143, 'name': 'building_ot', 'c_name': '其他建筑类', 'type': 'stuff'},
|
| 158 |
+
{'supercategory': 'clean_tool', 'id': 144, 'name': 'napkin', 'c_name': '餐巾', 'type': 'thing'},
|
| 159 |
+
{'supercategory': 'land_transportation', 'id': 145, 'name': 'bus', 'c_name': '公交车', 'type': 'thing'},
|
| 160 |
+
{'supercategory': 'entertainment_appliances', 'id': 146, 'name': 'speaker', 'c_name': '音响', 'type': 'thing'},
|
| 161 |
+
{'supercategory': 'entertainment_appliances', 'id': 147, 'name': 'camera', 'c_name': '照相机', 'type': 'thing'},
|
| 162 |
+
{'supercategory': 'common_furniture', 'id': 148, 'name': 'mirror', 'c_name': '镜子', 'type': 'thing'},
|
| 163 |
+
{'supercategory': 'boat_part', 'id': 149, 'name': 'paddle', 'c_name': '桨', 'type': 'thing'},
|
| 164 |
+
{'supercategory': 'dessert_snacks', 'id': 150, 'name': 'cake', 'c_name': '糕饼', 'type': 'thing'},
|
| 165 |
+
{'supercategory': 'footwear', 'id': 151, 'name': 'sneakers', 'c_name': '运动鞋', 'type': 'thing'},
|
| 166 |
+
{'supercategory': 'flexible_container', 'id': 152, 'name': 'basket', 'c_name': '篮子', 'type': 'thing'},
|
| 167 |
+
{'supercategory': 'building_structure', 'id': 153, 'name': 'ventilation', 'c_name': '排气孔', 'type': 'stuff'},
|
| 168 |
+
{'supercategory': 'underwater_vehicle', 'id': 154, 'name': 'sailboat', 'c_name': '帆船', 'type': 'thing'},
|
| 169 |
+
{'supercategory': 'underwater_vehicle', 'id': 155, 'name': 'ship', 'c_name': '大轮船', 'type': 'thing'},
|
| 170 |
+
{'supercategory': 'flexible_container', 'id': 156, 'name': 'can', 'c_name': '易拉罐', 'type': 'thing'},
|
| 171 |
+
{'supercategory': 'mammal', 'id': 157, 'name': 'cat', 'c_name': '猫', 'type': 'thing'},
|
| 172 |
+
{'supercategory': 'entertainment_appliances', 'id': 158, 'name': 'screen', 'c_name': '显示器', 'type': 'thing'},
|
| 173 |
+
{'supercategory': 'drink', 'id': 159, 'name': 'wine', 'c_name': '葡萄酒', 'type': 'thing'},
|
| 174 |
+
{'supercategory': 'fruit', 'id': 160, 'name': 'orange', 'c_name': '橘子', 'type': 'thing'},
|
| 175 |
+
{'supercategory': 'bed', 'id': 161, 'name': 'bedroom bed', 'c_name': '卧室床', 'type': 'thing'},
|
| 176 |
+
{'supercategory': 'ball', 'id': 162, 'name': 'ball_ot', 'c_name': '其他球类', 'type': 'thing'},
|
| 177 |
+
{'supercategory': 'non_individual_plants', 'id': 163, 'name': 'log', 'c_name': '原木', 'type': 'stuff'},
|
| 178 |
+
{'supercategory': 'entertainment_appliances', 'id': 164, 'name': 'switch', 'c_name': '开关', 'type': 'thing'},
|
| 179 |
+
{'supercategory': 'mammal', 'id': 165, 'name': 'elephant', 'c_name': '大象', 'type': 'thing'},
|
| 180 |
+
{'supercategory': 'blanket_furniture', 'id': 166, 'name': 'blanket', 'c_name': '毛毯', 'type': 'thing'},
|
| 181 |
+
{'supercategory': 'air_vehicle', 'id': 167, 'name': 'airplane', 'c_name': '飞机', 'type': 'thing'},
|
| 182 |
+
{'supercategory': 'energyfacility', 'id': 168, 'name': 'kiosk', 'c_name': '电话亭', 'type': 'thing'},
|
| 183 |
+
{'supercategory': 'entertainment_appliances', 'id': 169, 'name': 'television', 'c_name': '电视机', 'type': 'thing'},
|
| 184 |
+
{'supercategory': 'land_transportation', 'id': 170, 'name': 'trolley', 'c_name': '手推车', 'type': 'thing'},
|
| 185 |
+
{'supercategory': 'insect', 'id': 171, 'name': 'bee', 'c_name': '蜜蜂', 'type': 'thing'},
|
| 186 |
+
{'supercategory': 'solid', 'id': 172, 'name': 'gravel', 'c_name': '砂砾', 'type': 'stuff'},
|
| 187 |
+
{'supercategory': 'sofa', 'id': 173, 'name': 'couch', 'c_name': '长沙发', 'type': 'thing'},
|
| 188 |
+
{'supercategory': 'land_transportation', 'id': 174, 'name': 'van', 'c_name': '厢式货车', 'type': 'thing'},
|
| 189 |
+
{'supercategory': 'meat', 'id': 175, 'name': 'meat_ot', 'c_name': '其他肉', 'type': 'thing'},
|
| 190 |
+
{'supercategory': 'accessories', 'id': 176, 'name': 'accessories_ot', 'c_name': '其他服饰类', 'type': 'thing'},
|
| 191 |
+
{'supercategory': 'blanket_furniture', 'id': 177, 'name': 'blanket_furniture_ot', 'c_name': '其他毯子', 'type': 'thing'},
|
| 192 |
+
{'supercategory': 'common_furniture', 'id': 178, 'name': 'hanger', 'c_name': '衣架', 'type': 'thing'},
|
| 193 |
+
{'supercategory': 'blanket_furniture', 'id': 179, 'name': 'rug', 'c_name': '地毯', 'type': 'thing'},
|
| 194 |
+
{'supercategory': 'flexible_container', 'id': 180, 'name': 'paper_bag', 'c_name': '纸袋', 'type': 'thing'},
|
| 195 |
+
{'supercategory': 'entertainment_appliances', 'id': 181, 'name': 'remote_control', 'c_name': '遥控器', 'type': 'thing'},
|
| 196 |
+
{'supercategory': 'kitchen_tool', 'id': 182, 'name': 'kitchen_sink', 'c_name': '盥洗', 'type': 'thing'},
|
| 197 |
+
{'supercategory': 'kitchen_tool', 'id': 183, 'name': 'fork', 'c_name': '叉', 'type': 'thing'},
|
| 198 |
+
{'supercategory': 'kitchen_pot', 'id': 184, 'name': 'kitchen_pot_ot', 'c_name': '其他厨房用锅', 'type': 'thing'},
|
| 199 |
+
{'supercategory': 'insect', 'id': 185, 'name': 'insect_ot', 'c_name': '其他昆虫类', 'type': 'thing'},
|
| 200 |
+
{'supercategory': 'solid', 'id': 186, 'name': 'dirt', 'c_name': '贫瘠土地', 'type': 'stuff'},
|
| 201 |
+
{'supercategory': 'artifical_ground', 'id': 187, 'name': 'path', 'c_name': '小径', 'type': 'stuff'},
|
| 202 |
+
{'supercategory': 'underwater_vehicle', 'id': 188, 'name': 'underwater_vehicle_ot', 'c_name': '其他水中交通工具', 'type': 'thing'},
|
| 203 |
+
{'supercategory': 'sofa', 'id': 189, 'name': 'double_sofa', 'c_name': '双人沙发', 'type': 'thing'},
|
| 204 |
+
{'supercategory': 'seasoning', 'id': 190, 'name': 'condiment', 'c_name': '调味品', 'type': 'thing'},
|
| 205 |
+
{'supercategory': 'fooddrink', 'id': 191, 'name': 'drug', 'c_name': '药品', 'type': 'thing'},
|
| 206 |
+
{'supercategory': 'knife', 'id': 192, 'name': 'table-knife', 'c_name': '餐刀', 'type': 'thing'},
|
| 207 |
+
{'supercategory': 'fitness_equipment', 'id': 193, 'name': 'gym_equipment', 'c_name': '室内健身器材', 'type': 'thing'},
|
| 208 |
+
{'supercategory': 'footwear', 'id': 194, 'name': 'hose', 'c_name': '靴子', 'type': 'thing'},
|
| 209 |
+
{'supercategory': 'fruit', 'id': 195, 'name': 'peach', 'c_name': '桃', 'type': 'thing'},
|
| 210 |
+
{'supercategory': 'rigid_container', 'id': 196, 'name': 'flowerpot', 'c_name': '花盆', 'type': 'thing'},
|
| 211 |
+
{'supercategory': 'toy', 'id': 197, 'name': 'ballon', 'c_name': '气球', 'type': 'thing'},
|
| 212 |
+
{'supercategory': 'dessert_snacks', 'id': 198, 'name': 'bagel', 'c_name': '硬面包', 'type': 'thing'},
|
| 213 |
+
{'supercategory': 'non-building_houses', 'id': 199, 'name': 'tent', 'c_name': '帐篷', 'type': 'stuff'},
|
| 214 |
+
{'supercategory': 'entertainment_appliances', 'id': 200, 'name': 'tv_receiver', 'c_name': '电视接收器', 'type': 'thing'},
|
| 215 |
+
{'supercategory': 'cabinets', 'id': 201, 'name': 'nightstand', 'c_name': '床头柜', 'type': 'thing'},
|
| 216 |
+
{'supercategory': 'kitchen_appliances', 'id': 202, 'name': 'kitchen_appliances_ot', 'c_name': '其他厨房电器', 'type': 'thing'},
|
| 217 |
+
{'supercategory': 'fitness_equipment', 'id': 203, 'name': 'ski_pole', 'c_name': '滑雪杆', 'type': 'thing'},
|
| 218 |
+
{'supercategory': 'upper_body_clothing', 'id': 204, 'name': 'coat', 'c_name': '外套', 'type': 'thing'},
|
| 219 |
+
{'supercategory': 'kitchen_tool', 'id': 205, 'name': 'cutting_board', 'c_name': '砧板', 'type': 'thing'},
|
| 220 |
+
{'supercategory': 'building_structure', 'id': 206, 'name': 'stair', 'c_name': '楼梯', 'type': 'stuff'},
|
| 221 |
+
{'supercategory': 'plant_part', 'id': 207, 'name': 'plant_part_ot', 'c_name': '其他植物部分', 'type': 'thing'},
|
| 222 |
+
{'supercategory': 'footwear', 'id': 208, 'name': 'footwear_ot', 'c_name': '其他鞋', 'type': 'thing'},
|
| 223 |
+
{'supercategory': 'entertainment_appliances', 'id': 209, 'name': 'microphone', 'c_name': '麦克风', 'type': 'thing'},
|
| 224 |
+
{'supercategory': 'fruit', 'id': 210, 'name': 'lemon', 'c_name': '柠檬', 'type': 'thing'},
|
| 225 |
+
{'supercategory': 'non_individual_plants', 'id': 211, 'name': 'vine', 'c_name': '藤蔓', 'type': 'stuff'},
|
| 226 |
+
{'supercategory': 'upper_body_clothing', 'id': 212, 'name': 'upper_body_clothing_os', 'c_name': '其他上身类', 'type': 'thing'},
|
| 227 |
+
{'supercategory': 'hat', 'id': 213, 'name': 'hat_ot', 'c_name': '其他帽', 'type': 'thing'},
|
| 228 |
+
{'supercategory': 'vegetable', 'id': 214, 'name': 'mushroom', 'c_name': '蘑菇', 'type': 'thing'},
|
| 229 |
+
{'supercategory': 'vehicle_part', 'id': 215, 'name': 'tire', 'c_name': '轮胎', 'type': 'thing'},
|
| 230 |
+
{'supercategory': 'cabinets', 'id': 216, 'name': 'filling cabinets', 'c_name': '文件柜', 'type': 'thing'},
|
| 231 |
+
{'supercategory': 'ball', 'id': 217, 'name': 'billards', 'c_name': '台球', 'type': 'thing'},
|
| 232 |
+
{'supercategory': 'kitchen_tool', 'id': 218, 'name': 'teapot', 'c_name': '茶壶', 'type': 'thing'},
|
| 233 |
+
{'supercategory': 'building_structure', 'id': 219, 'name': 'awning', 'c_name': '遮篷', 'type': 'stuff'},
|
| 234 |
+
{'supercategory': 'entertainment_appliances', 'id': 220, 'name': 'keyboard', 'c_name': '键盘', 'type': 'thing'},
|
| 235 |
+
{'supercategory': 'repair_tool', 'id': 221, 'name': 'ladder', 'c_name': '梯子', 'type': 'thing'},
|
| 236 |
+
{'supercategory': 'entertainment_appliances', 'id': 222, 'name': 'mouse', 'c_name': '鼠标', 'type': 'thing'},
|
| 237 |
+
{'supercategory': 'kitchen_tool', 'id': 223, 'name': 'platter', 'c_name': '大浅盘', 'type': 'thing'},
|
| 238 |
+
{'supercategory': 'seat_furniture', 'id': 224, 'name': 'seat_furniture_ot', 'c_name': '其他椅子', 'type': 'thing'},
|
| 239 |
+
{'supercategory': 'kitchen_tool', 'id': 225, 'name': 'spatula', 'c_name': '厨房用铲', 'type': 'thing'},
|
| 240 |
+
{'supercategory': 'toy', 'id': 226, 'name': 'kite', 'c_name': '风筝', 'type': 'thing'},
|
| 241 |
+
{'supercategory': 'light', 'id': 227, 'name': 'lantern', 'c_name': '灯笼', 'type': 'thing'},
|
| 242 |
+
{'supercategory': 'land_transportation', 'id': 228, 'name': 'train', 'c_name': '火车', 'type': 'thing'},
|
| 243 |
+
{'supercategory': 'sofa', 'id': 229, 'name': 'sofa_ot', 'c_name': '其他沙发', 'type': 'thing'},
|
| 244 |
+
{'supercategory': 'artifical_ground', 'id': 230, 'name': 'trail', 'c_name': '小道', 'type': 'stuff'},
|
| 245 |
+
{'supercategory': 'table', 'id': 231, 'name': 'integrated_table_and_chair', 'c_name': '一体化桌椅', 'type': 'thing'},
|
| 246 |
+
{'supercategory': 'building_houses', 'id': 232, 'name': 'castle', 'c_name': '城堡', 'type': 'stuff'},
|
| 247 |
+
{'supercategory': 'lab_tool', 'id': 233, 'name': 'lab_tool_ot', 'c_name': '其他实验工具', 'type': 'thing'},
|
| 248 |
+
{'supercategory': 'seasoning', 'id': 234, 'name': 'seasoning_ot', 'c_name': '其他调味品', 'type': 'thing'},
|
| 249 |
+
{'supercategory': 'land_transportation', 'id': 235, 'name': 'cable_car', 'c_name': '缆车', 'type': 'thing'},
|
| 250 |
+
{'supercategory': 'fast_food', 'id': 236, 'name': 'fast_food_ot', 'c_name': '其他快餐食品', 'type': 'thing'},
|
| 251 |
+
{'supercategory': 'artifical_ground', 'id': 237, 'name': 'railroad', 'c_name': '铁路轨道', 'type': 'stuff'},
|
| 252 |
+
{'supercategory': 'kitchen_tool', 'id': 238, 'name': 'tableware', 'c_name': '餐具', 'type': 'thing'},
|
| 253 |
+
{'supercategory': 'artifical_ground', 'id': 239, 'name': 'court', 'c_name': '球场', 'type': 'stuff'},
|
| 254 |
+
{'supercategory': 'toy', 'id': 240, 'name': 'played_blocks', 'c_name': '积木', 'type': 'thing'},
|
| 255 |
+
{'supercategory': 'light', 'id': 241, 'name': 'lightbulb', 'c_name': '灯泡', 'type': 'thing'},
|
| 256 |
+
{'supercategory': 'toy', 'id': 242, 'name': 'chess', 'c_name': '棋类', 'type': 'thing'},
|
| 257 |
+
{'supercategory': 'non_individual_plants', 'id': 243, 'name': 'crops', 'c_name': '庄稼', 'type': 'stuff'},
|
| 258 |
+
{'supercategory': 'bag', 'id': 244, 'name': 'suitcase', 'c_name': '手提箱', 'type': 'thing'},
|
| 259 |
+
{'supercategory': 'reptile', 'id': 245, 'name': 'lizard', 'c_name': '蜥蜴', 'type': 'thing'},
|
| 260 |
+
{'supercategory': 'rigid_container', 'id': 246, 'name': 'earthware_pot_with_handle', 'c_name': '带柄的陶罐', 'type': 'thing'},
|
| 261 |
+
{'supercategory': 'fast_food', 'id': 247, 'name': 'pizza', 'c_name': '披萨', 'type': 'thing'},
|
| 262 |
+
{'supercategory': 'building_houses', 'id': 248, 'name': 'tower', 'c_name': '塔', 'type': 'stuff'},
|
| 263 |
+
{'supercategory': 'truck', 'id': 249, 'name': 'truck_ot', 'c_name': '其他卡车', 'type': 'thing'},
|
| 264 |
+
{'supercategory': 'fooddrink', 'id': 250, 'name': 'cigarette', 'c_name': '香烟', 'type': 'thing'},
|
| 265 |
+
{'supercategory': 'human_accessories', 'id': 251, 'name': 'scarf', 'c_name': '围巾', 'type': 'thing'},
|
| 266 |
+
{'supercategory': 'kitchen_appliances', 'id': 252, 'name': 'refrigerator', 'c_name': '冰箱', 'type': 'thing'},
|
| 267 |
+
{'supercategory': 'racket', 'id': 253, 'name': 'racket_ot', 'c_name': '其他拍子', 'type': 'thing'},
|
| 268 |
+
{'supercategory': 'deer', 'id': 254, 'name': 'giraffe', 'c_name': '长颈鹿', 'type': 'thing'},
|
| 269 |
+
{'supercategory': 'land_transportation', 'id': 255, 'name': 'scooter', 'c_name': '滑板车', 'type': 'thing'},
|
| 270 |
+
{'supercategory': 'appliances', 'id': 256, 'name': 'appliances_ot', 'c_name': '其他家电', 'type': 'thing'},
|
| 271 |
+
{'supercategory': 'fruit', 'id': 257, 'name': 'banana', 'c_name': '香蕉', 'type': 'thing'},
|
| 272 |
+
{'supercategory': 'fitness_equipment', 'id': 258, 'name': 'ski_board', 'c_name': '滑雪板', 'type': 'thing'},
|
| 273 |
+
{'supercategory': 'clean_tool', 'id': 259, 'name': 'clean_tool_ot', 'c_name': '其他清洁工具', 'type': 'thing'},
|
| 274 |
+
{'supercategory': 'toy', 'id': 260, 'name': 'dice', 'c_name': '筛子', 'type': 'thing'},
|
| 275 |
+
{'supercategory': 'dessert_snacks', 'id': 261, 'name': 'crumb', 'c_name': '面包屑', 'type': 'thing'},
|
| 276 |
+
{'supercategory': 'fruit', 'id': 262, 'name': 'commonfig', 'c_name': '无花果', 'type': 'thing'},
|
| 277 |
+
{'supercategory': 'vegetable', 'id': 263, 'name': 'tomato', 'c_name': '番茄', 'type': 'thing'},
|
| 278 |
+
{'supercategory': 'birds', 'id': 264, 'name': 'goose', 'c_name': '鹅', 'type': 'thing'},
|
| 279 |
+
{'supercategory': 'table', 'id': 265, 'name': 'desk', 'c_name': '书桌', 'type': 'thing'},
|
| 280 |
+
{'supercategory': 'media', 'id': 266, 'name': 'packaging_paper', 'c_name': '包装纸', 'type': 'thing'},
|
| 281 |
+
{'supercategory': 'toy', 'id': 267, 'name': 'poker', 'c_name': '扑克', 'type': 'thing'},
|
| 282 |
+
{'supercategory': 'non-building_houses', 'id': 268, 'name': 'pier', 'c_name': '码头', 'type': 'stuff'},
|
| 283 |
+
{'supercategory': 'non-building_houses', 'id': 269, 'name': 'swimmingpool', 'c_name': '游泳池', 'type': 'stuff'},
|
| 284 |
+
{'supercategory': 'fitness_equipment', 'id': 270, 'name': 'surfboard', 'c_name': '冲浪板', 'type': 'thing'},
|
| 285 |
+
{'supercategory': 'lab_tool', 'id': 271, 'name': ' medical_equipment', 'c_name': '医疗器械', 'type': 'thing'},
|
| 286 |
+
{'supercategory': 'footwear', 'id': 272, 'name': 'leather_shoes', 'c_name': '皮鞋', 'type': 'thing'},
|
| 287 |
+
{'supercategory': 'media', 'id': 273, 'name': 'blackboard', 'c_name': '黑板白板', 'type': 'thing'},
|
| 288 |
+
{'supercategory': 'vegetable', 'id': 274, 'name': 'egg', 'c_name': '鸡蛋', 'type': 'thing'},
|
| 289 |
+
{'supercategory': 'ventilation_appliances', 'id': 275, 'name': 'air_conditioner', 'c_name': '空调', 'type': 'thing'},
|
| 290 |
+
{'supercategory': 'entertainment_appliances', 'id': 276, 'name': 'gamepad', 'c_name': '游戏手柄', 'type': 'thing'},
|
| 291 |
+
{'supercategory': 'clean_tool', 'id': 277, 'name': 'pipe', 'c_name': '水管', 'type': 'thing'},
|
| 292 |
+
{'supercategory': 'insect', 'id': 278, 'name': 'moth', 'c_name': '飞蛾', 'type': 'thing'},
|
| 293 |
+
{'supercategory': 'crustacea', 'id': 279, 'name': 'crustacea_ot', 'c_name': '其他甲壳类动物', 'type': 'thing'},
|
| 294 |
+
{'supercategory': 'mollusca', 'id': 280, 'name': 'jellyfish', 'c_name': '水母', 'type': 'thing'},
|
| 295 |
+
{'supercategory': 'table', 'id': 281, 'name': 'table_cloth', 'c_name': '桌布', 'type': 'thing'},
|
| 296 |
+
{'supercategory': 'cabinets', 'id': 282, 'name': 'wardrobe', 'c_name': '衣柜', 'type': 'thing'},
|
| 297 |
+
{'supercategory': 'building_structure', 'id': 283, 'name': 'bar', 'c_name': '吧台', 'type': 'stuff'},
|
| 298 |
+
{'supercategory': 'underwater_vehicle', 'id': 284, 'name': 'canoe', 'c_name': '皮划艇', 'type': 'thing'},
|
| 299 |
+
{'supercategory': 'birds', 'id': 285, 'name': 'chicken', 'c_name': '鸡', 'type': 'thing'},
|
| 300 |
+
{'supercategory': 'fluid', 'id': 286, 'name': 'pond', 'c_name': '池塘', 'type': 'stuff'},
|
| 301 |
+
{'supercategory': 'upper_body_clothing', 'id': 287, 'name': 'T-shirt', 'c_name': 'T恤', 'type': 'thing'},
|
| 302 |
+
{'supercategory': 'footwear', 'id': 288, 'name': 'splippers', 'c_name': '拖鞋', 'type': 'thing'},
|
| 303 |
+
{'supercategory': 'media', 'id': 289, 'name': 'bulletin_board', 'c_name': '电子公告牌', 'type': 'thing'},
|
| 304 |
+
{'supercategory': 'fruit', 'id': 290, 'name': 'strawberry', 'c_name': '草莓', 'type': 'thing'},
|
| 305 |
+
{'supercategory': 'telephone', 'id': 291, 'name': 'corded_telephone', 'c_name': '有线电话', 'type': 'thing'},
|
| 306 |
+
{'supercategory': 'kitchen_tool', 'id': 292, 'name': 'saucer', 'c_name': '茶碟', 'type': 'thing'},
|
| 307 |
+
{'supercategory': 'reptile', 'id': 293, 'name': 'turtle', 'c_name': '龟', 'type': 'thing'},
|
| 308 |
+
{'supercategory': 'cup', 'id': 294, 'name': 'coffee cup', 'c_name': '咖啡杯', 'type': 'thing'},
|
| 309 |
+
{'supercategory': 'solid', 'id': 295, 'name': 'solid_ot', 'c_name': '其他固体', 'type': 'stuff'},
|
| 310 |
+
{'supercategory': 'wall', 'id': 296, 'name': 'glasswall', 'c_name': '玻璃墙', 'type': 'stuff'},
|
| 311 |
+
{'supercategory': 'vegetable', 'id': 297, 'name': 'carrot', 'c_name': '胡萝卜', 'type': 'thing'},
|
| 312 |
+
{'supercategory': 'clean_tool', 'id': 298, 'name': 'tissue', 'c_name': '抽纸', 'type': 'thing'},
|
| 313 |
+
{'supercategory': 'individual_plants', 'id': 299, 'name': 'individual_plants_ot', 'c_name': '其他独立植物', 'type': 'stuff'},
|
| 314 |
+
{'supercategory': 'traffic_facility', 'id': 300, 'name': 'fire_hyrant', 'c_name': '消防龙头', 'type': 'thing'},
|
| 315 |
+
{'supercategory': 'footwear', 'id': 301, 'name': ' high-heeled_shoes', 'c_name': '高跟鞋', 'type': 'thing'},
|
| 316 |
+
{'supercategory': 'vegetable', 'id': 302, 'name': 'potato', 'c_name': '马铃薯', 'type': 'thing'},
|
| 317 |
+
{'supercategory': 'entertainment_appliances', 'id': 303, 'name': 'radiator', 'c_name': '暖气', 'type': 'thing'},
|
| 318 |
+
{'supercategory': 'repair_tool', 'id': 304, 'name': 'wrench', 'c_name': '扳手', 'type': 'thing'},
|
| 319 |
+
{'supercategory': 'stove', 'id': 305, 'name': 'gas_stove', 'c_name': '燃气炉', 'type': 'thing'},
|
| 320 |
+
{'supercategory': 'horse', 'id': 306, 'name': 'zebra', 'c_name': '斑马', 'type': 'thing'},
|
| 321 |
+
{'supercategory': 'non-building_houses', 'id': 307, 'name': 'fountain_ground', 'c_name': '喷泉台', 'type': 'stuff'},
|
| 322 |
+
{'supercategory': 'knife', 'id': 308, 'name': 'knife_ot', 'c_name': '其他刀', 'type': 'thing'},
|
| 323 |
+
{'supercategory': 'weapon', 'id': 309, 'name': 'rifle', 'c_name': '步枪', 'type': 'thing'},
|
| 324 |
+
{'supercategory': 'mammal', 'id': 310, 'name': 'monkey', 'c_name': '猴子', 'type': 'thing'},
|
| 325 |
+
{'supercategory': 'individual_plants', 'id': 311, 'name': 'straw', 'c_name': '稻草', 'type': 'stuff'},
|
| 326 |
+
{'supercategory': 'ball', 'id': 312, 'name': 'golf', 'c_name': '高尔夫球', 'type': 'thing'},
|
| 327 |
+
{'supercategory': 'lab_tool', 'id': 313, 'name': ' folder', 'c_name': '文件夹', 'type': 'thing'},
|
| 328 |
+
{'supercategory': 'human_accessories', 'id': 314, 'name': 'gloves', 'c_name': '手套', 'type': 'thing'},
|
| 329 |
+
{'supercategory': 'repair_tool', 'id': 315, 'name': 'screwdriver', 'c_name': '螺丝刀', 'type': 'thing'},
|
| 330 |
+
{'supercategory': 'kitchen_tool', 'id': 316, 'name': 'drinking_straw', 'c_name': '吸管', 'type': 'thing'},
|
| 331 |
+
{'supercategory': 'mammal', 'id': 317, 'name': 'pig', 'c_name': '猪', 'type': 'thing'},
|
| 332 |
+
{'supercategory': 'plant', 'id': 318, 'name': 'plant_ot', 'c_name': '其他植物', 'type': 'thing'},
|
| 333 |
+
{'supercategory': 'cabinets', 'id': 319, 'name': 'bathroom cabinets', 'c_name': '浴室柜', 'type': 'thing'},
|
| 334 |
+
{'supercategory': 'ventilation_appliances', 'id': 320, 'name': 'vent', 'c_name': '通风孔', 'type': 'thing'},
|
| 335 |
+
{'supercategory': 'clean_appliances', 'id': 321, 'name': 'washing_machine', 'c_name': '洗衣机', 'type': 'thing'},
|
| 336 |
+
{'supercategory': 'racket', 'id': 322, 'name': 'tennis_racket', 'c_name': '网球拍', 'type': 'thing'},
|
| 337 |
+
{'supercategory': 'kitchen_tool', 'id': 323, 'name': 'chopsticks', 'c_name': '筷子', 'type': 'thing'},
|
| 338 |
+
{'supercategory': 'mammal', 'id': 324, 'name': 'seal', 'c_name': '海豹', 'type': 'thing'},
|
| 339 |
+
{'supercategory': 'building_houses', 'id': 325, 'name': 'lighthouse', 'c_name': '灯塔', 'type': 'stuff'},
|
| 340 |
+
{'supercategory': 'kitchen_appliances', 'id': 326, 'name': 'kettle', 'c_name': '水壶', 'type': 'thing'},
|
| 341 |
+
{'supercategory': 'fitness_equipment', 'id': 327, 'name': 'parachute', 'c_name': '降落伞', 'type': 'thing'},
|
| 342 |
+
{'supercategory': 'beddings', 'id': 328, 'name': 'blanket', 'c_name': '被子', 'type': 'thing'},
|
| 343 |
+
{'supercategory': 'drink', 'id': 329, 'name': 'juice', 'c_name': '果汁', 'type': 'thing'},
|
| 344 |
+
{'supercategory': 'kitchen_tool', 'id': 330, 'name': 'food_processor', 'c_name': '食品加工机', 'type': 'thing'},
|
| 345 |
+
{'supercategory': 'truck', 'id': 331, 'name': 'pickup_truck', 'c_name': '皮卡车', 'type': 'thing'},
|
| 346 |
+
{'supercategory': 'doll', 'id': 332, 'name': 'teddy_bear', 'c_name': '泰迪熊', 'type': 'thing'},
|
| 347 |
+
{'supercategory': 'deer', 'id': 333, 'name': 'deer_ot', 'c_name': '其他鹿', 'type': 'thing'},
|
| 348 |
+
{'supercategory': 'entity', 'id': 334, 'name': 'blur', 'c_name': '模糊的区域', 'type': 'stuff'},
|
| 349 |
+
{'supercategory': 'clock_furniture', 'id': 335, 'name': 'clock', 'c_name': '时钟', 'type': 'thing'},
|
| 350 |
+
{'supercategory': 'beddings', 'id': 336, 'name': 'beddings_ot', 'c_name': '其他床上用品', 'type': 'thing'},
|
| 351 |
+
{'supercategory': 'lab_tool', 'id': 337, 'name': 'tube', 'c_name': '试管', 'type': 'thing'},
|
| 352 |
+
{'supercategory': 'fluid', 'id': 338, 'name': 'fountain', 'c_name': '喷泉', 'type': 'stuff'},
|
| 353 |
+
{'supercategory': 'non-building_houses', 'id': 339, 'name': 'parterre', 'c_name': '花坛', 'type': 'stuff'},
|
| 354 |
+
{'supercategory': 'human_accessories', 'id': 340, 'name': 'human_accessories_ot', 'c_name': '其他人物服饰类', 'type': 'thing'},
|
| 355 |
+
{'supercategory': 'birds', 'id': 341, 'name': 'parrot', 'c_name': '鹦鹉', 'type': 'thing'},
|
| 356 |
+
{'supercategory': 'common_furniture', 'id': 342, 'name': 'toilet', 'c_name': '马桶', 'type': 'thing'},
|
| 357 |
+
{'supercategory': 'fitness_equipment', 'id': 343, 'name': 'dumbbell', 'c_name': '哑铃', 'type': 'thing'},
|
| 358 |
+
{'supercategory': 'fruit', 'id': 344, 'name': 'pear', 'c_name': '梨', 'type': 'thing'},
|
| 359 |
+
{'supercategory': 'fruit', 'id': 345, 'name': 'pineapple', 'c_name': '菠萝', 'type': 'thing'},
|
| 360 |
+
{'supercategory': 'building_houses', 'id': 346, 'name': 'temple', 'c_name': '寺庙', 'type': 'stuff'},
|
| 361 |
+
{'supercategory': 'repair_tool', 'id': 347, 'name': 'brush', 'c_name': '刷子', 'type': 'thing'},
|
| 362 |
+
{'supercategory': 'vegetable', 'id': 348, 'name': 'onion', 'c_name': '洋葱', 'type': 'thing'},
|
| 363 |
+
{'supercategory': 'crustacea', 'id': 349, 'name': 'crab', 'c_name': '螃蟹', 'type': 'thing'},
|
| 364 |
+
{'supercategory': 'camel', 'id': 350, 'name': 'camel_ot', 'c_name': '其他骆驼', 'type': 'thing'},
|
| 365 |
+
{'supercategory': 'traffic_facility', 'id': 351, 'name': 'guideboard', 'c_name': '路牌路标', 'type': 'thing'},
|
| 366 |
+
{'supercategory': 'human_accessories', 'id': 352, 'name': 'watch', 'c_name': '手表', 'type': 'thing'},
|
| 367 |
+
{'supercategory': 'kitchen_appliances', 'id': 353, 'name': 'range_hood', 'c_name': '油烟机', 'type': 'thing'},
|
| 368 |
+
{'supercategory': 'clock_furniture', 'id': 354, 'name': 'alarm clock', 'c_name': '闹钟', 'type': 'thing'},
|
| 369 |
+
{'supercategory': 'rigid_container', 'id': 355, 'name': 'cage', 'c_name': '笼子', 'type': 'thing'},
|
| 370 |
+
{'supercategory': 'ball', 'id': 356, 'name': 'tennis', 'c_name': '网球', 'type': 'thing'},
|
| 371 |
+
{'supercategory': 'kitchen_tool', 'id': 357, 'name': 'salt_shaker', 'c_name': '盐甁', 'type': 'thing'},
|
| 372 |
+
{'supercategory': 'kitchen_pot', 'id': 358, 'name': 'frying_pan', 'c_name': '煎锅', 'type': 'thing'},
|
| 373 |
+
{'supercategory': 'fast_food', 'id': 359, 'name': 'sausage', 'c_name': '香肠', 'type': 'thing'},
|
| 374 |
+
{'supercategory': 'fruit', 'id': 360, 'name': 'mango', 'c_name': '芒果', 'type': 'thing'},
|
| 375 |
+
{'supercategory': 'mammal', 'id': 361, 'name': 'lion', 'c_name': '狮子', 'type': 'thing'},
|
| 376 |
+
{'supercategory': 'kitchen_appliances', 'id': 362, 'name': 'oven', 'c_name': '烤箱', 'type': 'thing'},
|
| 377 |
+
{'supercategory': 'vehicle_part', 'id': 363, 'name': 'vehicle_part_ot', 'c_name': '其他车体部分', 'type': 'thing'},
|
| 378 |
+
{'supercategory': 'weapon', 'id': 364, 'name': 'sword', 'c_name': '剑', 'type': 'thing'},
|
| 379 |
+
{'supercategory': 'vegetable', 'id': 365, 'name': 'bell_papper', 'c_name': '甜椒', 'type': 'thing'},
|
| 380 |
+
{'supercategory': 'seafood', 'id': 366, 'name': 'seafood_ot', 'c_name': '其他海鲜', 'type': 'thing'},
|
| 381 |
+
{'supercategory': 'bed', 'id': 367, 'name': 'bed_ot', 'c_name': '其他床', 'type': 'thing'},
|
| 382 |
+
{'supercategory': 'land_transportation', 'id': 368, 'name': 'wheelchair', 'c_name': '轮椅', 'type': 'thing'},
|
| 383 |
+
{'supercategory': 'fish', 'id': 369, 'name': 'goldfish', 'c_name': '金鱼', 'type': 'thing'},
|
| 384 |
+
{'supercategory': 'cabinets', 'id': 370, 'name': 'chest_of_drawers', 'c_name': '五斗柜', 'type': 'thing'},
|
| 385 |
+
{'supercategory': 'bath_tool', 'id': 371, 'name': 'shampoo', 'c_name': '洗发水沐浴露', 'type': 'thing'},
|
| 386 |
+
{'supercategory': 'mammal', 'id': 372, 'name': 'squirrel', 'c_name': '松鼠', 'type': 'thing'},
|
| 387 |
+
{'supercategory': 'mammal', 'id': 373, 'name': 'sealion', 'c_name': '海狮', 'type': 'thing'},
|
| 388 |
+
{'supercategory': 'building_structure', 'id': 374, 'name': 'chimney', 'c_name': '烟筒', 'type': 'stuff'},
|
| 389 |
+
{'supercategory': 'building_structure', 'id': 375, 'name': 'fireplace', 'c_name': '壁炉', 'type': 'stuff'},
|
| 390 |
+
{'supercategory': 'helmet', 'id': 376, 'name': 'helmet_ot', 'c_name': '其他头盔', 'type': 'thing'},
|
| 391 |
+
{'supercategory': 'common_furniture', 'id': 377, 'name': 'bathhub', 'c_name': '澡盆', 'type': 'thing'},
|
| 392 |
+
{'supercategory': 'kitchen_appliances', 'id': 378, 'name': 'micro-wave_oven', 'c_name': '微波炉', 'type': 'thing'},
|
| 393 |
+
{'supercategory': 'racket', 'id': 379, 'name': 'golf_club', 'c_name': '高尔夫球杆', 'type': 'thing'},
|
| 394 |
+
{'supercategory': 'building_structure', 'id': 380, 'name': 'seating_area', 'c_name': '座位席', 'type': 'stuff'},
|
| 395 |
+
{'supercategory': 'glasses', 'id': 381, 'name': 'sunglasses_ot', 'c_name': '其他眼镜', 'type': 'thing'},
|
| 396 |
+
{'supercategory': 'ventilation_appliances', 'id': 382, 'name': 'ventilation_appliances_ot', 'c_name': '其他通风类电器', 'type': 'thing'},
|
| 397 |
+
{'supercategory': 'clock_furniture', 'id': 383, 'name': 'wall clock', 'c_name': '挂钟', 'type': 'thing'},
|
| 398 |
+
{'supercategory': 'racket', 'id': 384, 'name': 'baseball bat', 'c_name': '棒球棒', 'type': 'thing'},
|
| 399 |
+
{'supercategory': 'repair_tool', 'id': 385, 'name': 'shovel', 'c_name': '铲子', 'type': 'thing'},
|
| 400 |
+
{'supercategory': 'outdoor_supplies', 'id': 386, 'name': 'fishing_tool', 'c_name': '钓鱼工具', 'type': 'thing'},
|
| 401 |
+
{'supercategory': 'fast_food', 'id': 387, 'name': 'hotdog', 'c_name': '热狗', 'type': 'thing'},
|
| 402 |
+
{'supercategory': 'insect', 'id': 388, 'name': 'snail', 'c_name': '蜗牛', 'type': 'thing'},
|
| 403 |
+
{'supercategory': 'crustacea', 'id': 389, 'name': 'shrimp', 'c_name': '虾', 'type': 'thing'},
|
| 404 |
+
{'supercategory': 'clean_tool', 'id': 390, 'name': 'broom', 'c_name': '扫帚', 'type': 'thing'},
|
| 405 |
+
{'supercategory': 'cow', 'id': 391, 'name': 'antelope', 'c_name': '羚羊', 'type': 'thing'},
|
| 406 |
+
{'supercategory': 'solid', 'id': 392, 'name': 'cement_floor', 'c_name': '水泥地', 'type': 'stuff'},
|
| 407 |
+
{'supercategory': 'socks', 'id': 393, 'name': 'hose', 'c_name': '普通袜子', 'type': 'thing'},
|
| 408 |
+
{'supercategory': 'bag', 'id': 394, 'name': 'briefcase', 'c_name': '公文包', 'type': 'thing'},
|
| 409 |
+
{'supercategory': 'fluid', 'id': 395, 'name': 'brook', 'c_name': '小溪', 'type': 'stuff'},
|
| 410 |
+
{'supercategory': 'weapon', 'id': 396, 'name': 'weapon_ot', 'c_name': '其他武器', 'type': 'thing'},
|
| 411 |
+
{'supercategory': 'reptile', 'id': 397, 'name': 'snake', 'c_name': '蛇', 'type': 'thing'},
|
| 412 |
+
{'supercategory': 'upper_body_clothing', 'id': 398, 'name': 'shirt', 'c_name': '衬衫', 'type': 'thing'},
|
| 413 |
+
{'supercategory': 'ball', 'id': 399, 'name': 'football', 'c_name': '足球', 'type': 'thing'},
|
| 414 |
+
{'supercategory': 'fruit', 'id': 400, 'name': 'watermelon', 'c_name': '西瓜', 'type': 'thing'},
|
| 415 |
+
{'supercategory': 'artifical_ground', 'id': 401, 'name': 'alley', 'c_name': '胡同', 'type': 'stuff'},
|
| 416 |
+
{'supercategory': 'building_houses', 'id': 402, 'name': 'skyscraper', 'c_name': '摩天大楼', 'type': 'stuff'},
|
| 417 |
+
{'supercategory': 'clean_tool', 'id': 403, 'name': 'toilet_paper', 'c_name': '厕所用纸', 'type': 'thing'},
|
| 418 |
+
{'supercategory': 'media', 'id': 404, 'name': 'banner', 'c_name': '横幅', 'type': 'thing'},
|
| 419 |
+
{'supercategory': 'fruit', 'id': 405, 'name': 'grape', 'c_name': '葡萄', 'type': 'thing'},
|
| 420 |
+
{'supercategory': 'vegetable', 'id': 406, 'name': 'radish', 'c_name': '萝卜', 'type': 'thing'},
|
| 421 |
+
{'supercategory': 'drink', 'id': 407, 'name': 'coffee', 'c_name': '咖啡', 'type': 'thing'},
|
| 422 |
+
{'supercategory': 'individual_plants', 'id': 408, 'name': 'palm', 'c_name': '棕榈树', 'type': 'stuff'},
|
| 423 |
+
{'supercategory': 'fluid', 'id': 409, 'name': 'waterfall', 'c_name': '瀑布', 'type': 'stuff'},
|
| 424 |
+
{'supercategory': 'energyfacility', 'id': 410, 'name': 'solar_pannel', 'c_name': '太阳能板', 'type': 'thing'},
|
| 425 |
+
{'supercategory': 'entertainment_appliances', 'id': 411, 'name': 'radio', 'c_name': '收音机', 'type': 'thing'},
|
| 426 |
+
{'supercategory': 'repair_tool', 'id': 412, 'name': 'hammer', 'c_name': '锤子', 'type': 'thing'},
|
| 427 |
+
{'supercategory': 'land_transportation', 'id': 413, 'name': 'carriage', 'c_name': '马车', 'type': 'thing'},
|
| 428 |
+
{'supercategory': 'dessert_snacks', 'id': 414, 'name': 'doughnut', 'c_name': '甜甜圈', 'type': 'thing'},
|
| 429 |
+
{'supercategory': 'insect', 'id': 415, 'name': 'dragonfly', 'c_name': '蜻蜓', 'type': 'thing'},
|
| 430 |
+
{'supercategory': 'outdoor_supplies', 'id': 416, 'name': 'crutch', 'c_name': '拐杖', 'type': 'thing'},
|
| 431 |
+
{'supercategory': 'lab_tool', 'id': 417, 'name': 'ruler', 'c_name': '尺子', 'type': 'thing'},
|
| 432 |
+
{'supercategory': 'mollusca', 'id': 418, 'name': 'mollusca_ot', 'c_name': '其他软体类动物', 'type': 'thing'},
|
| 433 |
+
{'supercategory': 'mammal', 'id': 419, 'name': 'leopard', 'c_name': '豹子', 'type': 'thing'},
|
| 434 |
+
{'supercategory': 'jewlery', 'id': 420, 'name': 'jewlery_ot', 'c_name': '其他首饰', 'type': 'thing'},
|
| 435 |
+
{'supercategory': 'entertainment_appliances', 'id': 421, 'name': 'extension_cord', 'c_name': '延长线', 'type': 'thing'},
|
| 436 |
+
{'supercategory': 'repair_tool', 'id': 422, 'name': 'tong', 'c_name': '钳子', 'type': 'thing'},
|
| 437 |
+
{'supercategory': 'underwater_vehicle', 'id': 423, 'name': 'motorboat', 'c_name': '摩托艇', 'type': 'thing'},
|
| 438 |
+
{'supercategory': 'non_individual_plants', 'id': 424, 'name': 'moss', 'c_name': '苔藓', 'type': 'stuff'},
|
| 439 |
+
{'supercategory': 'traffic_facility', 'id': 425, 'name': 'parking_meter', 'c_name': '停车计时器', 'type': 'thing'},
|
| 440 |
+
{'supercategory': 'fitness_equipment', 'id': 426, 'name': 'ski', 'c_name': '雪橇', 'type': 'thing'},
|
| 441 |
+
{'supercategory': 'air_vehicle', 'id': 427, 'name': 'hot_ballon', 'c_name': '热气球', 'type': 'thing'},
|
| 442 |
+
{'supercategory': 'birds', 'id': 428, 'name': 'eagle', 'c_name': '鹰', 'type': 'thing'},
|
| 443 |
+
{'supercategory': 'mammal', 'id': 429, 'name': 'kangaroo', 'c_name': '袋鼠', 'type': 'thing'},
|
| 444 |
+
{'supercategory': 'mammal', 'id': 430, 'name': 'dolphin', 'c_name': '海豚', 'type': 'thing'},
|
| 445 |
+
{'supercategory': 'jewlery', 'id': 431, 'name': 'necklace', 'c_name': '项链', 'type': 'thing'},
|
| 446 |
+
{'supercategory': 'ventilation_appliances', 'id': 432, 'name': 'ceiling_fan', 'c_name': '吊扇', 'type': 'thing'},
|
| 447 |
+
{'supercategory': 'ball', 'id': 433, 'name': 'basketball', 'c_name': '篮球', 'type': 'thing'},
|
| 448 |
+
{'supercategory': 'fitness_equipment', 'id': 434, 'name': 'bow_and_arrow', 'c_name': '弓箭', 'type': 'thing'},
|
| 449 |
+
{'supercategory': 'land_transportation', 'id': 435, 'name': 'tank', 'c_name': '坦克', 'type': 'thing'},
|
| 450 |
+
{'supercategory': 'boat_part', 'id': 436, 'name': 'boat_part_ot', 'c_name': '其他船体部分', 'type': 'thing'},
|
| 451 |
+
{'supercategory': 'doll', 'id': 437, 'name': 'barbie_doll', 'c_name': '芭比娃娃', 'type': 'thing'},
|
| 452 |
+
{'supercategory': 'vegetable', 'id': 438, 'name': 'cabbage', 'c_name': '甘蓝', 'type': 'thing'},
|
| 453 |
+
{'supercategory': 'insect', 'id': 439, 'name': 'ant', 'c_name': '蚂蚁', 'type': 'thing'},
|
| 454 |
+
{'supercategory': 'crustacea', 'id': 440, 'name': 'lobster', 'c_name': '龙虾', 'type': 'thing'},
|
| 455 |
+
{'supercategory': 'mammal', 'id': 441, 'name': 'tiger', 'c_name': '老虎', 'type': 'thing'},
|
| 456 |
+
{'supercategory': 'ball', 'id': 442, 'name': 'baseball', 'c_name': '棒球', 'type': 'thing'},
|
| 457 |
+
{'supercategory': 'fitness_equipment', 'id': 443, 'name': 'frisbee', 'c_name': '飞盘', 'type': 'thing'},
|
| 458 |
+
{'supercategory': 'bath_tool', 'id': 444, 'name': 'hairdryer', 'c_name': '吹风机', 'type': 'thing'},
|
| 459 |
+
{'supercategory': 'dessert_snacks', 'id': 445, 'name': 'cookie', 'c_name': '饼干', 'type': 'thing'},
|
| 460 |
+
{'supercategory': 'birds', 'id': 446, 'name': 'sparrow', 'c_name': '麻雀', 'type': 'thing'},
|
| 461 |
+
{'supercategory': 'bear', 'id': 447, 'name': 'polar_bear', 'c_name': '北极熊', 'type': 'thing'},
|
| 462 |
+
{'supercategory': 'air_vehicle', 'id': 448, 'name': 'helicopter', 'c_name': '直升机', 'type': 'thing'},
|
| 463 |
+
{'supercategory': 'media', 'id': 449, 'name': 'trophies_medals_certification', 'c_name': '奖杯奖牌证书', 'type': 'thing'},
|
| 464 |
+
{'supercategory': 'bear', 'id': 450, 'name': 'bear_ot', 'c_name': '其他熊', 'type': 'thing'},
|
| 465 |
+
{'supercategory': 'glasses', 'id': 451, 'name': 'sunglasses', 'c_name': '墨镜', 'type': 'thing'},
|
| 466 |
+
{'supercategory': 'bath_tool', 'id': 452, 'name': 'toothbrush', 'c_name': '牙刷', 'type': 'thing'},
|
| 467 |
+
{'supercategory': 'fast_food', 'id': 453, 'name': 'sushi', 'c_name': '寿司', 'type': 'thing'},
|
| 468 |
+
{'supercategory': 'mammal', 'id': 454, 'name': 'rabbit', 'c_name': '兔子', 'type': 'thing'},
|
| 469 |
+
{'supercategory': 'artifical_ground', 'id': 455, 'name': 'platform', 'c_name': '站台', 'type': 'stuff'},
|
| 470 |
+
{'supercategory': 'hat', 'id': 456, 'name': 'sunhat', 'c_name': '太阳帽', 'type': 'thing'},
|
| 471 |
+
{'supercategory': 'ventilation_appliances', 'id': 457, 'name': 'mechanical_fan', 'c_name': '机械风扇', 'type': 'thing'},
|
| 472 |
+
{'supercategory': 'clock_furniture', 'id': 458, 'name': 'clock_furniture_ot', 'c_name': '其他钟', 'type': 'thing'},
|
| 473 |
+
{'supercategory': 'container', 'id': 459, 'name': 'container_ot', 'c_name': '其他容器类', 'type': 'thing'},
|
| 474 |
+
{'supercategory': 'birds', 'id': 460, 'name': 'owl', 'c_name': '猫头鹰', 'type': 'thing'},
|
| 475 |
+
{'supercategory': 'mollusca', 'id': 461, 'name': 'starfish', 'c_name': '海星', 'type': 'thing'},
|
| 476 |
+
{'supercategory': 'fish', 'id': 462, 'name': 'seahorse', 'c_name': '海马', 'type': 'thing'},
|
| 477 |
+
{'supercategory': 'amphibians', 'id': 463, 'name': 'frog', 'c_name': '蛙', 'type': 'thing'},
|
| 478 |
+
{'supercategory': 'artifical_ground', 'id': 464, 'name': 'parkinglot', 'c_name': '停车位', 'type': 'stuff'},
|
| 479 |
+
{'supercategory': 'artifical_ground', 'id': 465, 'name': 'playground', 'c_name': '运动场', 'type': 'stuff'},
|
| 480 |
+
{'supercategory': 'table', 'id': 466, 'name': 'billiard_table', 'c_name': '台球桌', 'type': 'thing'},
|
| 481 |
+
{'supercategory': 'fitness_equipment', 'id': 467, 'name': 'swing', 'c_name': '秋千', 'type': 'thing'},
|
| 482 |
+
{'supercategory': 'insect', 'id': 468, 'name': 'spider', 'c_name': '蜘蛛', 'type': 'thing'},
|
| 483 |
+
{'supercategory': 'mammal', 'id': 469, 'name': 'fox', 'c_name': '狐狸', 'type': 'thing'},
|
| 484 |
+
{'supercategory': 'jewlery', 'id': 470, 'name': 'earrings', 'c_name': '耳环', 'type': 'thing'},
|
| 485 |
+
{'supercategory': 'kitchen_appliances', 'id': 471, 'name': 'coffeemaker', 'c_name': '咖啡机', 'type': 'thing'},
|
| 486 |
+
{'supercategory': 'bath_tool', 'id': 472, 'name': 'soap', 'c_name': '肥皂', 'type': 'thing'},
|
| 487 |
+
{'supercategory': 'outdoor_supplies', 'id': 473, 'name': 'hammock', 'c_name': '吊床', 'type': 'thing'},
|
| 488 |
+
{'supercategory': 'dessert_snacks', 'id': 474, 'name': 'candy', 'c_name': '糖果', 'type': 'thing'},
|
| 489 |
+
{'supercategory': 'fast_food', 'id': 475, 'name': 'french_fries', 'c_name': '炸薯条', 'type': 'thing'},
|
| 490 |
+
{'supercategory': 'vegetable', 'id': 476, 'name': 'cucumber', 'c_name': '黄瓜', 'type': 'thing'},
|
| 491 |
+
{'supercategory': 'building_houses', 'id': 477, 'name': 'church', 'c_name': '教堂', 'type': 'stuff'},
|
| 492 |
+
{'supercategory': 'upper_body_clothing', 'id': 478, 'name': 'hoodie', 'c_name': '连帽衫', 'type': 'thing'},
|
| 493 |
+
{'supercategory': 'trousers', 'id': 479, 'name': 'pants', 'c_name': '长裤', 'type': 'thing'},
|
| 494 |
+
{'supercategory': 'stove', 'id': 480, 'name': 'stove_ot', 'c_name': '其他炉灶', 'type': 'thing'},
|
| 495 |
+
{'supercategory': 'bed', 'id': 481, 'name': 'crib', 'c_name': '婴儿床', 'type': 'thing'},
|
| 496 |
+
{'supercategory': 'land_transportation', 'id': 482, 'name': 'crane', 'c_name': '起重机', 'type': 'thing'},
|
| 497 |
+
{'supercategory': 'insect', 'id': 483, 'name': 'caterpillar', 'c_name': '毛毛虫', 'type': 'thing'},
|
| 498 |
+
{'supercategory': 'reptile', 'id': 484, 'name': 'crocodile', 'c_name': '鳄鱼', 'type': 'thing'},
|
| 499 |
+
{'supercategory': 'individual_plants', 'id': 485, 'name': 'sunflower', 'c_name': '向日葵', 'type': 'stuff'},
|
| 500 |
+
{'supercategory': 'building_structure', 'id': 486, 'name': 'stage', 'c_name': '舞台', 'type': 'stuff'},
|
| 501 |
+
{'supercategory': 'fitness_equipment', 'id': 487, 'name': 'slide', 'c_name': '滑梯', 'type': 'thing'},
|
| 502 |
+
{'supercategory': 'knife', 'id': 488, 'name': 'kitchen-knife', 'c_name': '菜刀', 'type': 'thing'},
|
| 503 |
+
{'supercategory': 'land_transportation', 'id': 489, 'name': 'segway', 'c_name': '二轮平衡小车', 'type': 'thing'},
|
| 504 |
+
{'supercategory': 'land_transportation', 'id': 490, 'name': 'snowmobile', 'c_name': '摩托雪橇', 'type': 'thing'},
|
| 505 |
+
{'supercategory': 'mammal', 'id': 491, 'name': 'hamster', 'c_name': '仓鼠', 'type': 'thing'},
|
| 506 |
+
{'supercategory': 'jewlery', 'id': 492, 'name': 'ring', 'c_name': '戒指', 'type': 'thing'},
|
| 507 |
+
{'supercategory': 'fruit', 'id': 493, 'name': 'blueberry', 'c_name': '蓝莓', 'type': 'thing'},
|
| 508 |
+
{'supercategory': 'drink', 'id': 494, 'name': 'ice_cream', 'c_name': '冰淇淋', 'type': 'thing'},
|
| 509 |
+
{'supercategory': 'hat', 'id': 495, 'name': 'baseball_cap', 'c_name': '棒球帽', 'type': 'thing'},
|
| 510 |
+
{'supercategory': 'clock_furniture', 'id': 496, 'name': 'digital clock', 'c_name': '数字钟', 'type': 'thing'},
|
| 511 |
+
{'supercategory': 'air_vehicle', 'id': 497, 'name': 'air_traffic_ot', 'c_name': '其他空中交通工具', 'type': 'thing'},
|
| 512 |
+
{'supercategory': 'bear', 'id': 498, 'name': 'brown_bear', 'c_name': '棕熊', 'type': 'thing'},
|
| 513 |
+
{'supercategory': 'sky', 'id': 499, 'name': 'cloud', 'c_name': '白云', 'type': 'stuff'},
|
| 514 |
+
{'supercategory': 'footwear', 'id': 500, 'name': 'sandals', 'c_name': '凉鞋', 'type': 'thing'},
|
| 515 |
+
{'supercategory': 'fitness_equipment', 'id': 501, 'name': 'punching_bag', 'c_name': '出气筒', 'type': 'thing'},
|
| 516 |
+
{'supercategory': 'building_structure', 'id': 502, 'name': 'door', 'c_name': '门', 'type': 'stuff'},
|
| 517 |
+
{'supercategory': 'stove', 'id': 503, 'name': 'electronic_stove', 'c_name': '电子炉', 'type': 'thing'},
|
| 518 |
+
{'supercategory': 'fitness_equipment', 'id': 504, 'name': 'dance_pole', 'c_name': '舞杆', 'type': 'thing'},
|
| 519 |
+
{'supercategory': 'weapon', 'id': 505, 'name': 'cannon', 'c_name': '大炮', 'type': 'thing'},
|
| 520 |
+
{'supercategory': 'individual_plants', 'id': 506, 'name': 'christmas_tree', 'c_name': '圣诞树', 'type': 'stuff'},
|
| 521 |
+
{'supercategory': 'inanimate_natural_objects', 'id': 507, 'name': 'inanimate_natural_objects_ot', 'c_name': '其他无生命自然物', 'type': 'stuff'},
|
| 522 |
+
{'supercategory': 'stove', 'id': 508, 'name': 'wood_stove', 'c_name': '烧柴炉', 'type': 'thing'},
|
| 523 |
+
{'supercategory': 'clean_tool', 'id': 509, 'name': 'mop', 'c_name': '拖把', 'type': 'thing'},
|
| 524 |
+
{'supercategory': 'weapon', 'id': 510, 'name': 'dagger', 'c_name': '匕首', 'type': 'thing'},
|
| 525 |
+
{'supercategory': 'building_structure', 'id': 511, 'name': 'countertop', 'c_name': '台面', 'type': 'stuff'},
|
| 526 |
+
{'supercategory': 'fitness_equipment', 'id': 512, 'name': 'treadmill', 'c_name': '跑步机', 'type': 'thing'},
|
| 527 |
+
{'supercategory': 'bath_tool', 'id': 513, 'name': 'liquid_soap', 'c_name': '洗手液', 'type': 'thing'},
|
| 528 |
+
{'supercategory': 'air_vehicle', 'id': 514, 'name': 'spacecraft', 'c_name': '火箭卫星宇宙飞船', 'type': 'thing'},
|
| 529 |
+
{'supercategory': 'vehicle_part', 'id': 515, 'name': 'wheel', 'c_name': '车轮', 'type': 'thing'},
|
| 530 |
+
{'supercategory': 'deer', 'id': 516, 'name': 'sika_deer', 'c_name': '梅花鹿', 'type': 'thing'},
|
| 531 |
+
{'supercategory': 'camel', 'id': 517, 'name': 'alpaca', 'c_name': '羊驼', 'type': 'thing'},
|
| 532 |
+
{'supercategory': 'individual_plants', 'id': 518, 'name': 'rose', 'c_name': '玫瑰', 'type': 'stuff'},
|
| 533 |
+
{'supercategory': 'entertainment_appliances', 'id': 519, 'name': 'flashlight', 'c_name': '手电筒', 'type': 'thing'},
|
| 534 |
+
{'supercategory': 'ball', 'id': 520, 'name': 'rugby', 'c_name': '橄榄球', 'type': 'thing'},
|
| 535 |
+
{'supercategory': 'kitchen_tool', 'id': 521, 'name': 'cake_stand', 'c_name': '蛋糕架', 'type': 'thing'},
|
| 536 |
+
{'supercategory': 'outdoor_supplies', 'id': 522, 'name': 'tripod', 'c_name': '三脚架', 'type': 'thing'},
|
| 537 |
+
{'supercategory': 'land_transportation', 'id': 523, 'name': 'golf_cart', 'c_name': '高尔夫球车', 'type': 'thing'},
|
| 538 |
+
{'supercategory': 'vehicle_part', 'id': 524, 'name': 'windshield_wiper', 'c_name': '雨刮器', 'type': 'thing'},
|
| 539 |
+
{'supercategory': 'boat_part', 'id': 525, 'name': 'mast', 'c_name': '桅杆', 'type': 'thing'},
|
| 540 |
+
{'supercategory': 'fruit', 'id': 526, 'name': 'coconut', 'c_name': '椰子', 'type': 'thing'},
|
| 541 |
+
{'supercategory': 'vegetable', 'id': 527, 'name': 'zucchini', 'c_name': '西葫芦', 'type': 'thing'},
|
| 542 |
+
{'supercategory': 'birds', 'id': 528, 'name': 'peacock', 'c_name': '孔雀', 'type': 'thing'},
|
| 543 |
+
{'supercategory': 'fish', 'id': 529, 'name': 'shark', 'c_name': '鲨鱼', 'type': 'thing'},
|
| 544 |
+
{'supercategory': 'mammal', 'id': 530, 'name': 'raccoon', 'c_name': '浣熊', 'type': 'thing'},
|
| 545 |
+
{'supercategory': 'building_structure', 'id': 531, 'name': 'stove', 'c_name': '火炉', 'type': 'stuff'},
|
| 546 |
+
{'supercategory': 'telephone', 'id': 532, 'name': 'cellular_telephone', 'c_name': '蜂窝电话', 'type': 'thing'},
|
| 547 |
+
{'supercategory': 'table', 'id': 533, 'name': 'coffee_table', 'c_name': '咖啡桌', 'type': 'thing'},
|
| 548 |
+
{'supercategory': 'rigid_container', 'id': 534, 'name': 'tank', 'c_name': '油罐', 'type': 'thing'},
|
| 549 |
+
{'supercategory': 'fitness_equipment', 'id': 535, 'name': 'binoculars', 'c_name': '双筒望远镜', 'type': 'thing'},
|
| 550 |
+
{'supercategory': 'fast_food', 'id': 536, 'name': 'hambuger', 'c_name': '汉堡包', 'type': 'thing'},
|
| 551 |
+
{'supercategory': 'vegetable', 'id': 537, 'name': 'broccolli', 'c_name': '西兰花', 'type': 'thing'},
|
| 552 |
+
{'supercategory': 'animal', 'id': 538, 'name': 'animal_ot', 'c_name': '其他动物', 'type': 'thing'},
|
| 553 |
+
{'supercategory': 'insect', 'id': 539, 'name': 'ladybug', 'c_name': '瓢虫', 'type': 'thing'},
|
| 554 |
+
{'supercategory': 'trousers', 'id': 540, 'name': 'trousers_ot', 'c_name': '其他裤', 'type': 'thing'},
|
| 555 |
+
{'supercategory': 'kitchen_appliances', 'id': 541, 'name': 'toaster', 'c_name': '烤面包机', 'type': 'thing'},
|
| 556 |
+
{'supercategory': 'telephone', 'id': 542, 'name': 'telephone_ot', 'c_name': '其他电话', 'type': 'thing'},
|
| 557 |
+
{'supercategory': 'cup', 'id': 543, 'name': 'measuring cup', 'c_name': '量杯', 'type': 'thing'},
|
| 558 |
+
{'supercategory': 'land_transportation', 'id': 544, 'name': 'snow_plow', 'c_name': '雪犁车', 'type': 'thing'},
|
| 559 |
+
{'supercategory': 'toy', 'id': 545, 'name': 'stuffed-animal', 'c_name': '动物标本', 'type': 'thing'},
|
| 560 |
+
{'supercategory': 'dessert_snacks', 'id': 546, 'name': 'popcorn', 'c_name': '爆米花', 'type': 'thing'},
|
| 561 |
+
{'supercategory': 'fast_food', 'id': 547, 'name': 'taco', 'c_name': '墨西哥玉米薄饼卷', 'type': 'thing'},
|
| 562 |
+
{'supercategory': 'reptile', 'id': 548, 'name': 'dinosar', 'c_name': '恐龙', 'type': 'thing'},
|
| 563 |
+
{'supercategory': 'mammal', 'id': 549, 'name': 'rhinoceros', 'c_name': '犀牛', 'type': 'thing'},
|
| 564 |
+
{'supercategory': 'individual_plants', 'id': 550, 'name': 'lavender', 'c_name': '薰衣草', 'type': 'stuff'},
|
| 565 |
+
{'supercategory': 'building_structure', 'id': 551, 'name': 'glass_window', 'c_name': '玻璃橱窗', 'type': 'stuff'},
|
| 566 |
+
{'supercategory': 'sofa', 'id': 552, 'name': 'sofa_bed', 'c_name': '沙发床', 'type': 'thing'},
|
| 567 |
+
{'supercategory': 'lab_tool', 'id': 553, 'name': 'balance', 'c_name': '天平', 'type': 'thing'},
|
| 568 |
+
{'supercategory': 'dessert_snacks', 'id': 554, 'name': 'pancake', 'c_name': '薄饼', 'type': 'thing'},
|
| 569 |
+
{'supercategory': 'fruit', 'id': 555, 'name': 'pomegranate', 'c_name': '石榴', 'type': 'thing'},
|
| 570 |
+
{'supercategory': 'vegetable', 'id': 556, 'name': 'asparagus', 'c_name': '芦笋', 'type': 'thing'},
|
| 571 |
+
{'supercategory': 'insect', 'id': 557, 'name': 'beetle', 'c_name': '甲虫', 'type': 'thing'},
|
| 572 |
+
{'supercategory': 'birds', 'id': 558, 'name': 'canary', 'c_name': '金丝雀', 'type': 'thing'},
|
| 573 |
+
{'supercategory': 'reptile', 'id': 559, 'name': 'reptile_ot', 'c_name': '其他爬行类', 'type': 'thing'},
|
| 574 |
+
{'supercategory': 'mammal', 'id': 560, 'name': 'whale', 'c_name': '鲸鱼', 'type': 'thing'},
|
| 575 |
+
{'supercategory': 'mammal', 'id': 561, 'name': 'donkey', 'c_name': '驴', 'type': 'thing'},
|
| 576 |
+
{'supercategory': 'sky', 'id': 562, 'name': 'sun', 'c_name': '太阳', 'type': 'stuff'},
|
| 577 |
+
{'supercategory': 'fluid', 'id': 563, 'name': 'waterdrop', 'c_name': '水滴', 'type': 'stuff'},
|
| 578 |
+
{'supercategory': 'entertainment_appliances', 'id': 564, 'name': 'sweing_machine', 'c_name': '缝纫机', 'type': 'thing'},
|
| 579 |
+
{'supercategory': 'cabinets', 'id': 565, 'name': 'drawer', 'c_name': '抽屉', 'type': 'thing'},
|
| 580 |
+
{'supercategory': 'fitness_equipment', 'id': 566, 'name': 'crossbar', 'c_name': '横杆', 'type': 'thing'},
|
| 581 |
+
{'supercategory': 'repair_tool', 'id': 567, 'name': 'ax', 'c_name': '斧子', 'type': 'thing'},
|
| 582 |
+
{'supercategory': 'repair_tool', 'id': 568, 'name': 'drill', 'c_name': '钻头', 'type': 'thing'},
|
| 583 |
+
{'supercategory': 'repair_tool', 'id': 569, 'name': 'bolt', 'c_name': '螺栓', 'type': 'thing'},
|
| 584 |
+
{'supercategory': 'kitchen_pot', 'id': 570, 'name': 'slow_cooker', 'c_name': '慢炖锅', 'type': 'thing'},
|
| 585 |
+
{'supercategory': 'clean_tool', 'id': 571, 'name': 'dustpan', 'c_name': '簸箕', 'type': 'thing'},
|
| 586 |
+
{'supercategory': 'beddings', 'id': 572, 'name': 'mattress', 'c_name': '床垫', 'type': 'thing'},
|
| 587 |
+
{'supercategory': 'weapon', 'id': 573, 'name': 'handgun', 'c_name': '手枪', 'type': 'thing'},
|
| 588 |
+
{'supercategory': 'fast_food', 'id': 574, 'name': 'sandwich', 'c_name': '三明治', 'type': 'thing'},
|
| 589 |
+
{'supercategory': 'birds', 'id': 575, 'name': 'crow', 'c_name': '乌鸦', 'type': 'thing'},
|
| 590 |
+
{'supercategory': 'birds', 'id': 576, 'name': 'woodpecker', 'c_name': '啄木鸟', 'type': 'thing'},
|
| 591 |
+
{'supercategory': 'glasses', 'id': 577, 'name': 'goggles', 'c_name': '护目镜', 'type': 'thing'},
|
| 592 |
+
{'supercategory': 'hat', 'id': 578, 'name': 'cowboy_hat', 'c_name': '牛仔帽', 'type': 'thing'},
|
| 593 |
+
{'supercategory': 'ball', 'id': 579, 'name': 'volleyball', 'c_name': '排球', 'type': 'thing'},
|
| 594 |
+
{'supercategory': 'kitchen_pot', 'id': 580, 'name': 'casserole', 'c_name': '砂锅', 'type': 'thing'},
|
| 595 |
+
{'supercategory': 'clean_tool', 'id': 581, 'name': 'vacuum_cleaner', 'c_name': '吸尘器', 'type': 'thing'},
|
| 596 |
+
{'supercategory': 'dessert_snacks', 'id': 582, 'name': 'waffle', 'c_name': '华夫饼', 'type': 'thing'},
|
| 597 |
+
{'supercategory': 'fast_food', 'id': 583, 'name': 'pie', 'c_name': '馅饼', 'type': 'thing'},
|
| 598 |
+
{'supercategory': 'building_structure', 'id': 584, 'name': 'escalator', 'c_name': '手动扶梯', 'type': 'stuff'},
|
| 599 |
+
{'supercategory': 'building_structure', 'id': 585, 'name': 'balcony', 'c_name': '阳台', 'type': 'stuff'},
|
| 600 |
+
{'supercategory': 'jewlery', 'id': 586, 'name': 'bracelet', 'c_name': '手镯', 'type': 'thing'},
|
| 601 |
+
{'supercategory': 'helmet', 'id': 587, 'name': 'bicyclehelmet', 'c_name': '自行车头盔', 'type': 'thing'},
|
| 602 |
+
{'supercategory': 'clean_appliances', 'id': 588, 'name': 'dishwasher', 'c_name': '洗碗机', 'type': 'thing'},
|
| 603 |
+
{'supercategory': 'clean_appliances', 'id': 589, 'name': 'clean_appliances_ot', 'c_name': '其他清洁类电器', 'type': 'thing'},
|
| 604 |
+
{'supercategory': 'entertainment_appliances', 'id': 590, 'name': 'converter', 'c_name': '转换器', 'type': 'thing'},
|
| 605 |
+
{'supercategory': 'common_furniture', 'id': 591, 'name': 'storage box', 'c_name': '储物箱', 'type': 'thing'},
|
| 606 |
+
{'supercategory': 'racket', 'id': 592, 'name': 'table_tennis_racket', 'c_name': '乒乓球拍', 'type': 'thing'},
|
| 607 |
+
{'supercategory': 'fitness_equipment', 'id': 593, 'name': 'scoreboard', 'c_name': '记分牌', 'type': 'thing'},
|
| 608 |
+
{'supercategory': 'sports_musical', 'id': 594, 'name': 'sports_musical_ot', 'c_name': '其他运动乐器', 'type': 'thing'},
|
| 609 |
+
{'supercategory': 'outdoor_supplies', 'id': 595, 'name': 'stretcher', 'c_name': '担架', 'type': 'thing'},
|
| 610 |
+
{'supercategory': 'vehicle', 'id': 596, 'name': 'vehicle_ot', 'c_name': '其他交通工具', 'type': 'thing'},
|
| 611 |
+
{'supercategory': 'sky', 'id': 597, 'name': 'moon', 'c_name': '月亮', 'type': 'stuff'},
|
| 612 |
+
{'supercategory': 'non-building_houses', 'id': 598, 'name': 'cage', 'c_name': '笼子', 'type': 'stuff'},
|
| 613 |
+
{'supercategory': 'lower_body_clothing', 'id': 599, 'name': 'lower_body_clothing_ot', 'c_name': '其他下身类', 'type': 'thing'},
|
| 614 |
+
{'supercategory': 'human_accessories', 'id': 600, 'name': 'crown', 'c_name': '王冠', 'type': 'thing'},
|
| 615 |
+
{'supercategory': 'bed', 'id': 601, 'name': 'dog bed', 'c_name': '狗床', 'type': 'thing'},
|
| 616 |
+
{'supercategory': 'seat_furniture', 'id': 602, 'name': 'fitness_chair', 'c_name': '健身椅子', 'type': 'thing'},
|
| 617 |
+
{'supercategory': 'dessert_snacks', 'id': 603, 'name': 'pretzel', 'c_name': '椒盐脆饼', 'type': 'thing'},
|
| 618 |
+
{'supercategory': 'dessert_snacks', 'id': 604, 'name': 'puff_pastry', 'c_name': '油酥饼', 'type': 'thing'},
|
| 619 |
+
{'supercategory': 'dress', 'id': 605, 'name': 'dress_ot', 'c_name': '其他裙子', 'type': 'thing'},
|
| 620 |
+
{'supercategory': 'entertainment_appliances', 'id': 606, 'name': 'mixer', 'c_name': '搅拌机', 'type': 'thing'},
|
| 621 |
+
{'supercategory': 'table', 'id': 607, 'name': 'tennis_table', 'c_name': '乒乓球桌', 'type': 'thing'},
|
| 622 |
+
{'supercategory': 'cup', 'id': 608, 'name': 'beaker', 'c_name': '烧杯', 'type': 'thing'},
|
| 623 |
+
{'supercategory': 'seasoning', 'id': 609, 'name': 'papper', 'c_name': '胡椒粉', 'type': 'thing'},
|
| 624 |
+
{'supercategory': 'seasoning', 'id': 610, 'name': 'salad', 'c_name': '沙拉', 'type': 'thing'},
|
| 625 |
+
{'supercategory': 'insect', 'id': 611, 'name': 'parasite', 'c_name': '寄生虫', 'type': 'thing'},
|
| 626 |
+
{'supercategory': 'non-building_houses', 'id': 612, 'name': 'tunnel', 'c_name': '隧道', 'type': 'stuff'},
|
| 627 |
+
{'supercategory': 'energyfacility', 'id': 613, 'name': 'conveyor_belt', 'c_name': '传送带', 'type': 'thing'},
|
| 628 |
+
{'supercategory': 'upper_body_clothing', 'id': 614, 'name': 'jacket', 'c_name': '夹克', 'type': 'thing'},
|
| 629 |
+
{'supercategory': 'upper_body_clothing', 'id': 615, 'name': 'tank_top', 'c_name': '背心', 'type': 'thing'},
|
| 630 |
+
{'supercategory': 'dress', 'id': 616, 'name': 'one-piece_dress', 'c_name': '连衣裙', 'type': 'thing'},
|
| 631 |
+
{'supercategory': 'bed', 'id': 617, 'name': 'cradle', 'c_name': '摇篮', 'type': 'thing'},
|
| 632 |
+
{'supercategory': 'vegetable', 'id': 618, 'name': 'wax_gourd', 'c_name': '冬瓜', 'type': 'thing'},
|
| 633 |
+
{'supercategory': 'drink', 'id': 619, 'name': 'cocktail', 'c_name': '鸡尾酒', 'type': 'thing'},
|
| 634 |
+
{'supercategory': 'insect', 'id': 620, 'name': 'centipede', 'c_name': '蜈蚣', 'type': 'thing'},
|
| 635 |
+
{'supercategory': 'individual_plants', 'id': 621, 'name': 'lily', 'c_name': '百合花', 'type': 'stuff'},
|
| 636 |
+
{'supercategory': 'individual_plants', 'id': 622, 'name': 'maple', 'c_name': '枫树', 'type': 'stuff'},
|
| 637 |
+
{'supercategory': 'sky', 'id': 623, 'name': 'rainbow', 'c_name': '彩虹', 'type': 'stuff'},
|
| 638 |
+
{'supercategory': 'building_houses', 'id': 624, 'name': 'statium', 'c_name': '体育场', 'type': 'stuff'},
|
| 639 |
+
{'supercategory': 'upper_body_clothing', 'id': 625, 'name': 'jersey', 'c_name': '运动衫', 'type': 'thing'},
|
| 640 |
+
{'supercategory': 'ball', 'id': 626, 'name': 'hockey', 'c_name': '曲棍球', 'type': 'thing'},
|
| 641 |
+
{'supercategory': 'kitchen_pot', 'id': 627, 'name': 'pressure_cooker', 'c_name': '高压锅', 'type': 'thing'},
|
| 642 |
+
{'supercategory': 'bath_tool', 'id': 628, 'name': 'nail_clippers', 'c_name': '指甲刀', 'type': 'thing'},
|
| 643 |
+
{'supercategory': 'beddings', 'id': 629, 'name': 'sleeping-bag', 'c_name': '睡袋', 'type': 'thing'},
|
| 644 |
+
{'supercategory': 'vehicle_part', 'id': 630, 'name': 'rearview_mirror', 'c_name': '后视镜', 'type': 'thing'},
|
| 645 |
+
{'supercategory': 'weapon', 'id': 631, 'name': 'shotgun', 'c_name': '猎枪', 'type': 'thing'},
|
| 646 |
+
{'supercategory': 'weapon', 'id': 632, 'name': 'missle', 'c_name': '导弹', 'type': 'thing'},
|
| 647 |
+
{'supercategory': 'dessert_snacks', 'id': 633, 'name': 'beehive', 'c_name': '蜂巢', 'type': 'thing'},
|
| 648 |
+
{'supercategory': 'fast_food', 'id': 634, 'name': 'spaghetti', 'c_name': '意大利面', 'type': 'thing'},
|
| 649 |
+
{'supercategory': 'fruit', 'id': 635, 'name': 'grapefruit', 'c_name': '柚子', 'type': 'thing'},
|
| 650 |
+
{'supercategory': 'amphibians', 'id': 636, 'name': 'amphibians_ot', 'c_name': '其他两栖类', 'type': 'thing'},
|
| 651 |
+
{'supercategory': 'mammal', 'id': 637, 'name': 'porcupine', 'c_name': '豪猪', 'type': 'thing'},
|
| 652 |
+
{'supercategory': 'individual_plants', 'id': 638, 'name': 'willow', 'c_name': '柳树', 'type': 'stuff'},
|
| 653 |
+
{'supercategory': 'trousers', 'id': 639, 'name': 'shorts', 'c_name': '短裤', 'type': 'thing'},
|
| 654 |
+
{'supercategory': 'person', 'id': 640, 'name': 'person_ot', 'c_name': '无法分辨年龄性别的人', 'type': 'thing'},
|
| 655 |
+
{'supercategory': 'person', 'id': 641, 'name': 'woman', 'c_name': '女人', 'type': 'thing'},
|
| 656 |
+
{'supercategory': 'person', 'id': 642, 'name': 'boy', 'c_name': '男孩', 'type': 'thing'},
|
| 657 |
+
{'supercategory': 'person', 'id': 643, 'name': 'girl', 'c_name': '女孩', 'type': 'thing'},
|
| 658 |
+
]
|
| 659 |
+
|
| 660 |
+
_PREDEFINED_SPLITS = {
|
| 661 |
+
"entityv2_entity_train_01": (
|
| 662 |
+
"entityseg/images/entity_01_11580",
|
| 663 |
+
"entityseg/annotations/entity_segmentation/entityv2_01_entity_train.json"
|
| 664 |
+
),
|
| 665 |
+
"entityv2_entity_train_02": (
|
| 666 |
+
"entityseg/images/entity_02_11598",
|
| 667 |
+
"entityseg/annotations/entity_segmentation/entityv2_02_entity_train.json"
|
| 668 |
+
),
|
| 669 |
+
"entityv2_entity_train_03": (
|
| 670 |
+
"entityseg/images/entity_03_10049",
|
| 671 |
+
"entityseg/annotations/entity_segmentation/entityv2_03_entity_train.json"
|
| 672 |
+
),
|
| 673 |
+
"entityv2_entity_train_all": (
|
| 674 |
+
"entityseg/images",
|
| 675 |
+
"entityseg/annotations/entity_segmentation/entityv2_010203_entity_train.json"
|
| 676 |
+
),
|
| 677 |
+
"entityv2_entity_val_all": (
|
| 678 |
+
"entityseg/images",
|
| 679 |
+
"entityseg/annotations/entity_segmentation/entityv2_010203_entity_val.json"
|
| 680 |
+
),
|
| 681 |
+
"entityv2_entity_train_all_lr": (
|
| 682 |
+
"entityseg/images_lr",
|
| 683 |
+
"entityseg/annotations/entity_segmentation/entityv2_010203_entity_val_lr.json"
|
| 684 |
+
),
|
| 685 |
+
"entityv2_entity_val_all_lr": (
|
| 686 |
+
"entityseg/images_lr",
|
| 687 |
+
"entityseg/annotations/entity_segmentation/entityv2_010203_entity_val_lr.json"
|
| 688 |
+
),
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
_PREDEFINED_SPLITS_COCO = {}
|
| 692 |
+
_PREDEFINED_SPLITS_COCO["coco_2017_train_entity_rle"] = ("coco/train2017", "coco/annotations/entity_train2017_RLE.json")
|
| 693 |
+
_PREDEFINED_SPLITS_COCO["coco_2017_val_entity_rle"] = ("coco/val2017", "coco/annotations/entity_val2017.json")
|
| 694 |
+
|
| 695 |
+
def _get_entity_meta():
|
| 696 |
+
entity_ids = [k["id"] for k in EntityV2_entity_CATEGORIES]
|
| 697 |
+
entity_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(entity_ids)}
|
| 698 |
+
entity_classes = [k["name"] for k in EntityV2_entity_CATEGORIES]
|
| 699 |
+
ret = {
|
| 700 |
+
"thing_dataset_id_to_contiguous_id": entity_dataset_id_to_contiguous_id,
|
| 701 |
+
"thing_classes": entity_classes,
|
| 702 |
+
}
|
| 703 |
+
return ret
|
| 704 |
+
|
| 705 |
+
def _get_coco_trans_meta():
|
| 706 |
+
oc2nc_map = {category['id']: [cid, category["isthing"], category["name"], category["color"]] for cid, category in enumerate(COCO_CATEGORIES)}
|
| 707 |
+
NEW_COCO_CATEGORIES = []
|
| 708 |
+
for key, value in oc2nc_map.items():
|
| 709 |
+
new_info = {"id": value[0], "isthing": value[1], "name": value[2], "color": value[3]}
|
| 710 |
+
NEW_COCO_CATEGORIES.append(new_info)
|
| 711 |
+
|
| 712 |
+
thing_ids = [k["id"] for k in NEW_COCO_CATEGORIES]
|
| 713 |
+
thing_colors = [k["color"] for k in NEW_COCO_CATEGORIES]
|
| 714 |
+
thing_classes = [k["name"] for k in NEW_COCO_CATEGORIES]
|
| 715 |
+
thing_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(thing_ids)}
|
| 716 |
+
ret = {
|
| 717 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 718 |
+
"thing_classes": thing_classes,
|
| 719 |
+
"thing_colors": thing_colors,
|
| 720 |
+
}
|
| 721 |
+
return ret
|
| 722 |
+
|
| 723 |
+
def register_entityv2_entity(root):
|
| 724 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS.items():
|
| 725 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 726 |
+
register_coco_instances(
|
| 727 |
+
key,
|
| 728 |
+
_get_entity_meta(),
|
| 729 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 730 |
+
os.path.join(root, image_root),
|
| 731 |
+
)
|
| 732 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_COCO.items():
|
| 733 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 734 |
+
register_coco_instances(
|
| 735 |
+
key,
|
| 736 |
+
_get_coco_trans_meta(),
|
| 737 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 738 |
+
os.path.join(root, image_root),
|
| 739 |
+
)
|
| 740 |
+
|
| 741 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 742 |
+
register_entityv2_entity(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_entityv2_instances.py
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import json
|
| 3 |
+
import logging
|
| 4 |
+
import numpy as np
|
| 5 |
+
import os
|
| 6 |
+
from PIL import Image
|
| 7 |
+
import pdb
|
| 8 |
+
|
| 9 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 10 |
+
from detectron2.data.datasets.coco import load_coco_json, register_coco_instances
|
| 11 |
+
from detectron2.utils.file_io import PathManager
|
| 12 |
+
|
| 13 |
+
EntityV2_instance_CATEGORIES = [
|
| 14 |
+
{'name': 'man', 'id': 1, 'c_name': '男人', 'supercategory': 'person', 'type': 'thing'},
|
| 15 |
+
{'name': 'car', 'id': 2, 'c_name': '小汽车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 16 |
+
{'name': 'chair', 'id': 4, 'c_name': '椅子', 'supercategory': 'seat_furniture', 'type': 'thing'},
|
| 17 |
+
{'name': 'utility_ot', 'id': 5, 'c_name': '其他工具', 'supercategory': 'utility', 'type': 'thing'},
|
| 18 |
+
{'name': 'street_light', 'id': 7, 'c_name': '路灯', 'supercategory': 'traffic_facility', 'type': 'thing'},
|
| 19 |
+
{'name': 'signboard', 'id': 9, 'c_name': '简介牌', 'supercategory': 'media', 'type': 'thing'},
|
| 20 |
+
{'name': 'facility_ot', 'id': 10, 'c_name': '其他设施类', 'supercategory': 'facility', 'type': 'thing'},
|
| 21 |
+
{'name': 'rigid_container_ot', 'id': 11, 'c_name': '其他定型容器', 'supercategory': 'rigid_container', 'type': 'thing'},
|
| 22 |
+
{'name': 'sculpture', 'id': 13, 'c_name': '雕塑雕像', 'supercategory': 'media', 'type': 'thing'},
|
| 23 |
+
{'name': 'book', 'id': 14, 'c_name': '书', 'supercategory': 'media', 'type': 'thing'},
|
| 24 |
+
{'name': 'box', 'id': 16, 'c_name': '盒子箱子', 'supercategory': 'rigid_container', 'type': 'thing'},
|
| 25 |
+
{'name': 'table_ot', 'id': 17, 'c_name': '其他桌子', 'supercategory': 'table', 'type': 'thing'},
|
| 26 |
+
{'name': 'noncommon_furniture', 'id': 19, 'c_name': '非常用家具', 'supercategory': 'furniture', 'type': 'thing'},
|
| 27 |
+
{'name': 'can_light', 'id': 20, 'c_name': '筒灯', 'supercategory': 'light', 'type': 'thing'},
|
| 28 |
+
{'name': 'painting', 'id': 24, 'c_name': '绘画类', 'supercategory': 'media', 'type': 'thing'},
|
| 29 |
+
{'name': 'traffic_sign', 'id': 26, 'c_name': '交通标志', 'supercategory': 'traffic_facility', 'type': 'thing'},
|
| 30 |
+
{'name': 'paper', 'id': 29, 'c_name': '纸', 'supercategory': 'media', 'type': 'thing'},
|
| 31 |
+
{'name': 'boat', 'id': 30, 'c_name': '小型船只', 'supercategory': 'underwater_vehicle', 'type': 'thing'},
|
| 32 |
+
{'name': 'entertainment_appliances_ot', 'id': 31, 'c_name': '其他娱乐设施', 'supercategory': 'entertainment_appliances_ot', 'type': 'thing'},
|
| 33 |
+
{'name': 'bottle', 'id': 32, 'c_name': '瓶子', 'supercategory': 'rigid_container', 'type': 'thing'},
|
| 34 |
+
{'name': 'birds_ot', 'id': 34, 'c_name': '其他飞禽', 'supercategory': 'birds', 'type': 'thing'},
|
| 35 |
+
{'name': 'cushion', 'id': 35, 'c_name': '抱枕', 'supercategory': 'common_furniture', 'type': 'thing'},
|
| 36 |
+
{'name': 'cup_ot', 'id': 37, 'c_name': '其他杯子', 'supercategory': 'cup', 'type': 'thing'},
|
| 37 |
+
{'name': 'backpack', 'id': 38, 'c_name': '背包', 'supercategory': 'bag', 'type': 'thing'},
|
| 38 |
+
{'name': 'sconce', 'id': 42, 'c_name': '壁灯', 'supercategory': 'light', 'type': 'thing'},
|
| 39 |
+
{'name': 'fooddrink_ot', 'id': 43, 'c_name': '其他食物饮品', 'supercategory': 'fooddrink', 'type': 'thing'},
|
| 40 |
+
{'name': 'handbag', 'id': 46, 'c_name': '手提包', 'supercategory': 'bag', 'type': 'thing'},
|
| 41 |
+
{'name': 'decoration', 'id': 47, 'c_name': '装饰物', 'supercategory': 'common_furniture', 'type': 'thing'},
|
| 42 |
+
{'name': 'electric_wire', 'id': 48, 'c_name': '电线电缆', 'supercategory': 'traffic_facility', 'type': 'thing'},
|
| 43 |
+
{'name': 'trash_bin', 'id': 49, 'c_name': '垃圾桶', 'supercategory': 'clean_tool', 'type': 'thing'},
|
| 44 |
+
{'name': 'plate', 'id': 51, 'c_name': '盘子', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 45 |
+
{'name': 'drink_ot', 'id': 52, 'c_name': '其他饮品', 'supercategory': 'drink', 'type': 'thing'},
|
| 46 |
+
{'name': 'toy_ot', 'id': 55, 'c_name': '其他玩具', 'supercategory': 'toy', 'type': 'thing'},
|
| 47 |
+
{'name': 'pen', 'id': 56, 'c_name': '笔', 'supercategory': 'media', 'type': 'thing'},
|
| 48 |
+
{'name': 'flag', 'id': 57, 'c_name': '旗帜', 'supercategory': 'media', 'type': 'thing'},
|
| 49 |
+
{'name': 'outdoor_supplies_ot', 'id': 59, 'c_name': '其他户外休闲用品', 'supercategory': 'outdoor_supplies', 'type': 'thing'},
|
| 50 |
+
{'name': 'curtain', 'id': 60, 'c_name': '窗帘', 'supercategory': 'common_furniture', 'type': 'thing'},
|
| 51 |
+
{'name': 'chandilier', 'id': 61, 'c_name': '吊灯', 'supercategory': 'light', 'type': 'thing'},
|
| 52 |
+
{'name': 'fish_ot', 'id': 62, 'c_name': '其他鱼类', 'supercategory': 'fish', 'type': 'thing'},
|
| 53 |
+
{'name': 'light_ot', 'id': 64, 'c_name': '其他灯', 'supercategory': 'light', 'type': 'thing'},
|
| 54 |
+
{'name': 'plugs_and_sockets', 'id': 65, 'c_name': '插头插座', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 55 |
+
{'name': 'rope', 'id': 66, 'c_name': '绳子', 'supercategory': 'outdoor_supplies', 'type': 'thing'},
|
| 56 |
+
{'name': 'land_transportation_ot', 'id': 68, 'c_name': '其他陆地交通工具', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 57 |
+
{'name': 'bicycle', 'id': 69, 'c_name': '自行车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 58 |
+
{'name': 'stool', 'id': 70, 'c_name': '凳子', 'supercategory': 'seat_furniture', 'type': 'thing'},
|
| 59 |
+
{'name': 'kitchen_tool_ot', 'id': 72, 'c_name': '其他厨房工具', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 60 |
+
{'name': 'mat', 'id': 75, 'c_name': '垫子', 'supercategory': 'blanket_furniture', 'type': 'thing'},
|
| 61 |
+
{'name': 'bench', 'id': 76, 'c_name': '长凳', 'supercategory': 'seat_furniture', 'type': 'thing'},
|
| 62 |
+
{'name': 'billboard', 'id': 79, 'c_name': '广告牌', 'supercategory': 'media', 'type': 'thing'},
|
| 63 |
+
{'name': 'flower', 'id': 80, 'c_name': '花', 'supercategory': 'plant_part', 'type': 'thing'},
|
| 64 |
+
{'name': 'bowl', 'id': 81, 'c_name': '碗', 'supercategory': 'rigid_container', 'type': 'thing'},
|
| 65 |
+
{'name': 'leaf', 'id': 82, 'c_name': '树叶', 'supercategory': 'plant_part', 'type': 'thing'},
|
| 66 |
+
{'name': 'cow_ot', 'id': 83, 'c_name': '其他牛', 'supercategory': 'cow', 'type': 'thing'},
|
| 67 |
+
{'name': 'dessert_snacks_ot', 'id': 84, 'c_name': '其他甜点小吃', 'supercategory': 'dessert_snacks', 'type': 'thing'},
|
| 68 |
+
{'name': 'dog', 'id': 85, 'c_name': '狗', 'supercategory': 'mammal', 'type': 'thing'},
|
| 69 |
+
{'name': 'bag_ot', 'id': 86, 'c_name': '其他包', 'supercategory': 'bag', 'type': 'thing'},
|
| 70 |
+
{'name': 'photo', 'id': 87, 'c_name': '照片', 'supercategory': 'media', 'type': 'thing'},
|
| 71 |
+
{'name': 'bath_tool_ot', 'id': 88, 'c_name': '其他沐浴工具', 'supercategory': 'bath_tool', 'type': 'thing'},
|
| 72 |
+
{'name': 'towel', 'id': 89, 'c_name': '毛巾', 'supercategory': 'bath_tool', 'type': 'thing'},
|
| 73 |
+
{'name': 'ceiling_lamp', 'id': 91, 'c_name': '吸顶灯', 'supercategory': 'light', 'type': 'thing'},
|
| 74 |
+
{'name': 'musical_instrument', 'id': 92, 'c_name': '乐器', 'supercategory': 'sports_musical', 'type': 'thing'},
|
| 75 |
+
{'name': 'barrel', 'id': 93, 'c_name': '桶', 'supercategory': 'rigid_container', 'type': 'thing'},
|
| 76 |
+
{'name': 'traffic_light', 'id': 94, 'c_name': '红绿灯', 'supercategory': 'traffic_facility', 'type': 'thing'},
|
| 77 |
+
{'name': 'wineglass', 'id': 95, 'c_name': '酒杯', 'supercategory': 'cup', 'type': 'thing'},
|
| 78 |
+
{'name': 'plastic_bag', 'id': 96, 'c_name': '塑料袋', 'supercategory': 'flexible_container', 'type': 'thing'},
|
| 79 |
+
{'name': 'cloth_ot', 'id': 97, 'c_name': '其他服饰类', 'supercategory': 'cloth', 'type': 'thing'},
|
| 80 |
+
{'name': 'jar', 'id': 98, 'c_name': '玻璃罐', 'supercategory': 'rigid_container', 'type': 'thing'},
|
| 81 |
+
{'name': 'mobilephone', 'id': 99, 'c_name': '手机', 'supercategory': 'telephone', 'type': 'thing'},
|
| 82 |
+
{'name': 'cable', 'id': 101, 'c_name': '连接线', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 83 |
+
{'name': 'fitness_equipment_ot', 'id': 102, 'c_name': '其他健身设备', 'supercategory': 'fitness_equipment', 'type': 'thing'},
|
| 84 |
+
{'name': 'poster', 'id': 103, 'c_name': '海报类', 'supercategory': 'media', 'type': 'thing'},
|
| 85 |
+
{'name': 'glass', 'id': 104, 'c_name': '玻璃杯', 'supercategory': 'cup', 'type': 'thing'},
|
| 86 |
+
{'name': 'branch', 'id': 105, 'c_name': '树枝', 'supercategory': 'plant_part', 'type': 'thing'},
|
| 87 |
+
{'name': 'repair_tool_ot', 'id': 106, 'c_name': '其他修理工具', 'supercategory': 'repair_tool', 'type': 'thing'},
|
| 88 |
+
{'name': 'pillow', 'id': 107, 'c_name': '枕头', 'supercategory': 'beddings', 'type': 'thing'},
|
| 89 |
+
{'name': 'cabinets_ot', 'id': 108, 'c_name': '其他橱柜', 'supercategory': 'cabinets', 'type': 'thing'},
|
| 90 |
+
{'name': 'apple', 'id': 109, 'c_name': '苹果', 'supercategory': 'fruit', 'type': 'thing'},
|
| 91 |
+
{'name': 'sheep', 'id': 110, 'c_name': '羊', 'supercategory': 'mammal', 'type': 'thing'},
|
| 92 |
+
{'name': 'doll_ot', 'id': 112, 'c_name': '其他玩偶', 'supercategory': 'doll', 'type': 'thing'},
|
| 93 |
+
{'name': 'fruit_ot', 'id': 113, 'c_name': '其他水果', 'supercategory': 'fruit', 'type': 'thing'},
|
| 94 |
+
{'name': 'kitchen cabinets', 'id': 115, 'c_name': '厨房里的柜子', 'supercategory': 'cabinets', 'type': 'thing'},
|
| 95 |
+
{'name': 'trunk', 'id': 118, 'c_name': '树干', 'supercategory': 'plant_part', 'type': 'thing'},
|
| 96 |
+
{'name': 'media_ot', 'id': 119, 'c_name': '其他传媒类', 'supercategory': 'media', 'type': 'thing'},
|
| 97 |
+
{'name': 'candle', 'id': 121, 'c_name': '蜡烛', 'supercategory': 'lab_tool', 'type': 'thing'},
|
| 98 |
+
{'name': 'duck', 'id': 123, 'c_name': '鸭', 'supercategory': 'birds', 'type': 'thing'},
|
| 99 |
+
{'name': 'pigeon', 'id': 124, 'c_name': '鸽子', 'supercategory': 'birds', 'type': 'thing'},
|
| 100 |
+
{'name': 'spoon', 'id': 125, 'c_name': '勺子', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 101 |
+
{'name': 'dining_table', 'id': 129, 'c_name': '餐桌', 'supercategory': 'table', 'type': 'thing'},
|
| 102 |
+
{'name': 'pumkin', 'id': 130, 'c_name': '南瓜', 'supercategory': 'vegetable', 'type': 'thing'},
|
| 103 |
+
{'name': 'horse_ot', 'id': 132, 'c_name': '其他马', 'supercategory': 'horse', 'type': 'thing'},
|
| 104 |
+
{'name': 'vegetable_ot', 'id': 133, 'c_name': '其他蔬菜', 'supercategory': 'vegetable', 'type': 'thing'},
|
| 105 |
+
{'name': 'flexible_container_ot', 'id': 134, 'c_name': '其他可改变外形的容器', 'supercategory': 'flexible_container', 'type': 'thing'},
|
| 106 |
+
{'name': 'surveillance_camera', 'id': 135, 'c_name': '监控器', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 107 |
+
{'name': 'motorbike', 'id': 136, 'c_name': '摩托车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 108 |
+
{'name': 'ordniary_sofa', 'id': 137, 'c_name': '普通沙发', 'supercategory': 'sofa', 'type': 'thing'},
|
| 109 |
+
{'name': 'laptop', 'id': 139, 'c_name': '笔记本电脑', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 110 |
+
{'name': 'umbrella', 'id': 140, 'c_name': '雨伞', 'supercategory': 'outdoor_supplies', 'type': 'thing'},
|
| 111 |
+
{'name': 'faucet', 'id': 141, 'c_name': '水龙头', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 112 |
+
{'name': 'mammal_ot', 'id': 142, 'c_name': '其他哺乳动物', 'supercategory': 'mammal', 'type': 'thing'},
|
| 113 |
+
{'name': 'napkin', 'id': 144, 'c_name': '餐巾', 'supercategory': 'clean_tool', 'type': 'thing'},
|
| 114 |
+
{'name': 'bus', 'id': 145, 'c_name': '公交车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 115 |
+
{'name': 'speaker', 'id': 146, 'c_name': '音响', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 116 |
+
{'name': 'camera', 'id': 147, 'c_name': '照相机', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 117 |
+
{'name': 'mirror', 'id': 148, 'c_name': '镜子', 'supercategory': 'common_furniture', 'type': 'thing'},
|
| 118 |
+
{'name': 'paddle', 'id': 149, 'c_name': '桨', 'supercategory': 'boat_part', 'type': 'thing'},
|
| 119 |
+
{'name': 'basket', 'id': 152, 'c_name': '篮子', 'supercategory': 'flexible_container', 'type': 'thing'},
|
| 120 |
+
{'name': 'sailboat', 'id': 154, 'c_name': '帆船', 'supercategory': 'underwater_vehicle', 'type': 'thing'},
|
| 121 |
+
{'name': 'ship', 'id': 155, 'c_name': '大轮船', 'supercategory': 'underwater_vehicle', 'type': 'thing'},
|
| 122 |
+
{'name': 'cat', 'id': 157, 'c_name': '猫', 'supercategory': 'mammal', 'type': 'thing'},
|
| 123 |
+
{'name': 'screen', 'id': 158, 'c_name': '显示器', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 124 |
+
{'name': 'orange', 'id': 160, 'c_name': '橘子', 'supercategory': 'fruit', 'type': 'thing'},
|
| 125 |
+
{'name': 'bedroom bed', 'id': 161, 'c_name': '卧室床', 'supercategory': 'bed', 'type': 'thing'},
|
| 126 |
+
{'name': 'ball_ot', 'id': 162, 'c_name': '其他球类', 'supercategory': 'ball', 'type': 'thing'},
|
| 127 |
+
{'name': 'switch', 'id': 164, 'c_name': '开关', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 128 |
+
{'name': 'elephant', 'id': 165, 'c_name': '大象', 'supercategory': 'mammal', 'type': 'thing'},
|
| 129 |
+
{'name': 'blanket', 'id': 166, 'c_name': '毛毯', 'supercategory': 'blanket_furniture', 'type': 'thing'},
|
| 130 |
+
{'name': 'airplane', 'id': 167, 'c_name': '飞机', 'supercategory': 'air_vehicle', 'type': 'thing'},
|
| 131 |
+
{'name': 'kiosk', 'id': 168, 'c_name': '电话亭', 'supercategory': 'energyfacility', 'type': 'thing'},
|
| 132 |
+
{'name': 'television', 'id': 169, 'c_name': '电视机', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 133 |
+
{'name': 'trolley', 'id': 170, 'c_name': '手推车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 134 |
+
{'name': 'couch', 'id': 173, 'c_name': '长沙发', 'supercategory': 'sofa', 'type': 'thing'},
|
| 135 |
+
{'name': 'van', 'id': 174, 'c_name': '厢式货车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 136 |
+
{'name': 'meat_ot', 'id': 175, 'c_name': '其他肉', 'supercategory': 'meat', 'type': 'thing'},
|
| 137 |
+
{'name': 'accessories_ot', 'id': 176, 'c_name': '其他服饰类', 'supercategory': 'accessories', 'type': 'thing'},
|
| 138 |
+
{'name': 'blanket_furniture_ot', 'id': 177, 'c_name': '其他毯子', 'supercategory': 'blanket_furniture', 'type': 'thing'},
|
| 139 |
+
{'name': 'hanger', 'id': 178, 'c_name': '衣架', 'supercategory': 'common_furniture', 'type': 'thing'},
|
| 140 |
+
{'name': 'rug', 'id': 179, 'c_name': '地毯', 'supercategory': 'blanket_furniture', 'type': 'thing'},
|
| 141 |
+
{'name': 'paper_bag', 'id': 180, 'c_name': '纸袋', 'supercategory': 'flexible_container', 'type': 'thing'},
|
| 142 |
+
{'name': 'remote_control', 'id': 181, 'c_name': '遥控器', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 143 |
+
{'name': 'kitchen_sink', 'id': 182, 'c_name': '盥洗', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 144 |
+
{'name': 'fork', 'id': 183, 'c_name': '叉', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 145 |
+
{'name': 'kitchen_pot_ot', 'id': 184, 'c_name': '其他厨房用锅', 'supercategory': 'kitchen_pot', 'type': 'thing'},
|
| 146 |
+
{'name': 'insect_ot', 'id': 185, 'c_name': '其他昆虫类', 'supercategory': 'insect', 'type': 'thing'},
|
| 147 |
+
{'name': 'underwater_vehicle_ot', 'id': 188, 'c_name': '其他水中交通工具', 'supercategory': 'underwater_vehicle', 'type': 'thing'},
|
| 148 |
+
{'name': 'table-knife', 'id': 192, 'c_name': '餐刀', 'supercategory': 'knife', 'type': 'thing'},
|
| 149 |
+
{'name': 'gym_equipment', 'id': 193, 'c_name': '室内健身器材', 'supercategory': 'fitness_equipment', 'type': 'thing'},
|
| 150 |
+
{'name': 'flowerpot', 'id': 196, 'c_name': '花盆', 'supercategory': 'rigid_container', 'type': 'thing'},
|
| 151 |
+
{'name': 'tv_receiver', 'id': 200, 'c_name': '电视接收器', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 152 |
+
{'name': 'nightstand', 'id': 201, 'c_name': '床头柜', 'supercategory': 'cabinets', 'type': 'thing'},
|
| 153 |
+
{'name': 'kitchen_appliances_ot', 'id': 202, 'c_name': '其他厨房电器', 'supercategory': 'kitchen_appliances', 'type': 'thing'},
|
| 154 |
+
{'name': 'ski_pole', 'id': 203, 'c_name': '滑雪杆', 'supercategory': 'fitness_equipment', 'type': 'thing'},
|
| 155 |
+
{'name': 'coat', 'id': 204, 'c_name': '外套', 'supercategory': 'upper_body_clothing', 'type': 'thing'},
|
| 156 |
+
{'name': 'cutting_board', 'id': 205, 'c_name': '砧板', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 157 |
+
{'name': 'footwear_ot', 'id': 208, 'c_name': '其他鞋', 'supercategory': 'footwear', 'type': 'thing'},
|
| 158 |
+
{'name': 'microphone', 'id': 209, 'c_name': '麦克风', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 159 |
+
{'name': 'lemon', 'id': 210, 'c_name': '柠檬', 'supercategory': 'fruit', 'type': 'thing'},
|
| 160 |
+
{'name': 'mushroom', 'id': 214, 'c_name': '蘑菇', 'supercategory': 'vegetable', 'type': 'thing'},
|
| 161 |
+
{'name': 'tire', 'id': 215, 'c_name': '轮胎', 'supercategory': 'vehicle_part', 'type': 'thing'},
|
| 162 |
+
{'name': 'filling cabinets', 'id': 216, 'c_name': '文件柜', 'supercategory': 'cabinets', 'type': 'thing'},
|
| 163 |
+
{'name': 'keyboard', 'id': 220, 'c_name': '键盘', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 164 |
+
{'name': 'ladder', 'id': 221, 'c_name': '梯子', 'supercategory': 'repair_tool', 'type': 'thing'},
|
| 165 |
+
{'name': 'mouse', 'id': 222, 'c_name': '鼠标', 'supercategory': 'entertainment_appliances', 'type': 'thing'},
|
| 166 |
+
{'name': 'seat_furniture_ot', 'id': 224, 'c_name': '其他椅子', 'supercategory': 'seat_furniture', 'type': 'thing'},
|
| 167 |
+
{'name': 'spatula', 'id': 225, 'c_name': '厨房用铲', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 168 |
+
{'name': 'kite', 'id': 226, 'c_name': '风筝', 'supercategory': 'toy', 'type': 'thing'},
|
| 169 |
+
{'name': 'train', 'id': 228, 'c_name': '火车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 170 |
+
{'name': 'sofa_ot', 'id': 229, 'c_name': '其他沙发', 'supercategory': 'sofa', 'type': 'thing'},
|
| 171 |
+
{'name': 'seasoning_ot', 'id': 234, 'c_name': '其他调味品', 'supercategory': 'seasoning', 'type': 'thing'},
|
| 172 |
+
{'name': 'cable_car', 'id': 235, 'c_name': '缆车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 173 |
+
{'name': 'fast_food_ot', 'id': 236, 'c_name': '其他快餐食品', 'supercategory': 'fast_food', 'type': 'thing'},
|
| 174 |
+
{'name': 'tableware', 'id': 238, 'c_name': '餐具', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 175 |
+
{'name': 'played_blocks', 'id': 240, 'c_name': '积木', 'supercategory': 'toy', 'type': 'thing'},
|
| 176 |
+
{'name': 'suitcase', 'id': 244, 'c_name': '手提箱', 'supercategory': 'bag', 'type': 'thing'},
|
| 177 |
+
{'name': 'earthware_pot_with_handle', 'id': 246, 'c_name': '带柄的陶罐', 'supercategory': 'rigid_container', 'type': 'thing'},
|
| 178 |
+
{'name': 'pizza', 'id': 247, 'c_name': '披萨', 'supercategory': 'fast_food', 'type': 'thing'},
|
| 179 |
+
{'name': 'scarf', 'id': 251, 'c_name': '围巾', 'supercategory': 'human_accessories', 'type': 'thing'},
|
| 180 |
+
{'name': 'giraffe', 'id': 254, 'c_name': '长颈鹿', 'supercategory': 'deer', 'type': 'thing'},
|
| 181 |
+
{'name': 'scooter', 'id': 255, 'c_name': '滑板车', 'supercategory': 'land_transportation', 'type': 'thing'},
|
| 182 |
+
{'name': 'ski_board', 'id': 258, 'c_name': '滑雪板', 'supercategory': 'fitness_equipment', 'type': 'thing'},
|
| 183 |
+
{'name': 'crumb', 'id': 261, 'c_name': '面包屑', 'supercategory': 'dessert_snacks', 'type': 'thing'},
|
| 184 |
+
{'name': 'packaging_paper', 'id': 266, 'c_name': '包装纸', 'supercategory': 'media', 'type': 'thing'},
|
| 185 |
+
{'name': ' medical_equipment', 'id': 271, 'c_name': '医疗器械', 'supercategory': 'lab_tool', 'type': 'thing'},
|
| 186 |
+
{'name': 'leather_shoes', 'id': 272, 'c_name': '皮鞋', 'supercategory': 'footwear', 'type': 'thing'},
|
| 187 |
+
{'name': 'pipe', 'id': 277, 'c_name': '水管', 'supercategory': 'clean_tool', 'type': 'thing'},
|
| 188 |
+
{'name': 'canoe', 'id': 284, 'c_name': '皮划艇', 'supercategory': 'underwater_vehicle', 'type': 'thing'},
|
| 189 |
+
{'name': 'chicken', 'id': 285, 'c_name': '鸡', 'supercategory': 'birds', 'type': 'thing'},
|
| 190 |
+
{'name': 'T-shirt', 'id': 287, 'c_name': 'T恤', 'supercategory': 'upper_body_clothing', 'type': 'thing'},
|
| 191 |
+
{'name': 'strawberry', 'id': 290, 'c_name': '草莓', 'supercategory': 'fruit', 'type': 'thing'},
|
| 192 |
+
{'name': 'saucer', 'id': 292, 'c_name': '茶碟', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 193 |
+
{'name': 'turtle', 'id': 293, 'c_name': '龟', 'supercategory': 'reptile', 'type': 'thing'},
|
| 194 |
+
{'name': 'coffee cup', 'id': 294, 'c_name': '咖啡杯', 'supercategory': 'cup', 'type': 'thing'},
|
| 195 |
+
{'name': 'wrench', 'id': 304, 'c_name': '扳手', 'supercategory': 'repair_tool', 'type': 'thing'},
|
| 196 |
+
{'name': 'gas_stove', 'id': 305, 'c_name': '燃气炉', 'supercategory': 'stove', 'type': 'thing'},
|
| 197 |
+
{'name': 'zebra', 'id': 306, 'c_name': '斑马', 'supercategory': 'horse', 'type': 'thing'},
|
| 198 |
+
{'name': 'knife_ot', 'id': 308, 'c_name': '其他刀', 'supercategory': 'knife', 'type': 'thing'},
|
| 199 |
+
{'name': 'rifle', 'id': 309, 'c_name': '步枪', 'supercategory': 'weapon', 'type': 'thing'},
|
| 200 |
+
{'name': 'golf', 'id': 312, 'c_name': '高尔夫球', 'supercategory': 'ball', 'type': 'thing'},
|
| 201 |
+
{'name': ' folder', 'id': 313, 'c_name': '文件夹', 'supercategory': 'lab_tool', 'type': 'thing'},
|
| 202 |
+
{'name': 'gloves', 'id': 314, 'c_name': '手套', 'supercategory': 'human_accessories', 'type': 'thing'},
|
| 203 |
+
{'name': 'screwdriver', 'id': 315, 'c_name': '螺丝刀', 'supercategory': 'repair_tool', 'type': 'thing'},
|
| 204 |
+
{'name': 'plant_ot', 'id': 318, 'c_name': '其他植物', 'supercategory': 'plant', 'type': 'thing'},
|
| 205 |
+
{'name': 'food_processor', 'id': 330, 'c_name': '食品加工机', 'supercategory': 'kitchen_tool', 'type': 'thing'},
|
| 206 |
+
{'name': 'deer_ot', 'id': 333, 'c_name': '其他鹿', 'supercategory': 'deer', 'type': 'thing'},
|
| 207 |
+
{'name': 'beddings_ot', 'id': 336, 'c_name': '其他床上用品', 'supercategory': 'beddings', 'type': 'thing'},
|
| 208 |
+
{'name': 'tube', 'id': 337, 'c_name': '试管', 'supercategory': 'lab_tool', 'type': 'thing'},
|
| 209 |
+
{'name': 'sausage', 'id': 359, 'c_name': '香肠', 'supercategory': 'fast_food', 'type': 'thing'},
|
| 210 |
+
{'name': 'radish', 'id': 406, 'c_name': '萝卜', 'supercategory': 'vegetable', 'type': 'thing'},
|
| 211 |
+
{'name': 'tong', 'id': 422, 'c_name': '钳子', 'supercategory': 'repair_tool', 'type': 'thing'},
|
| 212 |
+
{'name': 'ski', 'id': 426, 'c_name': '雪橇', 'supercategory': 'fitness_equipment', 'type': 'thing'},
|
| 213 |
+
{'name': 'hot_ballon', 'id': 427, 'c_name': '热气球', 'supercategory': 'air_vehicle', 'type': 'thing'},
|
| 214 |
+
{'name': 'sparrow', 'id': 446, 'c_name': '麻雀', 'supercategory': 'birds', 'type': 'thing'},
|
| 215 |
+
{'name': 'hoodie', 'id': 478, 'c_name': '连帽衫', 'supercategory': 'upper_body_clothing', 'type': 'thing'},
|
| 216 |
+
{'name': 'person_ot', 'id': 640, 'c_name': '无法分辨年龄性别的人', 'supercategory': 'person', 'type': 'thing'},
|
| 217 |
+
{'name': 'woman', 'id': 641, 'c_name': '女人', 'supercategory': 'person', 'type': 'thing'},
|
| 218 |
+
{'name': 'boy', 'id': 642, 'c_name': '男孩', 'supercategory': 'person', 'type': 'thing'},
|
| 219 |
+
{'name': 'girl', 'id': 643, 'c_name': '女孩', 'supercategory': 'person', 'type': 'thing'},
|
| 220 |
+
]
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
_PREDEFINED_SPLITS = {
|
| 224 |
+
"entityv2_instance_train": (
|
| 225 |
+
"entityseg/images/entity_01_11580",
|
| 226 |
+
"entityseg/annotations/instance_segmentation/entityv2_01_instances_train.json",
|
| 227 |
+
),
|
| 228 |
+
"entityv2_instance_val": (
|
| 229 |
+
"entityseg/images/entity_01_11580",
|
| 230 |
+
"entityseg/annotations/instance_segmentation/entityv2_01_instances_val.json",
|
| 231 |
+
),
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
def _get_entityv2_instances_meta():
|
| 235 |
+
thing_ids = [k["id"] for k in EntityV2_instance_CATEGORIES]
|
| 236 |
+
# Mapping from the incontiguous ADE category id to an id in [0, 99]
|
| 237 |
+
thing_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(thing_ids)}
|
| 238 |
+
thing_classes = [k["name"] for k in EntityV2_instance_CATEGORIES]
|
| 239 |
+
ret = {
|
| 240 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 241 |
+
"thing_classes": thing_classes,
|
| 242 |
+
}
|
| 243 |
+
return ret
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def register_all_entityv2_instance(root):
|
| 247 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS.items():
|
| 248 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 249 |
+
register_coco_instances(
|
| 250 |
+
key,
|
| 251 |
+
_get_entityv2_instances_meta(),
|
| 252 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 253 |
+
os.path.join(root, image_root),
|
| 254 |
+
)
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 258 |
+
register_all_entityv2_instance(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_entityv2_panoptic_350.py
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import copy
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 7 |
+
from detectron2.utils.file_io import PathManager
|
| 8 |
+
|
| 9 |
+
from detectron2.data.datasets.coco import load_coco_json, load_sem_seg
|
| 10 |
+
|
| 11 |
+
EntityV2_panoptic_CATEGORIES = [
|
| 12 |
+
{'supercategory': 'person', 'id': 1, 'name': 'man', 'c_name': '男人', 'isthing': True},
|
| 13 |
+
{'supercategory': 'land_transportation', 'id': 2, 'name': 'car', 'c_name': '小汽车', 'isthing': True},
|
| 14 |
+
{'supercategory': 'inanimate_natural_objects', 'id': 3, 'name': 'sky', 'c_name': '天空', 'isthing': False},
|
| 15 |
+
{'supercategory': 'seat_furniture', 'id': 4, 'name': 'chair', 'c_name': '椅子', 'isthing': True},
|
| 16 |
+
{'supercategory': 'utility', 'id': 5, 'name': 'utility_ot', 'c_name': '其他工具', 'isthing': True},
|
| 17 |
+
{'supercategory': 'non_individual_plants', 'id': 6, 'name': 'tree', 'c_name': '树木', 'isthing': False},
|
| 18 |
+
{'supercategory': 'traffic_facility', 'id': 7, 'name': 'street_light', 'c_name': '路灯', 'isthing': True},
|
| 19 |
+
{'supercategory': 'individual_plants', 'id': 8, 'name': 'potted_plants', 'c_name': '盆栽植物', 'isthing': False},
|
| 20 |
+
{'supercategory': 'media', 'id': 9, 'name': 'signboard', 'c_name': '简介牌', 'isthing': True},
|
| 21 |
+
{'supercategory': 'facility', 'id': 10, 'name': 'facility_ot', 'c_name': '其他设施类', 'isthing': True},
|
| 22 |
+
{'supercategory': 'rigid_container', 'id': 11, 'name': 'rigid_container_ot', 'c_name': '其他定型容器', 'isthing': True},
|
| 23 |
+
{'supercategory': 'non_individual_plants', 'id': 12, 'name': 'grass', 'c_name': '草地', 'isthing': False},
|
| 24 |
+
{'supercategory': 'media', 'id': 13, 'name': 'sculpture', 'c_name': '雕塑雕像', 'isthing': True},
|
| 25 |
+
{'supercategory': 'media', 'id': 14, 'name': 'book', 'c_name': '书', 'isthing': True},
|
| 26 |
+
{'supercategory': 'non_individual_plants', 'id': 15, 'name': 'shrub', 'c_name': '灌木', 'isthing': False},
|
| 27 |
+
{'supercategory': 'rigid_container', 'id': 16, 'name': 'box', 'c_name': '盒子箱子', 'isthing': True},
|
| 28 |
+
{'supercategory': 'table', 'id': 17, 'name': 'table_ot', 'c_name': '其他桌子', 'isthing': True},
|
| 29 |
+
{'supercategory': 'non-building_houses', 'id': 18, 'name': 'electricpole', 'c_name': '电线杆', 'isthing': False},
|
| 30 |
+
{'supercategory': 'furniture', 'id': 19, 'name': 'noncommon_furniture', 'c_name': '非常用家具', 'isthing': True},
|
| 31 |
+
{'supercategory': 'light', 'id': 20, 'name': 'can_light', 'c_name': '筒灯', 'isthing': True},
|
| 32 |
+
{'supercategory': 'wall', 'id': 21, 'name': 'concretewall', 'c_name': '水泥墙', 'isthing': False},
|
| 33 |
+
{'supercategory': 'floor_structure', 'id': 22, 'name': 'floor_structure_ot', 'c_name': '其他地面结构', 'isthing': False},
|
| 34 |
+
{'supercategory': 'barrier', 'id': 23, 'name': 'sunk_fence', 'c_name': '矮墙', 'isthing': False},
|
| 35 |
+
{'supercategory': 'media', 'id': 24, 'name': 'painting', 'c_name': '绘画类', 'isthing': True},
|
| 36 |
+
{'supercategory': 'building_houses', 'id': 25, 'name': 'house', 'c_name': '房屋', 'isthing': False},
|
| 37 |
+
{'supercategory': 'traffic_facility', 'id': 26, 'name': 'traffic_sign', 'c_name': '交通标志', 'isthing': True},
|
| 38 |
+
{'supercategory': 'barrier', 'id': 27, 'name': 'barrier_ot', 'c_name': '其他障碍物', 'isthing': False},
|
| 39 |
+
{'supercategory': 'building_structure', 'id': 28, 'name': 'floor', 'c_name': '地板', 'isthing': False},
|
| 40 |
+
{'supercategory': 'media', 'id': 29, 'name': 'paper', 'c_name': '纸', 'isthing': True},
|
| 41 |
+
{'supercategory': 'underwater_vehicle', 'id': 30, 'name': 'boat', 'c_name': '小型船只', 'isthing': True},
|
| 42 |
+
{'supercategory': 'entertainment_appliances_ot', 'id': 31, 'name': 'entertainment_appliances_ot', 'c_name': '其他娱乐设施', 'isthing': True},
|
| 43 |
+
{'supercategory': 'rigid_container', 'id': 32, 'name': 'bottle', 'c_name': '瓶子', 'isthing': True},
|
| 44 |
+
{'supercategory': 'solid', 'id': 33, 'name': 'mountain', 'c_name': '山', 'isthing': False},
|
| 45 |
+
{'supercategory': 'birds', 'id': 34, 'name': 'birds_ot', 'c_name': '其他飞禽', 'isthing': True},
|
| 46 |
+
{'supercategory': 'common_furniture', 'id': 35, 'name': 'cushion', 'c_name': '抱枕', 'isthing': True},
|
| 47 |
+
{'supercategory': 'building_structure', 'id': 36, 'name': 'pole', 'c_name': '细杆', 'isthing': False},
|
| 48 |
+
{'supercategory': 'cup', 'id': 37, 'name': 'cup_ot', 'c_name': '其他杯子', 'isthing': True},
|
| 49 |
+
{'supercategory': 'bag', 'id': 38, 'name': 'backpack', 'c_name': '背包', 'isthing': True},
|
| 50 |
+
{'supercategory': 'solid', 'id': 39, 'name': 'soil', 'c_name': '泥土', 'isthing': False},
|
| 51 |
+
{'supercategory': 'barrier', 'id': 40, 'name': 'fence', 'c_name': '栅栏', 'isthing': False},
|
| 52 |
+
{'supercategory': 'non-building_houses', 'id': 41, 'name': 'non-buildinghouse_ot', 'c_name': '其他非建筑房屋', 'isthing': False},
|
| 53 |
+
{'supercategory': 'light', 'id': 42, 'name': 'sconce', 'c_name': '壁灯', 'isthing': True},
|
| 54 |
+
{'supercategory': 'fooddrink', 'id': 43, 'name': 'fooddrink_ot', 'c_name': '其他食物饮品', 'isthing': True},
|
| 55 |
+
{'supercategory': 'solid', 'id': 44, 'name': 'stone', 'c_name': '小石头', 'isthing': False},
|
| 56 |
+
{'supercategory': 'building_structure', 'id': 45, 'name': 'gutter', 'c_name': '排水沟', 'isthing': False},
|
| 57 |
+
{'supercategory': 'bag', 'id': 46, 'name': 'handbag', 'c_name': '手提包', 'isthing': True},
|
| 58 |
+
{'supercategory': 'common_furniture', 'id': 47, 'name': 'decoration', 'c_name': '装饰物', 'isthing': True},
|
| 59 |
+
{'supercategory': 'traffic_facility', 'id': 48, 'name': 'electric_wire', 'c_name': '电线电缆', 'isthing': True},
|
| 60 |
+
{'supercategory': 'clean_tool', 'id': 49, 'name': 'trash_bin', 'c_name': '垃圾桶', 'isthing': True},
|
| 61 |
+
{'supercategory': 'artifical_ground', 'id': 50, 'name': 'road', 'c_name': '马路', 'isthing': False},
|
| 62 |
+
{'supercategory': 'kitchen_tool', 'id': 51, 'name': 'plate', 'c_name': '盘子', 'isthing': True},
|
| 63 |
+
{'supercategory': 'drink', 'id': 52, 'name': 'drink_ot', 'c_name': '其他饮品', 'isthing': True},
|
| 64 |
+
{'supercategory': 'building_structure', 'id': 53, 'name': 'ceiling', 'c_name': '天花板', 'isthing': False},
|
| 65 |
+
{'supercategory': 'fluid', 'id': 54, 'name': 'sea', 'c_name': '海', 'isthing': False},
|
| 66 |
+
{'supercategory': 'toy', 'id': 55, 'name': 'toy_ot', 'c_name': '其他玩具', 'isthing': True},
|
| 67 |
+
{'supercategory': 'media', 'id': 56, 'name': 'pen', 'c_name': '笔', 'isthing': True},
|
| 68 |
+
{'supercategory': 'media', 'id': 57, 'name': 'flag', 'c_name': '旗帜', 'isthing': True},
|
| 69 |
+
{'supercategory': 'solid', 'id': 58, 'name': 'rock', 'c_name': '岩石', 'isthing': False},
|
| 70 |
+
{'supercategory': 'outdoor_supplies', 'id': 59, 'name': 'outdoor_supplies_ot', 'c_name': '其他户外休闲用品', 'isthing': True},
|
| 71 |
+
{'supercategory': 'common_furniture', 'id': 60, 'name': 'curtain', 'c_name': '窗帘', 'isthing': True},
|
| 72 |
+
{'supercategory': 'light', 'id': 61, 'name': 'chandilier', 'c_name': '吊灯', 'isthing': True},
|
| 73 |
+
{'supercategory': 'fish', 'id': 62, 'name': 'fish_ot', 'c_name': '其他鱼类', 'isthing': True},
|
| 74 |
+
{'supercategory': 'building_structure', 'id': 63, 'name': 'window', 'c_name': '窗户', 'isthing': False},
|
| 75 |
+
{'supercategory': 'light', 'id': 64, 'name': 'light_ot', 'c_name': '其他灯', 'isthing': True},
|
| 76 |
+
{'supercategory': 'entertainment_appliances', 'id': 65, 'name': 'plugs_and_sockets', 'c_name': '插头插座', 'isthing': True},
|
| 77 |
+
{'supercategory': 'outdoor_supplies', 'id': 66, 'name': 'rope', 'c_name': '绳子', 'isthing': True},
|
| 78 |
+
{'supercategory': 'building_houses', 'id': 67, 'name': 'building_houses_ot', 'c_name': '其他建筑房屋', 'isthing': False},
|
| 79 |
+
{'supercategory': 'land_transportation', 'id': 68, 'name': 'land_transportation_ot', 'c_name': '其他陆地交通工具', 'isthing': True},
|
| 80 |
+
{'supercategory': 'land_transportation', 'id': 69, 'name': 'bicycle', 'c_name': '自行车', 'isthing': True},
|
| 81 |
+
{'supercategory': 'seat_furniture', 'id': 70, 'name': 'stool', 'c_name': '凳子', 'isthing': True},
|
| 82 |
+
{'supercategory': 'barrier', 'id': 71, 'name': 'wiredfence', 'c_name': '铁丝网栅栏', 'isthing': False},
|
| 83 |
+
{'supercategory': 'kitchen_tool', 'id': 72, 'name': 'kitchen_tool_ot', 'c_name': '其他厨房工具', 'isthing': True},
|
| 84 |
+
{'supercategory': 'building_structure', 'id': 73, 'name': 'building_structure_ot', 'c_name': '非建筑结构', 'isthing': False},
|
| 85 |
+
{'supercategory': 'building_houses', 'id': 74, 'name': 'high-rise', 'c_name': '高楼', 'isthing': False},
|
| 86 |
+
{'supercategory': 'blanket_furniture', 'id': 75, 'name': 'mat', 'c_name': '垫子', 'isthing': True},
|
| 87 |
+
{'supercategory': 'seat_furniture', 'id': 76, 'name': 'bench', 'c_name': '长凳', 'isthing': True},
|
| 88 |
+
{'supercategory': 'non_individual_plants', 'id': 77, 'name': 'nonindividual_plants_ot', 'c_name': '其他非独立植物', 'isthing': False},
|
| 89 |
+
{'supercategory': 'artifical_ground', 'id': 78, 'name': 'sidewalk', 'c_name': '人行道', 'isthing': False},
|
| 90 |
+
{'supercategory': 'media', 'id': 79, 'name': 'billboard', 'c_name': '广告牌', 'isthing': True},
|
| 91 |
+
{'supercategory': 'plant_part', 'id': 80, 'name': 'flower', 'c_name': '花', 'isthing': True},
|
| 92 |
+
{'supercategory': 'rigid_container', 'id': 81, 'name': 'bowl', 'c_name': '碗', 'isthing': True},
|
| 93 |
+
{'supercategory': 'plant_part', 'id': 82, 'name': 'leaf', 'c_name': '树叶', 'isthing': True},
|
| 94 |
+
{'supercategory': 'cow', 'id': 83, 'name': 'cow_ot', 'c_name': '其他牛', 'isthing': True},
|
| 95 |
+
{'supercategory': 'dessert_snacks', 'id': 84, 'name': 'dessert_snacks_ot', 'c_name': '其他甜点小吃', 'isthing': True},
|
| 96 |
+
{'supercategory': 'mammal', 'id': 85, 'name': 'dog', 'c_name': '狗', 'isthing': True},
|
| 97 |
+
{'supercategory': 'bag', 'id': 86, 'name': 'bag_ot', 'c_name': '其他包', 'isthing': True},
|
| 98 |
+
{'supercategory': 'media', 'id': 87, 'name': 'photo', 'c_name': '照片', 'isthing': True},
|
| 99 |
+
{'supercategory': 'bath_tool', 'id': 88, 'name': 'bath_tool_ot', 'c_name': '其他沐浴工具', 'isthing': True},
|
| 100 |
+
{'supercategory': 'bath_tool', 'id': 89, 'name': 'towel', 'c_name': '毛巾', 'isthing': True},
|
| 101 |
+
{'supercategory': 'building_structure', 'id': 90, 'name': 'step', 'c_name': '台阶', 'isthing': False},
|
| 102 |
+
{'supercategory': 'light', 'id': 91, 'name': 'ceiling_lamp', 'c_name': '吸顶灯', 'isthing': True},
|
| 103 |
+
{'supercategory': 'sports_musical', 'id': 92, 'name': 'musical_instrument', 'c_name': '乐器', 'isthing': True},
|
| 104 |
+
{'supercategory': 'rigid_container', 'id': 93, 'name': 'barrel', 'c_name': '桶', 'isthing': True},
|
| 105 |
+
{'supercategory': 'traffic_facility', 'id': 94, 'name': 'traffic_light', 'c_name': '红绿灯', 'isthing': True},
|
| 106 |
+
{'supercategory': 'cup', 'id': 95, 'name': 'wineglass', 'c_name': '酒杯', 'isthing': True},
|
| 107 |
+
{'supercategory': 'flexible_container', 'id': 96, 'name': 'plastic_bag', 'c_name': '塑料袋', 'isthing': True},
|
| 108 |
+
{'supercategory': 'cloth', 'id': 97, 'name': 'cloth_ot', 'c_name': '其他服饰类', 'isthing': True},
|
| 109 |
+
{'supercategory': 'rigid_container', 'id': 98, 'name': 'jar', 'c_name': '玻璃罐', 'isthing': True},
|
| 110 |
+
{'supercategory': 'telephone', 'id': 99, 'name': 'mobilephone', 'c_name': '手机', 'isthing': True},
|
| 111 |
+
{'supercategory': 'building_structure', 'id': 100, 'name': 'pipe', 'c_name': '管道', 'isthing': False},
|
| 112 |
+
{'supercategory': 'entertainment_appliances', 'id': 101, 'name': 'cable', 'c_name': '连接线', 'isthing': True},
|
| 113 |
+
{'supercategory': 'fitness_equipment', 'id': 102, 'name': 'fitness_equipment_ot', 'c_name': '其他健身设备', 'isthing': True},
|
| 114 |
+
{'supercategory': 'media', 'id': 103, 'name': 'poster', 'c_name': '海报类', 'isthing': True},
|
| 115 |
+
{'supercategory': 'cup', 'id': 104, 'name': 'glass', 'c_name': '玻璃杯', 'isthing': True},
|
| 116 |
+
{'supercategory': 'plant_part', 'id': 105, 'name': 'branch', 'c_name': '树枝', 'isthing': True},
|
| 117 |
+
{'supercategory': 'repair_tool', 'id': 106, 'name': 'repair_tool_ot', 'c_name': '其他修理工具', 'isthing': True},
|
| 118 |
+
{'supercategory': 'beddings', 'id': 107, 'name': 'pillow', 'c_name': '枕头', 'isthing': True},
|
| 119 |
+
{'supercategory': 'cabinets', 'id': 108, 'name': 'cabinets_ot', 'c_name': '其他橱柜', 'isthing': True},
|
| 120 |
+
{'supercategory': 'fruit', 'id': 109, 'name': 'apple', 'c_name': '苹果', 'isthing': True},
|
| 121 |
+
{'supercategory': 'mammal', 'id': 110, 'name': 'sheep', 'c_name': '羊', 'isthing': True},
|
| 122 |
+
{'supercategory': 'fluid', 'id': 111, 'name': 'lake', 'c_name': '湖', 'isthing': False},
|
| 123 |
+
{'supercategory': 'doll', 'id': 112, 'name': 'doll_ot', 'c_name': '其他玩偶', 'isthing': True},
|
| 124 |
+
{'supercategory': 'fruit', 'id': 113, 'name': 'fruit_ot', 'c_name': '其他水果', 'isthing': True},
|
| 125 |
+
{'supercategory': 'solid', 'id': 114, 'name': 'sand', 'c_name': '沙子', 'isthing': False},
|
| 126 |
+
{'supercategory': 'cabinets', 'id': 115, 'name': 'kitchen cabinets', 'c_name': '厨房里的柜子', 'isthing': True},
|
| 127 |
+
{'supercategory': 'non-building_houses', 'id': 116, 'name': 'bridge', 'c_name': '桥', 'isthing': False},
|
| 128 |
+
{'supercategory': 'fluid', 'id': 117, 'name': 'river', 'c_name': '河', 'isthing': False},
|
| 129 |
+
{'supercategory': 'plant_part', 'id': 118, 'name': 'trunk', 'c_name': '树干', 'isthing': True},
|
| 130 |
+
{'supercategory': 'media', 'id': 119, 'name': 'media_ot', 'c_name': '其他传媒类', 'isthing': True},
|
| 131 |
+
{'supercategory': 'wall', 'id': 120, 'name': 'wall_ot', 'c_name': '其他墙', 'isthing': False},
|
| 132 |
+
{'supercategory': 'lab_tool', 'id': 121, 'name': 'candle', 'c_name': '蜡烛', 'isthing': True},
|
| 133 |
+
{'supercategory': 'dessert_snacks', 'id': 122, 'name': 'bread', 'c_name': '面包', 'isthing': True},
|
| 134 |
+
{'supercategory': 'birds', 'id': 123, 'name': 'duck', 'c_name': '鸭', 'isthing': True},
|
| 135 |
+
{'supercategory': 'birds', 'id': 124, 'name': 'pigeon', 'c_name': '鸽子', 'isthing': True},
|
| 136 |
+
{'supercategory': 'kitchen_tool', 'id': 125, 'name': 'spoon', 'c_name': '勺子', 'isthing': True},
|
| 137 |
+
{'supercategory': 'artifical_ground', 'id': 126, 'name': 'park_ground', 'c_name': '公园地面', 'isthing': False},
|
| 138 |
+
{'supercategory': 'artifical_ground', 'id': 127, 'name': 'artifical_ground_ot', 'c_name': '其他人造地面', 'isthing': False},
|
| 139 |
+
{'supercategory': 'fluid', 'id': 128, 'name': 'fluid_ot', 'c_name': '其他液体', 'isthing': False},
|
| 140 |
+
{'supercategory': 'table', 'id': 129, 'name': 'dining_table', 'c_name': '餐桌', 'isthing': True},
|
| 141 |
+
{'supercategory': 'vegetable', 'id': 130, 'name': 'pumkin', 'c_name': '南瓜', 'isthing': True},
|
| 142 |
+
{'supercategory': 'fluid', 'id': 131, 'name': 'snow', 'c_name': '雪', 'isthing': False},
|
| 143 |
+
{'supercategory': 'horse', 'id': 132, 'name': 'horse_ot', 'c_name': '其他马', 'isthing': True},
|
| 144 |
+
{'supercategory': 'vegetable', 'id': 133, 'name': 'vegetable_ot', 'c_name': '其他蔬菜', 'isthing': True},
|
| 145 |
+
{'supercategory': 'flexible_container', 'id': 134, 'name': 'flexible_container_ot', 'c_name': '其他可改变外形的容器', 'isthing': True},
|
| 146 |
+
{'supercategory': 'entertainment_appliances', 'id': 135, 'name': 'surveillance_camera', 'c_name': '监控器', 'isthing': True},
|
| 147 |
+
{'supercategory': 'land_transportation', 'id': 136, 'name': 'motorbike', 'c_name': '摩托车', 'isthing': True},
|
| 148 |
+
{'supercategory': 'sofa', 'id': 137, 'name': 'ordniary_sofa', 'c_name': '普通沙发', 'isthing': True},
|
| 149 |
+
{'supercategory': 'building_structure', 'id': 138, 'name': 'banister', 'c_name': '扶手', 'isthing': False},
|
| 150 |
+
{'supercategory': 'entertainment_appliances', 'id': 139, 'name': 'laptop', 'c_name': '笔记本电脑', 'isthing': True},
|
| 151 |
+
{'supercategory': 'outdoor_supplies', 'id': 140, 'name': 'umbrella', 'c_name': '雨伞', 'isthing': True},
|
| 152 |
+
{'supercategory': 'kitchen_tool', 'id': 141, 'name': 'faucet', 'c_name': '水龙头', 'isthing': True},
|
| 153 |
+
{'supercategory': 'mammal', 'id': 142, 'name': 'mammal_ot', 'c_name': '其他哺乳动物', 'isthing': True},
|
| 154 |
+
{'supercategory': 'building', 'id': 143, 'name': 'building_ot', 'c_name': '其他建筑类', 'isthing': False},
|
| 155 |
+
{'supercategory': 'clean_tool', 'id': 144, 'name': 'napkin', 'c_name': '餐巾', 'isthing': True},
|
| 156 |
+
{'supercategory': 'land_transportation', 'id': 145, 'name': 'bus', 'c_name': '公交车', 'isthing': True},
|
| 157 |
+
{'supercategory': 'entertainment_appliances', 'id': 146, 'name': 'speaker', 'c_name': '音响', 'isthing': True},
|
| 158 |
+
{'supercategory': 'entertainment_appliances', 'id': 147, 'name': 'camera', 'c_name': '照相机', 'isthing': True},
|
| 159 |
+
{'supercategory': 'common_furniture', 'id': 148, 'name': 'mirror', 'c_name': '镜子', 'isthing': True},
|
| 160 |
+
{'supercategory': 'boat_part', 'id': 149, 'name': 'paddle', 'c_name': '桨', 'isthing': True},
|
| 161 |
+
{'supercategory': 'dessert_snacks', 'id': 150, 'name': 'cake', 'c_name': '糕饼', 'isthing': True},
|
| 162 |
+
{'supercategory': 'footwear', 'id': 151, 'name': 'sneakers', 'c_name': '运动鞋', 'isthing': True},
|
| 163 |
+
{'supercategory': 'flexible_container', 'id': 152, 'name': 'basket', 'c_name': '篮子', 'isthing': True},
|
| 164 |
+
{'supercategory': 'building_structure', 'id': 153, 'name': 'ventilation', 'c_name': '排气孔', 'isthing': False},
|
| 165 |
+
{'supercategory': 'underwater_vehicle', 'id': 154, 'name': 'sailboat', 'c_name': '帆船', 'isthing': True},
|
| 166 |
+
{'supercategory': 'underwater_vehicle', 'id': 155, 'name': 'ship', 'c_name': '大轮船', 'isthing': True},
|
| 167 |
+
{'supercategory': 'flexible_container', 'id': 156, 'name': 'can', 'c_name': '易拉罐', 'isthing': True},
|
| 168 |
+
{'supercategory': 'mammal', 'id': 157, 'name': 'cat', 'c_name': '猫', 'isthing': True},
|
| 169 |
+
{'supercategory': 'entertainment_appliances', 'id': 158, 'name': 'screen', 'c_name': '显示器', 'isthing': True},
|
| 170 |
+
{'supercategory': 'drink', 'id': 159, 'name': 'wine', 'c_name': '葡萄酒', 'isthing': True},
|
| 171 |
+
{'supercategory': 'fruit', 'id': 160, 'name': 'orange', 'c_name': '橘子', 'isthing': True},
|
| 172 |
+
{'supercategory': 'bed', 'id': 161, 'name': 'bedroom bed', 'c_name': '卧室床', 'isthing': True},
|
| 173 |
+
{'supercategory': 'ball', 'id': 162, 'name': 'ball_ot', 'c_name': '其他球类', 'isthing': True},
|
| 174 |
+
{'supercategory': 'non_individual_plants', 'id': 163, 'name': 'log', 'c_name': '原木', 'isthing': False},
|
| 175 |
+
{'supercategory': 'entertainment_appliances', 'id': 164, 'name': 'switch', 'c_name': '开关', 'isthing': True},
|
| 176 |
+
{'supercategory': 'mammal', 'id': 165, 'name': 'elephant', 'c_name': '大象', 'isthing': True},
|
| 177 |
+
{'supercategory': 'blanket_furniture', 'id': 166, 'name': 'blanket', 'c_name': '毛毯', 'isthing': True},
|
| 178 |
+
{'supercategory': 'air_vehicle', 'id': 167, 'name': 'airplane', 'c_name': '飞机', 'isthing': True},
|
| 179 |
+
{'supercategory': 'energyfacility', 'id': 168, 'name': 'kiosk', 'c_name': '电话亭', 'isthing': True},
|
| 180 |
+
{'supercategory': 'entertainment_appliances', 'id': 169, 'name': 'television', 'c_name': '电视机', 'isthing': True},
|
| 181 |
+
{'supercategory': 'land_transportation', 'id': 170, 'name': 'trolley', 'c_name': '手推车', 'isthing': True},
|
| 182 |
+
{'supercategory': 'insect', 'id': 171, 'name': 'bee', 'c_name': '蜜蜂', 'isthing': True},
|
| 183 |
+
{'supercategory': 'solid', 'id': 172, 'name': 'gravel', 'c_name': '砂砾', 'isthing': False},
|
| 184 |
+
{'supercategory': 'sofa', 'id': 173, 'name': 'couch', 'c_name': '长沙发', 'isthing': True},
|
| 185 |
+
{'supercategory': 'land_transportation', 'id': 174, 'name': 'van', 'c_name': '厢式货车', 'isthing': True},
|
| 186 |
+
{'supercategory': 'meat', 'id': 175, 'name': 'meat_ot', 'c_name': '其他肉', 'isthing': True},
|
| 187 |
+
{'supercategory': 'accessories', 'id': 176, 'name': 'accessories_ot', 'c_name': '其他服饰类', 'isthing': True},
|
| 188 |
+
{'supercategory': 'blanket_furniture', 'id': 177, 'name': 'blanket_furniture_ot', 'c_name': '其他毯子', 'isthing': True},
|
| 189 |
+
{'supercategory': 'common_furniture', 'id': 178, 'name': 'hanger', 'c_name': '衣架', 'isthing': True},
|
| 190 |
+
{'supercategory': 'blanket_furniture', 'id': 179, 'name': 'rug', 'c_name': '地毯', 'isthing': True},
|
| 191 |
+
{'supercategory': 'flexible_container', 'id': 180, 'name': 'paper_bag', 'c_name': '纸袋', 'isthing': True},
|
| 192 |
+
{'supercategory': 'entertainment_appliances', 'id': 181, 'name': 'remote_control', 'c_name': '遥控器', 'isthing': True},
|
| 193 |
+
{'supercategory': 'kitchen_tool', 'id': 182, 'name': 'kitchen_sink', 'c_name': '盥洗', 'isthing': True},
|
| 194 |
+
{'supercategory': 'kitchen_tool', 'id': 183, 'name': 'fork', 'c_name': '叉', 'isthing': True},
|
| 195 |
+
{'supercategory': 'kitchen_pot', 'id': 184, 'name': 'kitchen_pot_ot', 'c_name': '其他厨房用锅', 'isthing': True},
|
| 196 |
+
{'supercategory': 'insect', 'id': 185, 'name': 'insect_ot', 'c_name': '其他昆虫类', 'isthing': True},
|
| 197 |
+
{'supercategory': 'solid', 'id': 186, 'name': 'dirt', 'c_name': '贫瘠土地', 'isthing': False},
|
| 198 |
+
{'supercategory': 'artifical_ground', 'id': 187, 'name': 'path', 'c_name': '小径', 'isthing': False},
|
| 199 |
+
{'supercategory': 'underwater_vehicle', 'id': 188, 'name': 'underwater_vehicle_ot', 'c_name': '其他水中交通工具', 'isthing': True},
|
| 200 |
+
{'supercategory': 'sofa', 'id': 189, 'name': 'double_sofa', 'c_name': '双人沙发', 'isthing': True},
|
| 201 |
+
{'supercategory': 'seasoning', 'id': 190, 'name': 'condiment', 'c_name': '调味品', 'isthing': True},
|
| 202 |
+
{'supercategory': 'fooddrink', 'id': 191, 'name': 'drug', 'c_name': '药品', 'isthing': True},
|
| 203 |
+
{'supercategory': 'knife', 'id': 192, 'name': 'table-knife', 'c_name': '餐刀', 'isthing': True},
|
| 204 |
+
{'supercategory': 'fitness_equipment', 'id': 193, 'name': 'gym_equipment', 'c_name': '室内健身器材', 'isthing': True},
|
| 205 |
+
{'supercategory': 'footwear', 'id': 194, 'name': 'hose', 'c_name': '靴子', 'isthing': True},
|
| 206 |
+
{'supercategory': 'fruit', 'id': 195, 'name': 'peach', 'c_name': '桃', 'isthing': True},
|
| 207 |
+
{'supercategory': 'rigid_container', 'id': 196, 'name': 'flowerpot', 'c_name': '花盆', 'isthing': True},
|
| 208 |
+
{'supercategory': 'toy', 'id': 197, 'name': 'ballon', 'c_name': '气球', 'isthing': True},
|
| 209 |
+
{'supercategory': 'dessert_snacks', 'id': 198, 'name': 'bagel', 'c_name': '硬面包', 'isthing': True},
|
| 210 |
+
{'supercategory': 'non-building_houses', 'id': 199, 'name': 'tent', 'c_name': '帐篷', 'isthing': False},
|
| 211 |
+
{'supercategory': 'entertainment_appliances', 'id': 200, 'name': 'tv_receiver', 'c_name': '电视接收器', 'isthing': True},
|
| 212 |
+
{'supercategory': 'cabinets', 'id': 201, 'name': 'nightstand', 'c_name': '床头柜', 'isthing': True},
|
| 213 |
+
{'supercategory': 'kitchen_appliances', 'id': 202, 'name': 'kitchen_appliances_ot', 'c_name': '其他厨房电器', 'isthing': True},
|
| 214 |
+
{'supercategory': 'fitness_equipment', 'id': 203, 'name': 'ski_pole', 'c_name': '滑雪杆', 'isthing': True},
|
| 215 |
+
{'supercategory': 'upper_body_clothing', 'id': 204, 'name': 'coat', 'c_name': '外套', 'isthing': True},
|
| 216 |
+
{'supercategory': 'kitchen_tool', 'id': 205, 'name': 'cutting_board', 'c_name': '砧板', 'isthing': True},
|
| 217 |
+
{'supercategory': 'building_structure', 'id': 206, 'name': 'stair', 'c_name': '楼梯', 'isthing': False},
|
| 218 |
+
{'supercategory': 'plant_part', 'id': 207, 'name': 'plant_part_ot', 'c_name': '其他植物部分', 'isthing': True},
|
| 219 |
+
{'supercategory': 'footwear', 'id': 208, 'name': 'footwear_ot', 'c_name': '其他鞋', 'isthing': True},
|
| 220 |
+
{'supercategory': 'entertainment_appliances', 'id': 209, 'name': 'microphone', 'c_name': '麦克风', 'isthing': True},
|
| 221 |
+
{'supercategory': 'fruit', 'id': 210, 'name': 'lemon', 'c_name': '柠檬', 'isthing': True},
|
| 222 |
+
{'supercategory': 'non_individual_plants', 'id': 211, 'name': 'vine', 'c_name': '藤蔓', 'isthing': False},
|
| 223 |
+
{'supercategory': 'upper_body_clothing', 'id': 212, 'name': 'upper_body_clothing_os', 'c_name': '其他上身类', 'isthing': True},
|
| 224 |
+
{'supercategory': 'hat', 'id': 213, 'name': 'hat_ot', 'c_name': '其他帽', 'isthing': True},
|
| 225 |
+
{'supercategory': 'vegetable', 'id': 214, 'name': 'mushroom', 'c_name': '蘑菇', 'isthing': True},
|
| 226 |
+
{'supercategory': 'vehicle_part', 'id': 215, 'name': 'tire', 'c_name': '轮胎', 'isthing': True},
|
| 227 |
+
{'supercategory': 'cabinets', 'id': 216, 'name': 'filling cabinets', 'c_name': '文件柜', 'isthing': True},
|
| 228 |
+
{'supercategory': 'ball', 'id': 217, 'name': 'billards', 'c_name': '台球', 'isthing': True},
|
| 229 |
+
{'supercategory': 'kitchen_tool', 'id': 218, 'name': 'teapot', 'c_name': '茶壶', 'isthing': True},
|
| 230 |
+
{'supercategory': 'building_structure', 'id': 219, 'name': 'awning', 'c_name': '遮篷', 'isthing': False},
|
| 231 |
+
{'supercategory': 'entertainment_appliances', 'id': 220, 'name': 'keyboard', 'c_name': '键盘', 'isthing': True},
|
| 232 |
+
{'supercategory': 'repair_tool', 'id': 221, 'name': 'ladder', 'c_name': '梯子', 'isthing': True},
|
| 233 |
+
{'supercategory': 'entertainment_appliances', 'id': 222, 'name': 'mouse', 'c_name': '鼠标', 'isthing': True},
|
| 234 |
+
{'supercategory': 'kitchen_tool', 'id': 223, 'name': 'platter', 'c_name': '大浅盘', 'isthing': True},
|
| 235 |
+
{'supercategory': 'seat_furniture', 'id': 224, 'name': 'seat_furniture_ot', 'c_name': '其他椅子', 'isthing': True},
|
| 236 |
+
{'supercategory': 'kitchen_tool', 'id': 225, 'name': 'spatula', 'c_name': '厨房用铲', 'isthing': True},
|
| 237 |
+
{'supercategory': 'toy', 'id': 226, 'name': 'kite', 'c_name': '风筝', 'isthing': True},
|
| 238 |
+
{'supercategory': 'light', 'id': 227, 'name': 'lantern', 'c_name': '灯笼', 'isthing': True},
|
| 239 |
+
{'supercategory': 'land_transportation', 'id': 228, 'name': 'train', 'c_name': '火车', 'isthing': True},
|
| 240 |
+
{'supercategory': 'sofa', 'id': 229, 'name': 'sofa_ot', 'c_name': '其他沙发', 'isthing': True},
|
| 241 |
+
{'supercategory': 'artifical_ground', 'id': 230, 'name': 'trail', 'c_name': '小道', 'isthing': False},
|
| 242 |
+
{'supercategory': 'table', 'id': 231, 'name': 'integrated_table_and_chair', 'c_name': '一体化桌椅', 'isthing': True},
|
| 243 |
+
{'supercategory': 'building_houses', 'id': 232, 'name': 'castle', 'c_name': '城堡', 'isthing': False},
|
| 244 |
+
{'supercategory': 'lab_tool', 'id': 233, 'name': 'lab_tool_ot', 'c_name': '其他实验工具', 'isthing': True},
|
| 245 |
+
{'supercategory': 'seasoning', 'id': 234, 'name': 'seasoning_ot', 'c_name': '其他调味品', 'isthing': True},
|
| 246 |
+
{'supercategory': 'land_transportation', 'id': 235, 'name': 'cable_car', 'c_name': '缆车', 'isthing': True},
|
| 247 |
+
{'supercategory': 'fast_food', 'id': 236, 'name': 'fast_food_ot', 'c_name': '其���快餐食品', 'isthing': True},
|
| 248 |
+
{'supercategory': 'artifical_ground', 'id': 237, 'name': 'railroad', 'c_name': '铁路轨道', 'isthing': False},
|
| 249 |
+
{'supercategory': 'kitchen_tool', 'id': 238, 'name': 'tableware', 'c_name': '餐具', 'isthing': True},
|
| 250 |
+
{'supercategory': 'artifical_ground', 'id': 239, 'name': 'court', 'c_name': '球场', 'isthing': False},
|
| 251 |
+
{'supercategory': 'toy', 'id': 240, 'name': 'played_blocks', 'c_name': '积木', 'isthing': True},
|
| 252 |
+
{'supercategory': 'light', 'id': 241, 'name': 'lightbulb', 'c_name': '灯泡', 'isthing': True},
|
| 253 |
+
{'supercategory': 'toy', 'id': 242, 'name': 'chess', 'c_name': '棋类', 'isthing': True},
|
| 254 |
+
{'supercategory': 'non_individual_plants', 'id': 243, 'name': 'crops', 'c_name': '庄稼', 'isthing': False},
|
| 255 |
+
{'supercategory': 'bag', 'id': 244, 'name': 'suitcase', 'c_name': '手提箱', 'isthing': True},
|
| 256 |
+
{'supercategory': 'reptile', 'id': 245, 'name': 'lizard', 'c_name': '蜥蜴', 'isthing': True},
|
| 257 |
+
{'supercategory': 'rigid_container', 'id': 246, 'name': 'earthware_pot_with_handle', 'c_name': '带柄的陶罐', 'isthing': True},
|
| 258 |
+
{'supercategory': 'fast_food', 'id': 247, 'name': 'pizza', 'c_name': '披萨', 'isthing': True},
|
| 259 |
+
{'supercategory': 'building_houses', 'id': 248, 'name': 'tower', 'c_name': '塔', 'isthing': False},
|
| 260 |
+
{'supercategory': 'truck', 'id': 249, 'name': 'truck_ot', 'c_name': '其他卡车', 'isthing': True},
|
| 261 |
+
{'supercategory': 'fooddrink', 'id': 250, 'name': 'cigarette', 'c_name': '香烟', 'isthing': True},
|
| 262 |
+
{'supercategory': 'human_accessories', 'id': 251, 'name': 'scarf', 'c_name': '围巾', 'isthing': True},
|
| 263 |
+
{'supercategory': 'kitchen_appliances', 'id': 252, 'name': 'refrigerator', 'c_name': '冰箱', 'isthing': True},
|
| 264 |
+
{'supercategory': 'racket', 'id': 253, 'name': 'racket_ot', 'c_name': '其他拍子', 'isthing': True},
|
| 265 |
+
{'supercategory': 'deer', 'id': 254, 'name': 'giraffe', 'c_name': '长颈鹿', 'isthing': True},
|
| 266 |
+
{'supercategory': 'land_transportation', 'id': 255, 'name': 'scooter', 'c_name': '滑板车', 'isthing': True},
|
| 267 |
+
{'supercategory': 'appliances', 'id': 256, 'name': 'appliances_ot', 'c_name': '其他家电', 'isthing': True},
|
| 268 |
+
{'supercategory': 'fruit', 'id': 257, 'name': 'banana', 'c_name': '香蕉', 'isthing': True},
|
| 269 |
+
{'supercategory': 'fitness_equipment', 'id': 258, 'name': 'ski_board', 'c_name': '滑雪板', 'isthing': True},
|
| 270 |
+
{'supercategory': 'clean_tool', 'id': 259, 'name': 'clean_tool_ot', 'c_name': '其他清洁工具', 'isthing': True},
|
| 271 |
+
{'supercategory': 'toy', 'id': 260, 'name': 'dice', 'c_name': '筛子', 'isthing': True},
|
| 272 |
+
{'supercategory': 'dessert_snacks', 'id': 261, 'name': 'crumb', 'c_name': '面包屑', 'isthing': True},
|
| 273 |
+
{'supercategory': 'fruit', 'id': 262, 'name': 'commonfig', 'c_name': '无花果', 'isthing': True},
|
| 274 |
+
{'supercategory': 'vegetable', 'id': 263, 'name': 'tomato', 'c_name': '番茄', 'isthing': True},
|
| 275 |
+
{'supercategory': 'birds', 'id': 264, 'name': 'goose', 'c_name': '鹅', 'isthing': True},
|
| 276 |
+
{'supercategory': 'table', 'id': 265, 'name': 'desk', 'c_name': '书桌', 'isthing': True},
|
| 277 |
+
{'supercategory': 'media', 'id': 266, 'name': 'packaging_paper', 'c_name': '包装纸', 'isthing': True},
|
| 278 |
+
{'supercategory': 'toy', 'id': 267, 'name': 'poker', 'c_name': '扑克', 'isthing': True},
|
| 279 |
+
{'supercategory': 'non-building_houses', 'id': 268, 'name': 'pier', 'c_name': '码头', 'isthing': False},
|
| 280 |
+
{'supercategory': 'non-building_houses', 'id': 269, 'name': 'swimmingpool', 'c_name': '游泳池', 'isthing': False},
|
| 281 |
+
{'supercategory': 'fitness_equipment', 'id': 270, 'name': 'surfboard', 'c_name': '冲浪板', 'isthing': True},
|
| 282 |
+
{'supercategory': 'lab_tool', 'id': 271, 'name': ' medical_equipment', 'c_name': '医疗器械', 'isthing': True},
|
| 283 |
+
{'supercategory': 'footwear', 'id': 272, 'name': 'leather_shoes', 'c_name': '皮鞋', 'isthing': True},
|
| 284 |
+
{'supercategory': 'media', 'id': 273, 'name': 'blackboard', 'c_name': '黑板白板', 'isthing': True},
|
| 285 |
+
{'supercategory': 'vegetable', 'id': 274, 'name': 'egg', 'c_name': '鸡蛋', 'isthing': True},
|
| 286 |
+
{'supercategory': 'ventilation_appliances', 'id': 275, 'name': 'air_conditioner', 'c_name': '空调', 'isthing': True},
|
| 287 |
+
{'supercategory': 'entertainment_appliances', 'id': 276, 'name': 'gamepad', 'c_name': '游戏手柄', 'isthing': True},
|
| 288 |
+
{'supercategory': 'clean_tool', 'id': 277, 'name': 'pipe', 'c_name': '水管', 'isthing': True},
|
| 289 |
+
{'supercategory': 'insect', 'id': 278, 'name': 'moth', 'c_name': '飞蛾', 'isthing': True},
|
| 290 |
+
{'supercategory': 'crustacea', 'id': 279, 'name': 'crustacea_ot', 'c_name': '其他甲壳类动物', 'isthing': True},
|
| 291 |
+
{'supercategory': 'mollusca', 'id': 280, 'name': 'jellyfish', 'c_name': '水母', 'isthing': True},
|
| 292 |
+
{'supercategory': 'table', 'id': 281, 'name': 'table_cloth', 'c_name': '桌布', 'isthing': True},
|
| 293 |
+
{'supercategory': 'cabinets', 'id': 282, 'name': 'wardrobe', 'c_name': '衣柜', 'isthing': True},
|
| 294 |
+
{'supercategory': 'building_structure', 'id': 283, 'name': 'bar', 'c_name': '吧台', 'isthing': False},
|
| 295 |
+
{'supercategory': 'underwater_vehicle', 'id': 284, 'name': 'canoe', 'c_name': '皮划艇', 'isthing': True},
|
| 296 |
+
{'supercategory': 'birds', 'id': 285, 'name': 'chicken', 'c_name': '鸡', 'isthing': True},
|
| 297 |
+
{'supercategory': 'fluid', 'id': 286, 'name': 'pond', 'c_name': '池塘', 'isthing': False},
|
| 298 |
+
{'supercategory': 'upper_body_clothing', 'id': 287, 'name': 'T-shirt', 'c_name': 'T恤', 'isthing': True},
|
| 299 |
+
{'supercategory': 'footwear', 'id': 288, 'name': 'splippers', 'c_name': '拖鞋', 'isthing': True},
|
| 300 |
+
{'supercategory': 'media', 'id': 289, 'name': 'bulletin_board', 'c_name': '电子公告牌', 'isthing': True},
|
| 301 |
+
{'supercategory': 'fruit', 'id': 290, 'name': 'strawberry', 'c_name': '草莓', 'isthing': True},
|
| 302 |
+
{'supercategory': 'telephone', 'id': 291, 'name': 'corded_telephone', 'c_name': '有线电话', 'isthing': True},
|
| 303 |
+
{'supercategory': 'kitchen_tool', 'id': 292, 'name': 'saucer', 'c_name': '茶碟', 'isthing': True},
|
| 304 |
+
{'supercategory': 'reptile', 'id': 293, 'name': 'turtle', 'c_name': '龟', 'isthing': True},
|
| 305 |
+
{'supercategory': 'cup', 'id': 294, 'name': 'coffee cup', 'c_name': '咖啡杯', 'isthing': True},
|
| 306 |
+
{'supercategory': 'solid', 'id': 295, 'name': 'solid_ot', 'c_name': '其他固体', 'isthing': False},
|
| 307 |
+
{'supercategory': 'wall', 'id': 296, 'name': 'glasswall', 'c_name': '玻璃墙', 'isthing': False},
|
| 308 |
+
{'supercategory': 'vegetable', 'id': 297, 'name': 'carrot', 'c_name': '胡萝卜', 'isthing': True},
|
| 309 |
+
{'supercategory': 'clean_tool', 'id': 298, 'name': 'tissue', 'c_name': '抽纸', 'isthing': True},
|
| 310 |
+
{'supercategory': 'individual_plants', 'id': 299, 'name': 'individual_plants_ot', 'c_name': '其他独立植物', 'isthing': False},
|
| 311 |
+
{'supercategory': 'traffic_facility', 'id': 300, 'name': 'fire_hyrant', 'c_name': '消防龙头', 'isthing': True},
|
| 312 |
+
{'supercategory': 'footwear', 'id': 301, 'name': ' high-heeled_shoes', 'c_name': '高跟鞋', 'isthing': True},
|
| 313 |
+
{'supercategory': 'vegetable', 'id': 302, 'name': 'potato', 'c_name': '马铃薯', 'isthing': True},
|
| 314 |
+
{'supercategory': 'entertainment_appliances', 'id': 303, 'name': 'radiator', 'c_name': '暖气', 'isthing': True},
|
| 315 |
+
{'supercategory': 'repair_tool', 'id': 304, 'name': 'wrench', 'c_name': '扳手', 'isthing': True},
|
| 316 |
+
{'supercategory': 'stove', 'id': 305, 'name': 'gas_stove', 'c_name': '燃气炉', 'isthing': True},
|
| 317 |
+
{'supercategory': 'horse', 'id': 306, 'name': 'zebra', 'c_name': '斑马', 'isthing': True},
|
| 318 |
+
{'supercategory': 'non-building_houses', 'id': 307, 'name': 'fountain_ground', 'c_name': '喷泉台', 'isthing': False},
|
| 319 |
+
{'supercategory': 'knife', 'id': 308, 'name': 'knife_ot', 'c_name': '其他刀', 'isthing': True},
|
| 320 |
+
{'supercategory': 'weapon', 'id': 309, 'name': 'rifle', 'c_name': '步枪', 'isthing': True},
|
| 321 |
+
{'supercategory': 'mammal', 'id': 310, 'name': 'monkey', 'c_name': '猴子', 'isthing': True},
|
| 322 |
+
{'supercategory': 'individual_plants', 'id': 311, 'name': 'straw', 'c_name': '稻草', 'isthing': False},
|
| 323 |
+
{'supercategory': 'ball', 'id': 312, 'name': 'golf', 'c_name': '高尔夫球', 'isthing': True},
|
| 324 |
+
{'supercategory': 'lab_tool', 'id': 313, 'name': ' folder', 'c_name': '文件夹', 'isthing': True},
|
| 325 |
+
{'supercategory': 'human_accessories', 'id': 314, 'name': 'gloves', 'c_name': '手套', 'isthing': True},
|
| 326 |
+
{'supercategory': 'repair_tool', 'id': 315, 'name': 'screwdriver', 'c_name': '螺丝刀', 'isthing': True},
|
| 327 |
+
{'supercategory': 'kitchen_tool', 'id': 316, 'name': 'drinking_straw', 'c_name': '吸管', 'isthing': True},
|
| 328 |
+
{'supercategory': 'mammal', 'id': 317, 'name': 'pig', 'c_name': '猪', 'isthing': True},
|
| 329 |
+
{'supercategory': 'plant', 'id': 318, 'name': 'plant_ot', 'c_name': '其他植物', 'isthing': True},
|
| 330 |
+
{'supercategory': 'cabinets', 'id': 319, 'name': 'bathroom cabinets', 'c_name': '浴室柜', 'isthing': True},
|
| 331 |
+
{'supercategory': 'ventilation_appliances', 'id': 320, 'name': 'vent', 'c_name': '通风孔', 'isthing': True},
|
| 332 |
+
{'supercategory': 'clean_appliances', 'id': 321, 'name': 'washing_machine', 'c_name': '洗衣机', 'isthing': True},
|
| 333 |
+
{'supercategory': 'racket', 'id': 322, 'name': 'tennis_racket', 'c_name': '网球拍', 'isthing': True},
|
| 334 |
+
{'supercategory': 'kitchen_tool', 'id': 323, 'name': 'chopsticks', 'c_name': '筷子', 'isthing': True},
|
| 335 |
+
{'supercategory': 'mammal', 'id': 324, 'name': 'seal', 'c_name': '海豹', 'isthing': True},
|
| 336 |
+
{'supercategory': 'building_houses', 'id': 325, 'name': 'lighthouse', 'c_name': '灯塔', 'isthing': False},
|
| 337 |
+
{'supercategory': 'kitchen_appliances', 'id': 326, 'name': 'kettle', 'c_name': '水壶', 'isthing': True},
|
| 338 |
+
{'supercategory': 'fitness_equipment', 'id': 327, 'name': 'parachute', 'c_name': '降落伞', 'isthing': True},
|
| 339 |
+
{'supercategory': 'beddings', 'id': 328, 'name': 'blanket', 'c_name': '被子', 'isthing': True},
|
| 340 |
+
{'supercategory': 'drink', 'id': 329, 'name': 'juice', 'c_name': '果汁', 'isthing': True},
|
| 341 |
+
{'supercategory': 'kitchen_tool', 'id': 330, 'name': 'food_processor', 'c_name': '食品加工机', 'isthing': True},
|
| 342 |
+
{'supercategory': 'truck', 'id': 331, 'name': 'pickup_truck', 'c_name': '皮卡车', 'isthing': True},
|
| 343 |
+
{'supercategory': 'doll', 'id': 332, 'name': 'teddy_bear', 'c_name': '泰迪熊', 'isthing': True},
|
| 344 |
+
{'supercategory': 'deer', 'id': 333, 'name': 'deer_ot', 'c_name': '其他鹿', 'isthing': True},
|
| 345 |
+
{'supercategory': 'clock_furniture', 'id': 335, 'name': 'clock', 'c_name': '时钟', 'isthing': True},
|
| 346 |
+
{'supercategory': 'beddings', 'id': 336, 'name': 'beddings_ot', 'c_name': '其他床上用品', 'isthing': True},
|
| 347 |
+
{'supercategory': 'lab_tool', 'id': 337, 'name': 'tube', 'c_name': '试管', 'isthing': True},
|
| 348 |
+
{'supercategory': 'fluid', 'id': 338, 'name': 'fountain', 'c_name': '喷泉', 'isthing': False},
|
| 349 |
+
{'supercategory': 'non-building_houses', 'id': 339, 'name': 'parterre', 'c_name': '花坛', 'isthing': False},
|
| 350 |
+
{'supercategory': 'human_accessories', 'id': 340, 'name': 'human_accessories_ot', 'c_name': '其他人物服饰类', 'isthing': True},
|
| 351 |
+
{'supercategory': 'birds', 'id': 341, 'name': 'parrot', 'c_name': '鹦鹉', 'isthing': True},
|
| 352 |
+
{'supercategory': 'common_furniture', 'id': 342, 'name': 'toilet', 'c_name': '马桶', 'isthing': True},
|
| 353 |
+
{'supercategory': 'fitness_equipment', 'id': 343, 'name': 'dumbbell', 'c_name': '哑铃', 'isthing': True},
|
| 354 |
+
{'supercategory': 'fruit', 'id': 344, 'name': 'pear', 'c_name': '梨', 'isthing': True},
|
| 355 |
+
{'supercategory': 'fruit', 'id': 345, 'name': 'pineapple', 'c_name': '菠萝', 'isthing': True},
|
| 356 |
+
{'supercategory': 'building_houses', 'id': 346, 'name': 'temple', 'c_name': '寺庙', 'isthing': False},
|
| 357 |
+
{'supercategory': 'camel', 'id': 350, 'name': 'camel_ot', 'c_name': '其他骆驼', 'isthing': True},
|
| 358 |
+
{'supercategory': 'person', 'id': 640, 'name': 'person_ot', 'c_name': '无法分辨年龄性别的人', 'isthing': True},
|
| 359 |
+
{'supercategory': 'person', 'id': 641, 'name': 'woman', 'c_name': '女人', 'isthing': True},
|
| 360 |
+
{'supercategory': 'person', 'id': 642, 'name': 'boy', 'c_name': '男孩', 'isthing': True},
|
| 361 |
+
{'supercategory': 'person', 'id': 643, 'name': 'girl', 'c_name': '女孩', 'isthing': True},
|
| 362 |
+
]
|
| 363 |
+
|
| 364 |
+
def _get_entityv2_panoptic_meta():
|
| 365 |
+
meta = {}
|
| 366 |
+
|
| 367 |
+
## thing_dataset_id and stuff_dataset_id share the same contiguous id
|
| 368 |
+
thing_dataset_id_to_contiguous_id = {}
|
| 369 |
+
stuff_dataset_id_to_contiguous_id = {}
|
| 370 |
+
for i, cat in enumerate(EntityV2_panoptic_CATEGORIES):
|
| 371 |
+
if cat["isthing"]:
|
| 372 |
+
thing_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 373 |
+
else:
|
| 374 |
+
stuff_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 375 |
+
|
| 376 |
+
## add new map for PanopticFPN Dataloader
|
| 377 |
+
thing_contiguous_id_to_new_contiguous = {}
|
| 378 |
+
stuff_contiguous_id_to_new_contiguous = {}
|
| 379 |
+
for id_, (thing_id, contiguous_id) in enumerate(thing_dataset_id_to_contiguous_id.items()):
|
| 380 |
+
thing_contiguous_id_to_new_contiguous[contiguous_id] = id_
|
| 381 |
+
|
| 382 |
+
for id_, (stuff_id, contiguous_id) in enumerate(stuff_dataset_id_to_contiguous_id.items()):
|
| 383 |
+
stuff_contiguous_id_to_new_contiguous[contiguous_id] = id_+1
|
| 384 |
+
|
| 385 |
+
thing_classes = [k["name"] for k in EntityV2_panoptic_CATEGORIES]
|
| 386 |
+
stuff_classes = [k["name"] for k in EntityV2_panoptic_CATEGORIES]
|
| 387 |
+
|
| 388 |
+
meta["thing_classes"] = thing_classes
|
| 389 |
+
meta["stuff_classes"] = stuff_classes
|
| 390 |
+
|
| 391 |
+
meta["thing_dataset_id_to_contiguous_id"] = thing_dataset_id_to_contiguous_id
|
| 392 |
+
meta["stuff_dataset_id_to_contiguous_id"] = stuff_dataset_id_to_contiguous_id
|
| 393 |
+
meta["thing_contiguous_id_to_new_contiguous"] = thing_contiguous_id_to_new_contiguous
|
| 394 |
+
meta["stuff_contiguous_id_to_new_contiguous"] = stuff_contiguous_id_to_new_contiguous
|
| 395 |
+
|
| 396 |
+
return meta
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
def load_entityv2_panoptic_json(json_file, image_dir, gt_dir, meta):
|
| 400 |
+
"""
|
| 401 |
+
Args:
|
| 402 |
+
image_dir (str): path to the raw dataset. e.g., "~/coco/train2017".
|
| 403 |
+
gt_dir (str): path to the raw annotations. e.g., "~/coco/panoptic_train2017".
|
| 404 |
+
json_file (str): path to the json file. e.g., "~/coco/annotations/panoptic_train2017.json".
|
| 405 |
+
|
| 406 |
+
Returns:
|
| 407 |
+
list[dict]: a list of dicts in Detectron2 standard format. (See
|
| 408 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ )
|
| 409 |
+
"""
|
| 410 |
+
|
| 411 |
+
def _convert_category_id(segment_info, meta):
|
| 412 |
+
if segment_info["category_id"] in meta["thing_dataset_id_to_contiguous_id"]:
|
| 413 |
+
segment_info["category_id"] = meta["thing_dataset_id_to_contiguous_id"][
|
| 414 |
+
segment_info["category_id"]
|
| 415 |
+
]
|
| 416 |
+
segment_info["isthing"] = True
|
| 417 |
+
else:
|
| 418 |
+
segment_info["category_id"] = meta["stuff_dataset_id_to_contiguous_id"][
|
| 419 |
+
segment_info["category_id"]
|
| 420 |
+
]
|
| 421 |
+
segment_info["isthing"] = False
|
| 422 |
+
return segment_info
|
| 423 |
+
|
| 424 |
+
with PathManager.open(json_file) as f:
|
| 425 |
+
json_info = json.load(f)
|
| 426 |
+
|
| 427 |
+
ret = []
|
| 428 |
+
for ann in json_info["annotations"]:
|
| 429 |
+
image_id = int(ann["image_id"])
|
| 430 |
+
image_file = os.path.join(image_dir, ann["file_name"])
|
| 431 |
+
label_file = os.path.join(gt_dir, ann["file_name"].split(".")[0]+".png")
|
| 432 |
+
# segments_info = ann["segments_info"]
|
| 433 |
+
segments_info = [_convert_category_id(x, meta) for x in ann["segments_info"]]
|
| 434 |
+
ret.append(
|
| 435 |
+
{
|
| 436 |
+
"file_name": image_file,
|
| 437 |
+
"image_id": image_id,
|
| 438 |
+
"pan_seg_file_name": label_file,
|
| 439 |
+
"segments_info": segments_info,
|
| 440 |
+
}
|
| 441 |
+
)
|
| 442 |
+
assert len(ret), f"No images found in {image_dir}!"
|
| 443 |
+
assert PathManager.isfile(ret[0]["file_name"]), ret[0]["file_name"]
|
| 444 |
+
assert PathManager.isfile(ret[0]["pan_seg_file_name"]), ret[0]["pan_seg_file_name"]
|
| 445 |
+
return ret
|
| 446 |
+
|
| 447 |
+
def register_entityv2_panoptic(name, metadata, image_root, panoptic_root, panoptic_json):
|
| 448 |
+
"""
|
| 449 |
+
"""
|
| 450 |
+
panoptic_name = name
|
| 451 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 452 |
+
panoptic_json = os.path.join(_root, panoptic_json)
|
| 453 |
+
panoptic_root = os.path.join(_root, panoptic_root)
|
| 454 |
+
image_root = os.path.join(_root, image_root)
|
| 455 |
+
DatasetCatalog.register(
|
| 456 |
+
panoptic_name,
|
| 457 |
+
lambda: load_entityv2_panoptic_json(panoptic_json, image_root, panoptic_root, metadata),
|
| 458 |
+
)
|
| 459 |
+
MetadataCatalog.get(panoptic_name).set(
|
| 460 |
+
panoptic_root=panoptic_root,
|
| 461 |
+
image_root=image_root,
|
| 462 |
+
panoptic_json=panoptic_json,
|
| 463 |
+
evaluator_type="coco_panoptic_seg",
|
| 464 |
+
ignore_label=255,
|
| 465 |
+
label_divisor=1000,
|
| 466 |
+
**metadata,
|
| 467 |
+
)
|
| 468 |
+
|
| 469 |
+
_PREDEFINED_SPLITS = {
|
| 470 |
+
"entityv2_panoptic_train": (
|
| 471 |
+
"entityseg/images/entity_01_11580",
|
| 472 |
+
"entityseg/annotations/panoptic_segmentation/panoptic_maps_train",
|
| 473 |
+
"entityseg/annotations/panoptic_segmentation/entityv2_01_panoptic_train.json",
|
| 474 |
+
),
|
| 475 |
+
"entityv2_panoptic_val": (
|
| 476 |
+
"entityseg/images/entity_01_11580",
|
| 477 |
+
"entityseg/annotations/panoptic_segmentation/panoptic_maps_val",
|
| 478 |
+
"entityseg/annotations/panoptic_segmentation/entityv2_01_panoptic_val.json",
|
| 479 |
+
),
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
for name, (image_root, gt_root, json_path) in _PREDEFINED_SPLITS.items():
|
| 483 |
+
metadata = _get_entityv2_panoptic_meta()
|
| 484 |
+
register_entityv2_panoptic(name, metadata, image_root, gt_root, json_path)
|
| 485 |
+
|
| 486 |
+
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_entityv2_semseg_150.py
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 5 |
+
import mmcv
|
| 6 |
+
|
| 7 |
+
ENTITYV2_SEMSEG150_CATEGORIES = [
|
| 8 |
+
{'name': 'sky', 'id': 0},
|
| 9 |
+
{'name': 'concretewall', 'id': 1},
|
| 10 |
+
{'name': 'tree', 'id': 2},
|
| 11 |
+
{'name': 'grass', 'id': 3},
|
| 12 |
+
{'name': 'house', 'id': 4},
|
| 13 |
+
{'name': 'mountain', 'id': 5},
|
| 14 |
+
{'name': 'sea', 'id': 6},
|
| 15 |
+
{'name': 'floor', 'id': 7},
|
| 16 |
+
{'name': 'shrub', 'id': 8},
|
| 17 |
+
{'name': 'floor_structure_ot', 'id': 9},
|
| 18 |
+
{'name': 'woman', 'id': 10},
|
| 19 |
+
{'name': 'building_houses_ot', 'id': 11},
|
| 20 |
+
{'name': 'lake', 'id': 12},
|
| 21 |
+
{'name': 'high-rise', 'id': 13},
|
| 22 |
+
{'name': 'ceiling', 'id': 14},
|
| 23 |
+
{'name': 'non-buildinghouse_ot', 'id': 15},
|
| 24 |
+
{'name': 'man', 'id': 16},
|
| 25 |
+
{'name': 'noncommon_furniture', 'id': 17},
|
| 26 |
+
{'name': 'table_ot', 'id': 18},
|
| 27 |
+
{'name': 'snow', 'id': 19},
|
| 28 |
+
{'name': 'road', 'id': 20},
|
| 29 |
+
{'name': 'rock', 'id': 21},
|
| 30 |
+
{'name': 'river', 'id': 22},
|
| 31 |
+
{'name': 'window', 'id': 23},
|
| 32 |
+
{'name': 'sand', 'id': 24},
|
| 33 |
+
{'name': 'sunk_fence', 'id': 25},
|
| 34 |
+
{'name': 'building_ot', 'id': 26},
|
| 35 |
+
{'name': 'park_ground', 'id': 27},
|
| 36 |
+
{'name': 'soil', 'id': 28},
|
| 37 |
+
{'name': 'wall_ot', 'id': 29},
|
| 38 |
+
{'name': 'chair', 'id': 30},
|
| 39 |
+
{'name': 'curtain', 'id': 31},
|
| 40 |
+
{'name': 'buildingstructure_ot', 'id': 32},
|
| 41 |
+
{'name': 'rug', 'id': 33},
|
| 42 |
+
{'name': 'fluid_ot', 'id': 34},
|
| 43 |
+
{'name': 'potted_plants', 'id': 35},
|
| 44 |
+
{'name': 'painting', 'id': 36},
|
| 45 |
+
{'name': 'porch', 'id': 37},
|
| 46 |
+
{'name': 'person_ot', 'id': 38},
|
| 47 |
+
{'name': 'bedroom bed', 'id': 39},
|
| 48 |
+
{'name': 'court', 'id': 40},
|
| 49 |
+
{'name': 'car', 'id': 41},
|
| 50 |
+
{'name': 'crops', 'id': 42},
|
| 51 |
+
{'name': 'skyscraper', 'id': 43},
|
| 52 |
+
{'name': 'leaf', 'id': 44},
|
| 53 |
+
{'name': 'cabinets_ot', 'id': 45},
|
| 54 |
+
{'name': 'swimmingpool', 'id': 46},
|
| 55 |
+
{'name': 'sculpture', 'id': 47},
|
| 56 |
+
{'name': 'bridge', 'id': 48},
|
| 57 |
+
{'name': 'sidewalk', 'id': 49},
|
| 58 |
+
{'name': 'stone', 'id': 50},
|
| 59 |
+
{'name': 'book', 'id': 51},
|
| 60 |
+
{'name': 'castle', 'id': 52},
|
| 61 |
+
{'name': 'kitchen cabinets', 'id': 53},
|
| 62 |
+
{'name': 'entertainment_appliances_ot', 'id': 54},
|
| 63 |
+
{'name': 'mat', 'id': 55},
|
| 64 |
+
{'name': 'utility_ot', 'id': 56},
|
| 65 |
+
{'name': 'gravel', 'id': 57},
|
| 66 |
+
{'name': 'flower', 'id': 58},
|
| 67 |
+
{'name': 'cushion', 'id': 59},
|
| 68 |
+
{'name': 'pond', 'id': 60},
|
| 69 |
+
{'name': 'facility_ot', 'id': 61},
|
| 70 |
+
{'name': 'glasswall', 'id': 62},
|
| 71 |
+
{'name': 'nonindividual_plants_ot', 'id': 63},
|
| 72 |
+
{'name': 'land_transportation_ot', 'id': 64},
|
| 73 |
+
{'name': 'artifical_ground_ot', 'id': 65},
|
| 74 |
+
{'name': 'step', 'id': 66},
|
| 75 |
+
{'name': 'toy_ot', 'id': 67},
|
| 76 |
+
{'name': 'couch', 'id': 68},
|
| 77 |
+
{'name': 'box', 'id': 69},
|
| 78 |
+
{'name': 'mirror', 'id': 70},
|
| 79 |
+
{'name': 'dog', 'id': 71},
|
| 80 |
+
{'name': 'rigid_container_ot', 'id': 72},
|
| 81 |
+
{'name': 'refrigerator', 'id': 73},
|
| 82 |
+
{'name': 'wiredfence', 'id': 74},
|
| 83 |
+
{'name': 'boy', 'id': 75},
|
| 84 |
+
{'name': 'fence', 'id': 76},
|
| 85 |
+
{'name': 'waterfall', 'id': 77},
|
| 86 |
+
{'name': 'girl', 'id': 78},
|
| 87 |
+
{'name': 'ordniary_sofa', 'id': 79},
|
| 88 |
+
{'name': 'signboard', 'id': 80},
|
| 89 |
+
{'name': 'double_sofa', 'id': 81},
|
| 90 |
+
{'name': 'paper', 'id': 82},
|
| 91 |
+
{'name': 'dirt', 'id': 83},
|
| 92 |
+
{'name': 'cutting_board', 'id': 84},
|
| 93 |
+
{'name': ' medical_equipment', 'id': 85},
|
| 94 |
+
{'name': 'laptop', 'id': 86},
|
| 95 |
+
{'name': 'horse_ot', 'id': 87},
|
| 96 |
+
{'name': 'kiosk', 'id': 88},
|
| 97 |
+
{'name': 'boat', 'id': 89},
|
| 98 |
+
{'name': 'lab_tool_ot', 'id': 90},
|
| 99 |
+
{'name': 'train', 'id': 91},
|
| 100 |
+
{'name': 'trunk', 'id': 92},
|
| 101 |
+
{'name': 'airplane', 'id': 93},
|
| 102 |
+
{'name': 'television', 'id': 94},
|
| 103 |
+
{'name': 'wardrobe', 'id': 95},
|
| 104 |
+
{'name': 'dessert_snacks_ot', 'id': 96},
|
| 105 |
+
{'name': 'blanket', 'id': 97},
|
| 106 |
+
{'name': 'birds_ot', 'id': 98},
|
| 107 |
+
{'name': 'bottle', 'id': 99},
|
| 108 |
+
{'name': 'cat', 'id': 100},
|
| 109 |
+
{'name': 'drink_ot', 'id': 101},
|
| 110 |
+
{'name': 'tower', 'id': 102},
|
| 111 |
+
{'name': 'plate', 'id': 103},
|
| 112 |
+
{'name': 'outdoor_supplies_ot', 'id': 104},
|
| 113 |
+
{'name': 'pillow', 'id': 105},
|
| 114 |
+
{'name': 'temple', 'id': 106},
|
| 115 |
+
{'name': 'decoration', 'id': 107},
|
| 116 |
+
{'name': 'solid_ot', 'id': 108},
|
| 117 |
+
{'name': 'bathroom cabinets', 'id': 109},
|
| 118 |
+
{'name': 'parkinglot', 'id': 110},
|
| 119 |
+
{'name': 'blanket', 'id': 111},
|
| 120 |
+
{'name': 'stool', 'id': 112},
|
| 121 |
+
{'name': 'doll_ot', 'id': 113},
|
| 122 |
+
{'name': 'dining_table', 'id': 114},
|
| 123 |
+
{'name': 'pier', 'id': 115},
|
| 124 |
+
{'name': 'bathhub', 'id': 116},
|
| 125 |
+
{'name': 'playground', 'id': 117},
|
| 126 |
+
{'name': 'vine', 'id': 118},
|
| 127 |
+
{'name': 'tent', 'id': 119},
|
| 128 |
+
{'name': 'billiard_table', 'id': 120},
|
| 129 |
+
{'name': 'washing_machine', 'id': 121},
|
| 130 |
+
{'name': 'alley', 'id': 122},
|
| 131 |
+
{'name': 'barrier_ot', 'id': 123},
|
| 132 |
+
{'name': 'banister', 'id': 124},
|
| 133 |
+
{'name': 'bath_tool_ot', 'id': 125},
|
| 134 |
+
{'name': 'mammal_ot', 'id': 126},
|
| 135 |
+
{'name': 'stair', 'id': 127},
|
| 136 |
+
{'name': 'branch', 'id': 128},
|
| 137 |
+
{'name': 'chandilier', 'id': 129},
|
| 138 |
+
{'name': 'meat_ot', 'id': 130},
|
| 139 |
+
{'name': 'blackboard', 'id': 131},
|
| 140 |
+
{'name': 'table_cloth', 'id': 132},
|
| 141 |
+
{'name': 'backpack', 'id': 133},
|
| 142 |
+
{'name': 'ceiling_lamp', 'id': 134},
|
| 143 |
+
{'name': 'bench', 'id': 135},
|
| 144 |
+
{'name': 'screen', 'id': 136},
|
| 145 |
+
{'name': 'billboard', 'id': 137},
|
| 146 |
+
{'name': 'towel', 'id': 138},
|
| 147 |
+
{'name': 'cow_ot', 'id': 139},
|
| 148 |
+
{'name': 'fitness_equipment_ot', 'id': 140},
|
| 149 |
+
{'name': 'sofa_ot', 'id': 141},
|
| 150 |
+
{'name': 'bus', 'id': 142},
|
| 151 |
+
{'name': 'path', 'id': 143},
|
| 152 |
+
{'name': 'musical_instrument', 'id': 144},
|
| 153 |
+
{'name': 'cup_ot', 'id': 145},
|
| 154 |
+
{'name': 'mobilephone', 'id': 146},
|
| 155 |
+
{'name': 'photo', 'id': 147},
|
| 156 |
+
{'name': 'pants', 'id': 148},
|
| 157 |
+
{'name': 'pumkin', 'id': 149},
|
| 158 |
+
]
|
| 159 |
+
|
| 160 |
+
def load_sem_seg_w_txt(txt_path, image_root, gt_root):
|
| 161 |
+
"""
|
| 162 |
+
"""
|
| 163 |
+
infos = mmcv.list_from_file(txt_path)
|
| 164 |
+
input_files = []
|
| 165 |
+
gt_files = []
|
| 166 |
+
for info in infos:
|
| 167 |
+
img_name, gt_name = info.strip().split(" ")
|
| 168 |
+
input_files.append(os.path.join(image_root, img_name))
|
| 169 |
+
gt_files.append(os.path.join(gt_root, gt_name))
|
| 170 |
+
|
| 171 |
+
dataset_dicts = []
|
| 172 |
+
for (img_path, gt_path) in zip(input_files, gt_files):
|
| 173 |
+
record = {}
|
| 174 |
+
record["file_name"] = img_path
|
| 175 |
+
record["sem_seg_file_name"] = gt_path
|
| 176 |
+
dataset_dicts.append(record)
|
| 177 |
+
|
| 178 |
+
return dataset_dicts
|
| 179 |
+
|
| 180 |
+
def _get_entityv2_semseg_150_meta():
|
| 181 |
+
# Id 0 is reserved for ignore_label, we change ignore_label for 0
|
| 182 |
+
# to 255 in our pre-processing.
|
| 183 |
+
semseg_ids = [k["id"] for k in ENTITYV2_SEMSEG150_CATEGORIES]
|
| 184 |
+
assert len(semseg_ids) == 150, len(semseg_ids)
|
| 185 |
+
|
| 186 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 187 |
+
# (in [0, 91], used in models) to ids in the dataset (used for processing results)
|
| 188 |
+
stuff_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(semseg_ids)}
|
| 189 |
+
stuff_classes = [k["name"] for k in ENTITYV2_SEMSEG150_CATEGORIES]
|
| 190 |
+
|
| 191 |
+
ret = {
|
| 192 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 193 |
+
"stuff_classes": stuff_classes,
|
| 194 |
+
}
|
| 195 |
+
return ret
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def register_entityv2_sem150(root):
|
| 199 |
+
meta = _get_entityv2_semseg_150_meta()
|
| 200 |
+
for name, txt_name, image_dirname, sem_seg_dirname in [
|
| 201 |
+
("train", "entityseg/annotations/semantic_segmentation/train.txt", "entityseg/images/entity_01_11580", "entityseg/annotations/semantic_segmentation/semantic_maps_train"),
|
| 202 |
+
("test", "entityseg/annotations/semantic_segmentation/val.txt", "entityseg/images/entity_01_11580", "entityseg/annotations/semantic_segmentation/semantic_maps_val"),
|
| 203 |
+
]:
|
| 204 |
+
image_dir = os.path.join(root, image_dirname)
|
| 205 |
+
gt_dir = os.path.join(root, sem_seg_dirname)
|
| 206 |
+
txt_path = os.path.join(root, txt_name)
|
| 207 |
+
|
| 208 |
+
meta = _get_entityv2_semseg_150_meta()
|
| 209 |
+
|
| 210 |
+
name = f"entityv2_sem150_{name}"
|
| 211 |
+
DatasetCatalog.register(
|
| 212 |
+
name, lambda t=txt_path, x=image_dir, y=gt_dir: load_sem_seg_w_txt(t,x,y)
|
| 213 |
+
)
|
| 214 |
+
MetadataCatalog.get(name).set(
|
| 215 |
+
txt_path=txt_path,
|
| 216 |
+
image_root=image_dir,
|
| 217 |
+
sem_seg_root=gt_dir,
|
| 218 |
+
evaluator_type="sem_seg",
|
| 219 |
+
ignore_label=255,
|
| 220 |
+
**meta,
|
| 221 |
+
)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 225 |
+
register_entityv2_sem150(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_mapillary_vistas.py
ADDED
|
@@ -0,0 +1,507 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 5 |
+
from detectron2.data.datasets import load_sem_seg
|
| 6 |
+
|
| 7 |
+
MAPILLARY_VISTAS_SEM_SEG_CATEGORIES = [
|
| 8 |
+
{
|
| 9 |
+
"color": [165, 42, 42],
|
| 10 |
+
"instances": True,
|
| 11 |
+
"readable": "Bird",
|
| 12 |
+
"name": "animal--bird",
|
| 13 |
+
"evaluate": True,
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"color": [0, 192, 0],
|
| 17 |
+
"instances": True,
|
| 18 |
+
"readable": "Ground Animal",
|
| 19 |
+
"name": "animal--ground-animal",
|
| 20 |
+
"evaluate": True,
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"color": [196, 196, 196],
|
| 24 |
+
"instances": False,
|
| 25 |
+
"readable": "Curb",
|
| 26 |
+
"name": "construction--barrier--curb",
|
| 27 |
+
"evaluate": True,
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"color": [190, 153, 153],
|
| 31 |
+
"instances": False,
|
| 32 |
+
"readable": "Fence",
|
| 33 |
+
"name": "construction--barrier--fence",
|
| 34 |
+
"evaluate": True,
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"color": [180, 165, 180],
|
| 38 |
+
"instances": False,
|
| 39 |
+
"readable": "Guard Rail",
|
| 40 |
+
"name": "construction--barrier--guard-rail",
|
| 41 |
+
"evaluate": True,
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"color": [90, 120, 150],
|
| 45 |
+
"instances": False,
|
| 46 |
+
"readable": "Barrier",
|
| 47 |
+
"name": "construction--barrier--other-barrier",
|
| 48 |
+
"evaluate": True,
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"color": [102, 102, 156],
|
| 52 |
+
"instances": False,
|
| 53 |
+
"readable": "Wall",
|
| 54 |
+
"name": "construction--barrier--wall",
|
| 55 |
+
"evaluate": True,
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"color": [128, 64, 255],
|
| 59 |
+
"instances": False,
|
| 60 |
+
"readable": "Bike Lane",
|
| 61 |
+
"name": "construction--flat--bike-lane",
|
| 62 |
+
"evaluate": True,
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"color": [140, 140, 200],
|
| 66 |
+
"instances": True,
|
| 67 |
+
"readable": "Crosswalk - Plain",
|
| 68 |
+
"name": "construction--flat--crosswalk-plain",
|
| 69 |
+
"evaluate": True,
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"color": [170, 170, 170],
|
| 73 |
+
"instances": False,
|
| 74 |
+
"readable": "Curb Cut",
|
| 75 |
+
"name": "construction--flat--curb-cut",
|
| 76 |
+
"evaluate": True,
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"color": [250, 170, 160],
|
| 80 |
+
"instances": False,
|
| 81 |
+
"readable": "Parking",
|
| 82 |
+
"name": "construction--flat--parking",
|
| 83 |
+
"evaluate": True,
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"color": [96, 96, 96],
|
| 87 |
+
"instances": False,
|
| 88 |
+
"readable": "Pedestrian Area",
|
| 89 |
+
"name": "construction--flat--pedestrian-area",
|
| 90 |
+
"evaluate": True,
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"color": [230, 150, 140],
|
| 94 |
+
"instances": False,
|
| 95 |
+
"readable": "Rail Track",
|
| 96 |
+
"name": "construction--flat--rail-track",
|
| 97 |
+
"evaluate": True,
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"color": [128, 64, 128],
|
| 101 |
+
"instances": False,
|
| 102 |
+
"readable": "Road",
|
| 103 |
+
"name": "construction--flat--road",
|
| 104 |
+
"evaluate": True,
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"color": [110, 110, 110],
|
| 108 |
+
"instances": False,
|
| 109 |
+
"readable": "Service Lane",
|
| 110 |
+
"name": "construction--flat--service-lane",
|
| 111 |
+
"evaluate": True,
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"color": [244, 35, 232],
|
| 115 |
+
"instances": False,
|
| 116 |
+
"readable": "Sidewalk",
|
| 117 |
+
"name": "construction--flat--sidewalk",
|
| 118 |
+
"evaluate": True,
|
| 119 |
+
},
|
| 120 |
+
{
|
| 121 |
+
"color": [150, 100, 100],
|
| 122 |
+
"instances": False,
|
| 123 |
+
"readable": "Bridge",
|
| 124 |
+
"name": "construction--structure--bridge",
|
| 125 |
+
"evaluate": True,
|
| 126 |
+
},
|
| 127 |
+
{
|
| 128 |
+
"color": [70, 70, 70],
|
| 129 |
+
"instances": False,
|
| 130 |
+
"readable": "Building",
|
| 131 |
+
"name": "construction--structure--building",
|
| 132 |
+
"evaluate": True,
|
| 133 |
+
},
|
| 134 |
+
{
|
| 135 |
+
"color": [150, 120, 90],
|
| 136 |
+
"instances": False,
|
| 137 |
+
"readable": "Tunnel",
|
| 138 |
+
"name": "construction--structure--tunnel",
|
| 139 |
+
"evaluate": True,
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"color": [220, 20, 60],
|
| 143 |
+
"instances": True,
|
| 144 |
+
"readable": "Person",
|
| 145 |
+
"name": "human--person",
|
| 146 |
+
"evaluate": True,
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"color": [255, 0, 0],
|
| 150 |
+
"instances": True,
|
| 151 |
+
"readable": "Bicyclist",
|
| 152 |
+
"name": "human--rider--bicyclist",
|
| 153 |
+
"evaluate": True,
|
| 154 |
+
},
|
| 155 |
+
{
|
| 156 |
+
"color": [255, 0, 100],
|
| 157 |
+
"instances": True,
|
| 158 |
+
"readable": "Motorcyclist",
|
| 159 |
+
"name": "human--rider--motorcyclist",
|
| 160 |
+
"evaluate": True,
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"color": [255, 0, 200],
|
| 164 |
+
"instances": True,
|
| 165 |
+
"readable": "Other Rider",
|
| 166 |
+
"name": "human--rider--other-rider",
|
| 167 |
+
"evaluate": True,
|
| 168 |
+
},
|
| 169 |
+
{
|
| 170 |
+
"color": [200, 128, 128],
|
| 171 |
+
"instances": True,
|
| 172 |
+
"readable": "Lane Marking - Crosswalk",
|
| 173 |
+
"name": "marking--crosswalk-zebra",
|
| 174 |
+
"evaluate": True,
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"color": [255, 255, 255],
|
| 178 |
+
"instances": False,
|
| 179 |
+
"readable": "Lane Marking - General",
|
| 180 |
+
"name": "marking--general",
|
| 181 |
+
"evaluate": True,
|
| 182 |
+
},
|
| 183 |
+
{
|
| 184 |
+
"color": [64, 170, 64],
|
| 185 |
+
"instances": False,
|
| 186 |
+
"readable": "Mountain",
|
| 187 |
+
"name": "nature--mountain",
|
| 188 |
+
"evaluate": True,
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"color": [230, 160, 50],
|
| 192 |
+
"instances": False,
|
| 193 |
+
"readable": "Sand",
|
| 194 |
+
"name": "nature--sand",
|
| 195 |
+
"evaluate": True,
|
| 196 |
+
},
|
| 197 |
+
{
|
| 198 |
+
"color": [70, 130, 180],
|
| 199 |
+
"instances": False,
|
| 200 |
+
"readable": "Sky",
|
| 201 |
+
"name": "nature--sky",
|
| 202 |
+
"evaluate": True,
|
| 203 |
+
},
|
| 204 |
+
{
|
| 205 |
+
"color": [190, 255, 255],
|
| 206 |
+
"instances": False,
|
| 207 |
+
"readable": "Snow",
|
| 208 |
+
"name": "nature--snow",
|
| 209 |
+
"evaluate": True,
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"color": [152, 251, 152],
|
| 213 |
+
"instances": False,
|
| 214 |
+
"readable": "Terrain",
|
| 215 |
+
"name": "nature--terrain",
|
| 216 |
+
"evaluate": True,
|
| 217 |
+
},
|
| 218 |
+
{
|
| 219 |
+
"color": [107, 142, 35],
|
| 220 |
+
"instances": False,
|
| 221 |
+
"readable": "Vegetation",
|
| 222 |
+
"name": "nature--vegetation",
|
| 223 |
+
"evaluate": True,
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"color": [0, 170, 30],
|
| 227 |
+
"instances": False,
|
| 228 |
+
"readable": "Water",
|
| 229 |
+
"name": "nature--water",
|
| 230 |
+
"evaluate": True,
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"color": [255, 255, 128],
|
| 234 |
+
"instances": True,
|
| 235 |
+
"readable": "Banner",
|
| 236 |
+
"name": "object--banner",
|
| 237 |
+
"evaluate": True,
|
| 238 |
+
},
|
| 239 |
+
{
|
| 240 |
+
"color": [250, 0, 30],
|
| 241 |
+
"instances": True,
|
| 242 |
+
"readable": "Bench",
|
| 243 |
+
"name": "object--bench",
|
| 244 |
+
"evaluate": True,
|
| 245 |
+
},
|
| 246 |
+
{
|
| 247 |
+
"color": [100, 140, 180],
|
| 248 |
+
"instances": True,
|
| 249 |
+
"readable": "Bike Rack",
|
| 250 |
+
"name": "object--bike-rack",
|
| 251 |
+
"evaluate": True,
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"color": [220, 220, 220],
|
| 255 |
+
"instances": True,
|
| 256 |
+
"readable": "Billboard",
|
| 257 |
+
"name": "object--billboard",
|
| 258 |
+
"evaluate": True,
|
| 259 |
+
},
|
| 260 |
+
{
|
| 261 |
+
"color": [220, 128, 128],
|
| 262 |
+
"instances": True,
|
| 263 |
+
"readable": "Catch Basin",
|
| 264 |
+
"name": "object--catch-basin",
|
| 265 |
+
"evaluate": True,
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
"color": [222, 40, 40],
|
| 269 |
+
"instances": True,
|
| 270 |
+
"readable": "CCTV Camera",
|
| 271 |
+
"name": "object--cctv-camera",
|
| 272 |
+
"evaluate": True,
|
| 273 |
+
},
|
| 274 |
+
{
|
| 275 |
+
"color": [100, 170, 30],
|
| 276 |
+
"instances": True,
|
| 277 |
+
"readable": "Fire Hydrant",
|
| 278 |
+
"name": "object--fire-hydrant",
|
| 279 |
+
"evaluate": True,
|
| 280 |
+
},
|
| 281 |
+
{
|
| 282 |
+
"color": [40, 40, 40],
|
| 283 |
+
"instances": True,
|
| 284 |
+
"readable": "Junction Box",
|
| 285 |
+
"name": "object--junction-box",
|
| 286 |
+
"evaluate": True,
|
| 287 |
+
},
|
| 288 |
+
{
|
| 289 |
+
"color": [33, 33, 33],
|
| 290 |
+
"instances": True,
|
| 291 |
+
"readable": "Mailbox",
|
| 292 |
+
"name": "object--mailbox",
|
| 293 |
+
"evaluate": True,
|
| 294 |
+
},
|
| 295 |
+
{
|
| 296 |
+
"color": [100, 128, 160],
|
| 297 |
+
"instances": True,
|
| 298 |
+
"readable": "Manhole",
|
| 299 |
+
"name": "object--manhole",
|
| 300 |
+
"evaluate": True,
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"color": [142, 0, 0],
|
| 304 |
+
"instances": True,
|
| 305 |
+
"readable": "Phone Booth",
|
| 306 |
+
"name": "object--phone-booth",
|
| 307 |
+
"evaluate": True,
|
| 308 |
+
},
|
| 309 |
+
{
|
| 310 |
+
"color": [70, 100, 150],
|
| 311 |
+
"instances": False,
|
| 312 |
+
"readable": "Pothole",
|
| 313 |
+
"name": "object--pothole",
|
| 314 |
+
"evaluate": True,
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"color": [210, 170, 100],
|
| 318 |
+
"instances": True,
|
| 319 |
+
"readable": "Street Light",
|
| 320 |
+
"name": "object--street-light",
|
| 321 |
+
"evaluate": True,
|
| 322 |
+
},
|
| 323 |
+
{
|
| 324 |
+
"color": [153, 153, 153],
|
| 325 |
+
"instances": True,
|
| 326 |
+
"readable": "Pole",
|
| 327 |
+
"name": "object--support--pole",
|
| 328 |
+
"evaluate": True,
|
| 329 |
+
},
|
| 330 |
+
{
|
| 331 |
+
"color": [128, 128, 128],
|
| 332 |
+
"instances": True,
|
| 333 |
+
"readable": "Traffic Sign Frame",
|
| 334 |
+
"name": "object--support--traffic-sign-frame",
|
| 335 |
+
"evaluate": True,
|
| 336 |
+
},
|
| 337 |
+
{
|
| 338 |
+
"color": [0, 0, 80],
|
| 339 |
+
"instances": True,
|
| 340 |
+
"readable": "Utility Pole",
|
| 341 |
+
"name": "object--support--utility-pole",
|
| 342 |
+
"evaluate": True,
|
| 343 |
+
},
|
| 344 |
+
{
|
| 345 |
+
"color": [250, 170, 30],
|
| 346 |
+
"instances": True,
|
| 347 |
+
"readable": "Traffic Light",
|
| 348 |
+
"name": "object--traffic-light",
|
| 349 |
+
"evaluate": True,
|
| 350 |
+
},
|
| 351 |
+
{
|
| 352 |
+
"color": [192, 192, 192],
|
| 353 |
+
"instances": True,
|
| 354 |
+
"readable": "Traffic Sign (Back)",
|
| 355 |
+
"name": "object--traffic-sign--back",
|
| 356 |
+
"evaluate": True,
|
| 357 |
+
},
|
| 358 |
+
{
|
| 359 |
+
"color": [220, 220, 0],
|
| 360 |
+
"instances": True,
|
| 361 |
+
"readable": "Traffic Sign (Front)",
|
| 362 |
+
"name": "object--traffic-sign--front",
|
| 363 |
+
"evaluate": True,
|
| 364 |
+
},
|
| 365 |
+
{
|
| 366 |
+
"color": [140, 140, 20],
|
| 367 |
+
"instances": True,
|
| 368 |
+
"readable": "Trash Can",
|
| 369 |
+
"name": "object--trash-can",
|
| 370 |
+
"evaluate": True,
|
| 371 |
+
},
|
| 372 |
+
{
|
| 373 |
+
"color": [119, 11, 32],
|
| 374 |
+
"instances": True,
|
| 375 |
+
"readable": "Bicycle",
|
| 376 |
+
"name": "object--vehicle--bicycle",
|
| 377 |
+
"evaluate": True,
|
| 378 |
+
},
|
| 379 |
+
{
|
| 380 |
+
"color": [150, 0, 255],
|
| 381 |
+
"instances": True,
|
| 382 |
+
"readable": "Boat",
|
| 383 |
+
"name": "object--vehicle--boat",
|
| 384 |
+
"evaluate": True,
|
| 385 |
+
},
|
| 386 |
+
{
|
| 387 |
+
"color": [0, 60, 100],
|
| 388 |
+
"instances": True,
|
| 389 |
+
"readable": "Bus",
|
| 390 |
+
"name": "object--vehicle--bus",
|
| 391 |
+
"evaluate": True,
|
| 392 |
+
},
|
| 393 |
+
{
|
| 394 |
+
"color": [0, 0, 142],
|
| 395 |
+
"instances": True,
|
| 396 |
+
"readable": "Car",
|
| 397 |
+
"name": "object--vehicle--car",
|
| 398 |
+
"evaluate": True,
|
| 399 |
+
},
|
| 400 |
+
{
|
| 401 |
+
"color": [0, 0, 90],
|
| 402 |
+
"instances": True,
|
| 403 |
+
"readable": "Caravan",
|
| 404 |
+
"name": "object--vehicle--caravan",
|
| 405 |
+
"evaluate": True,
|
| 406 |
+
},
|
| 407 |
+
{
|
| 408 |
+
"color": [0, 0, 230],
|
| 409 |
+
"instances": True,
|
| 410 |
+
"readable": "Motorcycle",
|
| 411 |
+
"name": "object--vehicle--motorcycle",
|
| 412 |
+
"evaluate": True,
|
| 413 |
+
},
|
| 414 |
+
{
|
| 415 |
+
"color": [0, 80, 100],
|
| 416 |
+
"instances": False,
|
| 417 |
+
"readable": "On Rails",
|
| 418 |
+
"name": "object--vehicle--on-rails",
|
| 419 |
+
"evaluate": True,
|
| 420 |
+
},
|
| 421 |
+
{
|
| 422 |
+
"color": [128, 64, 64],
|
| 423 |
+
"instances": True,
|
| 424 |
+
"readable": "Other Vehicle",
|
| 425 |
+
"name": "object--vehicle--other-vehicle",
|
| 426 |
+
"evaluate": True,
|
| 427 |
+
},
|
| 428 |
+
{
|
| 429 |
+
"color": [0, 0, 110],
|
| 430 |
+
"instances": True,
|
| 431 |
+
"readable": "Trailer",
|
| 432 |
+
"name": "object--vehicle--trailer",
|
| 433 |
+
"evaluate": True,
|
| 434 |
+
},
|
| 435 |
+
{
|
| 436 |
+
"color": [0, 0, 70],
|
| 437 |
+
"instances": True,
|
| 438 |
+
"readable": "Truck",
|
| 439 |
+
"name": "object--vehicle--truck",
|
| 440 |
+
"evaluate": True,
|
| 441 |
+
},
|
| 442 |
+
{
|
| 443 |
+
"color": [0, 0, 192],
|
| 444 |
+
"instances": True,
|
| 445 |
+
"readable": "Wheeled Slow",
|
| 446 |
+
"name": "object--vehicle--wheeled-slow",
|
| 447 |
+
"evaluate": True,
|
| 448 |
+
},
|
| 449 |
+
{
|
| 450 |
+
"color": [32, 32, 32],
|
| 451 |
+
"instances": False,
|
| 452 |
+
"readable": "Car Mount",
|
| 453 |
+
"name": "void--car-mount",
|
| 454 |
+
"evaluate": True,
|
| 455 |
+
},
|
| 456 |
+
{
|
| 457 |
+
"color": [120, 10, 10],
|
| 458 |
+
"instances": False,
|
| 459 |
+
"readable": "Ego Vehicle",
|
| 460 |
+
"name": "void--ego-vehicle",
|
| 461 |
+
"evaluate": True,
|
| 462 |
+
},
|
| 463 |
+
{
|
| 464 |
+
"color": [0, 0, 0],
|
| 465 |
+
"instances": False,
|
| 466 |
+
"readable": "Unlabeled",
|
| 467 |
+
"name": "void--unlabeled",
|
| 468 |
+
"evaluate": False,
|
| 469 |
+
},
|
| 470 |
+
]
|
| 471 |
+
|
| 472 |
+
|
| 473 |
+
def _get_mapillary_vistas_meta():
|
| 474 |
+
stuff_classes = [k["readable"] for k in MAPILLARY_VISTAS_SEM_SEG_CATEGORIES if k["evaluate"]]
|
| 475 |
+
assert len(stuff_classes) == 65
|
| 476 |
+
|
| 477 |
+
stuff_colors = [k["color"] for k in MAPILLARY_VISTAS_SEM_SEG_CATEGORIES if k["evaluate"]]
|
| 478 |
+
assert len(stuff_colors) == 65
|
| 479 |
+
|
| 480 |
+
ret = {
|
| 481 |
+
"stuff_classes": stuff_classes,
|
| 482 |
+
"stuff_colors": stuff_colors,
|
| 483 |
+
}
|
| 484 |
+
return ret
|
| 485 |
+
|
| 486 |
+
|
| 487 |
+
def register_all_mapillary_vistas(root):
|
| 488 |
+
root = os.path.join(root, "mapillary_vistas")
|
| 489 |
+
meta = _get_mapillary_vistas_meta()
|
| 490 |
+
for name, dirname in [("train", "training"), ("val", "validation")]:
|
| 491 |
+
image_dir = os.path.join(root, dirname, "images")
|
| 492 |
+
gt_dir = os.path.join(root, dirname, "labels")
|
| 493 |
+
name = f"mapillary_vistas_sem_seg_{name}"
|
| 494 |
+
DatasetCatalog.register(
|
| 495 |
+
name, lambda x=image_dir, y=gt_dir: load_sem_seg(y, x, gt_ext="png", image_ext="jpg")
|
| 496 |
+
)
|
| 497 |
+
MetadataCatalog.get(name).set(
|
| 498 |
+
image_root=image_dir,
|
| 499 |
+
sem_seg_root=gt_dir,
|
| 500 |
+
evaluator_type="sem_seg",
|
| 501 |
+
ignore_label=65, # different from other datasets, Mapillary Vistas sets ignore_label to 65
|
| 502 |
+
**meta,
|
| 503 |
+
)
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 507 |
+
register_all_mapillary_vistas(_root)
|
MaskClustering/third_party/Entity/Entityv2/CropFormer/mask2former/data/datasets/register_mapillary_vistas_panoptic.py
ADDED
|
@@ -0,0 +1,508 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 6 |
+
from detectron2.utils.file_io import PathManager
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
MAPILLARY_VISTAS_SEM_SEG_CATEGORIES = [
|
| 10 |
+
{'color': [165, 42, 42],
|
| 11 |
+
'id': 1,
|
| 12 |
+
'isthing': 1,
|
| 13 |
+
'name': 'Bird',
|
| 14 |
+
'supercategory': 'animal--bird'},
|
| 15 |
+
{'color': [0, 192, 0],
|
| 16 |
+
'id': 2,
|
| 17 |
+
'isthing': 1,
|
| 18 |
+
'name': 'Ground Animal',
|
| 19 |
+
'supercategory': 'animal--ground-animal'},
|
| 20 |
+
{'color': [196, 196, 196],
|
| 21 |
+
'id': 3,
|
| 22 |
+
'isthing': 0,
|
| 23 |
+
'name': 'Curb',
|
| 24 |
+
'supercategory': 'construction--barrier--curb'},
|
| 25 |
+
{'color': [190, 153, 153],
|
| 26 |
+
'id': 4,
|
| 27 |
+
'isthing': 0,
|
| 28 |
+
'name': 'Fence',
|
| 29 |
+
'supercategory': 'construction--barrier--fence'},
|
| 30 |
+
{'color': [180, 165, 180],
|
| 31 |
+
'id': 5,
|
| 32 |
+
'isthing': 0,
|
| 33 |
+
'name': 'Guard Rail',
|
| 34 |
+
'supercategory': 'construction--barrier--guard-rail'},
|
| 35 |
+
{'color': [90, 120, 150],
|
| 36 |
+
'id': 6,
|
| 37 |
+
'isthing': 0,
|
| 38 |
+
'name': 'Barrier',
|
| 39 |
+
'supercategory': 'construction--barrier--other-barrier'},
|
| 40 |
+
{'color': [102, 102, 156],
|
| 41 |
+
'id': 7,
|
| 42 |
+
'isthing': 0,
|
| 43 |
+
'name': 'Wall',
|
| 44 |
+
'supercategory': 'construction--barrier--wall'},
|
| 45 |
+
{'color': [128, 64, 255],
|
| 46 |
+
'id': 8,
|
| 47 |
+
'isthing': 0,
|
| 48 |
+
'name': 'Bike Lane',
|
| 49 |
+
'supercategory': 'construction--flat--bike-lane'},
|
| 50 |
+
{'color': [140, 140, 200],
|
| 51 |
+
'id': 9,
|
| 52 |
+
'isthing': 1,
|
| 53 |
+
'name': 'Crosswalk - Plain',
|
| 54 |
+
'supercategory': 'construction--flat--crosswalk-plain'},
|
| 55 |
+
{'color': [170, 170, 170],
|
| 56 |
+
'id': 10,
|
| 57 |
+
'isthing': 0,
|
| 58 |
+
'name': 'Curb Cut',
|
| 59 |
+
'supercategory': 'construction--flat--curb-cut'},
|
| 60 |
+
{'color': [250, 170, 160],
|
| 61 |
+
'id': 11,
|
| 62 |
+
'isthing': 0,
|
| 63 |
+
'name': 'Parking',
|
| 64 |
+
'supercategory': 'construction--flat--parking'},
|
| 65 |
+
{'color': [96, 96, 96],
|
| 66 |
+
'id': 12,
|
| 67 |
+
'isthing': 0,
|
| 68 |
+
'name': 'Pedestrian Area',
|
| 69 |
+
'supercategory': 'construction--flat--pedestrian-area'},
|
| 70 |
+
{'color': [230, 150, 140],
|
| 71 |
+
'id': 13,
|
| 72 |
+
'isthing': 0,
|
| 73 |
+
'name': 'Rail Track',
|
| 74 |
+
'supercategory': 'construction--flat--rail-track'},
|
| 75 |
+
{'color': [128, 64, 128],
|
| 76 |
+
'id': 14,
|
| 77 |
+
'isthing': 0,
|
| 78 |
+
'name': 'Road',
|
| 79 |
+
'supercategory': 'construction--flat--road'},
|
| 80 |
+
{'color': [110, 110, 110],
|
| 81 |
+
'id': 15,
|
| 82 |
+
'isthing': 0,
|
| 83 |
+
'name': 'Service Lane',
|
| 84 |
+
'supercategory': 'construction--flat--service-lane'},
|
| 85 |
+
{'color': [244, 35, 232],
|
| 86 |
+
'id': 16,
|
| 87 |
+
'isthing': 0,
|
| 88 |
+
'name': 'Sidewalk',
|
| 89 |
+
'supercategory': 'construction--flat--sidewalk'},
|
| 90 |
+
{'color': [150, 100, 100],
|
| 91 |
+
'id': 17,
|
| 92 |
+
'isthing': 0,
|
| 93 |
+
'name': 'Bridge',
|
| 94 |
+
'supercategory': 'construction--structure--bridge'},
|
| 95 |
+
{'color': [70, 70, 70],
|
| 96 |
+
'id': 18,
|
| 97 |
+
'isthing': 0,
|
| 98 |
+
'name': 'Building',
|
| 99 |
+
'supercategory': 'construction--structure--building'},
|
| 100 |
+
{'color': [150, 120, 90],
|
| 101 |
+
'id': 19,
|
| 102 |
+
'isthing': 0,
|
| 103 |
+
'name': 'Tunnel',
|
| 104 |
+
'supercategory': 'construction--structure--tunnel'},
|
| 105 |
+
{'color': [220, 20, 60],
|
| 106 |
+
'id': 20,
|
| 107 |
+
'isthing': 1,
|
| 108 |
+
'name': 'Person',
|
| 109 |
+
'supercategory': 'human--person'},
|
| 110 |
+
{'color': [255, 0, 0],
|
| 111 |
+
'id': 21,
|
| 112 |
+
'isthing': 1,
|
| 113 |
+
'name': 'Bicyclist',
|
| 114 |
+
'supercategory': 'human--rider--bicyclist'},
|
| 115 |
+
{'color': [255, 0, 100],
|
| 116 |
+
'id': 22,
|
| 117 |
+
'isthing': 1,
|
| 118 |
+
'name': 'Motorcyclist',
|
| 119 |
+
'supercategory': 'human--rider--motorcyclist'},
|
| 120 |
+
{'color': [255, 0, 200],
|
| 121 |
+
'id': 23,
|
| 122 |
+
'isthing': 1,
|
| 123 |
+
'name': 'Other Rider',
|
| 124 |
+
'supercategory': 'human--rider--other-rider'},
|
| 125 |
+
{'color': [200, 128, 128],
|
| 126 |
+
'id': 24,
|
| 127 |
+
'isthing': 1,
|
| 128 |
+
'name': 'Lane Marking - Crosswalk',
|
| 129 |
+
'supercategory': 'marking--crosswalk-zebra'},
|
| 130 |
+
{'color': [255, 255, 255],
|
| 131 |
+
'id': 25,
|
| 132 |
+
'isthing': 0,
|
| 133 |
+
'name': 'Lane Marking - General',
|
| 134 |
+
'supercategory': 'marking--general'},
|
| 135 |
+
{'color': [64, 170, 64],
|
| 136 |
+
'id': 26,
|
| 137 |
+
'isthing': 0,
|
| 138 |
+
'name': 'Mountain',
|
| 139 |
+
'supercategory': 'nature--mountain'},
|
| 140 |
+
{'color': [230, 160, 50],
|
| 141 |
+
'id': 27,
|
| 142 |
+
'isthing': 0,
|
| 143 |
+
'name': 'Sand',
|
| 144 |
+
'supercategory': 'nature--sand'},
|
| 145 |
+
{'color': [70, 130, 180],
|
| 146 |
+
'id': 28,
|
| 147 |
+
'isthing': 0,
|
| 148 |
+
'name': 'Sky',
|
| 149 |
+
'supercategory': 'nature--sky'},
|
| 150 |
+
{'color': [190, 255, 255],
|
| 151 |
+
'id': 29,
|
| 152 |
+
'isthing': 0,
|
| 153 |
+
'name': 'Snow',
|
| 154 |
+
'supercategory': 'nature--snow'},
|
| 155 |
+
{'color': [152, 251, 152],
|
| 156 |
+
'id': 30,
|
| 157 |
+
'isthing': 0,
|
| 158 |
+
'name': 'Terrain',
|
| 159 |
+
'supercategory': 'nature--terrain'},
|
| 160 |
+
{'color': [107, 142, 35],
|
| 161 |
+
'id': 31,
|
| 162 |
+
'isthing': 0,
|
| 163 |
+
'name': 'Vegetation',
|
| 164 |
+
'supercategory': 'nature--vegetation'},
|
| 165 |
+
{'color': [0, 170, 30],
|
| 166 |
+
'id': 32,
|
| 167 |
+
'isthing': 0,
|
| 168 |
+
'name': 'Water',
|
| 169 |
+
'supercategory': 'nature--water'},
|
| 170 |
+
{'color': [255, 255, 128],
|
| 171 |
+
'id': 33,
|
| 172 |
+
'isthing': 1,
|
| 173 |
+
'name': 'Banner',
|
| 174 |
+
'supercategory': 'object--banner'},
|
| 175 |
+
{'color': [250, 0, 30],
|
| 176 |
+
'id': 34,
|
| 177 |
+
'isthing': 1,
|
| 178 |
+
'name': 'Bench',
|
| 179 |
+
'supercategory': 'object--bench'},
|
| 180 |
+
{'color': [100, 140, 180],
|
| 181 |
+
'id': 35,
|
| 182 |
+
'isthing': 1,
|
| 183 |
+
'name': 'Bike Rack',
|
| 184 |
+
'supercategory': 'object--bike-rack'},
|
| 185 |
+
{'color': [220, 220, 220],
|
| 186 |
+
'id': 36,
|
| 187 |
+
'isthing': 1,
|
| 188 |
+
'name': 'Billboard',
|
| 189 |
+
'supercategory': 'object--billboard'},
|
| 190 |
+
{'color': [220, 128, 128],
|
| 191 |
+
'id': 37,
|
| 192 |
+
'isthing': 1,
|
| 193 |
+
'name': 'Catch Basin',
|
| 194 |
+
'supercategory': 'object--catch-basin'},
|
| 195 |
+
{'color': [222, 40, 40],
|
| 196 |
+
'id': 38,
|
| 197 |
+
'isthing': 1,
|
| 198 |
+
'name': 'CCTV Camera',
|
| 199 |
+
'supercategory': 'object--cctv-camera'},
|
| 200 |
+
{'color': [100, 170, 30],
|
| 201 |
+
'id': 39,
|
| 202 |
+
'isthing': 1,
|
| 203 |
+
'name': 'Fire Hydrant',
|
| 204 |
+
'supercategory': 'object--fire-hydrant'},
|
| 205 |
+
{'color': [40, 40, 40],
|
| 206 |
+
'id': 40,
|
| 207 |
+
'isthing': 1,
|
| 208 |
+
'name': 'Junction Box',
|
| 209 |
+
'supercategory': 'object--junction-box'},
|
| 210 |
+
{'color': [33, 33, 33],
|
| 211 |
+
'id': 41,
|
| 212 |
+
'isthing': 1,
|
| 213 |
+
'name': 'Mailbox',
|
| 214 |
+
'supercategory': 'object--mailbox'},
|
| 215 |
+
{'color': [100, 128, 160],
|
| 216 |
+
'id': 42,
|
| 217 |
+
'isthing': 1,
|
| 218 |
+
'name': 'Manhole',
|
| 219 |
+
'supercategory': 'object--manhole'},
|
| 220 |
+
{'color': [142, 0, 0],
|
| 221 |
+
'id': 43,
|
| 222 |
+
'isthing': 1,
|
| 223 |
+
'name': 'Phone Booth',
|
| 224 |
+
'supercategory': 'object--phone-booth'},
|
| 225 |
+
{'color': [70, 100, 150],
|
| 226 |
+
'id': 44,
|
| 227 |
+
'isthing': 0,
|
| 228 |
+
'name': 'Pothole',
|
| 229 |
+
'supercategory': 'object--pothole'},
|
| 230 |
+
{'color': [210, 170, 100],
|
| 231 |
+
'id': 45,
|
| 232 |
+
'isthing': 1,
|
| 233 |
+
'name': 'Street Light',
|
| 234 |
+
'supercategory': 'object--street-light'},
|
| 235 |
+
{'color': [153, 153, 153],
|
| 236 |
+
'id': 46,
|
| 237 |
+
'isthing': 1,
|
| 238 |
+
'name': 'Pole',
|
| 239 |
+
'supercategory': 'object--support--pole'},
|
| 240 |
+
{'color': [128, 128, 128],
|
| 241 |
+
'id': 47,
|
| 242 |
+
'isthing': 1,
|
| 243 |
+
'name': 'Traffic Sign Frame',
|
| 244 |
+
'supercategory': 'object--support--traffic-sign-frame'},
|
| 245 |
+
{'color': [0, 0, 80],
|
| 246 |
+
'id': 48,
|
| 247 |
+
'isthing': 1,
|
| 248 |
+
'name': 'Utility Pole',
|
| 249 |
+
'supercategory': 'object--support--utility-pole'},
|
| 250 |
+
{'color': [250, 170, 30],
|
| 251 |
+
'id': 49,
|
| 252 |
+
'isthing': 1,
|
| 253 |
+
'name': 'Traffic Light',
|
| 254 |
+
'supercategory': 'object--traffic-light'},
|
| 255 |
+
{'color': [192, 192, 192],
|
| 256 |
+
'id': 50,
|
| 257 |
+
'isthing': 1,
|
| 258 |
+
'name': 'Traffic Sign (Back)',
|
| 259 |
+
'supercategory': 'object--traffic-sign--back'},
|
| 260 |
+
{'color': [220, 220, 0],
|
| 261 |
+
'id': 51,
|
| 262 |
+
'isthing': 1,
|
| 263 |
+
'name': 'Traffic Sign (Front)',
|
| 264 |
+
'supercategory': 'object--traffic-sign--front'},
|
| 265 |
+
{'color': [140, 140, 20],
|
| 266 |
+
'id': 52,
|
| 267 |
+
'isthing': 1,
|
| 268 |
+
'name': 'Trash Can',
|
| 269 |
+
'supercategory': 'object--trash-can'},
|
| 270 |
+
{'color': [119, 11, 32],
|
| 271 |
+
'id': 53,
|
| 272 |
+
'isthing': 1,
|
| 273 |
+
'name': 'Bicycle',
|
| 274 |
+
'supercategory': 'object--vehicle--bicycle'},
|
| 275 |
+
{'color': [150, 0, 255],
|
| 276 |
+
'id': 54,
|
| 277 |
+
'isthing': 1,
|
| 278 |
+
'name': 'Boat',
|
| 279 |
+
'supercategory': 'object--vehicle--boat'},
|
| 280 |
+
{'color': [0, 60, 100],
|
| 281 |
+
'id': 55,
|
| 282 |
+
'isthing': 1,
|
| 283 |
+
'name': 'Bus',
|
| 284 |
+
'supercategory': 'object--vehicle--bus'},
|
| 285 |
+
{'color': [0, 0, 142],
|
| 286 |
+
'id': 56,
|
| 287 |
+
'isthing': 1,
|
| 288 |
+
'name': 'Car',
|
| 289 |
+
'supercategory': 'object--vehicle--car'},
|
| 290 |
+
{'color': [0, 0, 90],
|
| 291 |
+
'id': 57,
|
| 292 |
+
'isthing': 1,
|
| 293 |
+
'name': 'Caravan',
|
| 294 |
+
'supercategory': 'object--vehicle--caravan'},
|
| 295 |
+
{'color': [0, 0, 230],
|
| 296 |
+
'id': 58,
|
| 297 |
+
'isthing': 1,
|
| 298 |
+
'name': 'Motorcycle',
|
| 299 |
+
'supercategory': 'object--vehicle--motorcycle'},
|
| 300 |
+
{'color': [0, 80, 100],
|
| 301 |
+
'id': 59,
|
| 302 |
+
'isthing': 0,
|
| 303 |
+
'name': 'On Rails',
|
| 304 |
+
'supercategory': 'object--vehicle--on-rails'},
|
| 305 |
+
{'color': [128, 64, 64],
|
| 306 |
+
'id': 60,
|
| 307 |
+
'isthing': 1,
|
| 308 |
+
'name': 'Other Vehicle',
|
| 309 |
+
'supercategory': 'object--vehicle--other-vehicle'},
|
| 310 |
+
{'color': [0, 0, 110],
|
| 311 |
+
'id': 61,
|
| 312 |
+
'isthing': 1,
|
| 313 |
+
'name': 'Trailer',
|
| 314 |
+
'supercategory': 'object--vehicle--trailer'},
|
| 315 |
+
{'color': [0, 0, 70],
|
| 316 |
+
'id': 62,
|
| 317 |
+
'isthing': 1,
|
| 318 |
+
'name': 'Truck',
|
| 319 |
+
'supercategory': 'object--vehicle--truck'},
|
| 320 |
+
{'color': [0, 0, 192],
|
| 321 |
+
'id': 63,
|
| 322 |
+
'isthing': 1,
|
| 323 |
+
'name': 'Wheeled Slow',
|
| 324 |
+
'supercategory': 'object--vehicle--wheeled-slow'},
|
| 325 |
+
{'color': [32, 32, 32],
|
| 326 |
+
'id': 64,
|
| 327 |
+
'isthing': 0,
|
| 328 |
+
'name': 'Car Mount',
|
| 329 |
+
'supercategory': 'void--car-mount'},
|
| 330 |
+
{'color': [120, 10, 10],
|
| 331 |
+
'id': 65,
|
| 332 |
+
'isthing': 0,
|
| 333 |
+
'name': 'Ego Vehicle',
|
| 334 |
+
'supercategory': 'void--ego-vehicle'}
|
| 335 |
+
]
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
def load_mapillary_vistas_panoptic_json(json_file, image_dir, gt_dir, semseg_dir, meta):
|
| 339 |
+
"""
|
| 340 |
+
Args:
|
| 341 |
+
image_dir (str): path to the raw dataset. e.g., "~/coco/train2017".
|
| 342 |
+
gt_dir (str): path to the raw annotations. e.g., "~/coco/panoptic_train2017".
|
| 343 |
+
json_file (str): path to the json file. e.g., "~/coco/annotations/panoptic_train2017.json".
|
| 344 |
+
Returns:
|
| 345 |
+
list[dict]: a list of dicts in Detectron2 standard format. (See
|
| 346 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ )
|
| 347 |
+
"""
|
| 348 |
+
|
| 349 |
+
def _convert_category_id(segment_info, meta):
|
| 350 |
+
if segment_info["category_id"] in meta["thing_dataset_id_to_contiguous_id"]:
|
| 351 |
+
segment_info["category_id"] = meta["thing_dataset_id_to_contiguous_id"][
|
| 352 |
+
segment_info["category_id"]
|
| 353 |
+
]
|
| 354 |
+
segment_info["isthing"] = True
|
| 355 |
+
else:
|
| 356 |
+
segment_info["category_id"] = meta["stuff_dataset_id_to_contiguous_id"][
|
| 357 |
+
segment_info["category_id"]
|
| 358 |
+
]
|
| 359 |
+
segment_info["isthing"] = False
|
| 360 |
+
return segment_info
|
| 361 |
+
|
| 362 |
+
with PathManager.open(json_file) as f:
|
| 363 |
+
json_info = json.load(f)
|
| 364 |
+
|
| 365 |
+
ret = []
|
| 366 |
+
for ann in json_info["annotations"]:
|
| 367 |
+
image_id = ann["image_id"]
|
| 368 |
+
# TODO: currently we assume image and label has the same filename but
|
| 369 |
+
# different extension, and images have extension ".jpg" for COCO. Need
|
| 370 |
+
# to make image extension a user-provided argument if we extend this
|
| 371 |
+
# function to support other COCO-like datasets.
|
| 372 |
+
image_file = os.path.join(image_dir, os.path.splitext(ann["file_name"])[0] + ".jpg")
|
| 373 |
+
label_file = os.path.join(gt_dir, ann["file_name"])
|
| 374 |
+
sem_label_file = os.path.join(semseg_dir, ann["file_name"])
|
| 375 |
+
segments_info = [_convert_category_id(x, meta) for x in ann["segments_info"]]
|
| 376 |
+
ret.append(
|
| 377 |
+
{
|
| 378 |
+
"file_name": image_file,
|
| 379 |
+
"image_id": image_id,
|
| 380 |
+
"pan_seg_file_name": label_file,
|
| 381 |
+
"sem_seg_file_name": sem_label_file,
|
| 382 |
+
"segments_info": segments_info,
|
| 383 |
+
}
|
| 384 |
+
)
|
| 385 |
+
assert len(ret), f"No images found in {image_dir}!"
|
| 386 |
+
assert PathManager.isfile(ret[0]["file_name"]), ret[0]["file_name"]
|
| 387 |
+
assert PathManager.isfile(ret[0]["pan_seg_file_name"]), ret[0]["pan_seg_file_name"]
|
| 388 |
+
assert PathManager.isfile(ret[0]["sem_seg_file_name"]), ret[0]["sem_seg_file_name"]
|
| 389 |
+
return ret
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
def register_mapillary_vistas_panoptic(
|
| 393 |
+
name, metadata, image_root, panoptic_root, semantic_root, panoptic_json, instances_json=None
|
| 394 |
+
):
|
| 395 |
+
"""
|
| 396 |
+
Register a "standard" version of ADE20k panoptic segmentation dataset named `name`.
|
| 397 |
+
The dictionaries in this registered dataset follows detectron2's standard format.
|
| 398 |
+
Hence it's called "standard".
|
| 399 |
+
Args:
|
| 400 |
+
name (str): the name that identifies a dataset,
|
| 401 |
+
e.g. "ade20k_panoptic_train"
|
| 402 |
+
metadata (dict): extra metadata associated with this dataset.
|
| 403 |
+
image_root (str): directory which contains all the images
|
| 404 |
+
panoptic_root (str): directory which contains panoptic annotation images in COCO format
|
| 405 |
+
panoptic_json (str): path to the json panoptic annotation file in COCO format
|
| 406 |
+
sem_seg_root (none): not used, to be consistent with
|
| 407 |
+
`register_coco_panoptic_separated`.
|
| 408 |
+
instances_json (str): path to the json instance annotation file
|
| 409 |
+
"""
|
| 410 |
+
panoptic_name = name
|
| 411 |
+
DatasetCatalog.register(
|
| 412 |
+
panoptic_name,
|
| 413 |
+
lambda: load_mapillary_vistas_panoptic_json(
|
| 414 |
+
panoptic_json, image_root, panoptic_root, semantic_root, metadata
|
| 415 |
+
),
|
| 416 |
+
)
|
| 417 |
+
MetadataCatalog.get(panoptic_name).set(
|
| 418 |
+
panoptic_root=panoptic_root,
|
| 419 |
+
image_root=image_root,
|
| 420 |
+
panoptic_json=panoptic_json,
|
| 421 |
+
json_file=instances_json,
|
| 422 |
+
evaluator_type="mapillary_vistas_panoptic_seg",
|
| 423 |
+
ignore_label=65, # different from other datasets, Mapillary Vistas sets ignore_label to 65
|
| 424 |
+
label_divisor=1000,
|
| 425 |
+
**metadata,
|
| 426 |
+
)
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
_PREDEFINED_SPLITS_ADE20K_PANOPTIC = {
|
| 430 |
+
"mapillary_vistas_panoptic_train": (
|
| 431 |
+
"mapillary_vistas/training/images",
|
| 432 |
+
"mapillary_vistas/training/panoptic",
|
| 433 |
+
"mapillary_vistas/training/panoptic/panoptic_2018.json",
|
| 434 |
+
"mapillary_vistas/training/labels",
|
| 435 |
+
),
|
| 436 |
+
"mapillary_vistas_panoptic_val": (
|
| 437 |
+
"mapillary_vistas/validation/images",
|
| 438 |
+
"mapillary_vistas/validation/panoptic",
|
| 439 |
+
"mapillary_vistas/validation/panoptic/panoptic_2018.json",
|
| 440 |
+
"mapillary_vistas/validation/labels",
|
| 441 |
+
),
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
def get_metadata():
|
| 446 |
+
meta = {}
|
| 447 |
+
# The following metadata maps contiguous id from [0, #thing categories +
|
| 448 |
+
# #stuff categories) to their names and colors. We have to replica of the
|
| 449 |
+
# same name and color under "thing_*" and "stuff_*" because the current
|
| 450 |
+
# visualization function in D2 handles thing and class classes differently
|
| 451 |
+
# due to some heuristic used in Panoptic FPN. We keep the same naming to
|
| 452 |
+
# enable reusing existing visualization functions.
|
| 453 |
+
thing_classes = [k["name"] for k in MAPILLARY_VISTAS_SEM_SEG_CATEGORIES]
|
| 454 |
+
thing_colors = [k["color"] for k in MAPILLARY_VISTAS_SEM_SEG_CATEGORIES]
|
| 455 |
+
stuff_classes = [k["name"] for k in MAPILLARY_VISTAS_SEM_SEG_CATEGORIES]
|
| 456 |
+
stuff_colors = [k["color"] for k in MAPILLARY_VISTAS_SEM_SEG_CATEGORIES]
|
| 457 |
+
|
| 458 |
+
meta["thing_classes"] = thing_classes
|
| 459 |
+
meta["thing_colors"] = thing_colors
|
| 460 |
+
meta["stuff_classes"] = stuff_classes
|
| 461 |
+
meta["stuff_colors"] = stuff_colors
|
| 462 |
+
|
| 463 |
+
# Convert category id for training:
|
| 464 |
+
# category id: like semantic segmentation, it is the class id for each
|
| 465 |
+
# pixel. Since there are some classes not used in evaluation, the category
|
| 466 |
+
# id is not always contiguous and thus we have two set of category ids:
|
| 467 |
+
# - original category id: category id in the original dataset, mainly
|
| 468 |
+
# used for evaluation.
|
| 469 |
+
# - contiguous category id: [0, #classes), in order to train the linear
|
| 470 |
+
# softmax classifier.
|
| 471 |
+
thing_dataset_id_to_contiguous_id = {}
|
| 472 |
+
stuff_dataset_id_to_contiguous_id = {}
|
| 473 |
+
|
| 474 |
+
for i, cat in enumerate(MAPILLARY_VISTAS_SEM_SEG_CATEGORIES):
|
| 475 |
+
if cat["isthing"]:
|
| 476 |
+
thing_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 477 |
+
# else:
|
| 478 |
+
# stuff_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 479 |
+
|
| 480 |
+
# in order to use sem_seg evaluator
|
| 481 |
+
stuff_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 482 |
+
|
| 483 |
+
meta["thing_dataset_id_to_contiguous_id"] = thing_dataset_id_to_contiguous_id
|
| 484 |
+
meta["stuff_dataset_id_to_contiguous_id"] = stuff_dataset_id_to_contiguous_id
|
| 485 |
+
|
| 486 |
+
return meta
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
def register_all_mapillary_vistas_panoptic(root):
|
| 490 |
+
metadata = get_metadata()
|
| 491 |
+
for (
|
| 492 |
+
prefix,
|
| 493 |
+
(image_root, panoptic_root, panoptic_json, semantic_root),
|
| 494 |
+
) in _PREDEFINED_SPLITS_ADE20K_PANOPTIC.items():
|
| 495 |
+
# The "standard" version of COCO panoptic segmentation dataset,
|
| 496 |
+
# e.g. used by Panoptic-DeepLab
|
| 497 |
+
register_mapillary_vistas_panoptic(
|
| 498 |
+
prefix,
|
| 499 |
+
metadata,
|
| 500 |
+
os.path.join(root, image_root),
|
| 501 |
+
os.path.join(root, panoptic_root),
|
| 502 |
+
os.path.join(root, semantic_root),
|
| 503 |
+
os.path.join(root, panoptic_json),
|
| 504 |
+
)
|
| 505 |
+
|
| 506 |
+
|
| 507 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 508 |
+
register_all_mapillary_vistas_panoptic(_root)
|
MaskClustering/third_party/detectron2/configs/common/data/coco.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from omegaconf import OmegaConf
|
| 2 |
+
|
| 3 |
+
import detectron2.data.transforms as T
|
| 4 |
+
from detectron2.config import LazyCall as L
|
| 5 |
+
from detectron2.data import (
|
| 6 |
+
DatasetMapper,
|
| 7 |
+
build_detection_test_loader,
|
| 8 |
+
build_detection_train_loader,
|
| 9 |
+
get_detection_dataset_dicts,
|
| 10 |
+
)
|
| 11 |
+
from detectron2.evaluation import COCOEvaluator
|
| 12 |
+
|
| 13 |
+
dataloader = OmegaConf.create()
|
| 14 |
+
|
| 15 |
+
dataloader.train = L(build_detection_train_loader)(
|
| 16 |
+
dataset=L(get_detection_dataset_dicts)(names="coco_2017_train"),
|
| 17 |
+
mapper=L(DatasetMapper)(
|
| 18 |
+
is_train=True,
|
| 19 |
+
augmentations=[
|
| 20 |
+
L(T.ResizeShortestEdge)(
|
| 21 |
+
short_edge_length=(640, 672, 704, 736, 768, 800),
|
| 22 |
+
sample_style="choice",
|
| 23 |
+
max_size=1333,
|
| 24 |
+
),
|
| 25 |
+
L(T.RandomFlip)(horizontal=True),
|
| 26 |
+
],
|
| 27 |
+
image_format="BGR",
|
| 28 |
+
use_instance_mask=True,
|
| 29 |
+
),
|
| 30 |
+
total_batch_size=16,
|
| 31 |
+
num_workers=4,
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
dataloader.test = L(build_detection_test_loader)(
|
| 35 |
+
dataset=L(get_detection_dataset_dicts)(names="coco_2017_val", filter_empty=False),
|
| 36 |
+
mapper=L(DatasetMapper)(
|
| 37 |
+
is_train=False,
|
| 38 |
+
augmentations=[
|
| 39 |
+
L(T.ResizeShortestEdge)(short_edge_length=800, max_size=1333),
|
| 40 |
+
],
|
| 41 |
+
image_format="${...train.mapper.image_format}",
|
| 42 |
+
),
|
| 43 |
+
num_workers=4,
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
dataloader.evaluator = L(COCOEvaluator)(
|
| 47 |
+
dataset_name="${..test.dataset.names}",
|
| 48 |
+
)
|
MaskClustering/third_party/detectron2/configs/common/data/coco_keypoint.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from detectron2.data.detection_utils import create_keypoint_hflip_indices
|
| 2 |
+
|
| 3 |
+
from .coco import dataloader
|
| 4 |
+
|
| 5 |
+
dataloader.train.dataset.min_keypoints = 1
|
| 6 |
+
dataloader.train.dataset.names = "keypoints_coco_2017_train"
|
| 7 |
+
dataloader.test.dataset.names = "keypoints_coco_2017_val"
|
| 8 |
+
|
| 9 |
+
dataloader.train.mapper.update(
|
| 10 |
+
use_instance_mask=False,
|
| 11 |
+
use_keypoint=True,
|
| 12 |
+
keypoint_hflip_indices=create_keypoint_hflip_indices(dataloader.train.dataset.names),
|
| 13 |
+
)
|
MaskClustering/third_party/detectron2/configs/common/data/coco_panoptic_separated.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from detectron2.config import LazyCall as L
|
| 2 |
+
from detectron2.evaluation import (
|
| 3 |
+
COCOEvaluator,
|
| 4 |
+
COCOPanopticEvaluator,
|
| 5 |
+
DatasetEvaluators,
|
| 6 |
+
SemSegEvaluator,
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
from .coco import dataloader
|
| 10 |
+
|
| 11 |
+
dataloader.train.dataset.names = "coco_2017_train_panoptic_separated"
|
| 12 |
+
dataloader.train.dataset.filter_empty = False
|
| 13 |
+
dataloader.test.dataset.names = "coco_2017_val_panoptic_separated"
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
dataloader.evaluator = [
|
| 17 |
+
L(COCOEvaluator)(
|
| 18 |
+
dataset_name="${...test.dataset.names}",
|
| 19 |
+
),
|
| 20 |
+
L(SemSegEvaluator)(
|
| 21 |
+
dataset_name="${...test.dataset.names}",
|
| 22 |
+
),
|
| 23 |
+
L(COCOPanopticEvaluator)(
|
| 24 |
+
dataset_name="${...test.dataset.names}",
|
| 25 |
+
),
|
| 26 |
+
]
|
MaskClustering/third_party/detectron2/configs/common/data/constants.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
constants = dict(
|
| 2 |
+
imagenet_rgb256_mean=[123.675, 116.28, 103.53],
|
| 3 |
+
imagenet_rgb256_std=[58.395, 57.12, 57.375],
|
| 4 |
+
imagenet_bgr256_mean=[103.530, 116.280, 123.675],
|
| 5 |
+
# When using pre-trained models in Detectron1 or any MSRA models,
|
| 6 |
+
# std has been absorbed into its conv1 weights, so the std needs to be set 1.
|
| 7 |
+
# Otherwise, you can use [57.375, 57.120, 58.395] (ImageNet std)
|
| 8 |
+
imagenet_bgr256_std=[1.0, 1.0, 1.0],
|
| 9 |
+
)
|
MaskClustering/third_party/detectron2/detectron2/data/__init__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
from . import transforms # isort:skip
|
| 3 |
+
|
| 4 |
+
from .build import (
|
| 5 |
+
build_batch_data_loader,
|
| 6 |
+
build_detection_test_loader,
|
| 7 |
+
build_detection_train_loader,
|
| 8 |
+
get_detection_dataset_dicts,
|
| 9 |
+
load_proposals_into_dataset,
|
| 10 |
+
print_instances_class_histogram,
|
| 11 |
+
)
|
| 12 |
+
from .catalog import DatasetCatalog, MetadataCatalog, Metadata
|
| 13 |
+
from .common import DatasetFromList, MapDataset, ToIterableDataset
|
| 14 |
+
from .dataset_mapper import DatasetMapper
|
| 15 |
+
|
| 16 |
+
# ensure the builtin datasets are registered
|
| 17 |
+
from . import datasets, samplers # isort:skip
|
| 18 |
+
|
| 19 |
+
__all__ = [k for k in globals().keys() if not k.startswith("_")]
|
MaskClustering/third_party/detectron2/detectron2/data/benchmark.py
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import logging
|
| 3 |
+
import numpy as np
|
| 4 |
+
from itertools import count
|
| 5 |
+
from typing import List, Tuple
|
| 6 |
+
import torch
|
| 7 |
+
import tqdm
|
| 8 |
+
from fvcore.common.timer import Timer
|
| 9 |
+
|
| 10 |
+
from detectron2.utils import comm
|
| 11 |
+
|
| 12 |
+
from .build import build_batch_data_loader
|
| 13 |
+
from .common import DatasetFromList, MapDataset
|
| 14 |
+
from .samplers import TrainingSampler
|
| 15 |
+
|
| 16 |
+
logger = logging.getLogger(__name__)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class _EmptyMapDataset(torch.utils.data.Dataset):
|
| 20 |
+
"""
|
| 21 |
+
Map anything to emptiness.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
def __init__(self, dataset):
|
| 25 |
+
self.ds = dataset
|
| 26 |
+
|
| 27 |
+
def __len__(self):
|
| 28 |
+
return len(self.ds)
|
| 29 |
+
|
| 30 |
+
def __getitem__(self, idx):
|
| 31 |
+
_ = self.ds[idx]
|
| 32 |
+
return [0]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def iter_benchmark(
|
| 36 |
+
iterator, num_iter: int, warmup: int = 5, max_time_seconds: float = 60
|
| 37 |
+
) -> Tuple[float, List[float]]:
|
| 38 |
+
"""
|
| 39 |
+
Benchmark an iterator/iterable for `num_iter` iterations with an extra
|
| 40 |
+
`warmup` iterations of warmup.
|
| 41 |
+
End early if `max_time_seconds` time is spent on iterations.
|
| 42 |
+
|
| 43 |
+
Returns:
|
| 44 |
+
float: average time (seconds) per iteration
|
| 45 |
+
list[float]: time spent on each iteration. Sometimes useful for further analysis.
|
| 46 |
+
"""
|
| 47 |
+
num_iter, warmup = int(num_iter), int(warmup)
|
| 48 |
+
|
| 49 |
+
iterator = iter(iterator)
|
| 50 |
+
for _ in range(warmup):
|
| 51 |
+
next(iterator)
|
| 52 |
+
timer = Timer()
|
| 53 |
+
all_times = []
|
| 54 |
+
for curr_iter in tqdm.trange(num_iter):
|
| 55 |
+
start = timer.seconds()
|
| 56 |
+
if start > max_time_seconds:
|
| 57 |
+
num_iter = curr_iter
|
| 58 |
+
break
|
| 59 |
+
next(iterator)
|
| 60 |
+
all_times.append(timer.seconds() - start)
|
| 61 |
+
avg = timer.seconds() / num_iter
|
| 62 |
+
return avg, all_times
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class DataLoaderBenchmark:
|
| 66 |
+
"""
|
| 67 |
+
Some common benchmarks that help understand perf bottleneck of a standard dataloader
|
| 68 |
+
made of dataset, mapper and sampler.
|
| 69 |
+
"""
|
| 70 |
+
|
| 71 |
+
def __init__(
|
| 72 |
+
self,
|
| 73 |
+
dataset,
|
| 74 |
+
*,
|
| 75 |
+
mapper,
|
| 76 |
+
sampler=None,
|
| 77 |
+
total_batch_size,
|
| 78 |
+
num_workers=0,
|
| 79 |
+
max_time_seconds: int = 90,
|
| 80 |
+
):
|
| 81 |
+
"""
|
| 82 |
+
Args:
|
| 83 |
+
max_time_seconds (int): maximum time to spent for each benchmark
|
| 84 |
+
other args: same as in `build.py:build_detection_train_loader`
|
| 85 |
+
"""
|
| 86 |
+
if isinstance(dataset, list):
|
| 87 |
+
dataset = DatasetFromList(dataset, copy=False, serialize=True)
|
| 88 |
+
if sampler is None:
|
| 89 |
+
sampler = TrainingSampler(len(dataset))
|
| 90 |
+
|
| 91 |
+
self.dataset = dataset
|
| 92 |
+
self.mapper = mapper
|
| 93 |
+
self.sampler = sampler
|
| 94 |
+
self.total_batch_size = total_batch_size
|
| 95 |
+
self.num_workers = num_workers
|
| 96 |
+
self.per_gpu_batch_size = self.total_batch_size // comm.get_world_size()
|
| 97 |
+
|
| 98 |
+
self.max_time_seconds = max_time_seconds
|
| 99 |
+
|
| 100 |
+
def _benchmark(self, iterator, num_iter, warmup, msg=None):
|
| 101 |
+
avg, all_times = iter_benchmark(iterator, num_iter, warmup, self.max_time_seconds)
|
| 102 |
+
if msg is not None:
|
| 103 |
+
self._log_time(msg, avg, all_times)
|
| 104 |
+
return avg, all_times
|
| 105 |
+
|
| 106 |
+
def _log_time(self, msg, avg, all_times, distributed=False):
|
| 107 |
+
percentiles = [np.percentile(all_times, k, interpolation="nearest") for k in [1, 5, 95, 99]]
|
| 108 |
+
if not distributed:
|
| 109 |
+
logger.info(
|
| 110 |
+
f"{msg}: avg={1.0/avg:.1f} it/s, "
|
| 111 |
+
f"p1={percentiles[0]:.2g}s, p5={percentiles[1]:.2g}s, "
|
| 112 |
+
f"p95={percentiles[2]:.2g}s, p99={percentiles[3]:.2g}s."
|
| 113 |
+
)
|
| 114 |
+
return
|
| 115 |
+
avg_per_gpu = comm.all_gather(avg)
|
| 116 |
+
percentiles_per_gpu = comm.all_gather(percentiles)
|
| 117 |
+
if comm.get_rank() > 0:
|
| 118 |
+
return
|
| 119 |
+
for idx, avg, percentiles in zip(count(), avg_per_gpu, percentiles_per_gpu):
|
| 120 |
+
logger.info(
|
| 121 |
+
f"GPU{idx} {msg}: avg={1.0/avg:.1f} it/s, "
|
| 122 |
+
f"p1={percentiles[0]:.2g}s, p5={percentiles[1]:.2g}s, "
|
| 123 |
+
f"p95={percentiles[2]:.2g}s, p99={percentiles[3]:.2g}s."
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
def benchmark_dataset(self, num_iter, warmup=5):
|
| 127 |
+
"""
|
| 128 |
+
Benchmark the speed of taking raw samples from the dataset.
|
| 129 |
+
"""
|
| 130 |
+
|
| 131 |
+
def loader():
|
| 132 |
+
while True:
|
| 133 |
+
for k in self.sampler:
|
| 134 |
+
yield self.dataset[k]
|
| 135 |
+
|
| 136 |
+
self._benchmark(loader(), num_iter, warmup, "Dataset Alone")
|
| 137 |
+
|
| 138 |
+
def benchmark_mapper(self, num_iter, warmup=5):
|
| 139 |
+
"""
|
| 140 |
+
Benchmark the speed of taking raw samples from the dataset and map
|
| 141 |
+
them in a single process.
|
| 142 |
+
"""
|
| 143 |
+
|
| 144 |
+
def loader():
|
| 145 |
+
while True:
|
| 146 |
+
for k in self.sampler:
|
| 147 |
+
yield self.mapper(self.dataset[k])
|
| 148 |
+
|
| 149 |
+
self._benchmark(loader(), num_iter, warmup, "Single Process Mapper (sec/sample)")
|
| 150 |
+
|
| 151 |
+
def benchmark_workers(self, num_iter, warmup=10):
|
| 152 |
+
"""
|
| 153 |
+
Benchmark the dataloader by tuning num_workers to [0, 1, self.num_workers].
|
| 154 |
+
"""
|
| 155 |
+
candidates = [0, 1]
|
| 156 |
+
if self.num_workers not in candidates:
|
| 157 |
+
candidates.append(self.num_workers)
|
| 158 |
+
|
| 159 |
+
dataset = MapDataset(self.dataset, self.mapper)
|
| 160 |
+
for n in candidates:
|
| 161 |
+
loader = build_batch_data_loader(
|
| 162 |
+
dataset,
|
| 163 |
+
self.sampler,
|
| 164 |
+
self.total_batch_size,
|
| 165 |
+
num_workers=n,
|
| 166 |
+
)
|
| 167 |
+
self._benchmark(
|
| 168 |
+
iter(loader),
|
| 169 |
+
num_iter * max(n, 1),
|
| 170 |
+
warmup * max(n, 1),
|
| 171 |
+
f"DataLoader ({n} workers, bs={self.per_gpu_batch_size})",
|
| 172 |
+
)
|
| 173 |
+
del loader
|
| 174 |
+
|
| 175 |
+
def benchmark_IPC(self, num_iter, warmup=10):
|
| 176 |
+
"""
|
| 177 |
+
Benchmark the dataloader where each worker outputs nothing. This
|
| 178 |
+
eliminates the IPC overhead compared to the regular dataloader.
|
| 179 |
+
|
| 180 |
+
PyTorch multiprocessing's IPC only optimizes for torch tensors.
|
| 181 |
+
Large numpy arrays or other data structure may incur large IPC overhead.
|
| 182 |
+
"""
|
| 183 |
+
n = self.num_workers
|
| 184 |
+
dataset = _EmptyMapDataset(MapDataset(self.dataset, self.mapper))
|
| 185 |
+
loader = build_batch_data_loader(
|
| 186 |
+
dataset, self.sampler, self.total_batch_size, num_workers=n
|
| 187 |
+
)
|
| 188 |
+
self._benchmark(
|
| 189 |
+
iter(loader),
|
| 190 |
+
num_iter * max(n, 1),
|
| 191 |
+
warmup * max(n, 1),
|
| 192 |
+
f"DataLoader ({n} workers, bs={self.per_gpu_batch_size}) w/o comm",
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
def benchmark_distributed(self, num_iter, warmup=10):
|
| 196 |
+
"""
|
| 197 |
+
Benchmark the dataloader in each distributed worker, and log results of
|
| 198 |
+
all workers. This helps understand the final performance as well as
|
| 199 |
+
the variances among workers.
|
| 200 |
+
|
| 201 |
+
It also prints startup time (first iter) of the dataloader.
|
| 202 |
+
"""
|
| 203 |
+
gpu = comm.get_world_size()
|
| 204 |
+
dataset = MapDataset(self.dataset, self.mapper)
|
| 205 |
+
n = self.num_workers
|
| 206 |
+
loader = build_batch_data_loader(
|
| 207 |
+
dataset, self.sampler, self.total_batch_size, num_workers=n
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
timer = Timer()
|
| 211 |
+
loader = iter(loader)
|
| 212 |
+
next(loader)
|
| 213 |
+
startup_time = timer.seconds()
|
| 214 |
+
logger.info("Dataloader startup time: {:.2f} seconds".format(startup_time))
|
| 215 |
+
|
| 216 |
+
comm.synchronize()
|
| 217 |
+
|
| 218 |
+
avg, all_times = self._benchmark(loader, num_iter * max(n, 1), warmup * max(n, 1))
|
| 219 |
+
del loader
|
| 220 |
+
self._log_time(
|
| 221 |
+
f"DataLoader ({gpu} GPUs x {n} workers, total bs={self.total_batch_size})",
|
| 222 |
+
avg,
|
| 223 |
+
all_times,
|
| 224 |
+
True,
|
| 225 |
+
)
|