Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- approach/ovod/APE/ape/data/datasets/__init__.py +19 -0
- approach/ovod/APE/ape/data/datasets/coco.py +383 -0
- approach/ovod/APE/ape/data/datasets/d_cube.py +275 -0
- approach/ovod/APE/ape/data/datasets/flickr30k.py +68 -0
- approach/ovod/APE/ape/data/datasets/gqa.py +60 -0
- approach/ovod/APE/ape/data/datasets/grit.py +60 -0
- approach/ovod/APE/ape/data/datasets/inst_categories.py +488 -0
- approach/ovod/APE/ape/data/datasets/lvis_coco.py +284 -0
- approach/ovod/APE/ape/data/datasets/lvis_coco_panoptic.py +192 -0
- approach/ovod/APE/ape/data/datasets/lvis_v1_coco_category_image_count.py +20 -0
- approach/ovod/APE/ape/data/datasets/objects365.py +799 -0
- approach/ovod/APE/ape/data/datasets/odinw_categories.py +377 -0
- approach/ovod/APE/ape/data/datasets/odinw_instance.py +824 -0
- approach/ovod/APE/ape/data/datasets/odinw_prompts.py +75 -0
- approach/ovod/APE/ape/data/datasets/oid.py +1573 -0
- approach/ovod/APE/ape/data/datasets/openimages_v6_category_image_count.py +2 -0
- approach/ovod/APE/ape/data/datasets/pascal_voc_external.py +1217 -0
- approach/ovod/APE/ape/data/datasets/phrasecut.py +60 -0
- approach/ovod/APE/ape/data/datasets/refcoco.py +337 -0
- approach/ovod/APE/ape/data/datasets/register_bdd100k_panoseg.py +277 -0
- approach/ovod/APE/ape/data/datasets/register_bdd100k_semseg.py +98 -0
- approach/ovod/APE/ape/data/datasets/register_pascal_context.py +587 -0
- approach/ovod/APE/ape/data/datasets/register_voc_seg.py +64 -0
- approach/ovod/APE/ape/data/datasets/sa1b.py +44 -0
- approach/ovod/APE/ape/data/datasets/seginw_categories.py +89 -0
- approach/ovod/APE/ape/data/datasets/seginw_instance.py +142 -0
- approach/ovod/APE/ape/data/datasets/visualgenome.py +220 -0
- approach/ovod/APE/ape/data/datasets/visualgenome_categories.py +0 -0
- approach/ovod/APE/ape/data/samplers/__init__.py +5 -0
- approach/ovod/APE/ape/data/samplers/distributed_sampler_multi_dataset.py +137 -0
- approach/ovod/APE/ape/data/transforms/__init__.py +5 -0
- approach/ovod/APE/ape/data/transforms/augmentation_aa.py +39 -0
- approach/ovod/APE/ape/data/transforms/augmentation_lsj.py +38 -0
- approach/ovod/APE/ape/modeling/backbone/__init__.py +0 -0
- approach/ovod/APE/ape/modeling/backbone/utils_eva.py +222 -0
- approach/ovod/APE/ape/modeling/backbone/utils_eva02.py +347 -0
- approach/ovod/APE/ape/modeling/backbone/vit.py +30 -0
- approach/ovod/APE/ape/modeling/backbone/vit_eva.py +644 -0
- approach/ovod/APE/ape/modeling/backbone/vit_eva02.py +625 -0
- approach/ovod/APE/ape/modeling/backbone/vit_eva_clip.py +931 -0
- approach/ovod/APE/ape/modeling/text/bert_wrapper.py +107 -0
- approach/ovod/APE/ape/modeling/text/clip_wrapper.py +224 -0
- approach/ovod/APE/ape/modeling/text/clip_wrapper_eva02.py +148 -0
- approach/ovod/APE/ape/modeling/text/eva01_clip/README.md +79 -0
- approach/ovod/APE/ape/modeling/text/eva01_clip/__init__.py +7 -0
- approach/ovod/APE/ape/modeling/text/eva01_clip/clip.py +232 -0
- approach/ovod/APE/ape/modeling/text/eva01_clip/eva_clip.py +173 -0
- approach/ovod/APE/ape/modeling/text/eva01_clip/eva_model.py +368 -0
- approach/ovod/APE/ape/modeling/text/eva01_clip/model.py +471 -0
- approach/ovod/APE/ape/modeling/text/eva01_clip/model_configs/EVA_CLIP_g_14.json +19 -0
approach/ovod/APE/ape/data/datasets/__init__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from . import d_cube as _d_cube
|
| 2 |
+
from . import flickr30k as _flickr30k
|
| 3 |
+
from . import gqa as _gqa
|
| 4 |
+
from . import grit as _grit
|
| 5 |
+
from . import lvis_coco as _lvis_coco
|
| 6 |
+
from . import lvis_coco_panoptic as _lvis_coco_panoptic
|
| 7 |
+
from . import objects365 as _objects365
|
| 8 |
+
from . import odinw_instance as _odinw_instance
|
| 9 |
+
from . import oid as _oid
|
| 10 |
+
from . import pascal_voc_external as _pascal_voc_external
|
| 11 |
+
from . import phrasecut as _phrasecut
|
| 12 |
+
from . import refcoco as _refcoco
|
| 13 |
+
from . import register_bdd100k_panoseg as _register_bdd100k_panoseg
|
| 14 |
+
from . import register_bdd100k_semseg as _register_bdd100k_semseg
|
| 15 |
+
from . import register_pascal_context as _register_pascal_context
|
| 16 |
+
from . import register_voc_seg as _register_voc_seg
|
| 17 |
+
from . import sa1b as _sa1b
|
| 18 |
+
from . import seginw_instance as _seginw_instance
|
| 19 |
+
from . import visualgenome as _visualgenome
|
approach/ovod/APE/ape/data/datasets/coco.py
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import io
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
import pycocotools.mask as mask_util
|
| 7 |
+
|
| 8 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 9 |
+
from detectron2.structures import BoxMode
|
| 10 |
+
from detectron2.utils.file_io import PathManager
|
| 11 |
+
from fvcore.common.timer import Timer
|
| 12 |
+
|
| 13 |
+
"""
|
| 14 |
+
This file contains functions to parse COCO-format annotations into dicts in "Detectron2 format".
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
logger = logging.getLogger(__name__)
|
| 19 |
+
|
| 20 |
+
__all__ = ["custom_load_coco_json", "custom_register_coco_instances"]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def custom_load_coco_json(json_file, image_root, dataset_name=None, extra_annotation_keys=None):
|
| 24 |
+
"""
|
| 25 |
+
Load a json file with COCO's instances annotation format.
|
| 26 |
+
Currently supports instance detection, instance segmentation,
|
| 27 |
+
and person keypoints annotations.
|
| 28 |
+
|
| 29 |
+
Args:
|
| 30 |
+
json_file (str): full path to the json file in COCO instances annotation format.
|
| 31 |
+
image_root (str or path-like): the directory where the images in this json file exists.
|
| 32 |
+
dataset_name (str or None): the name of the dataset (e.g., coco_2017_train).
|
| 33 |
+
When provided, this function will also do the following:
|
| 34 |
+
|
| 35 |
+
* Put "thing_classes" into the metadata associated with this dataset.
|
| 36 |
+
* Map the category ids into a contiguous range (needed by standard dataset format),
|
| 37 |
+
and add "thing_dataset_id_to_contiguous_id" to the metadata associated
|
| 38 |
+
with this dataset.
|
| 39 |
+
|
| 40 |
+
This option should usually be provided, unless users need to load
|
| 41 |
+
the original json content and apply more processing manually.
|
| 42 |
+
extra_annotation_keys (list[str]): list of per-annotation keys that should also be
|
| 43 |
+
loaded into the dataset dict (besides "iscrowd", "bbox", "keypoints",
|
| 44 |
+
"category_id", "segmentation"). The values for these keys will be returned as-is.
|
| 45 |
+
For example, the densepose annotations are loaded in this way.
|
| 46 |
+
|
| 47 |
+
Returns:
|
| 48 |
+
list[dict]: a list of dicts in Detectron2 standard dataset dicts format (See
|
| 49 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ ) when `dataset_name` is not None.
|
| 50 |
+
If `dataset_name` is None, the returned `category_ids` may be
|
| 51 |
+
incontiguous and may not conform to the Detectron2 standard format.
|
| 52 |
+
|
| 53 |
+
Notes:
|
| 54 |
+
1. This function does not read the image files.
|
| 55 |
+
The results do not have the "image" field.
|
| 56 |
+
"""
|
| 57 |
+
from pycocotools.coco import COCO
|
| 58 |
+
|
| 59 |
+
timer = Timer()
|
| 60 |
+
json_file = PathManager.get_local_path(json_file)
|
| 61 |
+
with contextlib.redirect_stdout(io.StringIO()):
|
| 62 |
+
coco_api = COCO(json_file)
|
| 63 |
+
if timer.seconds() > 1:
|
| 64 |
+
logger.info("Loading {} takes {:.2f} seconds.".format(json_file, timer.seconds()))
|
| 65 |
+
|
| 66 |
+
id_map = None
|
| 67 |
+
if dataset_name is not None:
|
| 68 |
+
meta = MetadataCatalog.get(dataset_name)
|
| 69 |
+
cat_ids = sorted(coco_api.getCatIds())
|
| 70 |
+
cats = coco_api.loadCats(cat_ids)
|
| 71 |
+
# The categories in a custom json file may not be sorted.
|
| 72 |
+
thing_classes = [c["name"] for c in sorted(cats, key=lambda x: x["id"])]
|
| 73 |
+
meta.thing_classes = thing_classes
|
| 74 |
+
|
| 75 |
+
# In COCO, certain category ids are artificially removed,
|
| 76 |
+
# and by convention they are always ignored.
|
| 77 |
+
# We deal with COCO's id issue and translate
|
| 78 |
+
# the category ids to contiguous ids in [0, 80).
|
| 79 |
+
|
| 80 |
+
# It works by looking at the "categories" field in the json, therefore
|
| 81 |
+
# if users' own json also have incontiguous ids, we'll
|
| 82 |
+
# apply this mapping as well but print a warning.
|
| 83 |
+
if not (min(cat_ids) == 1 and max(cat_ids) == len(cat_ids)):
|
| 84 |
+
if "coco" not in dataset_name:
|
| 85 |
+
logger.warning(
|
| 86 |
+
"""
|
| 87 |
+
Category ids in annotations are not in [1, #categories]! We'll apply a mapping for you.
|
| 88 |
+
"""
|
| 89 |
+
)
|
| 90 |
+
id_map = {v: i for i, v in enumerate(cat_ids)}
|
| 91 |
+
meta.thing_dataset_id_to_contiguous_id = id_map
|
| 92 |
+
|
| 93 |
+
cat_ids = cat_ids + list(range(max(cat_ids) + 1, 100000))
|
| 94 |
+
id_map = {v: i for i, v in enumerate(cat_ids)}
|
| 95 |
+
|
| 96 |
+
# sort indices for reproducible results
|
| 97 |
+
img_ids = sorted(coco_api.imgs.keys())
|
| 98 |
+
# imgs is a list of dicts, each looks something like:
|
| 99 |
+
# {'license': 4,
|
| 100 |
+
# 'url': 'http://farm6.staticflickr.com/5454/9413846304_881d5e5c3b_z.jpg',
|
| 101 |
+
# 'file_name': 'COCO_val2014_000000001268.jpg',
|
| 102 |
+
# 'height': 427,
|
| 103 |
+
# 'width': 640,
|
| 104 |
+
# 'date_captured': '2013-11-17 05:57:24',
|
| 105 |
+
# 'id': 1268}
|
| 106 |
+
imgs = coco_api.loadImgs(img_ids)
|
| 107 |
+
# anns is a list[list[dict]], where each dict is an annotation
|
| 108 |
+
# record for an object. The inner list enumerates the objects in an image
|
| 109 |
+
# and the outer list enumerates over images. Example of anns[0]:
|
| 110 |
+
# [{'segmentation': [[192.81,
|
| 111 |
+
# 247.09,
|
| 112 |
+
# ...
|
| 113 |
+
# 219.03,
|
| 114 |
+
# 249.06]],
|
| 115 |
+
# 'area': 1035.749,
|
| 116 |
+
# 'iscrowd': 0,
|
| 117 |
+
# 'image_id': 1268,
|
| 118 |
+
# 'bbox': [192.81, 224.8, 74.73, 33.43],
|
| 119 |
+
# 'category_id': 16,
|
| 120 |
+
# 'id': 42986},
|
| 121 |
+
# ...]
|
| 122 |
+
anns = [coco_api.imgToAnns[img_id] for img_id in img_ids]
|
| 123 |
+
total_num_valid_anns = sum([len(x) for x in anns])
|
| 124 |
+
total_num_anns = len(coco_api.anns)
|
| 125 |
+
if total_num_valid_anns < total_num_anns:
|
| 126 |
+
logger.warning(
|
| 127 |
+
f"{json_file} contains {total_num_anns} annotations, but only "
|
| 128 |
+
f"{total_num_valid_anns} of them match to images in the file."
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
+
if "minival" not in json_file:
|
| 132 |
+
# The popular valminusminival & minival annotations for COCO2014 contain this bug.
|
| 133 |
+
# However the ratio of buggy annotations there is tiny and does not affect accuracy.
|
| 134 |
+
# Therefore we explicitly white-list them.
|
| 135 |
+
ann_ids = [ann["id"] for anns_per_image in anns for ann in anns_per_image]
|
| 136 |
+
assert len(set(ann_ids)) == len(ann_ids), "Annotation ids in '{}' are not unique!".format(
|
| 137 |
+
json_file
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
imgs_anns = list(zip(imgs, anns))
|
| 141 |
+
logger.info("Loaded {} images in COCO format from {}".format(len(imgs_anns), json_file))
|
| 142 |
+
|
| 143 |
+
dataset_dicts = []
|
| 144 |
+
|
| 145 |
+
ann_keys = ["iscrowd", "bbox", "keypoints", "category_id"] + (extra_annotation_keys or [])
|
| 146 |
+
|
| 147 |
+
ann_keys += ["phrase", "isobject"]
|
| 148 |
+
|
| 149 |
+
num_instances_without_valid_segmentation = 0
|
| 150 |
+
|
| 151 |
+
for (img_dict, anno_dict_list) in imgs_anns:
|
| 152 |
+
record = {}
|
| 153 |
+
record["file_name"] = os.path.join(image_root, img_dict["file_name"])
|
| 154 |
+
record["height"] = img_dict["height"]
|
| 155 |
+
record["width"] = img_dict["width"]
|
| 156 |
+
image_id = record["image_id"] = img_dict["id"]
|
| 157 |
+
if "neg_category_ids" in img_dict:
|
| 158 |
+
record["neg_category_ids"] = [id_map[x] for x in img_dict["neg_category_ids"]]
|
| 159 |
+
|
| 160 |
+
objs = []
|
| 161 |
+
for anno in anno_dict_list:
|
| 162 |
+
# Check that the image_id in this annotation is the same as
|
| 163 |
+
# the image_id we're looking at.
|
| 164 |
+
# This fails only when the data parsing logic or the annotation file is buggy.
|
| 165 |
+
|
| 166 |
+
# The original COCO valminusminival2014 & minival2014 annotation files
|
| 167 |
+
# actually contains bugs that, together with certain ways of using COCO API,
|
| 168 |
+
# can trigger this assertion.
|
| 169 |
+
assert anno["image_id"] == image_id
|
| 170 |
+
|
| 171 |
+
assert anno.get("ignore", 0) == 0, '"ignore" in COCO json file is not supported.'
|
| 172 |
+
|
| 173 |
+
obj = {key: anno[key] for key in ann_keys if key in anno}
|
| 174 |
+
if "bbox" in obj and len(obj["bbox"]) == 0:
|
| 175 |
+
raise ValueError(
|
| 176 |
+
f"One annotation of image {image_id} contains empty 'bbox' value! "
|
| 177 |
+
"This json does not have valid COCO format."
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
segm = anno.get("segmentation", None)
|
| 181 |
+
if segm: # either list[list[float]] or dict(RLE)
|
| 182 |
+
if isinstance(segm, dict):
|
| 183 |
+
if isinstance(segm["counts"], list):
|
| 184 |
+
# convert to compressed RLE
|
| 185 |
+
segm = mask_util.frPyObjects(segm, *segm["size"])
|
| 186 |
+
else:
|
| 187 |
+
# filter out invalid polygons (< 3 points)
|
| 188 |
+
segm = [poly for poly in segm if len(poly) % 2 == 0 and len(poly) >= 6]
|
| 189 |
+
if len(segm) == 0:
|
| 190 |
+
num_instances_without_valid_segmentation += 1
|
| 191 |
+
continue # ignore this instance
|
| 192 |
+
obj["segmentation"] = segm
|
| 193 |
+
|
| 194 |
+
keypts = anno.get("keypoints", None)
|
| 195 |
+
if keypts: # list[int]
|
| 196 |
+
for idx, v in enumerate(keypts):
|
| 197 |
+
if idx % 3 != 2:
|
| 198 |
+
# COCO's segmentation coordinates are floating points in [0, H or W],
|
| 199 |
+
# but keypoint coordinates are integers in [0, H-1 or W-1]
|
| 200 |
+
# Therefore we assume the coordinates are "pixel indices" and
|
| 201 |
+
# add 0.5 to convert to floating point coordinates.
|
| 202 |
+
keypts[idx] = v + 0.5
|
| 203 |
+
obj["keypoints"] = keypts
|
| 204 |
+
|
| 205 |
+
# phrase = anno.get("phrase", None)
|
| 206 |
+
# if phrase:
|
| 207 |
+
# obj["phrase"] = phrase
|
| 208 |
+
|
| 209 |
+
# isobject = anno.get("isobject", None)
|
| 210 |
+
# if isobject:
|
| 211 |
+
# obj["isobject"] = isobject
|
| 212 |
+
|
| 213 |
+
obj["bbox_mode"] = BoxMode.XYWH_ABS
|
| 214 |
+
if id_map:
|
| 215 |
+
annotation_category_id = obj["category_id"]
|
| 216 |
+
try:
|
| 217 |
+
obj["category_id"] = id_map[annotation_category_id]
|
| 218 |
+
except KeyError as e:
|
| 219 |
+
raise KeyError(
|
| 220 |
+
f"Encountered category_id={annotation_category_id} "
|
| 221 |
+
"but this id does not exist in 'categories' of the json file."
|
| 222 |
+
) from e
|
| 223 |
+
objs.append(obj)
|
| 224 |
+
record["annotations"] = objs
|
| 225 |
+
dataset_dicts.append(record)
|
| 226 |
+
|
| 227 |
+
if num_instances_without_valid_segmentation > 0:
|
| 228 |
+
logger.warning(
|
| 229 |
+
"Filtered out {} instances without valid segmentation. ".format(
|
| 230 |
+
num_instances_without_valid_segmentation
|
| 231 |
+
)
|
| 232 |
+
+ "There might be issues in your dataset generation process. Please "
|
| 233 |
+
"check https://detectron2.readthedocs.io/en/latest/tutorials/datasets.html carefully"
|
| 234 |
+
)
|
| 235 |
+
return dataset_dicts
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
def custom_load_sem_seg(gt_root, image_root, gt_ext="png", image_ext="jpg"):
|
| 239 |
+
"""
|
| 240 |
+
Load semantic segmentation datasets. All files under "gt_root" with "gt_ext" extension are
|
| 241 |
+
treated as ground truth annotations and all files under "image_root" with "image_ext" extension
|
| 242 |
+
as input images. Ground truth and input images are matched using file paths relative to
|
| 243 |
+
"gt_root" and "image_root" respectively without taking into account file extensions.
|
| 244 |
+
This works for COCO as well as some other datasets.
|
| 245 |
+
|
| 246 |
+
Args:
|
| 247 |
+
gt_root (str): full path to ground truth semantic segmentation files. Semantic segmentation
|
| 248 |
+
annotations are stored as images with integer values in pixels that represent
|
| 249 |
+
corresponding semantic labels.
|
| 250 |
+
image_root (str): the directory where the input images are.
|
| 251 |
+
gt_ext (str): file extension for ground truth annotations.
|
| 252 |
+
image_ext (str): file extension for input images.
|
| 253 |
+
|
| 254 |
+
Returns:
|
| 255 |
+
list[dict]:
|
| 256 |
+
a list of dicts in detectron2 standard format without instance-level
|
| 257 |
+
annotation.
|
| 258 |
+
|
| 259 |
+
Notes:
|
| 260 |
+
1. This function does not read the image and ground truth files.
|
| 261 |
+
The results do not have the "image" and "sem_seg" fields.
|
| 262 |
+
"""
|
| 263 |
+
|
| 264 |
+
# We match input images with ground truth based on their relative filepaths (without file
|
| 265 |
+
# extensions) starting from 'image_root' and 'gt_root' respectively.
|
| 266 |
+
def file2id(folder_path, file_path):
|
| 267 |
+
# extract relative path starting from `folder_path`
|
| 268 |
+
image_id = os.path.normpath(os.path.relpath(file_path, start=folder_path))
|
| 269 |
+
# remove file extension
|
| 270 |
+
image_id = os.path.splitext(image_id)[0]
|
| 271 |
+
return image_id
|
| 272 |
+
|
| 273 |
+
input_files = sorted(
|
| 274 |
+
(os.path.join(image_root, f) for f in PathManager.ls(image_root) if f.endswith(image_ext)),
|
| 275 |
+
key=lambda file_path: file2id(image_root, file_path),
|
| 276 |
+
)
|
| 277 |
+
gt_files = sorted(
|
| 278 |
+
(os.path.join(gt_root, f) for f in PathManager.ls(gt_root) if f.endswith(gt_ext)),
|
| 279 |
+
key=lambda file_path: file2id(gt_root, file_path),
|
| 280 |
+
)
|
| 281 |
+
|
| 282 |
+
assert len(gt_files) > 0, "No annotations found in {}.".format(gt_root)
|
| 283 |
+
|
| 284 |
+
# Use the intersection, so that val2017_100 annotations can run smoothly with val2017 images
|
| 285 |
+
if len(input_files) != len(gt_files):
|
| 286 |
+
logger.warn(
|
| 287 |
+
"Directory {} and {} has {} and {} files, respectively.".format(
|
| 288 |
+
image_root, gt_root, len(input_files), len(gt_files)
|
| 289 |
+
)
|
| 290 |
+
)
|
| 291 |
+
input_basenames = [os.path.basename(f)[: -len(image_ext)] for f in input_files]
|
| 292 |
+
gt_basenames = [os.path.basename(f)[: -len(gt_ext)] for f in gt_files]
|
| 293 |
+
intersect = list(set(input_basenames) & set(gt_basenames))
|
| 294 |
+
# sort, otherwise each worker may obtain a list[dict] in different order
|
| 295 |
+
intersect = sorted(intersect)
|
| 296 |
+
logger.warn("Will use their intersection of {} files.".format(len(intersect)))
|
| 297 |
+
input_files = [os.path.join(image_root, f + image_ext) for f in intersect]
|
| 298 |
+
gt_files = [os.path.join(gt_root, f + gt_ext) for f in intersect]
|
| 299 |
+
|
| 300 |
+
logger.info(
|
| 301 |
+
"Loaded {} images with semantic segmentation from {}".format(len(input_files), image_root)
|
| 302 |
+
)
|
| 303 |
+
|
| 304 |
+
dataset_dicts = []
|
| 305 |
+
for (img_path, gt_path) in zip(input_files, gt_files):
|
| 306 |
+
record = {}
|
| 307 |
+
record["file_name"] = img_path
|
| 308 |
+
record["sem_seg_file_name"] = gt_path
|
| 309 |
+
dataset_dicts.append(record)
|
| 310 |
+
|
| 311 |
+
return dataset_dicts
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
def custom_load_sem_seg_list(gt_root, image_root, gt_ext="png", image_ext="jpg"):
|
| 315 |
+
if isinstance(image_root, list):
|
| 316 |
+
image_roots = image_root
|
| 317 |
+
else:
|
| 318 |
+
image_roots = [image_root]
|
| 319 |
+
if isinstance(gt_root, list):
|
| 320 |
+
gt_roots = gt_root
|
| 321 |
+
else:
|
| 322 |
+
gt_roots = [gt_root]
|
| 323 |
+
|
| 324 |
+
dataset_dicts = []
|
| 325 |
+
for gt_root, image_root in zip(gt_roots, image_roots):
|
| 326 |
+
dataset_dicts.extend(custom_load_sem_seg(gt_root, image_root, gt_ext, image_ext))
|
| 327 |
+
|
| 328 |
+
if len(image_roots) > 1:
|
| 329 |
+
logger.info(
|
| 330 |
+
"Loaded {} images with semantic segmentation from {}".format(
|
| 331 |
+
len(dataset_dicts), image_roots
|
| 332 |
+
)
|
| 333 |
+
)
|
| 334 |
+
|
| 335 |
+
return dataset_dicts
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
def custom_register_coco_instances(name, metadata, json_file, image_root):
|
| 339 |
+
"""
|
| 340 |
+
Register a dataset in COCO's json annotation format for
|
| 341 |
+
instance detection, instance segmentation and keypoint detection.
|
| 342 |
+
(i.e., Type 1 and 2 in http://cocodataset.org/#format-data.
|
| 343 |
+
`instances*.json` and `person_keypoints*.json` in the dataset).
|
| 344 |
+
|
| 345 |
+
This is an example of how to register a new dataset.
|
| 346 |
+
You can do something similar to this function, to register new datasets.
|
| 347 |
+
|
| 348 |
+
Args:
|
| 349 |
+
name (str): the name that identifies a dataset, e.g. "coco_2014_train".
|
| 350 |
+
metadata (dict): extra metadata associated with this dataset. You can
|
| 351 |
+
leave it as an empty dict.
|
| 352 |
+
json_file (str): path to the json instance annotation file.
|
| 353 |
+
image_root (str or path-like): directory which contains all the images.
|
| 354 |
+
"""
|
| 355 |
+
assert isinstance(name, str), name
|
| 356 |
+
assert isinstance(json_file, (str, os.PathLike)), json_file
|
| 357 |
+
assert isinstance(image_root, (str, os.PathLike)), image_root
|
| 358 |
+
# 1. register a function which returns dicts
|
| 359 |
+
DatasetCatalog.register(name, lambda: custom_load_coco_json(json_file, image_root, name))
|
| 360 |
+
|
| 361 |
+
# 2. Optionally, add metadata about this dataset,
|
| 362 |
+
# since they might be useful in evaluation, visualization or logging
|
| 363 |
+
MetadataCatalog.get(name).set(
|
| 364 |
+
json_file=json_file, image_root=image_root, evaluator_type="coco", **metadata
|
| 365 |
+
)
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
def custom_register_coco_semseg(name, metadata, sem_seg_root, image_root):
|
| 369 |
+
assert isinstance(name, str), name
|
| 370 |
+
assert isinstance(sem_seg_root, (str, os.PathLike, list)), sem_seg_root
|
| 371 |
+
assert isinstance(image_root, (str, os.PathLike, list)), image_root
|
| 372 |
+
# 1. register a function which returns dicts
|
| 373 |
+
DatasetCatalog.register(name, lambda: custom_load_sem_seg_list(sem_seg_root, image_root))
|
| 374 |
+
|
| 375 |
+
# 2. Optionally, add metadata about this dataset,
|
| 376 |
+
# since they might be useful in evaluation, visualization or logging
|
| 377 |
+
MetadataCatalog.get(name).set(
|
| 378 |
+
sem_seg_root=sem_seg_root,
|
| 379 |
+
image_root=image_root,
|
| 380 |
+
evaluator_type="sem_seg",
|
| 381 |
+
ignore_label=255,
|
| 382 |
+
**metad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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import pycocotools.mask as mask_util
|
| 5 |
+
|
| 6 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 7 |
+
from detectron2.data.datasets.builtin_meta import _get_coco_instances_meta
|
| 8 |
+
from detectron2.data.datasets.lvis_v0_5_categories import LVIS_CATEGORIES as LVIS_V0_5_CATEGORIES
|
| 9 |
+
from detectron2.data.datasets.lvis_v1_categories import LVIS_CATEGORIES as LVIS_V1_CATEGORIES
|
| 10 |
+
from detectron2.structures import BoxMode
|
| 11 |
+
from detectron2.utils.file_io import PathManager
|
| 12 |
+
from fvcore.common.timer import Timer
|
| 13 |
+
|
| 14 |
+
from .lvis_v1_coco_category_image_count import LVIS_V1_COCO_CATEGORY_IMAGE_COUNT
|
| 15 |
+
|
| 16 |
+
"""
|
| 17 |
+
This file contains functions to parse LVIS-format annotations into dicts in the
|
| 18 |
+
"Detectron2 format".
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
__all__ = ["load_d3_json", "register_d3_instances"]
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def register_d3_instances(name, metadata, json_file, image_root, anno_root):
|
| 27 |
+
"""
|
| 28 |
+
Register a dataset in LVIS's json annotation format for instance detection and segmentation.
|
| 29 |
+
|
| 30 |
+
Args:
|
| 31 |
+
name (str): a name that identifies the dataset, e.g. "lvis_v0.5_train".
|
| 32 |
+
metadata (dict): extra metadata associated with this dataset. It can be an empty dict.
|
| 33 |
+
json_file (str): path to the json instance annotation file.
|
| 34 |
+
image_root (str or path-like): directory which contains all the images.
|
| 35 |
+
"""
|
| 36 |
+
DatasetCatalog.register(name, lambda: load_d3_json(json_file, image_root, anno_root, name))
|
| 37 |
+
MetadataCatalog.get(name).set(
|
| 38 |
+
json_file=json_file, image_root=image_root, evaluator_type="d3", **metadata
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def load_d3_json(json_file, image_root, anno_root, dataset_name=None, extra_annotation_keys=None):
|
| 43 |
+
"""
|
| 44 |
+
Load a json file in LVIS's annotation format.
|
| 45 |
+
|
| 46 |
+
Args:
|
| 47 |
+
json_file (str): full path to the LVIS json annotation file.
|
| 48 |
+
image_root (str): the directory where the images in this json file exists.
|
| 49 |
+
dataset_name (str): the name of the dataset (e.g., "lvis_v0.5_train").
|
| 50 |
+
If provided, this function will put "thing_classes" into the metadata
|
| 51 |
+
associated with this dataset.
|
| 52 |
+
extra_annotation_keys (list[str]): list of per-annotation keys that should also be
|
| 53 |
+
loaded into the dataset dict (besides "bbox", "bbox_mode", "category_id",
|
| 54 |
+
"segmentation"). The values for these keys will be returned as-is.
|
| 55 |
+
|
| 56 |
+
Returns:
|
| 57 |
+
list[dict]: a list of dicts in Detectron2 standard format. (See
|
| 58 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ )
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
1. This function does not read the image files.
|
| 62 |
+
The results do not have the "image" field.
|
| 63 |
+
"""
|
| 64 |
+
from d_cube import D3
|
| 65 |
+
|
| 66 |
+
timer = Timer()
|
| 67 |
+
|
| 68 |
+
d3 = D3(image_root, anno_root)
|
| 69 |
+
|
| 70 |
+
if timer.seconds() > 1:
|
| 71 |
+
logger.info("Loading d3 takes {:.2f} seconds.".format(timer.seconds()))
|
| 72 |
+
|
| 73 |
+
id_map = None
|
| 74 |
+
if dataset_name is not None:
|
| 75 |
+
meta = MetadataCatalog.get(dataset_name)
|
| 76 |
+
cat_ids = sorted(d3.get_sent_ids())
|
| 77 |
+
cats = d3.load_sents(cat_ids)
|
| 78 |
+
# The categories in a custom json file may not be sorted.
|
| 79 |
+
thing_classes = [c["raw_sent"] for c in sorted(cats, key=lambda x: x["id"])]
|
| 80 |
+
meta.thing_classes = thing_classes
|
| 81 |
+
|
| 82 |
+
# In COCO, certain category ids are artificially removed,
|
| 83 |
+
# and by convention they are always ignored.
|
| 84 |
+
# We deal with COCO's id issue and translate
|
| 85 |
+
# the category ids to contiguous ids in [0, 80).
|
| 86 |
+
|
| 87 |
+
# It works by looking at the "categories" field in the json, therefore
|
| 88 |
+
# if users' own json also have incontiguous ids, we'll
|
| 89 |
+
# apply this mapping as well but print a warning.
|
| 90 |
+
if not (min(cat_ids) == 1 and max(cat_ids) == len(cat_ids)):
|
| 91 |
+
if "coco" not in dataset_name:
|
| 92 |
+
logger.warning(
|
| 93 |
+
"""
|
| 94 |
+
Category ids in annotations are not in [1, #categories]! We'll apply a mapping for you.
|
| 95 |
+
"""
|
| 96 |
+
)
|
| 97 |
+
id_map = {v: i for i, v in enumerate(cat_ids)}
|
| 98 |
+
meta.thing_dataset_id_to_contiguous_id = id_map
|
| 99 |
+
|
| 100 |
+
img_ids = d3.get_img_ids()
|
| 101 |
+
imgs = d3.load_imgs(img_ids)
|
| 102 |
+
anno_ids = [d3.get_anno_ids(img_ids=img_id) for img_id in img_ids]
|
| 103 |
+
anns = [d3.load_annos(anno_ids=anno_id) for anno_id in anno_ids]
|
| 104 |
+
total_num_valid_anns = sum([len(x) for x in anns])
|
| 105 |
+
total_num_anns = len(d3.load_annos())
|
| 106 |
+
if total_num_valid_anns < total_num_anns:
|
| 107 |
+
logger.warning(
|
| 108 |
+
f"{anno_root} contains {total_num_anns} annotations, but only "
|
| 109 |
+
f"{total_num_valid_anns} of them match to images in the file."
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
imgs_anns = list(zip(imgs, anns))
|
| 113 |
+
logger.info("Loaded {} images in COCO format from {}".format(len(imgs_anns), json_file))
|
| 114 |
+
|
| 115 |
+
dataset_dicts = []
|
| 116 |
+
|
| 117 |
+
ann_keys = ["iscrowd", "bbox", "keypoints", "sent_id"] + (extra_annotation_keys or [])
|
| 118 |
+
|
| 119 |
+
num_instances_without_valid_segmentation = 0
|
| 120 |
+
|
| 121 |
+
for (img_dict, anno_dict_list) in imgs_anns:
|
| 122 |
+
record = {}
|
| 123 |
+
record["file_name"] = os.path.join(image_root, img_dict["file_name"])
|
| 124 |
+
record["height"] = img_dict["height"]
|
| 125 |
+
record["width"] = img_dict["width"]
|
| 126 |
+
image_id = record["image_id"] = img_dict["id"]
|
| 127 |
+
|
| 128 |
+
if meta.group == "intra":
|
| 129 |
+
group_ids = d3.get_group_ids(img_ids=[image_id])
|
| 130 |
+
sent_ids = d3.get_sent_ids(group_ids=group_ids)
|
| 131 |
+
sent_list = d3.load_sents(sent_ids=sent_ids)
|
| 132 |
+
# assert len(anno_dict_list) == len(sent_ids)
|
| 133 |
+
elif meta.group == "inter":
|
| 134 |
+
sent_ids = d3.get_sent_ids()
|
| 135 |
+
sent_list = d3.load_sents(sent_ids=sent_ids)
|
| 136 |
+
# sent_list = d3.load_sents()
|
| 137 |
+
else:
|
| 138 |
+
assert False
|
| 139 |
+
ref_list = [sent["raw_sent"] for sent in sent_list]
|
| 140 |
+
record["expressions"] = ref_list
|
| 141 |
+
if id_map:
|
| 142 |
+
record["sent_ids"] = [id_map[x] for x in sent_ids]
|
| 143 |
+
|
| 144 |
+
objs = []
|
| 145 |
+
for anno in anno_dict_list:
|
| 146 |
+
# Check that the image_id in this annotation is the same as
|
| 147 |
+
# the image_id we're looking at.
|
| 148 |
+
# This fails only when the data parsing logic or the annotation file is buggy.
|
| 149 |
+
|
| 150 |
+
# The original COCO valminusminival2014 & minival2014 annotation files
|
| 151 |
+
# actually contains bugs that, together with certain ways of using COCO API,
|
| 152 |
+
# can trigger this assertion.
|
| 153 |
+
assert anno["image_id"] == image_id
|
| 154 |
+
|
| 155 |
+
assert anno.get("ignore", 0) == 0, '"ignore" in COCO json file is not supported.'
|
| 156 |
+
|
| 157 |
+
obj = {key: anno[key] for key in ann_keys if key in anno}
|
| 158 |
+
if "bbox" in obj and len(obj["bbox"]) == 0:
|
| 159 |
+
raise ValueError(
|
| 160 |
+
f"One annotation of image {image_id} contains empty 'bbox' value! "
|
| 161 |
+
"This json does not have valid COCO format."
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
assert len(obj["bbox"]) == 1
|
| 165 |
+
obj["bbox"] = list(obj["bbox"][0])
|
| 166 |
+
# assert len(obj["sent_id"]) == 1
|
| 167 |
+
obj["sent_id"] = obj["sent_id"][0]
|
| 168 |
+
|
| 169 |
+
segm = anno.get("segmentation", None)
|
| 170 |
+
assert len(segm) == 1
|
| 171 |
+
segm = segm[0]
|
| 172 |
+
if segm: # either list[list[float]] or dict(RLE)
|
| 173 |
+
if isinstance(segm, dict):
|
| 174 |
+
if isinstance(segm["counts"], list):
|
| 175 |
+
# convert to compressed RLE
|
| 176 |
+
segm = mask_util.frPyObjects(segm, *segm["size"])
|
| 177 |
+
else:
|
| 178 |
+
# filter out invalid polygons (< 3 points)
|
| 179 |
+
segm = [poly for poly in segm if len(poly) % 2 == 0 and len(poly) >= 6]
|
| 180 |
+
if len(segm) == 0:
|
| 181 |
+
num_instances_without_valid_segmentation += 1
|
| 182 |
+
continue # ignore this instance
|
| 183 |
+
obj["segmentation"] = segm
|
| 184 |
+
|
| 185 |
+
keypts = anno.get("keypoints", None)
|
| 186 |
+
if keypts: # list[int]
|
| 187 |
+
for idx, v in enumerate(keypts):
|
| 188 |
+
if idx % 3 != 2:
|
| 189 |
+
# COCO's segmentation coordinates are floating points in [0, H or W],
|
| 190 |
+
# but keypoint coordinates are integers in [0, H-1 or W-1]
|
| 191 |
+
# Therefore we assume the coordinates are "pixel indices" and
|
| 192 |
+
# add 0.5 to convert to floating point coordinates.
|
| 193 |
+
keypts[idx] = v + 0.5
|
| 194 |
+
obj["keypoints"] = keypts
|
| 195 |
+
|
| 196 |
+
obj["bbox_mode"] = BoxMode.XYWH_ABS
|
| 197 |
+
if id_map:
|
| 198 |
+
annotation_category_id = obj["sent_id"]
|
| 199 |
+
try:
|
| 200 |
+
obj["sent_id"] = id_map[annotation_category_id]
|
| 201 |
+
except KeyError as e:
|
| 202 |
+
raise KeyError(
|
| 203 |
+
f"Encountered sent_id={annotation_category_id} "
|
| 204 |
+
"but this id does not exist in 'categories' of the json file."
|
| 205 |
+
) from e
|
| 206 |
+
obj["category_id"] = obj["sent_id"]
|
| 207 |
+
obj["iscrowd"] = 0
|
| 208 |
+
objs.append(obj)
|
| 209 |
+
record["annotations"] = objs
|
| 210 |
+
dataset_dicts.append(record)
|
| 211 |
+
|
| 212 |
+
if num_instances_without_valid_segmentation > 0:
|
| 213 |
+
logger.warning(
|
| 214 |
+
"Filtered out {} instances without valid segmentation. ".format(
|
| 215 |
+
num_instances_without_valid_segmentation
|
| 216 |
+
)
|
| 217 |
+
+ "There might be issues in your dataset generation process. Please "
|
| 218 |
+
"check https://detectron2.readthedocs.io/en/latest/tutorials/datasets.html carefully"
|
| 219 |
+
)
|
| 220 |
+
return dataset_dicts
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def get_d3_instances_meta(dataset_name):
|
| 224 |
+
if "intra_scenario" in dataset_name:
|
| 225 |
+
group = "intra"
|
| 226 |
+
elif "inter_scenario" in dataset_name:
|
| 227 |
+
group = "inter"
|
| 228 |
+
else:
|
| 229 |
+
assert False
|
| 230 |
+
return {"group": group}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
_PREDEFINED_SPLITS_D3 = {
|
| 234 |
+
"d3_inter_scenario": {
|
| 235 |
+
"d3_inter_scenario": (
|
| 236 |
+
"D3/d3_images/",
|
| 237 |
+
{
|
| 238 |
+
"FULL": "D3/d3_json/d3_full_annotations.json",
|
| 239 |
+
"PRES": "D3/d3_json/d3_pres_annotations.json",
|
| 240 |
+
"ABS": "D3/d3_json/d3_abs_annotations.json",
|
| 241 |
+
},
|
| 242 |
+
"D3/d3_pkl/",
|
| 243 |
+
),
|
| 244 |
+
},
|
| 245 |
+
"d3_intra_scenario": {
|
| 246 |
+
"d3_intra_scenario": (
|
| 247 |
+
"D3/d3_images/",
|
| 248 |
+
{
|
| 249 |
+
"FULL": "D3/d3_json/d3_full_annotations.json",
|
| 250 |
+
"PRES": "D3/d3_json/d3_pres_annotations.json",
|
| 251 |
+
"ABS": "D3/d3_json/d3_abs_annotations.json",
|
| 252 |
+
},
|
| 253 |
+
"D3/d3_pkl/",
|
| 254 |
+
),
|
| 255 |
+
},
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
def register_all_D3(root):
|
| 260 |
+
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_D3.items():
|
| 261 |
+
for key, (image_root, json_file, anno_root) in splits_per_dataset.items():
|
| 262 |
+
register_d3_instances(
|
| 263 |
+
key,
|
| 264 |
+
get_d3_instances_meta(dataset_name),
|
| 265 |
+
# os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 266 |
+
{k: os.path.join(root, v) for k, v in json_file.items()},
|
| 267 |
+
os.path.join(root, image_root),
|
| 268 |
+
os.path.join(root, anno_root),
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
if __name__.endswith(".d_cube"):
|
| 273 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 274 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 275 |
+
register_all_D3(_root)
|
approach/ovod/APE/ape/data/datasets/flickr30k.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
from .coco import custom_register_coco_instances
|
| 5 |
+
|
| 6 |
+
logger = logging.getLogger(__name__)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _get_builtin_metadata(dataset_name):
|
| 10 |
+
return _get_flickr30k_metadata([])
|
| 11 |
+
|
| 12 |
+
raise KeyError("No built-in metadata for dataset {}".format(dataset_name))
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _get_flickr30k_metadata(categories):
|
| 16 |
+
if len(categories) == 0:
|
| 17 |
+
return {}
|
| 18 |
+
id_to_name = {x["id"]: x["name"] for x in categories}
|
| 19 |
+
thing_dataset_id_to_contiguous_id = {i + 1: i for i in range(len(categories))}
|
| 20 |
+
thing_classes = [id_to_name[k] for k in sorted(id_to_name)]
|
| 21 |
+
return {
|
| 22 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 23 |
+
"thing_classes": thing_classes,
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
_PREDEFINED_SPLITS_FLICKR30k = {}
|
| 28 |
+
_PREDEFINED_SPLITS_FLICKR30k["flickr30k"] = {
|
| 29 |
+
"flickr30k": (
|
| 30 |
+
"flickr30k/flickr30k-images",
|
| 31 |
+
"flickr30k/flickr30k.json",
|
| 32 |
+
),
|
| 33 |
+
"flickr30k_separateGT_train": (
|
| 34 |
+
"flickr30k/flickr30k-images",
|
| 35 |
+
"flickr30k/flickr30k_separateGT_train.json",
|
| 36 |
+
),
|
| 37 |
+
"flickr30k_separateGT_val": (
|
| 38 |
+
"flickr30k/flickr30k-images",
|
| 39 |
+
"flickr30k/flickr30k_separateGT_val.json",
|
| 40 |
+
),
|
| 41 |
+
"flickr30k_mergedGT_train": (
|
| 42 |
+
"flickr30k/flickr30k-images",
|
| 43 |
+
"flickr30k/flickr30k_mergedGT_train.json",
|
| 44 |
+
),
|
| 45 |
+
"flickr30k_mergedGT_val": (
|
| 46 |
+
"flickr30k/flickr30k-images",
|
| 47 |
+
"flickr30k/flickr30k_mergedGT_val.json",
|
| 48 |
+
),
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def register_all_flickr30k(root):
|
| 53 |
+
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_FLICKR30k.items():
|
| 54 |
+
for key, (image_root, json_file) in splits_per_dataset.items():
|
| 55 |
+
custom_register_coco_instances(
|
| 56 |
+
key,
|
| 57 |
+
_get_builtin_metadata(dataset_name),
|
| 58 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 59 |
+
os.path.join(root, image_root),
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
# True for open source;
|
| 64 |
+
# Internally at fb, we register them elsewhere
|
| 65 |
+
if __name__.endswith(".flickr30k"):
|
| 66 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 67 |
+
_root = os.path.expanduser(os.getenv("DETECTRON2_DATASETS", "datasets"))
|
| 68 |
+
register_all_flickr30k(_root)
|
approach/ovod/APE/ape/data/datasets/gqa.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
from .coco import custom_register_coco_instances
|
| 5 |
+
|
| 6 |
+
logger = logging.getLogger(__name__)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _get_builtin_metadata(dataset_name):
|
| 10 |
+
return _get_gqa_metadata([])
|
| 11 |
+
|
| 12 |
+
raise KeyError("No built-in metadata for dataset {}".format(dataset_name))
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _get_gqa_metadata(categories):
|
| 16 |
+
if len(categories) == 0:
|
| 17 |
+
return {}
|
| 18 |
+
id_to_name = {x["id"]: x["name"] for x in categories}
|
| 19 |
+
thing_dataset_id_to_contiguous_id = {i + 1: i for i in range(len(categories))}
|
| 20 |
+
thing_classes = [id_to_name[k] for k in sorted(id_to_name)]
|
| 21 |
+
return {
|
| 22 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 23 |
+
"thing_classes": thing_classes,
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
_PREDEFINED_SPLITS_GQA = {}
|
| 28 |
+
_PREDEFINED_SPLITS_GQA["gqa_region"] = {
|
| 29 |
+
"gqa_region": (
|
| 30 |
+
"gqa/images",
|
| 31 |
+
"gqa/gqa_region.json",
|
| 32 |
+
),
|
| 33 |
+
"gqa_region_train": (
|
| 34 |
+
"gqa/images",
|
| 35 |
+
"gqa/gqa_region_train.json",
|
| 36 |
+
),
|
| 37 |
+
"gqa_region_val": (
|
| 38 |
+
"gqa/images",
|
| 39 |
+
"gqa/gqa_region_val.json",
|
| 40 |
+
),
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def register_all_gqa(root):
|
| 45 |
+
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_GQA.items():
|
| 46 |
+
for key, (image_root, json_file) in splits_per_dataset.items():
|
| 47 |
+
custom_register_coco_instances(
|
| 48 |
+
key,
|
| 49 |
+
_get_builtin_metadata(dataset_name),
|
| 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 |
+
|
| 55 |
+
# True for open source;
|
| 56 |
+
# Internally at fb, we register them elsewhere
|
| 57 |
+
if __name__.endswith(".gqa"):
|
| 58 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 59 |
+
_root = os.path.expanduser(os.getenv("DETECTRON2_DATASETS", "datasets"))
|
| 60 |
+
register_all_gqa(_root)
|
approach/ovod/APE/ape/data/datasets/grit.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from .coco import custom_register_coco_instances
|
| 4 |
+
|
| 5 |
+
GRIT_CATEGORIES = [
|
| 6 |
+
{"id": 0, "name": "object"},
|
| 7 |
+
]
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _get_builtin_metadata(dataset_name):
|
| 11 |
+
id_to_name = {x["id"]: x["name"] for x in GRIT_CATEGORIES}
|
| 12 |
+
thing_dataset_id_to_contiguous_id = {i: i for i in range(len(GRIT_CATEGORIES))}
|
| 13 |
+
thing_classes = [id_to_name[k] for k in sorted(id_to_name)]
|
| 14 |
+
return {
|
| 15 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 16 |
+
"thing_classes": thing_classes,
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
_PREDEFINED_SPLITS_GRIT = {
|
| 21 |
+
"grit": ("GRIT/images", "GRIT/grit.json"),
|
| 22 |
+
"grit_0_snappy": ("GRIT/images", "GRIT/grit_0_snappy.json"),
|
| 23 |
+
"grit_1_snappy": ("GRIT/images", "GRIT/grit_1_snappy.json"),
|
| 24 |
+
"grit_2_snappy": ("GRIT/images", "GRIT/grit_2_snappy.json"),
|
| 25 |
+
"grit_3_snappy": ("GRIT/images", "GRIT/grit_3_snappy.json"),
|
| 26 |
+
"grit_4_snappy": ("GRIT/images", "GRIT/grit_4_snappy.json"),
|
| 27 |
+
"grit_5_snappy": ("GRIT/images", "GRIT/grit_5_snappy.json"),
|
| 28 |
+
"grit_6_snappy": ("GRIT/images", "GRIT/grit_6_snappy.json"),
|
| 29 |
+
"grit_7_snappy": ("GRIT/images", "GRIT/grit_7_snappy.json"),
|
| 30 |
+
"grit_8_snappy": ("GRIT/images", "GRIT/grit_8_snappy.json"),
|
| 31 |
+
"grit_9_snappy": ("GRIT/images", "GRIT/grit_9_snappy.json"),
|
| 32 |
+
"grit_10_snappy": ("GRIT/images", "GRIT/grit_10_snappy.json"),
|
| 33 |
+
"grit_11_snappy": ("GRIT/images", "GRIT/grit_11_snappy.json"),
|
| 34 |
+
"grit_12_snappy": ("GRIT/images", "GRIT/grit_12_snappy.json"),
|
| 35 |
+
"grit_13_snappy": ("GRIT/images", "GRIT/grit_13_snappy.json"),
|
| 36 |
+
"grit_14_snappy": ("GRIT/images", "GRIT/grit_14_snappy.json"),
|
| 37 |
+
"grit_15_snappy": ("GRIT/images", "GRIT/grit_15_snappy.json"),
|
| 38 |
+
"grit_16_snappy": ("GRIT/images", "GRIT/grit_16_snappy.json"),
|
| 39 |
+
"grit_17_snappy": ("GRIT/images", "GRIT/grit_17_snappy.json"),
|
| 40 |
+
"grit_18_snappy": ("GRIT/images", "GRIT/grit_18_snappy.json"),
|
| 41 |
+
"grit_19_snappy": ("GRIT/images", "GRIT/grit_19_snappy.json"),
|
| 42 |
+
"grit_20_snappy": ("GRIT/images", "GRIT/grit_20_snappy.json"),
|
| 43 |
+
"grit_21_snappy": ("GRIT/images", "GRIT/grit_21_snappy.json"),
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def register_all_GRIT(root):
|
| 48 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_GRIT.items():
|
| 49 |
+
custom_register_coco_instances(
|
| 50 |
+
key,
|
| 51 |
+
_get_builtin_metadata(key),
|
| 52 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 53 |
+
os.path.join(root, image_root),
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if __name__.endswith(".grit"):
|
| 58 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 59 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 60 |
+
register_all_GRIT(_root)
|
approach/ovod/APE/ape/data/datasets/inst_categories.py
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
categories = {
|
| 2 |
+
"coco": [
|
| 3 |
+
{"color": [220, 20, 60], "isthing": 1, "id": 1, "name": "person"},
|
| 4 |
+
{"color": [119, 11, 32], "isthing": 1, "id": 2, "name": "bicycle"},
|
| 5 |
+
{"color": [0, 0, 142], "isthing": 1, "id": 3, "name": "car"},
|
| 6 |
+
{"color": [0, 0, 230], "isthing": 1, "id": 4, "name": "motorcycle"},
|
| 7 |
+
{"color": [106, 0, 228], "isthing": 1, "id": 5, "name": "airplane"},
|
| 8 |
+
{"color": [0, 60, 100], "isthing": 1, "id": 6, "name": "bus"},
|
| 9 |
+
{"color": [0, 80, 100], "isthing": 1, "id": 7, "name": "train"},
|
| 10 |
+
{"color": [0, 0, 70], "isthing": 1, "id": 8, "name": "truck"},
|
| 11 |
+
{"color": [0, 0, 192], "isthing": 1, "id": 9, "name": "boat"},
|
| 12 |
+
{"color": [250, 170, 30], "isthing": 1, "id": 10, "name": "traffic light"},
|
| 13 |
+
{"color": [100, 170, 30], "isthing": 1, "id": 11, "name": "fire hydrant"},
|
| 14 |
+
{"color": [220, 220, 0], "isthing": 1, "id": 13, "name": "stop sign"},
|
| 15 |
+
{"color": [175, 116, 175], "isthing": 1, "id": 14, "name": "parking meter"},
|
| 16 |
+
{"color": [250, 0, 30], "isthing": 1, "id": 15, "name": "bench"},
|
| 17 |
+
{"color": [165, 42, 42], "isthing": 1, "id": 16, "name": "bird"},
|
| 18 |
+
{"color": [255, 77, 255], "isthing": 1, "id": 17, "name": "cat"},
|
| 19 |
+
{"color": [0, 226, 252], "isthing": 1, "id": 18, "name": "dog"},
|
| 20 |
+
{"color": [182, 182, 255], "isthing": 1, "id": 19, "name": "horse"},
|
| 21 |
+
{"color": [0, 82, 0], "isthing": 1, "id": 20, "name": "sheep"},
|
| 22 |
+
{"color": [120, 166, 157], "isthing": 1, "id": 21, "name": "cow"},
|
| 23 |
+
{"color": [110, 76, 0], "isthing": 1, "id": 22, "name": "elephant"},
|
| 24 |
+
{"color": [174, 57, 255], "isthing": 1, "id": 23, "name": "bear"},
|
| 25 |
+
{"color": [199, 100, 0], "isthing": 1, "id": 24, "name": "zebra"},
|
| 26 |
+
{"color": [72, 0, 118], "isthing": 1, "id": 25, "name": "giraffe"},
|
| 27 |
+
{"color": [255, 179, 240], "isthing": 1, "id": 27, "name": "backpack"},
|
| 28 |
+
{"color": [0, 125, 92], "isthing": 1, "id": 28, "name": "umbrella"},
|
| 29 |
+
{"color": [209, 0, 151], "isthing": 1, "id": 31, "name": "handbag"},
|
| 30 |
+
{"color": [188, 208, 182], "isthing": 1, "id": 32, "name": "tie"},
|
| 31 |
+
{"color": [0, 220, 176], "isthing": 1, "id": 33, "name": "suitcase"},
|
| 32 |
+
{"color": [255, 99, 164], "isthing": 1, "id": 34, "name": "frisbee"},
|
| 33 |
+
{"color": [92, 0, 73], "isthing": 1, "id": 35, "name": "skis"},
|
| 34 |
+
{"color": [133, 129, 255], "isthing": 1, "id": 36, "name": "snowboard"},
|
| 35 |
+
{"color": [78, 180, 255], "isthing": 1, "id": 37, "name": "sports ball"},
|
| 36 |
+
{"color": [0, 228, 0], "isthing": 1, "id": 38, "name": "kite"},
|
| 37 |
+
{"color": [174, 255, 243], "isthing": 1, "id": 39, "name": "baseball bat"},
|
| 38 |
+
{"color": [45, 89, 255], "isthing": 1, "id": 40, "name": "baseball glove"},
|
| 39 |
+
{"color": [134, 134, 103], "isthing": 1, "id": 41, "name": "skateboard"},
|
| 40 |
+
{"color": [145, 148, 174], "isthing": 1, "id": 42, "name": "surfboard"},
|
| 41 |
+
{"color": [255, 208, 186], "isthing": 1, "id": 43, "name": "tennis racket"},
|
| 42 |
+
{"color": [197, 226, 255], "isthing": 1, "id": 44, "name": "bottle"},
|
| 43 |
+
{"color": [171, 134, 1], "isthing": 1, "id": 46, "name": "wine glass"},
|
| 44 |
+
{"color": [109, 63, 54], "isthing": 1, "id": 47, "name": "cup"},
|
| 45 |
+
{"color": [207, 138, 255], "isthing": 1, "id": 48, "name": "fork"},
|
| 46 |
+
{"color": [151, 0, 95], "isthing": 1, "id": 49, "name": "knife"},
|
| 47 |
+
{"color": [9, 80, 61], "isthing": 1, "id": 50, "name": "spoon"},
|
| 48 |
+
{"color": [84, 105, 51], "isthing": 1, "id": 51, "name": "bowl"},
|
| 49 |
+
{"color": [74, 65, 105], "isthing": 1, "id": 52, "name": "banana"},
|
| 50 |
+
{"color": [166, 196, 102], "isthing": 1, "id": 53, "name": "apple"},
|
| 51 |
+
{"color": [208, 195, 210], "isthing": 1, "id": 54, "name": "sandwich"},
|
| 52 |
+
{"color": [255, 109, 65], "isthing": 1, "id": 55, "name": "orange"},
|
| 53 |
+
{"color": [0, 143, 149], "isthing": 1, "id": 56, "name": "broccoli"},
|
| 54 |
+
{"color": [179, 0, 194], "isthing": 1, "id": 57, "name": "carrot"},
|
| 55 |
+
{"color": [209, 99, 106], "isthing": 1, "id": 58, "name": "hot dog"},
|
| 56 |
+
{"color": [5, 121, 0], "isthing": 1, "id": 59, "name": "pizza"},
|
| 57 |
+
{"color": [227, 255, 205], "isthing": 1, "id": 60, "name": "donut"},
|
| 58 |
+
{"color": [147, 186, 208], "isthing": 1, "id": 61, "name": "cake"},
|
| 59 |
+
{"color": [153, 69, 1], "isthing": 1, "id": 62, "name": "chair"},
|
| 60 |
+
{"color": [3, 95, 161], "isthing": 1, "id": 63, "name": "couch"},
|
| 61 |
+
{"color": [163, 255, 0], "isthing": 1, "id": 64, "name": "potted plant"},
|
| 62 |
+
{"color": [119, 0, 170], "isthing": 1, "id": 65, "name": "bed"},
|
| 63 |
+
{"color": [0, 182, 199], "isthing": 1, "id": 67, "name": "dining table"},
|
| 64 |
+
{"color": [0, 165, 120], "isthing": 1, "id": 70, "name": "toilet"},
|
| 65 |
+
{"color": [183, 130, 88], "isthing": 1, "id": 72, "name": "tv"},
|
| 66 |
+
{"color": [95, 32, 0], "isthing": 1, "id": 73, "name": "laptop"},
|
| 67 |
+
{"color": [130, 114, 135], "isthing": 1, "id": 74, "name": "mouse"},
|
| 68 |
+
{"color": [110, 129, 133], "isthing": 1, "id": 75, "name": "remote"},
|
| 69 |
+
{"color": [166, 74, 118], "isthing": 1, "id": 76, "name": "keyboard"},
|
| 70 |
+
{"color": [219, 142, 185], "isthing": 1, "id": 77, "name": "cell phone"},
|
| 71 |
+
{"color": [79, 210, 114], "isthing": 1, "id": 78, "name": "microwave"},
|
| 72 |
+
{"color": [178, 90, 62], "isthing": 1, "id": 79, "name": "oven"},
|
| 73 |
+
{"color": [65, 70, 15], "isthing": 1, "id": 80, "name": "toaster"},
|
| 74 |
+
{"color": [127, 167, 115], "isthing": 1, "id": 81, "name": "sink"},
|
| 75 |
+
{"color": [59, 105, 106], "isthing": 1, "id": 82, "name": "refrigerator"},
|
| 76 |
+
{"color": [142, 108, 45], "isthing": 1, "id": 84, "name": "book"},
|
| 77 |
+
{"color": [196, 172, 0], "isthing": 1, "id": 85, "name": "clock"},
|
| 78 |
+
{"color": [95, 54, 80], "isthing": 1, "id": 86, "name": "vase"},
|
| 79 |
+
{"color": [128, 76, 255], "isthing": 1, "id": 87, "name": "scissors"},
|
| 80 |
+
{"color": [201, 57, 1], "isthing": 1, "id": 88, "name": "teddy bear"},
|
| 81 |
+
{"color": [246, 0, 122], "isthing": 1, "id": 89, "name": "hair drier"},
|
| 82 |
+
{"color": [191, 162, 208], "isthing": 1, "id": 90, "name": "toothbrush"},
|
| 83 |
+
],
|
| 84 |
+
"cityscapes": [
|
| 85 |
+
{"id": i + 1, "name": x}
|
| 86 |
+
for i, x in enumerate(
|
| 87 |
+
["person", "rider", "car", "truck", "bus", "train", "motorcycle", "bicycle"]
|
| 88 |
+
)
|
| 89 |
+
],
|
| 90 |
+
"mapillary": [
|
| 91 |
+
{"id": 1, "name": "animal--bird"},
|
| 92 |
+
{"id": 2, "name": "animal--ground-animal"},
|
| 93 |
+
{"id": 9, "name": "construction--flat--crosswalk-plain"},
|
| 94 |
+
{"id": 20, "name": "human--person"},
|
| 95 |
+
{"id": 21, "name": "human--rider--bicyclist"},
|
| 96 |
+
{"id": 22, "name": "human--rider--motorcyclist"},
|
| 97 |
+
{"id": 23, "name": "human--rider--other-rider"},
|
| 98 |
+
{"id": 24, "name": "marking--crosswalk-zebra"},
|
| 99 |
+
{"id": 33, "name": "object--banner"},
|
| 100 |
+
{"id": 34, "name": "object--bench"},
|
| 101 |
+
{"id": 35, "name": "object--bike-rack"},
|
| 102 |
+
{"id": 36, "name": "object--billboard"},
|
| 103 |
+
{"id": 37, "name": "object--catch-basin"},
|
| 104 |
+
{"id": 38, "name": "object--cctv-camera"},
|
| 105 |
+
{"id": 39, "name": "object--fire-hydrant"},
|
| 106 |
+
{"id": 40, "name": "object--junction-box"},
|
| 107 |
+
{"id": 41, "name": "object--mailbox"},
|
| 108 |
+
{"id": 42, "name": "object--manhole"},
|
| 109 |
+
{"id": 43, "name": "object--phone-booth"},
|
| 110 |
+
{"id": 45, "name": "object--street-light"},
|
| 111 |
+
{"id": 46, "name": "object--support--pole"},
|
| 112 |
+
{"id": 47, "name": "object--support--traffic-sign-frame"},
|
| 113 |
+
{"id": 48, "name": "object--support--utility-pole"},
|
| 114 |
+
{"id": 49, "name": "object--traffic-light"},
|
| 115 |
+
{"id": 50, "name": "object--traffic-sign--back"},
|
| 116 |
+
{"id": 51, "name": "object--traffic-sign--front"},
|
| 117 |
+
{"id": 52, "name": "object--trash-can"},
|
| 118 |
+
{"id": 53, "name": "object--vehicle--bicycle"},
|
| 119 |
+
{"id": 54, "name": "object--vehicle--boat"},
|
| 120 |
+
{"id": 55, "name": "object--vehicle--bus"},
|
| 121 |
+
{"id": 56, "name": "object--vehicle--car"},
|
| 122 |
+
{"id": 57, "name": "object--vehicle--caravan"},
|
| 123 |
+
{"id": 58, "name": "object--vehicle--motorcycle"},
|
| 124 |
+
{"id": 60, "name": "object--vehicle--other-vehicle"},
|
| 125 |
+
{"id": 61, "name": "object--vehicle--trailer"},
|
| 126 |
+
{"id": 62, "name": "object--vehicle--truck"},
|
| 127 |
+
{"id": 63, "name": "object--vehicle--wheeled-slow"},
|
| 128 |
+
],
|
| 129 |
+
"viper": [
|
| 130 |
+
{"id": 13, "name": "trafficlight", "supercategory": ""},
|
| 131 |
+
{"id": 16, "name": "firehydrant", "supercategory": ""},
|
| 132 |
+
{"id": 17, "name": "chair", "supercategory": ""},
|
| 133 |
+
{"id": 19, "name": "trashcan", "supercategory": ""},
|
| 134 |
+
{"id": 20, "name": "person", "supercategory": ""},
|
| 135 |
+
{"id": 23, "name": "motorcycle", "supercategory": ""},
|
| 136 |
+
{"id": 24, "name": "car", "supercategory": ""},
|
| 137 |
+
{"id": 25, "name": "van", "supercategory": ""},
|
| 138 |
+
{"id": 26, "name": "bus", "supercategory": ""},
|
| 139 |
+
{"id": 27, "name": "truck", "supercategory": ""},
|
| 140 |
+
],
|
| 141 |
+
"scannet": [
|
| 142 |
+
{"id": 3, "name": "cabinet", "supercategory": "furniture"},
|
| 143 |
+
{"id": 4, "name": "bed", "supercategory": "furniture"},
|
| 144 |
+
{"id": 5, "name": "chair", "supercategory": "furniture"},
|
| 145 |
+
{"id": 6, "name": "sofa", "supercategory": "furniture"},
|
| 146 |
+
{"id": 7, "name": "table", "supercategory": "furniture"},
|
| 147 |
+
{"id": 8, "name": "door", "supercategory": "furniture"},
|
| 148 |
+
{"id": 9, "name": "window", "supercategory": "furniture"},
|
| 149 |
+
{"id": 10, "name": "bookshelf", "supercategory": "furniture"},
|
| 150 |
+
{"id": 11, "name": "picture", "supercategory": "furniture"},
|
| 151 |
+
{"id": 12, "name": "counter", "supercategory": "furniture"},
|
| 152 |
+
{"id": 14, "name": "desk", "supercategory": "furniture"},
|
| 153 |
+
{"id": 16, "name": "curtain", "supercategory": "furniture"},
|
| 154 |
+
{"id": 24, "name": "refrigerator", "supercategory": "appliance"},
|
| 155 |
+
{"id": 28, "name": "shower curtain", "supercategory": "furniture"},
|
| 156 |
+
{"id": 33, "name": "toilet", "supercategory": "furniture"},
|
| 157 |
+
{"id": 34, "name": "sink", "supercategory": "appliance"},
|
| 158 |
+
{"id": 36, "name": "bathtub", "supercategory": "furniture"},
|
| 159 |
+
{"id": 39, "name": "otherfurniture", "supercategory": "furniture"},
|
| 160 |
+
],
|
| 161 |
+
"oid": [
|
| 162 |
+
{"id": 1, "name": "Screwdriver", "freebase_id": "/m/01bms0"},
|
| 163 |
+
{"id": 2, "name": "Light switch", "freebase_id": "/m/03jbxj"},
|
| 164 |
+
{"id": 3, "name": "Doughnut", "freebase_id": "/m/0jy4k"},
|
| 165 |
+
{"id": 4, "name": "Toilet paper", "freebase_id": "/m/09gtd"},
|
| 166 |
+
{"id": 5, "name": "Wrench", "freebase_id": "/m/01j5ks"},
|
| 167 |
+
{"id": 6, "name": "Toaster", "freebase_id": "/m/01k6s3"},
|
| 168 |
+
{"id": 7, "name": "Tennis ball", "freebase_id": "/m/05ctyq"},
|
| 169 |
+
{"id": 8, "name": "Radish", "freebase_id": "/m/015x5n"},
|
| 170 |
+
{"id": 9, "name": "Pomegranate", "freebase_id": "/m/0jwn_"},
|
| 171 |
+
{"id": 10, "name": "Kite", "freebase_id": "/m/02zt3"},
|
| 172 |
+
{"id": 11, "name": "Table tennis racket", "freebase_id": "/m/05_5p_0"},
|
| 173 |
+
{"id": 12, "name": "Hamster", "freebase_id": "/m/03qrc"},
|
| 174 |
+
{"id": 13, "name": "Barge", "freebase_id": "/m/01btn"},
|
| 175 |
+
{"id": 14, "name": "Shower", "freebase_id": "/m/02f9f_"},
|
| 176 |
+
{"id": 15, "name": "Printer", "freebase_id": "/m/01m4t"},
|
| 177 |
+
{"id": 16, "name": "Snowmobile", "freebase_id": "/m/01x3jk"},
|
| 178 |
+
{"id": 17, "name": "Fire hydrant", "freebase_id": "/m/01pns0"},
|
| 179 |
+
{"id": 18, "name": "Limousine", "freebase_id": "/m/01lcw4"},
|
| 180 |
+
{"id": 19, "name": "Whale", "freebase_id": "/m/084zz"},
|
| 181 |
+
{"id": 20, "name": "Microwave oven", "freebase_id": "/m/0fx9l"},
|
| 182 |
+
{"id": 21, "name": "Asparagus", "freebase_id": "/m/0cjs7"},
|
| 183 |
+
{"id": 22, "name": "Lion", "freebase_id": "/m/096mb"},
|
| 184 |
+
{"id": 23, "name": "Spatula", "freebase_id": "/m/02d1br"},
|
| 185 |
+
{"id": 24, "name": "Torch", "freebase_id": "/m/07dd4"},
|
| 186 |
+
{"id": 25, "name": "Volleyball", "freebase_id": "/m/02rgn06"},
|
| 187 |
+
{"id": 26, "name": "Ambulance", "freebase_id": "/m/012n7d"},
|
| 188 |
+
{"id": 27, "name": "Chopsticks", "freebase_id": "/m/01_5g"},
|
| 189 |
+
{"id": 28, "name": "Raccoon", "freebase_id": "/m/0dq75"},
|
| 190 |
+
{"id": 29, "name": "Blue jay", "freebase_id": "/m/01f8m5"},
|
| 191 |
+
{"id": 30, "name": "Lynx", "freebase_id": "/m/04g2r"},
|
| 192 |
+
{"id": 31, "name": "Dice", "freebase_id": "/m/029b3"},
|
| 193 |
+
{"id": 32, "name": "Filing cabinet", "freebase_id": "/m/047j0r"},
|
| 194 |
+
{"id": 33, "name": "Ruler", "freebase_id": "/m/0hdln"},
|
| 195 |
+
{"id": 34, "name": "Power plugs and sockets", "freebase_id": "/m/03bbps"},
|
| 196 |
+
{"id": 35, "name": "Bell pepper", "freebase_id": "/m/0jg57"},
|
| 197 |
+
{"id": 36, "name": "Binoculars", "freebase_id": "/m/0lt4_"},
|
| 198 |
+
{"id": 37, "name": "Pretzel", "freebase_id": "/m/01f91_"},
|
| 199 |
+
{"id": 38, "name": "Hot dog", "freebase_id": "/m/01b9xk"},
|
| 200 |
+
{"id": 39, "name": "Missile", "freebase_id": "/m/04ylt"},
|
| 201 |
+
{"id": 40, "name": "Common fig", "freebase_id": "/m/043nyj"},
|
| 202 |
+
{"id": 41, "name": "Croissant", "freebase_id": "/m/015wgc"},
|
| 203 |
+
{"id": 42, "name": "Adhesive tape", "freebase_id": "/m/03m3vtv"},
|
| 204 |
+
{"id": 43, "name": "Slow cooker", "freebase_id": "/m/02tsc9"},
|
| 205 |
+
{"id": 44, "name": "Dog bed", "freebase_id": "/m/0h8n6f9"},
|
| 206 |
+
{"id": 45, "name": "Harpsichord", "freebase_id": "/m/03q5t"},
|
| 207 |
+
{"id": 46, "name": "Billiard table", "freebase_id": "/m/04p0qw"},
|
| 208 |
+
{"id": 47, "name": "Alpaca", "freebase_id": "/m/0pcr"},
|
| 209 |
+
{"id": 48, "name": "Harbor seal", "freebase_id": "/m/02l8p9"},
|
| 210 |
+
{"id": 49, "name": "Grape", "freebase_id": "/m/0388q"},
|
| 211 |
+
{"id": 50, "name": "Nail", "freebase_id": "/m/05bm6"},
|
| 212 |
+
{"id": 51, "name": "Paper towel", "freebase_id": "/m/02w3r3"},
|
| 213 |
+
{"id": 52, "name": "Alarm clock", "freebase_id": "/m/046dlr"},
|
| 214 |
+
{"id": 53, "name": "Guacamole", "freebase_id": "/m/02g30s"},
|
| 215 |
+
{"id": 54, "name": "Starfish", "freebase_id": "/m/01h8tj"},
|
| 216 |
+
{"id": 55, "name": "Zebra", "freebase_id": "/m/0898b"},
|
| 217 |
+
{"id": 56, "name": "Segway", "freebase_id": "/m/076bq"},
|
| 218 |
+
{"id": 57, "name": "Sea turtle", "freebase_id": "/m/0120dh"},
|
| 219 |
+
{"id": 58, "name": "Scissors", "freebase_id": "/m/01lsmm"},
|
| 220 |
+
{"id": 59, "name": "Rhinoceros", "freebase_id": "/m/03d443"},
|
| 221 |
+
{"id": 60, "name": "Kangaroo", "freebase_id": "/m/04c0y"},
|
| 222 |
+
{"id": 61, "name": "Jaguar", "freebase_id": "/m/0449p"},
|
| 223 |
+
{"id": 62, "name": "Leopard", "freebase_id": "/m/0c29q"},
|
| 224 |
+
{"id": 63, "name": "Dumbbell", "freebase_id": "/m/04h8sr"},
|
| 225 |
+
{"id": 64, "name": "Envelope", "freebase_id": "/m/0frqm"},
|
| 226 |
+
{"id": 65, "name": "Winter melon", "freebase_id": "/m/02cvgx"},
|
| 227 |
+
{"id": 66, "name": "Teapot", "freebase_id": "/m/01fh4r"},
|
| 228 |
+
{"id": 67, "name": "Camel", "freebase_id": "/m/01x_v"},
|
| 229 |
+
{"id": 68, "name": "Beaker", "freebase_id": "/m/0d20w4"},
|
| 230 |
+
{"id": 69, "name": "Brown bear", "freebase_id": "/m/01dxs"},
|
| 231 |
+
{"id": 70, "name": "Toilet", "freebase_id": "/m/09g1w"},
|
| 232 |
+
{"id": 71, "name": "Teddy bear", "freebase_id": "/m/0kmg4"},
|
| 233 |
+
{"id": 72, "name": "Briefcase", "freebase_id": "/m/0584n8"},
|
| 234 |
+
{"id": 73, "name": "Stop sign", "freebase_id": "/m/02pv19"},
|
| 235 |
+
{"id": 74, "name": "Tiger", "freebase_id": "/m/07dm6"},
|
| 236 |
+
{"id": 75, "name": "Cabbage", "freebase_id": "/m/0fbw6"},
|
| 237 |
+
{"id": 76, "name": "Giraffe", "freebase_id": "/m/03bk1"},
|
| 238 |
+
{"id": 77, "name": "Polar bear", "freebase_id": "/m/0633h"},
|
| 239 |
+
{"id": 78, "name": "Shark", "freebase_id": "/m/0by6g"},
|
| 240 |
+
{"id": 79, "name": "Rabbit", "freebase_id": "/m/06mf6"},
|
| 241 |
+
{"id": 80, "name": "Swim cap", "freebase_id": "/m/04tn4x"},
|
| 242 |
+
{"id": 81, "name": "Pressure cooker", "freebase_id": "/m/0h8ntjv"},
|
| 243 |
+
{"id": 82, "name": "Kitchen knife", "freebase_id": "/m/058qzx"},
|
| 244 |
+
{"id": 83, "name": "Submarine sandwich", "freebase_id": "/m/06pcq"},
|
| 245 |
+
{"id": 84, "name": "Flashlight", "freebase_id": "/m/01kb5b"},
|
| 246 |
+
{"id": 85, "name": "Penguin", "freebase_id": "/m/05z6w"},
|
| 247 |
+
{"id": 86, "name": "Snake", "freebase_id": "/m/078jl"},
|
| 248 |
+
{"id": 87, "name": "Zucchini", "freebase_id": "/m/027pcv"},
|
| 249 |
+
{"id": 88, "name": "Bat", "freebase_id": "/m/01h44"},
|
| 250 |
+
{"id": 89, "name": "Food processor", "freebase_id": "/m/03y6mg"},
|
| 251 |
+
{"id": 90, "name": "Ostrich", "freebase_id": "/m/05n4y"},
|
| 252 |
+
{"id": 91, "name": "Sea lion", "freebase_id": "/m/0gd36"},
|
| 253 |
+
{"id": 92, "name": "Goldfish", "freebase_id": "/m/03fj2"},
|
| 254 |
+
{"id": 93, "name": "Elephant", "freebase_id": "/m/0bwd_0j"},
|
| 255 |
+
{"id": 94, "name": "Rocket", "freebase_id": "/m/09rvcxw"},
|
| 256 |
+
{"id": 95, "name": "Mouse", "freebase_id": "/m/04rmv"},
|
| 257 |
+
{"id": 96, "name": "Oyster", "freebase_id": "/m/0_cp5"},
|
| 258 |
+
{"id": 97, "name": "Digital clock", "freebase_id": "/m/06_72j"},
|
| 259 |
+
{"id": 98, "name": "Otter", "freebase_id": "/m/0cn6p"},
|
| 260 |
+
{"id": 99, "name": "Dolphin", "freebase_id": "/m/02hj4"},
|
| 261 |
+
{"id": 100, "name": "Punching bag", "freebase_id": "/m/0420v5"},
|
| 262 |
+
{"id": 101, "name": "Corded phone", "freebase_id": "/m/0h8lkj8"},
|
| 263 |
+
{"id": 102, "name": "Tennis racket", "freebase_id": "/m/0h8my_4"},
|
| 264 |
+
{"id": 103, "name": "Pancake", "freebase_id": "/m/01dwwc"},
|
| 265 |
+
{"id": 104, "name": "Mango", "freebase_id": "/m/0fldg"},
|
| 266 |
+
{"id": 105, "name": "Crocodile", "freebase_id": "/m/09f_2"},
|
| 267 |
+
{"id": 106, "name": "Waffle", "freebase_id": "/m/01dwsz"},
|
| 268 |
+
{"id": 107, "name": "Computer mouse", "freebase_id": "/m/020lf"},
|
| 269 |
+
{"id": 108, "name": "Kettle", "freebase_id": "/m/03s_tn"},
|
| 270 |
+
{"id": 109, "name": "Tart", "freebase_id": "/m/02zvsm"},
|
| 271 |
+
{"id": 110, "name": "Oven", "freebase_id": "/m/029bxz"},
|
| 272 |
+
{"id": 111, "name": "Banana", "freebase_id": "/m/09qck"},
|
| 273 |
+
{"id": 112, "name": "Cheetah", "freebase_id": "/m/0cd4d"},
|
| 274 |
+
{"id": 113, "name": "Raven", "freebase_id": "/m/06j2d"},
|
| 275 |
+
{"id": 114, "name": "Frying pan", "freebase_id": "/m/04v6l4"},
|
| 276 |
+
{"id": 115, "name": "Pear", "freebase_id": "/m/061_f"},
|
| 277 |
+
{"id": 116, "name": "Fox", "freebase_id": "/m/0306r"},
|
| 278 |
+
{"id": 117, "name": "Skateboard", "freebase_id": "/m/06_fw"},
|
| 279 |
+
{"id": 118, "name": "Rugby ball", "freebase_id": "/m/0wdt60w"},
|
| 280 |
+
{"id": 119, "name": "Watermelon", "freebase_id": "/m/0kpqd"},
|
| 281 |
+
{"id": 120, "name": "Flute", "freebase_id": "/m/0l14j_"},
|
| 282 |
+
{"id": 121, "name": "Canary", "freebase_id": "/m/0ccs93"},
|
| 283 |
+
{"id": 122, "name": "Door handle", "freebase_id": "/m/03c7gz"},
|
| 284 |
+
{"id": 123, "name": "Saxophone", "freebase_id": "/m/06ncr"},
|
| 285 |
+
{"id": 124, "name": "Burrito", "freebase_id": "/m/01j3zr"},
|
| 286 |
+
{"id": 125, "name": "Suitcase", "freebase_id": "/m/01s55n"},
|
| 287 |
+
{"id": 126, "name": "Roller skates", "freebase_id": "/m/02p3w7d"},
|
| 288 |
+
{"id": 127, "name": "Dagger", "freebase_id": "/m/02gzp"},
|
| 289 |
+
{"id": 128, "name": "Seat belt", "freebase_id": "/m/0dkzw"},
|
| 290 |
+
{"id": 129, "name": "Washing machine", "freebase_id": "/m/0174k2"},
|
| 291 |
+
{"id": 130, "name": "Jet ski", "freebase_id": "/m/01xs3r"},
|
| 292 |
+
{"id": 131, "name": "Sombrero", "freebase_id": "/m/02jfl0"},
|
| 293 |
+
{"id": 132, "name": "Pig", "freebase_id": "/m/068zj"},
|
| 294 |
+
{"id": 133, "name": "Drinking straw", "freebase_id": "/m/03v5tg"},
|
| 295 |
+
{"id": 134, "name": "Peach", "freebase_id": "/m/0dj6p"},
|
| 296 |
+
{"id": 135, "name": "Tortoise", "freebase_id": "/m/011k07"},
|
| 297 |
+
{"id": 136, "name": "Towel", "freebase_id": "/m/0162_1"},
|
| 298 |
+
{"id": 137, "name": "Tablet computer", "freebase_id": "/m/0bh9flk"},
|
| 299 |
+
{"id": 138, "name": "Cucumber", "freebase_id": "/m/015x4r"},
|
| 300 |
+
{"id": 139, "name": "Mule", "freebase_id": "/m/0dbzx"},
|
| 301 |
+
{"id": 140, "name": "Potato", "freebase_id": "/m/05vtc"},
|
| 302 |
+
{"id": 141, "name": "Frog", "freebase_id": "/m/09ld4"},
|
| 303 |
+
{"id": 142, "name": "Bear", "freebase_id": "/m/01dws"},
|
| 304 |
+
{"id": 143, "name": "Lighthouse", "freebase_id": "/m/04h7h"},
|
| 305 |
+
{"id": 144, "name": "Belt", "freebase_id": "/m/0176mf"},
|
| 306 |
+
{"id": 145, "name": "Baseball bat", "freebase_id": "/m/03g8mr"},
|
| 307 |
+
{"id": 146, "name": "Racket", "freebase_id": "/m/0dv9c"},
|
| 308 |
+
{"id": 147, "name": "Sword", "freebase_id": "/m/06y5r"},
|
| 309 |
+
{"id": 148, "name": "Bagel", "freebase_id": "/m/01fb_0"},
|
| 310 |
+
{"id": 149, "name": "Goat", "freebase_id": "/m/03fwl"},
|
| 311 |
+
{"id": 150, "name": "Lizard", "freebase_id": "/m/04m9y"},
|
| 312 |
+
{"id": 151, "name": "Parrot", "freebase_id": "/m/0gv1x"},
|
| 313 |
+
{"id": 152, "name": "Owl", "freebase_id": "/m/09d5_"},
|
| 314 |
+
{"id": 153, "name": "Turkey", "freebase_id": "/m/0jly1"},
|
| 315 |
+
{"id": 154, "name": "Cello", "freebase_id": "/m/01xqw"},
|
| 316 |
+
{"id": 155, "name": "Knife", "freebase_id": "/m/04ctx"},
|
| 317 |
+
{"id": 156, "name": "Handgun", "freebase_id": "/m/0gxl3"},
|
| 318 |
+
{"id": 157, "name": "Carrot", "freebase_id": "/m/0fj52s"},
|
| 319 |
+
{"id": 158, "name": "Hamburger", "freebase_id": "/m/0cdn1"},
|
| 320 |
+
{"id": 159, "name": "Grapefruit", "freebase_id": "/m/0hqkz"},
|
| 321 |
+
{"id": 160, "name": "Tap", "freebase_id": "/m/02jz0l"},
|
| 322 |
+
{"id": 161, "name": "Tea", "freebase_id": "/m/07clx"},
|
| 323 |
+
{"id": 162, "name": "Bull", "freebase_id": "/m/0cnyhnx"},
|
| 324 |
+
{"id": 163, "name": "Turtle", "freebase_id": "/m/09dzg"},
|
| 325 |
+
{"id": 164, "name": "Bust", "freebase_id": "/m/04yqq2"},
|
| 326 |
+
{"id": 165, "name": "Monkey", "freebase_id": "/m/08pbxl"},
|
| 327 |
+
{"id": 166, "name": "Wok", "freebase_id": "/m/084rd"},
|
| 328 |
+
{"id": 167, "name": "Broccoli", "freebase_id": "/m/0hkxq"},
|
| 329 |
+
{"id": 168, "name": "Pitcher", "freebase_id": "/m/054fyh"},
|
| 330 |
+
{"id": 169, "name": "Whiteboard", "freebase_id": "/m/02d9qx"},
|
| 331 |
+
{"id": 170, "name": "Squirrel", "freebase_id": "/m/071qp"},
|
| 332 |
+
{"id": 171, "name": "Jug", "freebase_id": "/m/08hvt4"},
|
| 333 |
+
{"id": 172, "name": "Woodpecker", "freebase_id": "/m/01dy8n"},
|
| 334 |
+
{"id": 173, "name": "Pizza", "freebase_id": "/m/0663v"},
|
| 335 |
+
{"id": 174, "name": "Surfboard", "freebase_id": "/m/019w40"},
|
| 336 |
+
{"id": 175, "name": "Sofa bed", "freebase_id": "/m/03m3pdh"},
|
| 337 |
+
{"id": 176, "name": "Sheep", "freebase_id": "/m/07bgp"},
|
| 338 |
+
{"id": 177, "name": "Candle", "freebase_id": "/m/0c06p"},
|
| 339 |
+
{"id": 178, "name": "Muffin", "freebase_id": "/m/01tcjp"},
|
| 340 |
+
{"id": 179, "name": "Cookie", "freebase_id": "/m/021mn"},
|
| 341 |
+
{"id": 180, "name": "Apple", "freebase_id": "/m/014j1m"},
|
| 342 |
+
{"id": 181, "name": "Chest of drawers", "freebase_id": "/m/05kyg_"},
|
| 343 |
+
{"id": 182, "name": "Skull", "freebase_id": "/m/016m2d"},
|
| 344 |
+
{"id": 183, "name": "Chicken", "freebase_id": "/m/09b5t"},
|
| 345 |
+
{"id": 184, "name": "Loveseat", "freebase_id": "/m/0703r8"},
|
| 346 |
+
{"id": 185, "name": "Baseball glove", "freebase_id": "/m/03grzl"},
|
| 347 |
+
{"id": 186, "name": "Piano", "freebase_id": "/m/05r5c"},
|
| 348 |
+
{"id": 187, "name": "Waste container", "freebase_id": "/m/0bjyj5"},
|
| 349 |
+
{"id": 188, "name": "Barrel", "freebase_id": "/m/02zn6n"},
|
| 350 |
+
{"id": 189, "name": "Swan", "freebase_id": "/m/0dftk"},
|
| 351 |
+
{"id": 190, "name": "Taxi", "freebase_id": "/m/0pg52"},
|
| 352 |
+
{"id": 191, "name": "Lemon", "freebase_id": "/m/09k_b"},
|
| 353 |
+
{"id": 192, "name": "Pumpkin", "freebase_id": "/m/05zsy"},
|
| 354 |
+
{"id": 193, "name": "Sparrow", "freebase_id": "/m/0h23m"},
|
| 355 |
+
{"id": 194, "name": "Orange", "freebase_id": "/m/0cyhj_"},
|
| 356 |
+
{"id": 195, "name": "Tank", "freebase_id": "/m/07cmd"},
|
| 357 |
+
{"id": 196, "name": "Sandwich", "freebase_id": "/m/0l515"},
|
| 358 |
+
{"id": 197, "name": "Coffee", "freebase_id": "/m/02vqfm"},
|
| 359 |
+
{"id": 198, "name": "Juice", "freebase_id": "/m/01z1kdw"},
|
| 360 |
+
{"id": 199, "name": "Coin", "freebase_id": "/m/0242l"},
|
| 361 |
+
{"id": 200, "name": "Pen", "freebase_id": "/m/0k1tl"},
|
| 362 |
+
{"id": 201, "name": "Watch", "freebase_id": "/m/0gjkl"},
|
| 363 |
+
{"id": 202, "name": "Eagle", "freebase_id": "/m/09csl"},
|
| 364 |
+
{"id": 203, "name": "Goose", "freebase_id": "/m/0dbvp"},
|
| 365 |
+
{"id": 204, "name": "Falcon", "freebase_id": "/m/0f6wt"},
|
| 366 |
+
{"id": 205, "name": "Christmas tree", "freebase_id": "/m/025nd"},
|
| 367 |
+
{"id": 206, "name": "Sunflower", "freebase_id": "/m/0ftb8"},
|
| 368 |
+
{"id": 207, "name": "Vase", "freebase_id": "/m/02s195"},
|
| 369 |
+
{"id": 208, "name": "Football", "freebase_id": "/m/01226z"},
|
| 370 |
+
{"id": 209, "name": "Canoe", "freebase_id": "/m/0ph39"},
|
| 371 |
+
{"id": 210, "name": "High heels", "freebase_id": "/m/06k2mb"},
|
| 372 |
+
{"id": 211, "name": "Spoon", "freebase_id": "/m/0cmx8"},
|
| 373 |
+
{"id": 212, "name": "Mug", "freebase_id": "/m/02jvh9"},
|
| 374 |
+
{"id": 213, "name": "Swimwear", "freebase_id": "/m/01gkx_"},
|
| 375 |
+
{"id": 214, "name": "Duck", "freebase_id": "/m/09ddx"},
|
| 376 |
+
{"id": 215, "name": "Cat", "freebase_id": "/m/01yrx"},
|
| 377 |
+
{"id": 216, "name": "Tomato", "freebase_id": "/m/07j87"},
|
| 378 |
+
{"id": 217, "name": "Cocktail", "freebase_id": "/m/024g6"},
|
| 379 |
+
{"id": 218, "name": "Clock", "freebase_id": "/m/01x3z"},
|
| 380 |
+
{"id": 219, "name": "Cowboy hat", "freebase_id": "/m/025rp__"},
|
| 381 |
+
{"id": 220, "name": "Miniskirt", "freebase_id": "/m/01cmb2"},
|
| 382 |
+
{"id": 221, "name": "Cattle", "freebase_id": "/m/01xq0k1"},
|
| 383 |
+
{"id": 222, "name": "Strawberry", "freebase_id": "/m/07fbm7"},
|
| 384 |
+
{"id": 223, "name": "Bronze sculpture", "freebase_id": "/m/01yx86"},
|
| 385 |
+
{"id": 224, "name": "Pillow", "freebase_id": "/m/034c16"},
|
| 386 |
+
{"id": 225, "name": "Squash", "freebase_id": "/m/0dv77"},
|
| 387 |
+
{"id": 226, "name": "Traffic light", "freebase_id": "/m/015qff"},
|
| 388 |
+
{"id": 227, "name": "Saucer", "freebase_id": "/m/03q5c7"},
|
| 389 |
+
{"id": 228, "name": "Reptile", "freebase_id": "/m/06bt6"},
|
| 390 |
+
{"id": 229, "name": "Cake", "freebase_id": "/m/0fszt"},
|
| 391 |
+
{"id": 230, "name": "Plastic bag", "freebase_id": "/m/05gqfk"},
|
| 392 |
+
{"id": 231, "name": "Studio couch", "freebase_id": "/m/026qbn5"},
|
| 393 |
+
{"id": 232, "name": "Beer", "freebase_id": "/m/01599"},
|
| 394 |
+
{"id": 233, "name": "Scarf", "freebase_id": "/m/02h19r"},
|
| 395 |
+
{"id": 234, "name": "Coffee cup", "freebase_id": "/m/02p5f1q"},
|
| 396 |
+
{"id": 235, "name": "Wine", "freebase_id": "/m/081qc"},
|
| 397 |
+
{"id": 236, "name": "Mushroom", "freebase_id": "/m/052sf"},
|
| 398 |
+
{"id": 237, "name": "Traffic sign", "freebase_id": "/m/01mqdt"},
|
| 399 |
+
{"id": 238, "name": "Camera", "freebase_id": "/m/0dv5r"},
|
| 400 |
+
{"id": 239, "name": "Rose", "freebase_id": "/m/06m11"},
|
| 401 |
+
{"id": 240, "name": "Couch", "freebase_id": "/m/02crq1"},
|
| 402 |
+
{"id": 241, "name": "Handbag", "freebase_id": "/m/080hkjn"},
|
| 403 |
+
{"id": 242, "name": "Fedora", "freebase_id": "/m/02fq_6"},
|
| 404 |
+
{"id": 243, "name": "Sock", "freebase_id": "/m/01nq26"},
|
| 405 |
+
{"id": 244, "name": "Computer keyboard", "freebase_id": "/m/01m2v"},
|
| 406 |
+
{"id": 245, "name": "Mobile phone", "freebase_id": "/m/050k8"},
|
| 407 |
+
{"id": 246, "name": "Ball", "freebase_id": "/m/018xm"},
|
| 408 |
+
{"id": 247, "name": "Balloon", "freebase_id": "/m/01j51"},
|
| 409 |
+
{"id": 248, "name": "Horse", "freebase_id": "/m/03k3r"},
|
| 410 |
+
{"id": 249, "name": "Boot", "freebase_id": "/m/01b638"},
|
| 411 |
+
{"id": 250, "name": "Fish", "freebase_id": "/m/0ch_cf"},
|
| 412 |
+
{"id": 251, "name": "Backpack", "freebase_id": "/m/01940j"},
|
| 413 |
+
{"id": 252, "name": "Skirt", "freebase_id": "/m/02wv6h6"},
|
| 414 |
+
{"id": 253, "name": "Van", "freebase_id": "/m/0h2r6"},
|
| 415 |
+
{"id": 254, "name": "Bread", "freebase_id": "/m/09728"},
|
| 416 |
+
{"id": 255, "name": "Glove", "freebase_id": "/m/0174n1"},
|
| 417 |
+
{"id": 256, "name": "Dog", "freebase_id": "/m/0bt9lr"},
|
| 418 |
+
{"id": 257, "name": "Airplane", "freebase_id": "/m/0cmf2"},
|
| 419 |
+
{"id": 258, "name": "Motorcycle", "freebase_id": "/m/04_sv"},
|
| 420 |
+
{"id": 259, "name": "Drink", "freebase_id": "/m/0271t"},
|
| 421 |
+
{"id": 260, "name": "Book", "freebase_id": "/m/0bt_c3"},
|
| 422 |
+
{"id": 261, "name": "Train", "freebase_id": "/m/07jdr"},
|
| 423 |
+
{"id": 262, "name": "Flower", "freebase_id": "/m/0c9ph5"},
|
| 424 |
+
{"id": 263, "name": "Carnivore", "freebase_id": "/m/01lrl"},
|
| 425 |
+
{"id": 264, "name": "Human ear", "freebase_id": "/m/039xj_"},
|
| 426 |
+
{"id": 265, "name": "Toy", "freebase_id": "/m/0138tl"},
|
| 427 |
+
{"id": 266, "name": "Box", "freebase_id": "/m/025dyy"},
|
| 428 |
+
{"id": 267, "name": "Truck", "freebase_id": "/m/07r04"},
|
| 429 |
+
{"id": 268, "name": "Wheel", "freebase_id": "/m/083wq"},
|
| 430 |
+
{"id": 269, "name": "Aircraft", "freebase_id": "/m/0k5j"},
|
| 431 |
+
{"id": 270, "name": "Bus", "freebase_id": "/m/01bjv"},
|
| 432 |
+
{"id": 271, "name": "Human mouth", "freebase_id": "/m/0283dt1"},
|
| 433 |
+
{"id": 272, "name": "Sculpture", "freebase_id": "/m/06msq"},
|
| 434 |
+
{"id": 273, "name": "Shirt", "freebase_id": "/m/01n4qj"},
|
| 435 |
+
{"id": 274, "name": "Hat", "freebase_id": "/m/02dl1y"},
|
| 436 |
+
{"id": 275, "name": "Vehicle registration plate", "freebase_id": "/m/01jfm_"},
|
| 437 |
+
{"id": 276, "name": "Guitar", "freebase_id": "/m/0342h"},
|
| 438 |
+
{"id": 277, "name": "Sun hat", "freebase_id": "/m/02wbtzl"},
|
| 439 |
+
{"id": 278, "name": "Bottle", "freebase_id": "/m/04dr76w"},
|
| 440 |
+
{"id": 279, "name": "Luggage and bags", "freebase_id": "/m/0hf58v5"},
|
| 441 |
+
{"id": 280, "name": "Trousers", "freebase_id": "/m/07mhn"},
|
| 442 |
+
{"id": 281, "name": "Bicycle wheel", "freebase_id": "/m/01bqk0"},
|
| 443 |
+
{"id": 282, "name": "Suit", "freebase_id": "/m/01xyhv"},
|
| 444 |
+
{"id": 283, "name": "Bowl", "freebase_id": "/m/04kkgm"},
|
| 445 |
+
{"id": 284, "name": "Man", "freebase_id": "/m/04yx4"},
|
| 446 |
+
{"id": 285, "name": "Flowerpot", "freebase_id": "/m/0fm3zh"},
|
| 447 |
+
{"id": 286, "name": "Laptop", "freebase_id": "/m/01c648"},
|
| 448 |
+
{"id": 287, "name": "Boy", "freebase_id": "/m/01bl7v"},
|
| 449 |
+
{"id": 288, "name": "Picture frame", "freebase_id": "/m/06z37_"},
|
| 450 |
+
{"id": 289, "name": "Bird", "freebase_id": "/m/015p6"},
|
| 451 |
+
{"id": 290, "name": "Car", "freebase_id": "/m/0k4j"},
|
| 452 |
+
{"id": 291, "name": "Shorts", "freebase_id": "/m/01bfm9"},
|
| 453 |
+
{"id": 292, "name": "Woman", "freebase_id": "/m/03bt1vf"},
|
| 454 |
+
{"id": 293, "name": "Platter", "freebase_id": "/m/099ssp"},
|
| 455 |
+
{"id": 294, "name": "Tie", "freebase_id": "/m/01rkbr"},
|
| 456 |
+
{"id": 295, "name": "Girl", "freebase_id": "/m/05r655"},
|
| 457 |
+
{"id": 296, "name": "Skyscraper", "freebase_id": "/m/079cl"},
|
| 458 |
+
{"id": 297, "name": "Person", "freebase_id": "/m/01g317"},
|
| 459 |
+
{"id": 298, "name": "Flag", "freebase_id": "/m/03120"},
|
| 460 |
+
{"id": 299, "name": "Jeans", "freebase_id": "/m/0fly7"},
|
| 461 |
+
{"id": 300, "name": "Dress", "freebase_id": "/m/01d40f"},
|
| 462 |
+
],
|
| 463 |
+
"kitti": [
|
| 464 |
+
{"id": 24, "name": "person"},
|
| 465 |
+
{"id": 25, "name": "rider"},
|
| 466 |
+
{"id": 26, "name": "car"},
|
| 467 |
+
{"id": 27, "name": "truck"},
|
| 468 |
+
{"id": 28, "name": "bus"},
|
| 469 |
+
{"id": 31, "name": "train"},
|
| 470 |
+
{"id": 32, "name": "motorcycle"},
|
| 471 |
+
{"id": 33, "name": "bicycle"},
|
| 472 |
+
],
|
| 473 |
+
"wilddash": [
|
| 474 |
+
{"id": 1, "name": "ego vehicle"},
|
| 475 |
+
{"id": 24, "name": "person"},
|
| 476 |
+
{"id": 25, "name": "rider"},
|
| 477 |
+
{"id": 26, "name": "car"},
|
| 478 |
+
{"id": 27, "name": "truck"},
|
| 479 |
+
{"id": 28, "name": "bus"},
|
| 480 |
+
{"id": 29, "name": "caravan"},
|
| 481 |
+
{"id": 30, "name": "trailer"},
|
| 482 |
+
{"id": 31, "name": "train"},
|
| 483 |
+
{"id": 32, "name": "motorcycle"},
|
| 484 |
+
{"id": 33, "name": "bicycle"},
|
| 485 |
+
{"id": 34, "name": "pickup"},
|
| 486 |
+
{"id": 35, "name": "van"},
|
| 487 |
+
],
|
| 488 |
+
}
|
approach/ovod/APE/ape/data/datasets/lvis_coco.py
ADDED
|
@@ -0,0 +1,284 @@
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import pycocotools.mask as mask_util
|
| 5 |
+
|
| 6 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 7 |
+
from detectron2.data.datasets.builtin_meta import _get_coco_instances_meta
|
| 8 |
+
from detectron2.data.datasets.lvis_v0_5_categories import LVIS_CATEGORIES as LVIS_V0_5_CATEGORIES
|
| 9 |
+
from detectron2.data.datasets.lvis_v1_categories import LVIS_CATEGORIES as LVIS_V1_CATEGORIES
|
| 10 |
+
from detectron2.structures import BoxMode
|
| 11 |
+
from detectron2.utils.file_io import PathManager
|
| 12 |
+
from fvcore.common.timer import Timer
|
| 13 |
+
|
| 14 |
+
from .lvis_v1_coco_category_image_count import LVIS_V1_COCO_CATEGORY_IMAGE_COUNT
|
| 15 |
+
|
| 16 |
+
"""
|
| 17 |
+
This file contains functions to parse LVIS-format annotations into dicts in the
|
| 18 |
+
"Detectron2 format".
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
__all__ = ["custom_load_lvis_json", "custom_register_lvis_instances"]
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def custom_register_lvis_instances(name, metadata, json_file, image_root):
|
| 27 |
+
"""
|
| 28 |
+
Register a dataset in LVIS's json annotation format for instance detection and segmentation.
|
| 29 |
+
|
| 30 |
+
Args:
|
| 31 |
+
name (str): a name that identifies the dataset, e.g. "lvis_v0.5_train".
|
| 32 |
+
metadata (dict): extra metadata associated with this dataset. It can be an empty dict.
|
| 33 |
+
json_file (str): path to the json instance annotation file.
|
| 34 |
+
image_root (str or path-like): directory which contains all the images.
|
| 35 |
+
"""
|
| 36 |
+
DatasetCatalog.register(name, lambda: custom_load_lvis_json(json_file, image_root, name))
|
| 37 |
+
MetadataCatalog.get(name).set(
|
| 38 |
+
json_file=json_file, image_root=image_root, evaluator_type="lvis", **metadata
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def custom_load_lvis_json(json_file, image_root, dataset_name=None, extra_annotation_keys=None):
|
| 43 |
+
"""
|
| 44 |
+
Load a json file in LVIS's annotation format.
|
| 45 |
+
|
| 46 |
+
Args:
|
| 47 |
+
json_file (str): full path to the LVIS json annotation file.
|
| 48 |
+
image_root (str): the directory where the images in this json file exists.
|
| 49 |
+
dataset_name (str): the name of the dataset (e.g., "lvis_v0.5_train").
|
| 50 |
+
If provided, this function will put "thing_classes" into the metadata
|
| 51 |
+
associated with this dataset.
|
| 52 |
+
extra_annotation_keys (list[str]): list of per-annotation keys that should also be
|
| 53 |
+
loaded into the dataset dict (besides "bbox", "bbox_mode", "category_id",
|
| 54 |
+
"segmentation"). The values for these keys will be returned as-is.
|
| 55 |
+
|
| 56 |
+
Returns:
|
| 57 |
+
list[dict]: a list of dicts in Detectron2 standard format. (See
|
| 58 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ )
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
1. This function does not read the image files.
|
| 62 |
+
The results do not have the "image" field.
|
| 63 |
+
"""
|
| 64 |
+
from lvis import LVIS
|
| 65 |
+
|
| 66 |
+
json_file = PathManager.get_local_path(json_file)
|
| 67 |
+
|
| 68 |
+
timer = Timer()
|
| 69 |
+
lvis_api = LVIS(json_file)
|
| 70 |
+
if timer.seconds() > 1:
|
| 71 |
+
logger.info("Loading {} takes {:.2f} seconds.".format(json_file, timer.seconds()))
|
| 72 |
+
|
| 73 |
+
if dataset_name is not None:
|
| 74 |
+
meta = get_lvis_instances_meta(dataset_name)
|
| 75 |
+
MetadataCatalog.get(dataset_name).set(**meta)
|
| 76 |
+
|
| 77 |
+
# sort indices for reproducible results
|
| 78 |
+
img_ids = sorted(lvis_api.imgs.keys())
|
| 79 |
+
# imgs is a list of dicts, each looks something like:
|
| 80 |
+
# {'license': 4,
|
| 81 |
+
# 'url': 'http://farm6.staticflickr.com/5454/9413846304_881d5e5c3b_z.jpg',
|
| 82 |
+
# 'file_name': 'COCO_val2014_000000001268.jpg',
|
| 83 |
+
# 'height': 427,
|
| 84 |
+
# 'width': 640,
|
| 85 |
+
# 'date_captured': '2013-11-17 05:57:24',
|
| 86 |
+
# 'id': 1268}
|
| 87 |
+
imgs = lvis_api.load_imgs(img_ids)
|
| 88 |
+
# anns is a list[list[dict]], where each dict is an annotation
|
| 89 |
+
# record for an object. The inner list enumerates the objects in an image
|
| 90 |
+
# and the outer list enumerates over images. Example of anns[0]:
|
| 91 |
+
# [{'segmentation': [[192.81,
|
| 92 |
+
# 247.09,
|
| 93 |
+
# ...
|
| 94 |
+
# 219.03,
|
| 95 |
+
# 249.06]],
|
| 96 |
+
# 'area': 1035.749,
|
| 97 |
+
# 'image_id': 1268,
|
| 98 |
+
# 'bbox': [192.81, 224.8, 74.73, 33.43],
|
| 99 |
+
# 'category_id': 16,
|
| 100 |
+
# 'id': 42986},
|
| 101 |
+
# ...]
|
| 102 |
+
anns = [lvis_api.img_ann_map[img_id] for img_id in img_ids]
|
| 103 |
+
|
| 104 |
+
# Sanity check that each annotation has a unique id
|
| 105 |
+
ann_ids = [ann["id"] for anns_per_image in anns for ann in anns_per_image]
|
| 106 |
+
assert len(set(ann_ids)) == len(ann_ids), "Annotation ids in '{}' are not unique".format(
|
| 107 |
+
json_file
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
imgs_anns = list(zip(imgs, anns))
|
| 111 |
+
|
| 112 |
+
logger.info("Loaded {} images in the LVIS format from {}".format(len(imgs_anns), json_file))
|
| 113 |
+
|
| 114 |
+
if extra_annotation_keys:
|
| 115 |
+
logger.info(
|
| 116 |
+
"The following extra annotation keys will be loaded: {} ".format(extra_annotation_keys)
|
| 117 |
+
)
|
| 118 |
+
else:
|
| 119 |
+
extra_annotation_keys = []
|
| 120 |
+
|
| 121 |
+
def get_file_name(img_root, img_dict):
|
| 122 |
+
# Determine the path including the split folder ("train2017", "val2017", "test2017") from
|
| 123 |
+
# the coco_url field. Example:
|
| 124 |
+
# 'coco_url': 'http://images.cocodataset.org/train2017/000000155379.jpg'
|
| 125 |
+
if "file_name" in img_dict:
|
| 126 |
+
file_name = img_dict["file_name"]
|
| 127 |
+
if img_dict["file_name"].startswith("COCO"):
|
| 128 |
+
file_name = file_name[-16:]
|
| 129 |
+
return os.path.join(image_root, file_name)
|
| 130 |
+
split_folder, file_name = img_dict["coco_url"].split("/")[-2:]
|
| 131 |
+
return os.path.join(img_root + split_folder, file_name)
|
| 132 |
+
|
| 133 |
+
dataset_dicts = []
|
| 134 |
+
|
| 135 |
+
for (img_dict, anno_dict_list) in imgs_anns:
|
| 136 |
+
record = {}
|
| 137 |
+
record["file_name"] = get_file_name(image_root, img_dict)
|
| 138 |
+
record["height"] = img_dict["height"]
|
| 139 |
+
record["width"] = img_dict["width"]
|
| 140 |
+
record["not_exhaustive_category_ids"] = img_dict.get("not_exhaustive_category_ids", [])
|
| 141 |
+
record["neg_category_ids"] = img_dict.get("neg_category_ids", [])
|
| 142 |
+
record["pos_category_ids"] = img_dict.get("pos_category_ids", [])
|
| 143 |
+
if dataset_name is not None and "thing_dataset_id_to_contiguous_id" in meta:
|
| 144 |
+
record["neg_category_ids"] = [
|
| 145 |
+
meta["thing_dataset_id_to_contiguous_id"][x] for x in record["neg_category_ids"]
|
| 146 |
+
]
|
| 147 |
+
record["pos_category_ids"] = [
|
| 148 |
+
meta["thing_dataset_id_to_contiguous_id"][x] for x in record["pos_category_ids"]
|
| 149 |
+
]
|
| 150 |
+
else:
|
| 151 |
+
record["neg_category_ids"] = [x - 1 for x in record["neg_category_ids"]]
|
| 152 |
+
record["pos_category_ids"] = [x - 1 for x in record["pos_category_ids"]]
|
| 153 |
+
if "captions" in img_dict:
|
| 154 |
+
record["captions"] = img_dict["captions"]
|
| 155 |
+
if "caption_features" in img_dict:
|
| 156 |
+
record["caption_features"] = img_dict["caption_features"]
|
| 157 |
+
image_id = record["image_id"] = img_dict["id"]
|
| 158 |
+
|
| 159 |
+
objs = []
|
| 160 |
+
for anno in anno_dict_list:
|
| 161 |
+
assert anno["image_id"] == image_id
|
| 162 |
+
if anno.get("iscrowd", 0) > 0:
|
| 163 |
+
continue
|
| 164 |
+
# Check that the image_id in this annotation is the same as
|
| 165 |
+
# the image_id we're looking at.
|
| 166 |
+
# This fails only when the data parsing logic or the annotation file is buggy.
|
| 167 |
+
assert anno["image_id"] == image_id
|
| 168 |
+
obj = {"bbox": anno["bbox"], "bbox_mode": BoxMode.XYWH_ABS}
|
| 169 |
+
# LVIS data loader can be used to load COCO dataset categories. In this case `meta`
|
| 170 |
+
# variable will have a field with COCO-specific category mapping.
|
| 171 |
+
if dataset_name is not None and "thing_dataset_id_to_contiguous_id" in meta:
|
| 172 |
+
obj["category_id"] = meta["thing_dataset_id_to_contiguous_id"][anno["category_id"]]
|
| 173 |
+
else:
|
| 174 |
+
obj["category_id"] = anno["category_id"] - 1 # Convert 1-indexed to 0-indexed
|
| 175 |
+
# segm = anno["segmentation"] # list[list[float]]
|
| 176 |
+
# # filter out invalid polygons (< 3 points)
|
| 177 |
+
# valid_segm = [poly for poly in segm if len(poly) % 2 == 0 and len(poly) >= 6]
|
| 178 |
+
# assert len(segm) == len(
|
| 179 |
+
# valid_segm
|
| 180 |
+
# ), "Annotation contains an invalid polygon with < 3 points"
|
| 181 |
+
# assert len(segm) > 0
|
| 182 |
+
# obj["segmentation"] = segm
|
| 183 |
+
segm = anno.get("segmentation", None)
|
| 184 |
+
if segm: # either list[list[float]] or dict(RLE)
|
| 185 |
+
if isinstance(segm, dict):
|
| 186 |
+
if isinstance(segm["counts"], list):
|
| 187 |
+
# convert to compressed RLE
|
| 188 |
+
segm = mask_util.frPyObjects(segm, *segm["size"])
|
| 189 |
+
else:
|
| 190 |
+
# filter out invalid polygons (< 3 points)
|
| 191 |
+
segm = [poly for poly in segm if len(poly) % 2 == 0 and len(poly) >= 6]
|
| 192 |
+
if len(segm) == 0:
|
| 193 |
+
num_instances_without_valid_segmentation += 1
|
| 194 |
+
continue # ignore this instance
|
| 195 |
+
obj["segmentation"] = segm
|
| 196 |
+
|
| 197 |
+
phrase = anno.get("phrase", None)
|
| 198 |
+
if phrase:
|
| 199 |
+
obj["phrase"] = phrase
|
| 200 |
+
|
| 201 |
+
for extra_ann_key in extra_annotation_keys:
|
| 202 |
+
obj[extra_ann_key] = anno[extra_ann_key]
|
| 203 |
+
objs.append(obj)
|
| 204 |
+
record["annotations"] = objs
|
| 205 |
+
dataset_dicts.append(record)
|
| 206 |
+
|
| 207 |
+
return dataset_dicts
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def get_lvis_instances_meta(dataset_name):
|
| 211 |
+
"""
|
| 212 |
+
Load LVIS metadata.
|
| 213 |
+
|
| 214 |
+
Args:
|
| 215 |
+
dataset_name (str): LVIS dataset name without the split name (e.g., "lvis_v0.5").
|
| 216 |
+
|
| 217 |
+
Returns:
|
| 218 |
+
dict: LVIS metadata with keys: thing_classes
|
| 219 |
+
"""
|
| 220 |
+
if "cocofied" in dataset_name:
|
| 221 |
+
return _get_coco_instances_meta()
|
| 222 |
+
if "v0.5" in dataset_name:
|
| 223 |
+
return _get_lvis_instances_meta_v0_5()
|
| 224 |
+
elif "v1" in dataset_name:
|
| 225 |
+
return _get_lvis_instances_meta_v1()
|
| 226 |
+
logger.info("No built-in metadata for dataset {}".format(dataset_name))
|
| 227 |
+
return {}
|
| 228 |
+
raise ValueError("No built-in metadata for dataset {}".format(dataset_name))
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def _get_lvis_instances_meta_v0_5():
|
| 232 |
+
assert len(LVIS_V0_5_CATEGORIES) == 1230
|
| 233 |
+
cat_ids = [k["id"] for k in LVIS_V0_5_CATEGORIES]
|
| 234 |
+
assert min(cat_ids) == 1 and max(cat_ids) == len(
|
| 235 |
+
cat_ids
|
| 236 |
+
), "Category ids are not in [1, #categories], as expected"
|
| 237 |
+
# Ensure that the category list is sorted by id
|
| 238 |
+
lvis_categories = sorted(LVIS_V0_5_CATEGORIES, key=lambda x: x["id"])
|
| 239 |
+
thing_classes = [k["synonyms"][0] for k in lvis_categories]
|
| 240 |
+
meta = {"thing_classes": thing_classes}
|
| 241 |
+
return meta
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
def _get_lvis_instances_meta_v1():
|
| 245 |
+
assert len(LVIS_V1_CATEGORIES) == 1203
|
| 246 |
+
cat_ids = [k["id"] for k in LVIS_V1_CATEGORIES]
|
| 247 |
+
assert min(cat_ids) == 1 and max(cat_ids) == len(
|
| 248 |
+
cat_ids
|
| 249 |
+
), "Category ids are not in [1, #categories], as expected"
|
| 250 |
+
# Ensure that the category list is sorted by id
|
| 251 |
+
lvis_categories = sorted(LVIS_V1_CATEGORIES, key=lambda x: x["id"])
|
| 252 |
+
thing_classes = [k["synonyms"][0] for k in lvis_categories]
|
| 253 |
+
meta = {"thing_classes": thing_classes, "class_image_count": LVIS_V1_COCO_CATEGORY_IMAGE_COUNT}
|
| 254 |
+
return meta
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
_PREDEFINED_SPLITS_LVIS = {
|
| 258 |
+
"lvis_v1_train+coco": {
|
| 259 |
+
"lvis_v1_train+coco": ("coco/", "lvis/lvis_v1_train+coco_mask.json"),
|
| 260 |
+
},
|
| 261 |
+
"lvis_v1_val+coco": {
|
| 262 |
+
"lvis_v1_val+coco": ("coco/", "lvis/lvis_v1_val+coco_mask.json"),
|
| 263 |
+
},
|
| 264 |
+
"lvis_v1_minival": {
|
| 265 |
+
"lvis_v1_minival": ("coco/", "lvis/lvis_v1_minival_inserted_image_name.json"),
|
| 266 |
+
},
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def register_all_lvis_coco(root):
|
| 271 |
+
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_LVIS.items():
|
| 272 |
+
for key, (image_root, json_file) in splits_per_dataset.items():
|
| 273 |
+
custom_register_lvis_instances(
|
| 274 |
+
key,
|
| 275 |
+
get_lvis_instances_meta(dataset_name),
|
| 276 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 277 |
+
os.path.join(root, image_root),
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
if __name__.endswith(".lvis_coco"):
|
| 282 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 283 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 284 |
+
register_all_lvis_coco(_root)
|
approach/ovod/APE/ape/data/datasets/lvis_coco_panoptic.py
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.data.datasets.builtin_meta import COCO_CATEGORIES
|
| 8 |
+
from detectron2.data.datasets.coco import load_sem_seg
|
| 9 |
+
from detectron2.utils.file_io import PathManager
|
| 10 |
+
|
| 11 |
+
from .lvis_coco import custom_load_lvis_json, get_lvis_instances_meta
|
| 12 |
+
|
| 13 |
+
__all__ = ["register_lvis_panoptic_separated"]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def register_lvis_panoptic_separated(
|
| 17 |
+
name, metadata, image_root, panoptic_root, panoptic_json, sem_seg_root, instances_json
|
| 18 |
+
):
|
| 19 |
+
"""
|
| 20 |
+
Register a "separated" version of COCO panoptic segmentation dataset named `name`.
|
| 21 |
+
The annotations in this registered dataset will contain both instance annotations and
|
| 22 |
+
semantic annotations, each with its own contiguous ids. Hence it's called "separated".
|
| 23 |
+
|
| 24 |
+
It follows the setting used by the PanopticFPN paper:
|
| 25 |
+
|
| 26 |
+
1. The instance annotations directly come from polygons in the COCO
|
| 27 |
+
instances annotation task, rather than from the masks in the COCO panoptic annotations.
|
| 28 |
+
|
| 29 |
+
The two format have small differences:
|
| 30 |
+
Polygons in the instance annotations may have overlaps.
|
| 31 |
+
The mask annotations are produced by labeling the overlapped polygons
|
| 32 |
+
with depth ordering.
|
| 33 |
+
|
| 34 |
+
2. The semantic annotations are converted from panoptic annotations, where
|
| 35 |
+
all "things" are assigned a semantic id of 0.
|
| 36 |
+
All semantic categories will therefore have ids in contiguous
|
| 37 |
+
range [1, #stuff_categories].
|
| 38 |
+
|
| 39 |
+
This function will also register a pure semantic segmentation dataset
|
| 40 |
+
named ``name + '_stuffonly'``.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
name (str): the name that identifies a dataset,
|
| 44 |
+
e.g. "coco_2017_train_panoptic"
|
| 45 |
+
metadata (dict): extra metadata associated with this dataset.
|
| 46 |
+
image_root (str): directory which contains all the images
|
| 47 |
+
panoptic_root (str): directory which contains panoptic annotation images
|
| 48 |
+
panoptic_json (str): path to the json panoptic annotation file
|
| 49 |
+
sem_seg_root (str): directory which contains all the ground truth segmentation annotations.
|
| 50 |
+
instances_json (str): path to the json instance annotation file
|
| 51 |
+
"""
|
| 52 |
+
panoptic_name = name + "_separated"
|
| 53 |
+
split_folder = sem_seg_root.split("_")[-1] # datasets/coco/panoptic_stuff_train2017
|
| 54 |
+
DatasetCatalog.register(
|
| 55 |
+
panoptic_name,
|
| 56 |
+
lambda: merge_to_panoptic(
|
| 57 |
+
custom_load_lvis_json(instances_json, image_root, panoptic_name),
|
| 58 |
+
load_sem_seg(sem_seg_root, os.path.join(image_root, split_folder)),
|
| 59 |
+
),
|
| 60 |
+
)
|
| 61 |
+
MetadataCatalog.get(panoptic_name).set(
|
| 62 |
+
panoptic_root=panoptic_root,
|
| 63 |
+
image_root=image_root,
|
| 64 |
+
panoptic_json=panoptic_json,
|
| 65 |
+
sem_seg_root=sem_seg_root,
|
| 66 |
+
json_file=instances_json, # TODO rename
|
| 67 |
+
evaluator_type="coco_panoptic_seg",
|
| 68 |
+
ignore_label=255,
|
| 69 |
+
**metadata,
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
semantic_name = name + "_stuffonly"
|
| 73 |
+
DatasetCatalog.register(semantic_name, lambda: load_sem_seg(sem_seg_root, image_root))
|
| 74 |
+
MetadataCatalog.get(semantic_name).set(
|
| 75 |
+
sem_seg_root=sem_seg_root,
|
| 76 |
+
image_root=image_root,
|
| 77 |
+
evaluator_type="sem_seg",
|
| 78 |
+
ignore_label=255,
|
| 79 |
+
**metadata,
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def merge_to_panoptic(detection_dicts, sem_seg_dicts):
|
| 84 |
+
"""
|
| 85 |
+
Create dataset dicts for panoptic segmentation, by
|
| 86 |
+
merging two dicts using "file_name" field to match their entries.
|
| 87 |
+
|
| 88 |
+
Args:
|
| 89 |
+
detection_dicts (list[dict]): lists of dicts for object detection or instance segmentation.
|
| 90 |
+
sem_seg_dicts (list[dict]): lists of dicts for semantic segmentation.
|
| 91 |
+
|
| 92 |
+
Returns:
|
| 93 |
+
list[dict] (one per input image): Each dict contains all (key, value) pairs from dicts in
|
| 94 |
+
both detection_dicts and sem_seg_dicts that correspond to the same image.
|
| 95 |
+
The function assumes that the same key in different dicts has the same value.
|
| 96 |
+
"""
|
| 97 |
+
results = []
|
| 98 |
+
sem_seg_file_to_entry = {x["file_name"]: x for x in sem_seg_dicts}
|
| 99 |
+
assert len(sem_seg_file_to_entry) > 0
|
| 100 |
+
|
| 101 |
+
for det_dict in detection_dicts:
|
| 102 |
+
dic = copy.copy(det_dict)
|
| 103 |
+
dic.update(sem_seg_file_to_entry[dic["file_name"]])
|
| 104 |
+
results.append(dic)
|
| 105 |
+
return results
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def _get_builtin_metadata(dataset_name):
|
| 109 |
+
if dataset_name == "lvis_panoptic_separated":
|
| 110 |
+
return _get_lvis_panoptic_separated_meta()
|
| 111 |
+
|
| 112 |
+
raise KeyError("No built-in metadata for dataset {}".format(dataset_name))
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def _get_lvis_panoptic_separated_meta():
|
| 116 |
+
"""
|
| 117 |
+
Returns metadata for "separated" version of the panoptic segmentation dataset.
|
| 118 |
+
"""
|
| 119 |
+
stuff_ids = [k["id"] for k in COCO_CATEGORIES if k["isthing"] == 0]
|
| 120 |
+
assert len(stuff_ids) == 53, len(stuff_ids)
|
| 121 |
+
|
| 122 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 123 |
+
# (in [0, 53], used in models) to ids in the dataset (used for processing results)
|
| 124 |
+
# The id 0 is mapped to an extra category "thing".
|
| 125 |
+
stuff_dataset_id_to_contiguous_id = {k: i + 1 for i, k in enumerate(stuff_ids)}
|
| 126 |
+
# When converting COCO panoptic annotations to semantic annotations
|
| 127 |
+
# We label the "thing" category to 0
|
| 128 |
+
stuff_dataset_id_to_contiguous_id[0] = 0
|
| 129 |
+
|
| 130 |
+
# 54 names for COCO stuff categories (including "things")
|
| 131 |
+
stuff_classes = ["things"] + [
|
| 132 |
+
k["name"].replace("-other", "").replace("-merged", "").replace("-stuff", "")
|
| 133 |
+
for k in COCO_CATEGORIES
|
| 134 |
+
if k["isthing"] == 0
|
| 135 |
+
]
|
| 136 |
+
|
| 137 |
+
# NOTE: I randomly picked a color for things
|
| 138 |
+
stuff_colors = [[82, 18, 128]] + [k["color"] for k in COCO_CATEGORIES if k["isthing"] == 0]
|
| 139 |
+
ret = {
|
| 140 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 141 |
+
"stuff_classes": stuff_classes,
|
| 142 |
+
"stuff_colors": stuff_colors,
|
| 143 |
+
}
|
| 144 |
+
ret.update(get_lvis_instances_meta("v1"))
|
| 145 |
+
return ret
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
_PREDEFINED_SPLITS_LVIS_PANOPTIC = {
|
| 149 |
+
"lvis_v1_train+coco_panoptic": (
|
| 150 |
+
# This is the original panoptic annotation directory
|
| 151 |
+
"coco/panoptic_train2017",
|
| 152 |
+
"coco/annotations/panoptic_train2017.json",
|
| 153 |
+
# This directory contains semantic annotations that are
|
| 154 |
+
# converted from panoptic annotations.
|
| 155 |
+
# It is used by PanopticFPN.
|
| 156 |
+
# You can use the script at detectron2/datasets/prepare_panoptic_fpn.py
|
| 157 |
+
# to create these directories.
|
| 158 |
+
"coco/panoptic_stuff_train2017",
|
| 159 |
+
),
|
| 160 |
+
"lvis_v1_val+coco_panoptic": (
|
| 161 |
+
"coco/panoptic_val2017",
|
| 162 |
+
"coco/annotations/panoptic_val2017.json",
|
| 163 |
+
"coco/panoptic_stuff_val2017",
|
| 164 |
+
),
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def register_all_lvis_coco_panoptic(root):
|
| 169 |
+
for (
|
| 170 |
+
prefix,
|
| 171 |
+
(panoptic_root, panoptic_json, semantic_root),
|
| 172 |
+
) in _PREDEFINED_SPLITS_LVIS_PANOPTIC.items():
|
| 173 |
+
prefix_instances = prefix[: -len("_panoptic")]
|
| 174 |
+
instances_meta = MetadataCatalog.get(prefix_instances)
|
| 175 |
+
image_root, instances_json = instances_meta.image_root, instances_meta.json_file
|
| 176 |
+
# The "separated" version of COCO panoptic segmentation dataset,
|
| 177 |
+
# e.g. used by Panoptic FPN
|
| 178 |
+
register_lvis_panoptic_separated(
|
| 179 |
+
prefix,
|
| 180 |
+
_get_builtin_metadata("lvis_panoptic_separated"),
|
| 181 |
+
image_root,
|
| 182 |
+
os.path.join(root, panoptic_root),
|
| 183 |
+
os.path.join(root, panoptic_json),
|
| 184 |
+
os.path.join(root, semantic_root),
|
| 185 |
+
instances_json,
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
if __name__.endswith(".lvis_coco_panoptic"):
|
| 190 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 191 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 192 |
+
register_all_lvis_coco_panoptic(_root)
|
approach/ovod/APE/ape/data/datasets/lvis_v1_coco_category_image_count.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# Autogen with
|
| 3 |
+
# with open("lvis_v1_train.json", "r") as f:
|
| 4 |
+
# a = json.load(f)
|
| 5 |
+
# c = a["categories"]
|
| 6 |
+
# for x in c:
|
| 7 |
+
# del x["name"]
|
| 8 |
+
# del x["instance_count"]
|
| 9 |
+
# del x["def"]
|
| 10 |
+
# del x["synonyms"]
|
| 11 |
+
# del x["frequency"]
|
| 12 |
+
# del x["synset"]
|
| 13 |
+
# LVIS_CATEGORY_IMAGE_COUNT = repr(c) + " # noqa"
|
| 14 |
+
# with open("/tmp/lvis_category_image_count.py", "wt") as f:
|
| 15 |
+
# f.write(f"LVIS_CATEGORY_IMAGE_COUNT = {LVIS_CATEGORY_IMAGE_COUNT}")
|
| 16 |
+
# Then paste the contents of that file below
|
| 17 |
+
|
| 18 |
+
# fmt: off
|
| 19 |
+
LVIS_V1_COCO_CATEGORY_IMAGE_COUNT = [{'image_count': 64, 'id': 1}, {'image_count': 364, 'id': 2}, {'image_count': 2596, 'id': 3}, {'image_count': 149, 'id': 4}, {'image_count': 29, 'id': 5}, {'image_count': 26, 'id': 6}, {'image_count': 59, 'id': 7}, {'image_count': 22, 'id': 8}, {'image_count': 12, 'id': 9}, {'image_count': 28, 'id': 10}, {'image_count': 505, 'id': 11}, {'image_count': 1626, 'id': 12}, {'image_count': 4, 'id': 13}, {'image_count': 10, 'id': 14}, {'image_count': 500, 'id': 15}, {'image_count': 33, 'id': 16}, {'image_count': 3, 'id': 17}, {'image_count': 44, 'id': 18}, {'image_count': 561, 'id': 19}, {'image_count': 8, 'id': 20}, {'image_count': 9, 'id': 21}, {'image_count': 33, 'id': 22}, {'image_count': 1883, 'id': 23}, {'image_count': 98, 'id': 24}, {'image_count': 70, 'id': 25}, {'image_count': 46, 'id': 26}, {'image_count': 117, 'id': 27}, {'image_count': 41, 'id': 28}, {'image_count': 1395, 'id': 29}, {'image_count': 7, 'id': 30}, {'image_count': 1, 'id': 31}, {'image_count': 314, 'id': 32}, {'image_count': 31, 'id': 33}, {'image_count': 4965, 'id': 34}, {'image_count': 6090, 'id': 35}, {'image_count': 2183, 'id': 36}, {'image_count': 47, 'id': 37}, {'image_count': 3, 'id': 38}, {'image_count': 3, 'id': 39}, {'image_count': 1, 'id': 40}, {'image_count': 3780, 'id': 41}, {'image_count': 6, 'id': 42}, {'image_count': 210, 'id': 43}, {'image_count': 36, 'id': 44}, {'image_count': 2000, 'id': 45}, {'image_count': 17, 'id': 46}, {'image_count': 51, 'id': 47}, {'image_count': 138, 'id': 48}, {'image_count': 3, 'id': 49}, {'image_count': 1470, 'id': 50}, {'image_count': 3, 'id': 51}, {'image_count': 2, 'id': 52}, {'image_count': 186, 'id': 53}, {'image_count': 76, 'id': 54}, {'image_count': 26, 'id': 55}, {'image_count': 303, 'id': 56}, {'image_count': 738, 'id': 57}, {'image_count': 2216, 'id': 58}, {'image_count': 1934, 'id': 59}, {'image_count': 2287, 'id': 60}, {'image_count': 1622, 'id': 61}, {'image_count': 41, 'id': 62}, {'image_count': 4, 'id': 63}, {'image_count': 11, 'id': 64}, {'image_count': 270, 'id': 65}, {'image_count': 349, 'id': 66}, {'image_count': 42, 'id': 67}, {'image_count': 823, 'id': 68}, {'image_count': 6, 'id': 69}, {'image_count': 48, 'id': 70}, {'image_count': 3, 'id': 71}, {'image_count': 42, 'id': 72}, {'image_count': 24, 'id': 73}, {'image_count': 16, 'id': 74}, {'image_count': 605, 'id': 75}, {'image_count': 898, 'id': 76}, {'image_count': 3194, 'id': 77}, {'image_count': 2, 'id': 78}, {'image_count': 125, 'id': 79}, {'image_count': 1739, 'id': 80}, {'image_count': 140, 'id': 81}, {'image_count': 4, 'id': 82}, {'image_count': 322, 'id': 83}, {'image_count': 60, 'id': 84}, {'image_count': 2, 'id': 85}, {'image_count': 231, 'id': 86}, {'image_count': 333, 'id': 87}, {'image_count': 1941, 'id': 88}, {'image_count': 367, 'id': 89}, {'image_count': 4908, 'id': 90}, {'image_count': 18, 'id': 91}, {'image_count': 81, 'id': 92}, {'image_count': 1, 'id': 93}, {'image_count': 2940, 'id': 94}, {'image_count': 430, 'id': 95}, {'image_count': 247, 'id': 96}, {'image_count': 94, 'id': 97}, {'image_count': 21, 'id': 98}, {'image_count': 2950, 'id': 99}, {'image_count': 16, 'id': 100}, {'image_count': 12, 'id': 101}, {'image_count': 25, 'id': 102}, {'image_count': 41, 'id': 103}, {'image_count': 244, 'id': 104}, {'image_count': 7, 'id': 105}, {'image_count': 1, 'id': 106}, {'image_count': 40, 'id': 107}, {'image_count': 40, 'id': 108}, {'image_count': 104, 'id': 109}, {'image_count': 1671, 'id': 110}, {'image_count': 49, 'id': 111}, {'image_count': 243, 'id': 112}, {'image_count': 2, 'id': 113}, {'image_count': 242, 'id': 114}, {'image_count': 271, 'id': 115}, {'image_count': 104, 'id': 116}, {'image_count': 8, 'id': 117}, {'image_count': 2674, 'id': 118}, {'image_count': 1, 'id': 119}, {'image_count': 48, 'id': 120}, {'image_count': 14, 'id': 121}, {'image_count': 40, 'id': 122}, {'image_count': 1, 'id': 123}, {'image_count': 37, 'id': 124}, {'image_count': 1510, 'id': 125}, {'image_count': 6, 'id': 126}, {'image_count': 4808, 'id': 127}, {'image_count': 70, 'id': 128}, {'image_count': 86, 'id': 129}, {'image_count': 7, 'id': 130}, {'image_count': 5, 'id': 131}, {'image_count': 1406, 'id': 132}, {'image_count': 7655, 'id': 133}, {'image_count': 15, 'id': 134}, {'image_count': 28, 'id': 135}, {'image_count': 6, 'id': 136}, {'image_count': 494, 'id': 137}, {'image_count': 234, 'id': 138}, {'image_count': 6332, 'id': 139}, {'image_count': 1, 'id': 140}, {'image_count': 35, 'id': 141}, {'image_count': 5, 'id': 142}, {'image_count': 1828, 'id': 143}, {'image_count': 8, 'id': 144}, {'image_count': 63, 'id': 145}, {'image_count': 1668, 'id': 146}, {'image_count': 4, 'id': 147}, {'image_count': 95, 'id': 148}, {'image_count': 17, 'id': 149}, {'image_count': 1567, 'id': 150}, {'image_count': 2, 'id': 151}, {'image_count': 103, 'id': 152}, {'image_count': 50, 'id': 153}, {'image_count': 1678, 'id': 154}, {'image_count': 6, 'id': 155}, {'image_count': 92, 'id': 156}, {'image_count': 19, 'id': 157}, {'image_count': 37, 'id': 158}, {'image_count': 4, 'id': 159}, {'image_count': 709, 'id': 160}, {'image_count': 9, 'id': 161}, {'image_count': 82, 'id': 162}, {'image_count': 15, 'id': 163}, {'image_count': 3, 'id': 164}, {'image_count': 61, 'id': 165}, {'image_count': 51, 'id': 166}, {'image_count': 5, 'id': 167}, {'image_count': 13, 'id': 168}, {'image_count': 642, 'id': 169}, {'image_count': 24, 'id': 170}, {'image_count': 255, 'id': 171}, {'image_count': 9, 'id': 172}, {'image_count': 3431, 'id': 173}, {'image_count': 31, 'id': 174}, {'image_count': 158, 'id': 175}, {'image_count': 80, 'id': 176}, {'image_count': 1884, 'id': 177}, {'image_count': 158, 'id': 178}, {'image_count': 2, 'id': 179}, {'image_count': 12, 'id': 180}, {'image_count': 1659, 'id': 181}, {'image_count': 7, 'id': 182}, {'image_count': 2555, 'id': 183}, {'image_count': 57, 'id': 184}, {'image_count': 174, 'id': 185}, {'image_count': 95, 'id': 186}, {'image_count': 27, 'id': 187}, {'image_count': 22, 'id': 188}, {'image_count': 1391, 'id': 189}, {'image_count': 90, 'id': 190}, {'image_count': 40, 'id': 191}, {'image_count': 445, 'id': 192}, {'image_count': 21, 'id': 193}, {'image_count': 1132, 'id': 194}, {'image_count': 177, 'id': 195}, {'image_count': 4, 'id': 196}, {'image_count': 17, 'id': 197}, {'image_count': 84, 'id': 198}, {'image_count': 55, 'id': 199}, {'image_count': 30, 'id': 200}, {'image_count': 25, 'id': 201}, {'image_count': 2, 'id': 202}, {'image_count': 125, 'id': 203}, {'image_count': 1135, 'id': 204}, {'image_count': 19, 'id': 205}, {'image_count': 72, 'id': 206}, {'image_count': 10661, 'id': 207}, {'image_count': 159, 'id': 208}, {'image_count': 7, 'id': 209}, {'image_count': 1, 'id': 210}, {'image_count': 13, 'id': 211}, {'image_count': 35, 'id': 212}, {'image_count': 18, 'id': 213}, {'image_count': 8, 'id': 214}, {'image_count': 6, 'id': 215}, {'image_count': 35, 'id': 216}, {'image_count': 1531, 'id': 217}, {'image_count': 103, 'id': 218}, {'image_count': 28, 'id': 219}, {'image_count': 63, 'id': 220}, {'image_count': 28, 'id': 221}, {'image_count': 5, 'id': 222}, {'image_count': 7, 'id': 223}, {'image_count': 14, 'id': 224}, {'image_count': 3422, 'id': 225}, {'image_count': 133, 'id': 226}, {'image_count': 16, 'id': 227}, {'image_count': 27, 'id': 228}, {'image_count': 110, 'id': 229}, {'image_count': 4201, 'id': 230}, {'image_count': 4, 'id': 231}, {'image_count': 11104, 'id': 232}, {'image_count': 8, 'id': 233}, {'image_count': 1, 'id': 234}, {'image_count': 263, 'id': 235}, {'image_count': 10, 'id': 236}, {'image_count': 2, 'id': 237}, {'image_count': 3, 'id': 238}, {'image_count': 87, 'id': 239}, {'image_count': 9, 'id': 240}, {'image_count': 71, 'id': 241}, {'image_count': 13, 'id': 242}, {'image_count': 18, 'id': 243}, {'image_count': 2, 'id': 244}, {'image_count': 5, 'id': 245}, {'image_count': 45, 'id': 246}, {'image_count': 1, 'id': 247}, {'image_count': 23, 'id': 248}, {'image_count': 32, 'id': 249}, {'image_count': 4, 'id': 250}, {'image_count': 1, 'id': 251}, {'image_count': 858, 'id': 252}, {'image_count': 661, 'id': 253}, {'image_count': 168, 'id': 254}, {'image_count': 210, 'id': 255}, {'image_count': 65, 'id': 256}, {'image_count': 4, 'id': 257}, {'image_count': 2, 'id': 258}, {'image_count': 159, 'id': 259}, {'image_count': 31, 'id': 260}, {'image_count': 811, 'id': 261}, {'image_count': 1, 'id': 262}, {'image_count': 42, 'id': 263}, {'image_count': 27, 'id': 264}, {'image_count': 2, 'id': 265}, {'image_count': 5, 'id': 266}, {'image_count': 95, 'id': 267}, {'image_count': 32, 'id': 268}, {'image_count': 1, 'id': 269}, {'image_count': 1, 'id': 270}, {'image_count': 4053, 'id': 271}, {'image_count': 897, 'id': 272}, {'image_count': 31, 'id': 273}, {'image_count': 23, 'id': 274}, {'image_count': 1, 'id': 275}, {'image_count': 202, 'id': 276}, {'image_count': 746, 'id': 277}, {'image_count': 44, 'id': 278}, {'image_count': 14, 'id': 279}, {'image_count': 26, 'id': 280}, {'image_count': 1, 'id': 281}, {'image_count': 2, 'id': 282}, {'image_count': 25, 'id': 283}, {'image_count': 238, 'id': 284}, {'image_count': 592, 'id': 285}, {'image_count': 26, 'id': 286}, {'image_count': 5, 'id': 287}, {'image_count': 42, 'id': 288}, {'image_count': 13, 'id': 289}, {'image_count': 46, 'id': 290}, {'image_count': 1, 'id': 291}, {'image_count': 8, 'id': 292}, {'image_count': 34, 'id': 293}, {'image_count': 5, 'id': 294}, {'image_count': 1, 'id': 295}, {'image_count': 2356, 'id': 296}, {'image_count': 717, 'id': 297}, {'image_count': 1010, 'id': 298}, {'image_count': 679, 'id': 299}, {'image_count': 3, 'id': 300}, {'image_count': 4, 'id': 301}, {'image_count': 1, 'id': 302}, {'image_count': 166, 'id': 303}, {'image_count': 2, 'id': 304}, {'image_count': 266, 'id': 305}, {'image_count': 101, 'id': 306}, {'image_count': 6, 'id': 307}, {'image_count': 14, 'id': 308}, {'image_count': 133, 'id': 309}, {'image_count': 2, 'id': 310}, {'image_count': 38, 'id': 311}, {'image_count': 95, 'id': 312}, {'image_count': 1, 'id': 313}, {'image_count': 12, 'id': 314}, {'image_count': 49, 'id': 315}, {'image_count': 5, 'id': 316}, {'image_count': 5, 'id': 317}, {'image_count': 16, 'id': 318}, {'image_count': 216, 'id': 319}, {'image_count': 12, 'id': 320}, {'image_count': 1, 'id': 321}, {'image_count': 54, 'id': 322}, {'image_count': 5, 'id': 323}, {'image_count': 245, 'id': 324}, {'image_count': 12, 'id': 325}, {'image_count': 7, 'id': 326}, {'image_count': 35, 'id': 327}, {'image_count': 36, 'id': 328}, {'image_count': 32, 'id': 329}, {'image_count': 1027, 'id': 330}, {'image_count': 10, 'id': 331}, {'image_count': 12, 'id': 332}, {'image_count': 1, 'id': 333}, {'image_count': 67, 'id': 334}, {'image_count': 71, 'id': 335}, {'image_count': 30, 'id': 336}, {'image_count': 48, 'id': 337}, {'image_count': 249, 'id': 338}, {'image_count': 13, 'id': 339}, {'image_count': 29, 'id': 340}, {'image_count': 14, 'id': 341}, {'image_count': 236, 'id': 342}, {'image_count': 15, 'id': 343}, {'image_count': 8183, 'id': 344}, {'image_count': 25, 'id': 345}, {'image_count': 249, 'id': 346}, {'image_count': 139, 'id': 347}, {'image_count': 2, 'id': 348}, {'image_count': 2, 'id': 349}, {'image_count': 1890, 'id': 350}, {'image_count': 1240, 'id': 351}, {'image_count': 1, 'id': 352}, {'image_count': 9, 'id': 353}, {'image_count': 1, 'id': 354}, {'image_count': 3, 'id': 355}, {'image_count': 11, 'id': 356}, {'image_count': 4, 'id': 357}, {'image_count': 236, 'id': 358}, {'image_count': 44, 'id': 359}, {'image_count': 19, 'id': 360}, {'image_count': 1100, 'id': 361}, {'image_count': 7, 'id': 362}, {'image_count': 69, 'id': 363}, {'image_count': 2, 'id': 364}, {'image_count': 8, 'id': 365}, {'image_count': 5, 'id': 366}, {'image_count': 10225, 'id': 367}, {'image_count': 6, 'id': 368}, {'image_count': 106, 'id': 369}, {'image_count': 81, 'id': 370}, {'image_count': 17, 'id': 371}, {'image_count': 134, 'id': 372}, {'image_count': 312, 'id': 373}, {'image_count': 8, 'id': 374}, {'image_count': 271, 'id': 375}, {'image_count': 2, 'id': 376}, {'image_count': 103, 'id': 377}, {'image_count': 3758, 'id': 378}, {'image_count': 574, 'id': 379}, {'image_count': 120, 'id': 380}, {'image_count': 2, 'id': 381}, {'image_count': 2, 'id': 382}, {'image_count': 13, 'id': 383}, {'image_count': 29, 'id': 384}, {'image_count': 1710, 'id': 385}, {'image_count': 66, 'id': 386}, {'image_count': 1326, 'id': 387}, {'image_count': 1, 'id': 388}, {'image_count': 3, 'id': 389}, {'image_count': 1942, 'id': 390}, {'image_count': 19, 'id': 391}, {'image_count': 1488, 'id': 392}, {'image_count': 46, 'id': 393}, {'image_count': 106, 'id': 394}, {'image_count': 115, 'id': 395}, {'image_count': 19, 'id': 396}, {'image_count': 2, 'id': 397}, {'image_count': 1, 'id': 398}, {'image_count': 28, 'id': 399}, {'image_count': 9, 'id': 400}, {'image_count': 192, 'id': 401}, {'image_count': 12, 'id': 402}, {'image_count': 21, 'id': 403}, {'image_count': 247, 'id': 404}, {'image_count': 6, 'id': 405}, {'image_count': 64, 'id': 406}, {'image_count': 7, 'id': 407}, {'image_count': 40, 'id': 408}, {'image_count': 542, 'id': 409}, {'image_count': 2, 'id': 410}, {'image_count': 1898, 'id': 411}, {'image_count': 36, 'id': 412}, {'image_count': 4, 'id': 413}, {'image_count': 1, 'id': 414}, {'image_count': 191, 'id': 415}, {'image_count': 6, 'id': 416}, {'image_count': 41, 'id': 417}, {'image_count': 39, 'id': 418}, {'image_count': 46, 'id': 419}, {'image_count': 1, 'id': 420}, {'image_count': 2100, 'id': 421}, {'image_count': 1915, 'id': 422}, {'image_count': 11, 'id': 423}, {'image_count': 82, 'id': 424}, {'image_count': 18, 'id': 425}, {'image_count': 1, 'id': 426}, {'image_count': 7, 'id': 427}, {'image_count': 3, 'id': 428}, {'image_count': 575, 'id': 429}, {'image_count': 1907, 'id': 430}, {'image_count': 8, 'id': 431}, {'image_count': 4, 'id': 432}, {'image_count': 32, 'id': 433}, {'image_count': 11, 'id': 434}, {'image_count': 4, 'id': 435}, {'image_count': 54, 'id': 436}, {'image_count': 202, 'id': 437}, {'image_count': 32, 'id': 438}, {'image_count': 3, 'id': 439}, {'image_count': 130, 'id': 440}, {'image_count': 119, 'id': 441}, {'image_count': 141, 'id': 442}, {'image_count': 29, 'id': 443}, {'image_count': 525, 'id': 444}, {'image_count': 1537, 'id': 445}, {'image_count': 2, 'id': 446}, {'image_count': 113, 'id': 447}, {'image_count': 16, 'id': 448}, {'image_count': 7, 'id': 449}, {'image_count': 35, 'id': 450}, {'image_count': 1908, 'id': 451}, {'image_count': 353, 'id': 452}, {'image_count': 18, 'id': 453}, {'image_count': 14, 'id': 454}, {'image_count': 77, 'id': 455}, {'image_count': 8, 'id': 456}, {'image_count': 37, 'id': 457}, {'image_count': 1, 'id': 458}, {'image_count': 346, 'id': 459}, {'image_count': 19, 'id': 460}, {'image_count': 1779, 'id': 461}, {'image_count': 23, 'id': 462}, {'image_count': 25, 'id': 463}, {'image_count': 67, 'id': 464}, {'image_count': 19, 'id': 465}, {'image_count': 28, 'id': 466}, {'image_count': 4, 'id': 467}, {'image_count': 27, 'id': 468}, {'image_count': 3150, 'id': 469}, {'image_count': 11, 'id': 470}, {'image_count': 13, 'id': 471}, {'image_count': 13, 'id': 472}, {'image_count': 32, 'id': 473}, {'image_count': 1911, 'id': 474}, {'image_count': 42, 'id': 475}, {'image_count': 17, 'id': 476}, {'image_count': 128, 'id': 477}, {'image_count': 1, 'id': 478}, {'image_count': 9, 'id': 479}, {'image_count': 10, 'id': 480}, {'image_count': 4, 'id': 481}, {'image_count': 9, 'id': 482}, {'image_count': 18, 'id': 483}, {'image_count': 41, 'id': 484}, {'image_count': 28, 'id': 485}, {'image_count': 3, 'id': 486}, {'image_count': 65, 'id': 487}, {'image_count': 9, 'id': 488}, {'image_count': 23, 'id': 489}, {'image_count': 24, 'id': 490}, {'image_count': 1, 'id': 491}, {'image_count': 2, 'id': 492}, {'image_count': 59, 'id': 493}, {'image_count': 48, 'id': 494}, {'image_count': 17, 'id': 495}, {'image_count': 2056, 'id': 496}, {'image_count': 18, 'id': 497}, {'image_count': 1920, 'id': 498}, {'image_count': 50, 'id': 499}, {'image_count': 1890, 'id': 500}, {'image_count': 99, 'id': 501}, {'image_count': 1530, 'id': 502}, {'image_count': 3, 'id': 503}, {'image_count': 11, 'id': 504}, {'image_count': 19, 'id': 505}, {'image_count': 3, 'id': 506}, {'image_count': 63, 'id': 507}, {'image_count': 5, 'id': 508}, {'image_count': 6, 'id': 509}, {'image_count': 233, 'id': 510}, {'image_count': 54, 'id': 511}, {'image_count': 36, 'id': 512}, {'image_count': 10, 'id': 513}, {'image_count': 124, 'id': 514}, {'image_count': 101, 'id': 515}, {'image_count': 3, 'id': 516}, {'image_count': 363, 'id': 517}, {'image_count': 3, 'id': 518}, {'image_count': 30, 'id': 519}, {'image_count': 18, 'id': 520}, {'image_count': 199, 'id': 521}, {'image_count': 97, 'id': 522}, {'image_count': 32, 'id': 523}, {'image_count': 121, 'id': 524}, {'image_count': 16, 'id': 525}, {'image_count': 12, 'id': 526}, {'image_count': 2, 'id': 527}, {'image_count': 214, 'id': 528}, {'image_count': 48, 'id': 529}, {'image_count': 26, 'id': 530}, {'image_count': 13, 'id': 531}, {'image_count': 4, 'id': 532}, {'image_count': 11, 'id': 533}, {'image_count': 171, 'id': 534}, {'image_count': 7, 'id': 535}, {'image_count': 200, 'id': 536}, {'image_count': 91, 'id': 537}, {'image_count': 9, 'id': 538}, {'image_count': 72, 'id': 539}, {'image_count': 1886, 'id': 540}, {'image_count': 4, 'id': 541}, {'image_count': 1, 'id': 542}, {'image_count': 1, 'id': 543}, {'image_count': 1932, 'id': 544}, {'image_count': 4, 'id': 545}, {'image_count': 56, 'id': 546}, {'image_count': 854, 'id': 547}, {'image_count': 755, 'id': 548}, {'image_count': 1843, 'id': 549}, {'image_count': 96, 'id': 550}, {'image_count': 7, 'id': 551}, {'image_count': 74, 'id': 552}, {'image_count': 66, 'id': 553}, {'image_count': 57, 'id': 554}, {'image_count': 44, 'id': 555}, {'image_count': 1905, 'id': 556}, {'image_count': 4, 'id': 557}, {'image_count': 90, 'id': 558}, {'image_count': 1635, 'id': 559}, {'image_count': 8, 'id': 560}, {'image_count': 5, 'id': 561}, {'image_count': 50, 'id': 562}, {'image_count': 545, 'id': 563}, {'image_count': 20, 'id': 564}, {'image_count': 193, 'id': 565}, {'image_count': 285, 'id': 566}, {'image_count': 3, 'id': 567}, {'image_count': 1, 'id': 568}, {'image_count': 2488, 'id': 569}, {'image_count': 294, 'id': 570}, {'image_count': 3, 'id': 571}, {'image_count': 5, 'id': 572}, {'image_count': 24, 'id': 573}, {'image_count': 2, 'id': 574}, {'image_count': 2, 'id': 575}, {'image_count': 16, 'id': 576}, {'image_count': 8, 'id': 577}, {'image_count': 154, 'id': 578}, {'image_count': 66, 'id': 579}, {'image_count': 1, 'id': 580}, {'image_count': 24, 'id': 581}, {'image_count': 1, 'id': 582}, {'image_count': 4, 'id': 583}, {'image_count': 75, 'id': 584}, {'image_count': 6, 'id': 585}, {'image_count': 126, 'id': 586}, {'image_count': 24, 'id': 587}, {'image_count': 22, 'id': 588}, {'image_count': 1872, 'id': 589}, {'image_count': 16, 'id': 590}, {'image_count': 423, 'id': 591}, {'image_count': 1927, 'id': 592}, {'image_count': 38, 'id': 593}, {'image_count': 3, 'id': 594}, {'image_count': 1945, 'id': 595}, {'image_count': 35, 'id': 596}, {'image_count': 1, 'id': 597}, {'image_count': 13, 'id': 598}, {'image_count': 9, 'id': 599}, {'image_count': 14, 'id': 600}, {'image_count': 37, 'id': 601}, {'image_count': 3, 'id': 602}, {'image_count': 4, 'id': 603}, {'image_count': 100, 'id': 604}, {'image_count': 195, 'id': 605}, {'image_count': 1, 'id': 606}, {'image_count': 12, 'id': 607}, {'image_count': 24, 'id': 608}, {'image_count': 489, 'id': 609}, {'image_count': 10, 'id': 610}, {'image_count': 1921, 'id': 611}, {'image_count': 42, 'id': 612}, {'image_count': 81, 'id': 613}, {'image_count': 894, 'id': 614}, {'image_count': 3839, 'id': 615}, {'image_count': 7, 'id': 616}, {'image_count': 1567, 'id': 617}, {'image_count': 10, 'id': 618}, {'image_count': 8, 'id': 619}, {'image_count': 7, 'id': 620}, {'image_count': 629, 'id': 621}, {'image_count': 89, 'id': 622}, {'image_count': 15, 'id': 623}, {'image_count': 134, 'id': 624}, {'image_count': 4, 'id': 625}, {'image_count': 1802, 'id': 626}, {'image_count': 595, 'id': 627}, {'image_count': 1210, 'id': 628}, {'image_count': 48, 'id': 629}, {'image_count': 418, 'id': 630}, {'image_count': 3050, 'id': 631}, {'image_count': 5, 'id': 632}, {'image_count': 221, 'id': 633}, {'image_count': 10, 'id': 634}, {'image_count': 7, 'id': 635}, {'image_count': 76, 'id': 636}, {'image_count': 22, 'id': 637}, {'image_count': 10, 'id': 638}, {'image_count': 341, 'id': 639}, {'image_count': 1, 'id': 640}, {'image_count': 705, 'id': 641}, {'image_count': 1900, 'id': 642}, {'image_count': 188, 'id': 643}, {'image_count': 227, 'id': 644}, {'image_count': 861, 'id': 645}, {'image_count': 6, 'id': 646}, {'image_count': 115, 'id': 647}, {'image_count': 5, 'id': 648}, {'image_count': 43, 'id': 649}, {'image_count': 14, 'id': 650}, {'image_count': 6, 'id': 651}, {'image_count': 15, 'id': 652}, {'image_count': 1167, 'id': 653}, {'image_count': 15, 'id': 654}, {'image_count': 994, 'id': 655}, {'image_count': 28, 'id': 656}, {'image_count': 2, 'id': 657}, {'image_count': 338, 'id': 658}, {'image_count': 334, 'id': 659}, {'image_count': 15, 'id': 660}, {'image_count': 102, 'id': 661}, {'image_count': 1, 'id': 662}, {'image_count': 8, 'id': 663}, {'image_count': 1, 'id': 664}, {'image_count': 1, 'id': 665}, {'image_count': 28, 'id': 666}, {'image_count': 91, 'id': 667}, {'image_count': 260, 'id': 668}, {'image_count': 131, 'id': 669}, {'image_count': 128, 'id': 670}, {'image_count': 3, 'id': 671}, {'image_count': 10, 'id': 672}, {'image_count': 39, 'id': 673}, {'image_count': 2, 'id': 674}, {'image_count': 925, 'id': 675}, {'image_count': 354, 'id': 676}, {'image_count': 31, 'id': 677}, {'image_count': 10, 'id': 678}, {'image_count': 215, 'id': 679}, {'image_count': 71, 'id': 680}, {'image_count': 43, 'id': 681}, {'image_count': 28, 'id': 682}, {'image_count': 34, 'id': 683}, {'image_count': 16, 'id': 684}, {'image_count': 273, 'id': 685}, {'image_count': 2, 'id': 686}, {'image_count': 1388, 'id': 687}, {'image_count': 4, 'id': 688}, {'image_count': 107, 'id': 689}, {'image_count': 2, 'id': 690}, {'image_count': 1, 'id': 691}, {'image_count': 454, 'id': 692}, {'image_count': 9, 'id': 693}, {'image_count': 1901, 'id': 694}, {'image_count': 61, 'id': 695}, {'image_count': 91, 'id': 696}, {'image_count': 46, 'id': 697}, {'image_count': 1402, 'id': 698}, {'image_count': 74, 'id': 699}, {'image_count': 421, 'id': 700}, {'image_count': 226, 'id': 701}, {'image_count': 10, 'id': 702}, {'image_count': 3011, 'id': 703}, {'image_count': 261, 'id': 704}, {'image_count': 1671, 'id': 705}, {'image_count': 293, 'id': 706}, {'image_count': 62, 'id': 707}, {'image_count': 814, 'id': 708}, {'image_count': 407, 'id': 709}, {'image_count': 6, 'id': 710}, {'image_count': 16, 'id': 711}, {'image_count': 7, 'id': 712}, {'image_count': 1791, 'id': 713}, {'image_count': 2, 'id': 714}, {'image_count': 1915, 'id': 715}, {'image_count': 3327, 'id': 716}, {'image_count': 13, 'id': 717}, {'image_count': 16, 'id': 718}, {'image_count': 448, 'id': 719}, {'image_count': 12, 'id': 720}, {'image_count': 18, 'id': 721}, {'image_count': 4, 'id': 722}, {'image_count': 71, 'id': 723}, {'image_count': 189, 'id': 724}, {'image_count': 74, 'id': 725}, {'image_count': 103, 'id': 726}, {'image_count': 3, 'id': 727}, {'image_count': 110, 'id': 728}, {'image_count': 5, 'id': 729}, {'image_count': 9, 'id': 730}, {'image_count': 15, 'id': 731}, {'image_count': 25, 'id': 732}, {'image_count': 7, 'id': 733}, {'image_count': 647, 'id': 734}, {'image_count': 1510, 'id': 735}, {'image_count': 100, 'id': 736}, {'image_count': 47, 'id': 737}, {'image_count': 121, 'id': 738}, {'image_count': 2530, 'id': 739}, {'image_count': 73, 'id': 740}, {'image_count': 49, 'id': 741}, {'image_count': 23, 'id': 742}, {'image_count': 4, 'id': 743}, {'image_count': 62, 'id': 744}, {'image_count': 118, 'id': 745}, {'image_count': 99, 'id': 746}, {'image_count': 40, 'id': 747}, {'image_count': 1036, 'id': 748}, {'image_count': 105, 'id': 749}, {'image_count': 21, 'id': 750}, {'image_count': 229, 'id': 751}, {'image_count': 7, 'id': 752}, {'image_count': 72, 'id': 753}, {'image_count': 9, 'id': 754}, {'image_count': 10, 'id': 755}, {'image_count': 328, 'id': 756}, {'image_count': 468, 'id': 757}, {'image_count': 1, 'id': 758}, {'image_count': 2, 'id': 759}, {'image_count': 24, 'id': 760}, {'image_count': 11, 'id': 761}, {'image_count': 72, 'id': 762}, {'image_count': 17, 'id': 763}, {'image_count': 10, 'id': 764}, {'image_count': 17, 'id': 765}, {'image_count': 626, 'id': 766}, {'image_count': 47, 'id': 767}, {'image_count': 93, 'id': 768}, {'image_count': 1, 'id': 769}, {'image_count': 12, 'id': 770}, {'image_count': 228, 'id': 771}, {'image_count': 5, 'id': 772}, {'image_count': 76, 'id': 773}, {'image_count': 71, 'id': 774}, {'image_count': 30, 'id': 775}, {'image_count': 109, 'id': 776}, {'image_count': 14, 'id': 777}, {'image_count': 1, 'id': 778}, {'image_count': 8, 'id': 779}, {'image_count': 26, 'id': 780}, {'image_count': 339, 'id': 781}, {'image_count': 153, 'id': 782}, {'image_count': 2, 'id': 783}, {'image_count': 3, 'id': 784}, {'image_count': 8, 'id': 785}, {'image_count': 47, 'id': 786}, {'image_count': 8, 'id': 787}, {'image_count': 6, 'id': 788}, {'image_count': 116, 'id': 789}, {'image_count': 69, 'id': 790}, {'image_count': 13, 'id': 791}, {'image_count': 6, 'id': 792}, {'image_count': 54790, 'id': 793}, {'image_count': 79, 'id': 794}, {'image_count': 14, 'id': 795}, {'image_count': 7, 'id': 796}, {'image_count': 20, 'id': 797}, {'image_count': 114, 'id': 798}, {'image_count': 221, 'id': 799}, {'image_count': 502, 'id': 800}, {'image_count': 62, 'id': 801}, {'image_count': 87, 'id': 802}, {'image_count': 4, 'id': 803}, {'image_count': 1912, 'id': 804}, {'image_count': 7, 'id': 805}, {'image_count': 186, 'id': 806}, {'image_count': 18, 'id': 807}, {'image_count': 4, 'id': 808}, {'image_count': 3, 'id': 809}, {'image_count': 7, 'id': 810}, {'image_count': 1413, 'id': 811}, {'image_count': 7, 'id': 812}, {'image_count': 12, 'id': 813}, {'image_count': 248, 'id': 814}, {'image_count': 4, 'id': 815}, {'image_count': 2732, 'id': 816}, {'image_count': 529, 'id': 817}, {'image_count': 1932, 'id': 818}, {'image_count': 50, 'id': 819}, {'image_count': 3, 'id': 820}, {'image_count': 28, 'id': 821}, {'image_count': 10, 'id': 822}, {'image_count': 5, 'id': 823}, {'image_count': 5, 'id': 824}, {'image_count': 18, 'id': 825}, {'image_count': 14, 'id': 826}, {'image_count': 1890, 'id': 827}, {'image_count': 660, 'id': 828}, {'image_count': 8, 'id': 829}, {'image_count': 25, 'id': 830}, {'image_count': 10, 'id': 831}, {'image_count': 218, 'id': 832}, {'image_count': 36, 'id': 833}, {'image_count': 16, 'id': 834}, {'image_count': 808, 'id': 835}, {'image_count': 479, 'id': 836}, {'image_count': 3999, 'id': 837}, {'image_count': 307, 'id': 838}, {'image_count': 57, 'id': 839}, {'image_count': 28, 'id': 840}, {'image_count': 80, 'id': 841}, {'image_count': 11, 'id': 842}, {'image_count': 92, 'id': 843}, {'image_count': 20, 'id': 844}, {'image_count': 194, 'id': 845}, {'image_count': 23, 'id': 846}, {'image_count': 52, 'id': 847}, {'image_count': 673, 'id': 848}, {'image_count': 2, 'id': 849}, {'image_count': 2, 'id': 850}, {'image_count': 1, 'id': 851}, {'image_count': 2, 'id': 852}, {'image_count': 8, 'id': 853}, {'image_count': 80, 'id': 854}, {'image_count': 3, 'id': 855}, {'image_count': 3, 'id': 856}, {'image_count': 15, 'id': 857}, {'image_count': 2, 'id': 858}, {'image_count': 10, 'id': 859}, {'image_count': 386, 'id': 860}, {'image_count': 65, 'id': 861}, {'image_count': 3, 'id': 862}, {'image_count': 35, 'id': 863}, {'image_count': 5, 'id': 864}, {'image_count': 180, 'id': 865}, {'image_count': 99, 'id': 866}, {'image_count': 49, 'id': 867}, {'image_count': 28, 'id': 868}, {'image_count': 1, 'id': 869}, {'image_count': 52, 'id': 870}, {'image_count': 36, 'id': 871}, {'image_count': 70, 'id': 872}, {'image_count': 6, 'id': 873}, {'image_count': 29, 'id': 874}, {'image_count': 24, 'id': 875}, {'image_count': 1115, 'id': 876}, {'image_count': 61, 'id': 877}, {'image_count': 18, 'id': 878}, {'image_count': 18, 'id': 879}, {'image_count': 665, 'id': 880}, {'image_count': 2753, 'id': 881}, {'image_count': 29, 'id': 882}, {'image_count': 8, 'id': 883}, {'image_count': 14, 'id': 884}, {'image_count': 1622, 'id': 885}, {'image_count': 2, 'id': 886}, {'image_count': 3, 'id': 887}, {'image_count': 32, 'id': 888}, {'image_count': 55, 'id': 889}, {'image_count': 1, 'id': 890}, {'image_count': 10, 'id': 891}, {'image_count': 10, 'id': 892}, {'image_count': 47, 'id': 893}, {'image_count': 3, 'id': 894}, {'image_count': 29, 'id': 895}, {'image_count': 342, 'id': 896}, {'image_count': 25, 'id': 897}, {'image_count': 1469, 'id': 898}, {'image_count': 521, 'id': 899}, {'image_count': 347, 'id': 900}, {'image_count': 35, 'id': 901}, {'image_count': 7, 'id': 902}, {'image_count': 207, 'id': 903}, {'image_count': 108, 'id': 904}, {'image_count': 2, 'id': 905}, {'image_count': 34, 'id': 906}, {'image_count': 12, 'id': 907}, {'image_count': 10, 'id': 908}, {'image_count': 13, 'id': 909}, {'image_count': 361, 'id': 910}, {'image_count': 1023, 'id': 911}, {'image_count': 2074, 'id': 912}, {'image_count': 2, 'id': 913}, {'image_count': 5, 'id': 914}, {'image_count': 247, 'id': 915}, {'image_count': 1197, 'id': 916}, {'image_count': 4, 'id': 917}, {'image_count': 8, 'id': 918}, {'image_count': 158, 'id': 919}, {'image_count': 3, 'id': 920}, {'image_count': 752, 'id': 921}, {'image_count': 64, 'id': 922}, {'image_count': 840, 'id': 923}, {'image_count': 143, 'id': 924}, {'image_count': 1, 'id': 925}, {'image_count': 49, 'id': 926}, {'image_count': 126, 'id': 927}, {'image_count': 76, 'id': 928}, {'image_count': 11, 'id': 929}, {'image_count': 11, 'id': 930}, {'image_count': 4, 'id': 931}, {'image_count': 39, 'id': 932}, {'image_count': 11, 'id': 933}, {'image_count': 13, 'id': 934}, {'image_count': 91, 'id': 935}, {'image_count': 14, 'id': 936}, {'image_count': 5, 'id': 937}, {'image_count': 3, 'id': 938}, {'image_count': 10, 'id': 939}, {'image_count': 18, 'id': 940}, {'image_count': 9, 'id': 941}, {'image_count': 6, 'id': 942}, {'image_count': 1283, 'id': 943}, {'image_count': 2, 'id': 944}, {'image_count': 1, 'id': 945}, {'image_count': 19, 'id': 946}, {'image_count': 1942, 'id': 947}, {'image_count': 1916, 'id': 948}, {'image_count': 139, 'id': 949}, {'image_count': 43, 'id': 950}, {'image_count': 1969, 'id': 951}, {'image_count': 5, 'id': 952}, {'image_count': 134, 'id': 953}, {'image_count': 74, 'id': 954}, {'image_count': 381, 'id': 955}, {'image_count': 1, 'id': 956}, {'image_count': 381, 'id': 957}, {'image_count': 6, 'id': 958}, {'image_count': 1826, 'id': 959}, {'image_count': 28, 'id': 960}, {'image_count': 4082, 'id': 961}, {'image_count': 2943, 'id': 962}, {'image_count': 16, 'id': 963}, {'image_count': 2716, 'id': 964}, {'image_count': 1789, 'id': 965}, {'image_count': 401, 'id': 966}, {'image_count': 1968, 'id': 967}, {'image_count': 1167, 'id': 968}, {'image_count': 1, 'id': 969}, {'image_count': 56, 'id': 970}, {'image_count': 17, 'id': 971}, {'image_count': 1, 'id': 972}, {'image_count': 58, 'id': 973}, {'image_count': 9, 'id': 974}, {'image_count': 8, 'id': 975}, {'image_count': 1438, 'id': 976}, {'image_count': 31, 'id': 977}, {'image_count': 16, 'id': 978}, {'image_count': 491, 'id': 979}, {'image_count': 432, 'id': 980}, {'image_count': 1945, 'id': 981}, {'image_count': 3826, 'id': 982}, {'image_count': 5, 'id': 983}, {'image_count': 28, 'id': 984}, {'image_count': 7, 'id': 985}, {'image_count': 146, 'id': 986}, {'image_count': 1, 'id': 987}, {'image_count': 25, 'id': 988}, {'image_count': 22, 'id': 989}, {'image_count': 1, 'id': 990}, {'image_count': 10, 'id': 991}, {'image_count': 9, 'id': 992}, {'image_count': 308, 'id': 993}, {'image_count': 4, 'id': 994}, {'image_count': 1969, 'id': 995}, {'image_count': 45, 'id': 996}, {'image_count': 12, 'id': 997}, {'image_count': 1, 'id': 998}, {'image_count': 85, 'id': 999}, {'image_count': 3117, 'id': 1000}, {'image_count': 11, 'id': 1001}, {'image_count': 60, 'id': 1002}, {'image_count': 1, 'id': 1003}, {'image_count': 16, 'id': 1004}, {'image_count': 1, 'id': 1005}, {'image_count': 65, 'id': 1006}, {'image_count': 13, 'id': 1007}, {'image_count': 655, 'id': 1008}, {'image_count': 51, 'id': 1009}, {'image_count': 1, 'id': 1010}, {'image_count': 673, 'id': 1011}, {'image_count': 5, 'id': 1012}, {'image_count': 36, 'id': 1013}, {'image_count': 54, 'id': 1014}, {'image_count': 5, 'id': 1015}, {'image_count': 8, 'id': 1016}, {'image_count': 305, 'id': 1017}, {'image_count': 297, 'id': 1018}, {'image_count': 1508, 'id': 1019}, {'image_count': 223, 'id': 1020}, {'image_count': 1037, 'id': 1021}, {'image_count': 63, 'id': 1022}, {'image_count': 1881, 'id': 1023}, {'image_count': 507, 'id': 1024}, {'image_count': 333, 'id': 1025}, {'image_count': 1911, 'id': 1026}, {'image_count': 1765, 'id': 1027}, {'image_count': 1, 'id': 1028}, {'image_count': 5, 'id': 1029}, {'image_count': 1, 'id': 1030}, {'image_count': 9, 'id': 1031}, {'image_count': 2, 'id': 1032}, {'image_count': 151, 'id': 1033}, {'image_count': 82, 'id': 1034}, {'image_count': 1931, 'id': 1035}, {'image_count': 41, 'id': 1036}, {'image_count': 2877, 'id': 1037}, {'image_count': 24, 'id': 1038}, {'image_count': 22, 'id': 1039}, {'image_count': 35, 'id': 1040}, {'image_count': 69, 'id': 1041}, {'image_count': 962, 'id': 1042}, {'image_count': 588, 'id': 1043}, {'image_count': 21, 'id': 1044}, {'image_count': 825, 'id': 1045}, {'image_count': 52, 'id': 1046}, {'image_count': 5, 'id': 1047}, {'image_count': 5, 'id': 1048}, {'image_count': 5, 'id': 1049}, {'image_count': 1860, 'id': 1050}, {'image_count': 56, 'id': 1051}, {'image_count': 1582, 'id': 1052}, {'image_count': 7, 'id': 1053}, {'image_count': 2, 'id': 1054}, {'image_count': 1562, 'id': 1055}, {'image_count': 1885, 'id': 1056}, {'image_count': 1, 'id': 1057}, {'image_count': 5, 'id': 1058}, {'image_count': 137, 'id': 1059}, {'image_count': 1094, 'id': 1060}, {'image_count': 134, 'id': 1061}, {'image_count': 29, 'id': 1062}, {'image_count': 22, 'id': 1063}, {'image_count': 522, 'id': 1064}, {'image_count': 50, 'id': 1065}, {'image_count': 68, 'id': 1066}, {'image_count': 16, 'id': 1067}, {'image_count': 40, 'id': 1068}, {'image_count': 35, 'id': 1069}, {'image_count': 135, 'id': 1070}, {'image_count': 1866, 'id': 1071}, {'image_count': 772, 'id': 1072}, {'image_count': 50, 'id': 1073}, {'image_count': 1015, 'id': 1074}, {'image_count': 1, 'id': 1075}, {'image_count': 65, 'id': 1076}, {'image_count': 3978, 'id': 1077}, {'image_count': 1302, 'id': 1078}, {'image_count': 2925, 'id': 1079}, {'image_count': 2, 'id': 1080}, {'image_count': 29, 'id': 1081}, {'image_count': 36, 'id': 1082}, {'image_count': 138, 'id': 1083}, {'image_count': 4, 'id': 1084}, {'image_count': 67, 'id': 1085}, {'image_count': 26, 'id': 1086}, {'image_count': 25, 'id': 1087}, {'image_count': 33, 'id': 1088}, {'image_count': 37, 'id': 1089}, {'image_count': 50, 'id': 1090}, {'image_count': 270, 'id': 1091}, {'image_count': 12, 'id': 1092}, {'image_count': 316, 'id': 1093}, {'image_count': 41, 'id': 1094}, {'image_count': 299, 'id': 1095}, {'image_count': 105, 'id': 1096}, {'image_count': 2879, 'id': 1097}, {'image_count': 1021, 'id': 1098}, {'image_count': 1213, 'id': 1099}, {'image_count': 172, 'id': 1100}, {'image_count': 28, 'id': 1101}, {'image_count': 899, 'id': 1102}, {'image_count': 187, 'id': 1103}, {'image_count': 147, 'id': 1104}, {'image_count': 136, 'id': 1105}, {'image_count': 34, 'id': 1106}, {'image_count': 41, 'id': 1107}, {'image_count': 636, 'id': 1108}, {'image_count': 570, 'id': 1109}, {'image_count': 1149, 'id': 1110}, {'image_count': 61, 'id': 1111}, {'image_count': 3556, 'id': 1112}, {'image_count': 18, 'id': 1113}, {'image_count': 143, 'id': 1114}, {'image_count': 2951, 'id': 1115}, {'image_count': 7, 'id': 1116}, {'image_count': 943, 'id': 1117}, {'image_count': 6, 'id': 1118}, {'image_count': 1, 'id': 1119}, {'image_count': 11, 'id': 1120}, {'image_count': 101, 'id': 1121}, {'image_count': 1909, 'id': 1122}, {'image_count': 5302, 'id': 1123}, {'image_count': 1, 'id': 1124}, {'image_count': 44, 'id': 1125}, {'image_count': 3, 'id': 1126}, {'image_count': 44, 'id': 1127}, {'image_count': 31, 'id': 1128}, {'image_count': 7, 'id': 1129}, {'image_count': 20, 'id': 1130}, {'image_count': 11, 'id': 1131}, {'image_count': 13, 'id': 1132}, {'image_count': 3452, 'id': 1133}, {'image_count': 113, 'id': 1134}, {'image_count': 2, 'id': 1135}, {'image_count': 139, 'id': 1136}, {'image_count': 12, 'id': 1137}, {'image_count': 37, 'id': 1138}, {'image_count': 3213, 'id': 1139}, {'image_count': 47, 'id': 1140}, {'image_count': 1468, 'id': 1141}, {'image_count': 729, 'id': 1142}, {'image_count': 24, 'id': 1143}, {'image_count': 1, 'id': 1144}, {'image_count': 10, 'id': 1145}, {'image_count': 3, 'id': 1146}, {'image_count': 14, 'id': 1147}, {'image_count': 4, 'id': 1148}, {'image_count': 29, 'id': 1149}, {'image_count': 4, 'id': 1150}, {'image_count': 70, 'id': 1151}, {'image_count': 46, 'id': 1152}, {'image_count': 14, 'id': 1153}, {'image_count': 48, 'id': 1154}, {'image_count': 1855, 'id': 1155}, {'image_count': 113, 'id': 1156}, {'image_count': 1, 'id': 1157}, {'image_count': 1, 'id': 1158}, {'image_count': 10, 'id': 1159}, {'image_count': 54, 'id': 1160}, {'image_count': 1923, 'id': 1161}, {'image_count': 630, 'id': 1162}, {'image_count': 31, 'id': 1163}, {'image_count': 69, 'id': 1164}, {'image_count': 7, 'id': 1165}, {'image_count': 11, 'id': 1166}, {'image_count': 1, 'id': 1167}, {'image_count': 30, 'id': 1168}, {'image_count': 50, 'id': 1169}, {'image_count': 45, 'id': 1170}, {'image_count': 28, 'id': 1171}, {'image_count': 114, 'id': 1172}, {'image_count': 193, 'id': 1173}, {'image_count': 21, 'id': 1174}, {'image_count': 91, 'id': 1175}, {'image_count': 31, 'id': 1176}, {'image_count': 1469, 'id': 1177}, {'image_count': 1924, 'id': 1178}, {'image_count': 87, 'id': 1179}, {'image_count': 77, 'id': 1180}, {'image_count': 11, 'id': 1181}, {'image_count': 47, 'id': 1182}, {'image_count': 21, 'id': 1183}, {'image_count': 47, 'id': 1184}, {'image_count': 70, 'id': 1185}, {'image_count': 1838, 'id': 1186}, {'image_count': 19, 'id': 1187}, {'image_count': 531, 'id': 1188}, {'image_count': 11, 'id': 1189}, {'image_count': 2179, 'id': 1190}, {'image_count': 113, 'id': 1191}, {'image_count': 26, 'id': 1192}, {'image_count': 5, 'id': 1193}, {'image_count': 56, 'id': 1194}, {'image_count': 73, 'id': 1195}, {'image_count': 32, 'id': 1196}, {'image_count': 128, 'id': 1197}, {'image_count': 623, 'id': 1198}, {'image_count': 12, 'id': 1199}, {'image_count': 52, 'id': 1200}, {'image_count': 11, 'id': 1201}, {'image_count': 1687, 'id': 1202}, {'image_count': 81, 'id': 1203}] # noqa
|
| 20 |
+
# fmt: on
|
approach/ovod/APE/ape/data/datasets/objects365.py
ADDED
|
@@ -0,0 +1,799 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from detectron2.data.datasets.register_coco import register_coco_instances
|
| 4 |
+
|
| 5 |
+
OBJECTS365_CATEGORIES_FIXNAME = [
|
| 6 |
+
{"id": 1, "name": "Person"},
|
| 7 |
+
{"id": 2, "name": "Sneakers"},
|
| 8 |
+
{"id": 3, "name": "Chair"},
|
| 9 |
+
{"id": 4, "name": "Other Shoes"},
|
| 10 |
+
{"id": 5, "name": "Hat"},
|
| 11 |
+
{"id": 6, "name": "Car"},
|
| 12 |
+
{"id": 7, "name": "Lamp"},
|
| 13 |
+
{"id": 8, "name": "Glasses"},
|
| 14 |
+
{"id": 9, "name": "Bottle"},
|
| 15 |
+
{"id": 10, "name": "Desk"},
|
| 16 |
+
{"id": 11, "name": "Cup"},
|
| 17 |
+
{"id": 12, "name": "Street Lights"},
|
| 18 |
+
{"id": 13, "name": "Cabinet/shelf"},
|
| 19 |
+
{"id": 14, "name": "Handbag/Satchel"},
|
| 20 |
+
{"id": 15, "name": "Bracelet"},
|
| 21 |
+
{"id": 16, "name": "Plate"},
|
| 22 |
+
{"id": 17, "name": "Picture/Frame"},
|
| 23 |
+
{"id": 18, "name": "Helmet"},
|
| 24 |
+
{"id": 19, "name": "Book"},
|
| 25 |
+
{"id": 20, "name": "Gloves"},
|
| 26 |
+
{"id": 21, "name": "Storage box"},
|
| 27 |
+
{"id": 22, "name": "Boat"},
|
| 28 |
+
{"id": 23, "name": "Leather Shoes"},
|
| 29 |
+
{"id": 24, "name": "Flower"},
|
| 30 |
+
{"id": 25, "name": "Bench"},
|
| 31 |
+
{"id": 26, "name": "Potted Plant"},
|
| 32 |
+
{"id": 27, "name": "Bowl/Basin"},
|
| 33 |
+
{"id": 28, "name": "Flag"},
|
| 34 |
+
{"id": 29, "name": "Pillow"},
|
| 35 |
+
{"id": 30, "name": "Boots"},
|
| 36 |
+
{"id": 31, "name": "Vase"},
|
| 37 |
+
{"id": 32, "name": "Microphone"},
|
| 38 |
+
{"id": 33, "name": "Necklace"},
|
| 39 |
+
{"id": 34, "name": "Ring"},
|
| 40 |
+
{"id": 35, "name": "SUV"},
|
| 41 |
+
{"id": 36, "name": "Wine Glass"},
|
| 42 |
+
{"id": 37, "name": "Belt"},
|
| 43 |
+
{"id": 38, "name": "Monitor/TV"},
|
| 44 |
+
{"id": 39, "name": "Backpack"},
|
| 45 |
+
{"id": 40, "name": "Umbrella"},
|
| 46 |
+
{"id": 41, "name": "Traffic Light"},
|
| 47 |
+
{"id": 42, "name": "Speaker"},
|
| 48 |
+
{"id": 43, "name": "Watch"},
|
| 49 |
+
{"id": 44, "name": "Tie"},
|
| 50 |
+
{"id": 45, "name": "Trash bin Can"},
|
| 51 |
+
{"id": 46, "name": "Slippers"},
|
| 52 |
+
{"id": 47, "name": "Bicycle"},
|
| 53 |
+
{"id": 48, "name": "Stool"},
|
| 54 |
+
{"id": 49, "name": "Barrel/bucket"},
|
| 55 |
+
{"id": 50, "name": "Van"},
|
| 56 |
+
{"id": 51, "name": "Couch"},
|
| 57 |
+
{"id": 52, "name": "Sandals"},
|
| 58 |
+
{"id": 53, "name": "Basket"},
|
| 59 |
+
{"id": 54, "name": "Drum"},
|
| 60 |
+
{"id": 55, "name": "Pen/Pencil"},
|
| 61 |
+
{"id": 56, "name": "Bus"},
|
| 62 |
+
{"id": 57, "name": "Wild Bird"},
|
| 63 |
+
{"id": 58, "name": "High Heels"},
|
| 64 |
+
{"id": 59, "name": "Motorcycle"},
|
| 65 |
+
{"id": 60, "name": "Guitar"},
|
| 66 |
+
{"id": 61, "name": "Carpet"},
|
| 67 |
+
{"id": 62, "name": "Cell Phone"},
|
| 68 |
+
{"id": 63, "name": "Bread"},
|
| 69 |
+
{"id": 64, "name": "Camera"},
|
| 70 |
+
{"id": 65, "name": "Canned"},
|
| 71 |
+
{"id": 66, "name": "Truck"},
|
| 72 |
+
{"id": 67, "name": "Traffic cone"},
|
| 73 |
+
{"id": 68, "name": "Cymbal"},
|
| 74 |
+
{"id": 69, "name": "Lifesaver"},
|
| 75 |
+
{"id": 70, "name": "Towel"},
|
| 76 |
+
{"id": 71, "name": "Stuffed Toy"},
|
| 77 |
+
{"id": 72, "name": "Candle"},
|
| 78 |
+
{"id": 73, "name": "Sailboat"},
|
| 79 |
+
{"id": 74, "name": "Laptop"},
|
| 80 |
+
{"id": 75, "name": "Awning"},
|
| 81 |
+
{"id": 76, "name": "Bed"},
|
| 82 |
+
{"id": 77, "name": "Faucet"},
|
| 83 |
+
{"id": 78, "name": "Tent"},
|
| 84 |
+
{"id": 79, "name": "Horse"},
|
| 85 |
+
{"id": 80, "name": "Mirror"},
|
| 86 |
+
{"id": 81, "name": "Power outlet"},
|
| 87 |
+
{"id": 82, "name": "Sink"},
|
| 88 |
+
{"id": 83, "name": "Apple"},
|
| 89 |
+
{"id": 84, "name": "Air Conditioner"},
|
| 90 |
+
{"id": 85, "name": "Knife"},
|
| 91 |
+
{"id": 86, "name": "Hockey Stick"},
|
| 92 |
+
{"id": 87, "name": "Paddle"},
|
| 93 |
+
{"id": 88, "name": "Pickup Truck"},
|
| 94 |
+
{"id": 89, "name": "Fork"},
|
| 95 |
+
{"id": 90, "name": "Traffic Sign"},
|
| 96 |
+
{"id": 91, "name": "Ballon"},
|
| 97 |
+
{"id": 92, "name": "Tripod"},
|
| 98 |
+
{"id": 93, "name": "Dog"},
|
| 99 |
+
{"id": 94, "name": "Spoon"},
|
| 100 |
+
{"id": 95, "name": "Clock"},
|
| 101 |
+
{"id": 96, "name": "Pot"},
|
| 102 |
+
{"id": 97, "name": "Cow"},
|
| 103 |
+
{"id": 98, "name": "Cake"},
|
| 104 |
+
{"id": 99, "name": "Dining Table"},
|
| 105 |
+
{"id": 100, "name": "Sheep"},
|
| 106 |
+
{"id": 101, "name": "Hanger"},
|
| 107 |
+
{"id": 102, "name": "Blackboard/Whiteboard"},
|
| 108 |
+
{"id": 103, "name": "Napkin"},
|
| 109 |
+
{"id": 104, "name": "Other Fish"},
|
| 110 |
+
{"id": 105, "name": "Orange/Tangerine"},
|
| 111 |
+
{"id": 106, "name": "Toiletry"},
|
| 112 |
+
{"id": 107, "name": "Keyboard"},
|
| 113 |
+
{"id": 108, "name": "Tomato"},
|
| 114 |
+
{"id": 109, "name": "Lantern"},
|
| 115 |
+
{"id": 110, "name": "Machinery Vehicle"},
|
| 116 |
+
{"id": 111, "name": "Fan"},
|
| 117 |
+
{"id": 112, "name": "Green Vegetables"},
|
| 118 |
+
{"id": 113, "name": "Banana"},
|
| 119 |
+
{"id": 114, "name": "Baseball Glove"},
|
| 120 |
+
{"id": 115, "name": "Airplane"},
|
| 121 |
+
{"id": 116, "name": "Mouse"},
|
| 122 |
+
{"id": 117, "name": "Train"},
|
| 123 |
+
{"id": 118, "name": "Pumpkin"},
|
| 124 |
+
{"id": 119, "name": "Soccer"},
|
| 125 |
+
{"id": 120, "name": "Skiboard"},
|
| 126 |
+
{"id": 121, "name": "Luggage"},
|
| 127 |
+
{"id": 122, "name": "Nightstand"},
|
| 128 |
+
{"id": 123, "name": "Teapot"},
|
| 129 |
+
{"id": 124, "name": "Telephone"},
|
| 130 |
+
{"id": 125, "name": "Trolley"},
|
| 131 |
+
{"id": 126, "name": "Head Phone"},
|
| 132 |
+
{"id": 127, "name": "Sports Car"},
|
| 133 |
+
{"id": 128, "name": "Stop Sign"},
|
| 134 |
+
{"id": 129, "name": "Dessert"},
|
| 135 |
+
{"id": 130, "name": "Scooter"},
|
| 136 |
+
{"id": 131, "name": "Stroller"},
|
| 137 |
+
{"id": 132, "name": "Crane"},
|
| 138 |
+
{"id": 133, "name": "Remote"},
|
| 139 |
+
{"id": 134, "name": "Refrigerator"},
|
| 140 |
+
{"id": 135, "name": "Oven"},
|
| 141 |
+
{"id": 136, "name": "Lemon"},
|
| 142 |
+
{"id": 137, "name": "Duck"},
|
| 143 |
+
{"id": 138, "name": "Baseball Bat"},
|
| 144 |
+
{"id": 139, "name": "Surveillance Camera"},
|
| 145 |
+
{"id": 140, "name": "Cat"},
|
| 146 |
+
{"id": 141, "name": "Jug"},
|
| 147 |
+
{"id": 142, "name": "Broccoli"},
|
| 148 |
+
{"id": 143, "name": "Piano"},
|
| 149 |
+
{"id": 144, "name": "Pizza"},
|
| 150 |
+
{"id": 145, "name": "Elephant"},
|
| 151 |
+
{"id": 146, "name": "Skateboard"},
|
| 152 |
+
{"id": 147, "name": "Surfboard"},
|
| 153 |
+
{"id": 148, "name": "Gun"},
|
| 154 |
+
{"id": 149, "name": "Skating and Skiing shoes"},
|
| 155 |
+
{"id": 150, "name": "Gas stove"},
|
| 156 |
+
{"id": 151, "name": "Donut"},
|
| 157 |
+
{"id": 152, "name": "Bow Tie"},
|
| 158 |
+
{"id": 153, "name": "Carrot"},
|
| 159 |
+
{"id": 154, "name": "Toilet"},
|
| 160 |
+
{"id": 155, "name": "Kite"},
|
| 161 |
+
{"id": 156, "name": "Strawberry"},
|
| 162 |
+
{"id": 157, "name": "Other Balls"},
|
| 163 |
+
{"id": 158, "name": "Shovel"},
|
| 164 |
+
{"id": 159, "name": "Pepper"},
|
| 165 |
+
{"id": 160, "name": "Computer Box"},
|
| 166 |
+
{"id": 161, "name": "Toilet Paper"},
|
| 167 |
+
{"id": 162, "name": "Cleaning Products"},
|
| 168 |
+
{"id": 163, "name": "Chopsticks"},
|
| 169 |
+
{"id": 164, "name": "Microwave"},
|
| 170 |
+
{"id": 165, "name": "Pigeon"},
|
| 171 |
+
{"id": 166, "name": "Baseball"},
|
| 172 |
+
{"id": 167, "name": "Cutting/chopping Board"},
|
| 173 |
+
{"id": 168, "name": "Coffee Table"},
|
| 174 |
+
{"id": 169, "name": "Side Table"},
|
| 175 |
+
{"id": 170, "name": "Scissors"},
|
| 176 |
+
{"id": 171, "name": "Marker"},
|
| 177 |
+
{"id": 172, "name": "Pie"},
|
| 178 |
+
{"id": 173, "name": "Ladder"},
|
| 179 |
+
{"id": 174, "name": "Snowboard"},
|
| 180 |
+
{"id": 175, "name": "Cookies"},
|
| 181 |
+
{"id": 176, "name": "Radiator"},
|
| 182 |
+
{"id": 177, "name": "Fire Hydrant"},
|
| 183 |
+
{"id": 178, "name": "Basketball"},
|
| 184 |
+
{"id": 179, "name": "Zebra"},
|
| 185 |
+
{"id": 180, "name": "Grape"},
|
| 186 |
+
{"id": 181, "name": "Giraffe"},
|
| 187 |
+
{"id": 182, "name": "Potato"},
|
| 188 |
+
{"id": 183, "name": "Sausage"},
|
| 189 |
+
{"id": 184, "name": "Tricycle"},
|
| 190 |
+
{"id": 185, "name": "Violin"},
|
| 191 |
+
{"id": 186, "name": "Egg"},
|
| 192 |
+
{"id": 187, "name": "Fire Extinguisher"},
|
| 193 |
+
{"id": 188, "name": "Candy"},
|
| 194 |
+
{"id": 189, "name": "Fire Truck"},
|
| 195 |
+
{"id": 190, "name": "Billards"},
|
| 196 |
+
{"id": 191, "name": "Converter"},
|
| 197 |
+
{"id": 192, "name": "Bathtub"},
|
| 198 |
+
{"id": 193, "name": "Wheelchair"},
|
| 199 |
+
{"id": 194, "name": "Golf Club"},
|
| 200 |
+
{"id": 195, "name": "Briefcase"},
|
| 201 |
+
{"id": 196, "name": "Cucumber"},
|
| 202 |
+
{"id": 197, "name": "Cigar/Cigarette "},
|
| 203 |
+
{"id": 198, "name": "Paint Brush"},
|
| 204 |
+
{"id": 199, "name": "Pear"},
|
| 205 |
+
{"id": 200, "name": "Heavy Truck"},
|
| 206 |
+
{"id": 201, "name": "Hamburger"},
|
| 207 |
+
{"id": 202, "name": "Extractor"},
|
| 208 |
+
{"id": 203, "name": "Extension Cord"},
|
| 209 |
+
{"id": 204, "name": "Tong"},
|
| 210 |
+
{"id": 205, "name": "Tennis Racket"},
|
| 211 |
+
{"id": 206, "name": "Folder"},
|
| 212 |
+
{"id": 207, "name": "American Football"},
|
| 213 |
+
{"id": 208, "name": "earphone"},
|
| 214 |
+
{"id": 209, "name": "Mask"},
|
| 215 |
+
{"id": 210, "name": "Kettle"},
|
| 216 |
+
{"id": 211, "name": "Tennis"},
|
| 217 |
+
{"id": 212, "name": "Ship"},
|
| 218 |
+
{"id": 213, "name": "Swing"},
|
| 219 |
+
{"id": 214, "name": "Coffee Machine"},
|
| 220 |
+
{"id": 215, "name": "Slide"},
|
| 221 |
+
{"id": 216, "name": "Carriage"},
|
| 222 |
+
{"id": 217, "name": "Onion"},
|
| 223 |
+
{"id": 218, "name": "Green beans"},
|
| 224 |
+
{"id": 219, "name": "Projector"},
|
| 225 |
+
{"id": 220, "name": "Frisbee"},
|
| 226 |
+
{"id": 221, "name": "Washing Machine/Drying Machine"},
|
| 227 |
+
{"id": 222, "name": "Chicken"},
|
| 228 |
+
{"id": 223, "name": "Printer"},
|
| 229 |
+
{"id": 224, "name": "Watermelon"},
|
| 230 |
+
{"id": 225, "name": "Saxophone"},
|
| 231 |
+
{"id": 226, "name": "Tissue"},
|
| 232 |
+
{"id": 227, "name": "Toothbrush"},
|
| 233 |
+
{"id": 228, "name": "Ice cream"},
|
| 234 |
+
{"id": 229, "name": "Hot air balloon"},
|
| 235 |
+
{"id": 230, "name": "Cello"},
|
| 236 |
+
{"id": 231, "name": "French Fries"},
|
| 237 |
+
{"id": 232, "name": "Scale"},
|
| 238 |
+
{"id": 233, "name": "Trophy"},
|
| 239 |
+
{"id": 234, "name": "Cabbage"},
|
| 240 |
+
{"id": 235, "name": "Hot dog"},
|
| 241 |
+
{"id": 236, "name": "Blender"},
|
| 242 |
+
{"id": 237, "name": "Peach"},
|
| 243 |
+
{"id": 238, "name": "Rice"},
|
| 244 |
+
{"id": 239, "name": "Wallet/Purse"},
|
| 245 |
+
{"id": 240, "name": "Volleyball"},
|
| 246 |
+
{"id": 241, "name": "Deer"},
|
| 247 |
+
{"id": 242, "name": "Goose"},
|
| 248 |
+
{"id": 243, "name": "Tape"},
|
| 249 |
+
{"id": 244, "name": "Tablet"},
|
| 250 |
+
{"id": 245, "name": "Cosmetics"},
|
| 251 |
+
{"id": 246, "name": "Trumpet"},
|
| 252 |
+
{"id": 247, "name": "Pineapple"},
|
| 253 |
+
{"id": 248, "name": "Golf Ball"},
|
| 254 |
+
{"id": 249, "name": "Ambulance"},
|
| 255 |
+
{"id": 250, "name": "Parking meter"},
|
| 256 |
+
{"id": 251, "name": "Mango"},
|
| 257 |
+
{"id": 252, "name": "Key"},
|
| 258 |
+
{"id": 253, "name": "Hurdle"},
|
| 259 |
+
{"id": 254, "name": "Fishing Rod"},
|
| 260 |
+
{"id": 255, "name": "Medal"},
|
| 261 |
+
{"id": 256, "name": "Flute"},
|
| 262 |
+
{"id": 257, "name": "Brush"},
|
| 263 |
+
{"id": 258, "name": "Penguin"},
|
| 264 |
+
{"id": 259, "name": "Megaphone"},
|
| 265 |
+
{"id": 260, "name": "Corn"},
|
| 266 |
+
{"id": 261, "name": "Lettuce"},
|
| 267 |
+
{"id": 262, "name": "Garlic"},
|
| 268 |
+
{"id": 263, "name": "Swan"},
|
| 269 |
+
{"id": 264, "name": "Helicopter"},
|
| 270 |
+
{"id": 265, "name": "Green Onion"},
|
| 271 |
+
{"id": 266, "name": "Sandwich"},
|
| 272 |
+
{"id": 267, "name": "Nuts"},
|
| 273 |
+
{"id": 268, "name": "Speed Limit Sign"},
|
| 274 |
+
{"id": 269, "name": "Induction Cooker"},
|
| 275 |
+
{"id": 270, "name": "Broom"},
|
| 276 |
+
{"id": 271, "name": "Trombone"},
|
| 277 |
+
{"id": 272, "name": "Plum"},
|
| 278 |
+
{"id": 273, "name": "Rickshaw"},
|
| 279 |
+
{"id": 274, "name": "Goldfish"},
|
| 280 |
+
{"id": 275, "name": "Kiwi fruit"},
|
| 281 |
+
{"id": 276, "name": "Router/modem"},
|
| 282 |
+
{"id": 277, "name": "Poker Card"},
|
| 283 |
+
{"id": 278, "name": "Toaster"},
|
| 284 |
+
{"id": 279, "name": "Shrimp"},
|
| 285 |
+
{"id": 280, "name": "Sushi"},
|
| 286 |
+
{"id": 281, "name": "Cheese"},
|
| 287 |
+
{"id": 282, "name": "Notepaper"},
|
| 288 |
+
{"id": 283, "name": "Cherry"},
|
| 289 |
+
{"id": 284, "name": "Pliers"},
|
| 290 |
+
{"id": 285, "name": "CD"},
|
| 291 |
+
{"id": 286, "name": "Pasta"},
|
| 292 |
+
{"id": 287, "name": "Hammer"},
|
| 293 |
+
{"id": 288, "name": "Cue"},
|
| 294 |
+
{"id": 289, "name": "Avocado"},
|
| 295 |
+
{"id": 290, "name": "Hami melon"},
|
| 296 |
+
{"id": 291, "name": "Flask"},
|
| 297 |
+
{"id": 292, "name": "Mushroom"},
|
| 298 |
+
{"id": 293, "name": "Screwdriver"},
|
| 299 |
+
{"id": 294, "name": "Soap"},
|
| 300 |
+
{"id": 295, "name": "Recorder"},
|
| 301 |
+
{"id": 296, "name": "Bear"},
|
| 302 |
+
{"id": 297, "name": "Eggplant"},
|
| 303 |
+
{"id": 298, "name": "Board Eraser"},
|
| 304 |
+
{"id": 299, "name": "Coconut"},
|
| 305 |
+
{"id": 300, "name": "Tape Measure/ Ruler"},
|
| 306 |
+
{"id": 301, "name": "Pig"},
|
| 307 |
+
{"id": 302, "name": "Showerhead"},
|
| 308 |
+
{"id": 303, "name": "Globe"},
|
| 309 |
+
{"id": 304, "name": "Chips"},
|
| 310 |
+
{"id": 305, "name": "Steak"},
|
| 311 |
+
{"id": 306, "name": "Crosswalk Sign"},
|
| 312 |
+
{"id": 307, "name": "Stapler"},
|
| 313 |
+
{"id": 308, "name": "Camel"},
|
| 314 |
+
{"id": 309, "name": "Formula 1 "},
|
| 315 |
+
{"id": 310, "name": "Pomegranate"},
|
| 316 |
+
{"id": 311, "name": "Dishwasher"},
|
| 317 |
+
{"id": 312, "name": "Crab"},
|
| 318 |
+
{"id": 313, "name": "Hoverboard"},
|
| 319 |
+
{"id": 314, "name": "Meatball"},
|
| 320 |
+
{"id": 315, "name": "Rice Cooker"},
|
| 321 |
+
{"id": 316, "name": "Tuba"},
|
| 322 |
+
{"id": 317, "name": "Calculator"},
|
| 323 |
+
{"id": 318, "name": "Papaya"},
|
| 324 |
+
{"id": 319, "name": "Antelope"},
|
| 325 |
+
{"id": 320, "name": "Parrot"},
|
| 326 |
+
{"id": 321, "name": "Seal"},
|
| 327 |
+
{"id": 322, "name": "Butterfly"},
|
| 328 |
+
{"id": 323, "name": "Dumbbell"},
|
| 329 |
+
{"id": 324, "name": "Donkey"},
|
| 330 |
+
{"id": 325, "name": "Lion"},
|
| 331 |
+
{"id": 326, "name": "Urinal"},
|
| 332 |
+
{"id": 327, "name": "Dolphin"},
|
| 333 |
+
{"id": 328, "name": "Electric Drill"},
|
| 334 |
+
{"id": 329, "name": "Hair Dryer"},
|
| 335 |
+
{"id": 330, "name": "Egg tart"},
|
| 336 |
+
{"id": 331, "name": "Jellyfish"},
|
| 337 |
+
{"id": 332, "name": "Treadmill"},
|
| 338 |
+
{"id": 333, "name": "Lighter"},
|
| 339 |
+
{"id": 334, "name": "Grapefruit"},
|
| 340 |
+
{"id": 335, "name": "Game board"},
|
| 341 |
+
{"id": 336, "name": "Mop"},
|
| 342 |
+
{"id": 337, "name": "Radish"},
|
| 343 |
+
{"id": 338, "name": "Baozi"},
|
| 344 |
+
{"id": 339, "name": "Target"},
|
| 345 |
+
{"id": 340, "name": "French"},
|
| 346 |
+
{"id": 341, "name": "Spring Rolls"},
|
| 347 |
+
{"id": 342, "name": "Monkey"},
|
| 348 |
+
{"id": 343, "name": "Rabbit"},
|
| 349 |
+
{"id": 344, "name": "Pencil Case"},
|
| 350 |
+
{"id": 345, "name": "Yak"},
|
| 351 |
+
{"id": 346, "name": "Red Cabbage"},
|
| 352 |
+
{"id": 347, "name": "Binoculars"},
|
| 353 |
+
{"id": 348, "name": "Asparagus"},
|
| 354 |
+
{"id": 349, "name": "Barbell"},
|
| 355 |
+
{"id": 350, "name": "Scallop"},
|
| 356 |
+
{"id": 351, "name": "Noddles"},
|
| 357 |
+
{"id": 352, "name": "Comb"},
|
| 358 |
+
{"id": 353, "name": "Dumpling"},
|
| 359 |
+
{"id": 354, "name": "Oyster"},
|
| 360 |
+
{"id": 355, "name": "Table Tennis paddle"},
|
| 361 |
+
{"id": 356, "name": "Cosmetics Brush/Eyeliner Pencil"},
|
| 362 |
+
{"id": 357, "name": "Chainsaw"},
|
| 363 |
+
{"id": 358, "name": "Eraser"},
|
| 364 |
+
{"id": 359, "name": "Lobster"},
|
| 365 |
+
{"id": 360, "name": "Durian"},
|
| 366 |
+
{"id": 361, "name": "Okra"},
|
| 367 |
+
{"id": 362, "name": "Lipstick"},
|
| 368 |
+
{"id": 363, "name": "Cosmetics Mirror"},
|
| 369 |
+
{"id": 364, "name": "Curling"},
|
| 370 |
+
{"id": 365, "name": "Table Tennis "},
|
| 371 |
+
]
|
| 372 |
+
|
| 373 |
+
OBJECTS365_CATEGORIES = [
|
| 374 |
+
{"id": 1, "name": "Person"},
|
| 375 |
+
{"id": 2, "name": "Sneakers"},
|
| 376 |
+
{"id": 3, "name": "Chair"},
|
| 377 |
+
{"id": 4, "name": "Other Shoes"},
|
| 378 |
+
{"id": 5, "name": "Hat"},
|
| 379 |
+
{"id": 6, "name": "Car"},
|
| 380 |
+
{"id": 7, "name": "Lamp"},
|
| 381 |
+
{"id": 8, "name": "Glasses"},
|
| 382 |
+
{"id": 9, "name": "Bottle"},
|
| 383 |
+
{"id": 10, "name": "Desk"},
|
| 384 |
+
{"id": 11, "name": "Cup"},
|
| 385 |
+
{"id": 12, "name": "Street Lights"},
|
| 386 |
+
{"id": 13, "name": "Cabinet/shelf"},
|
| 387 |
+
{"id": 14, "name": "Handbag/Satchel"},
|
| 388 |
+
{"id": 15, "name": "Bracelet"},
|
| 389 |
+
{"id": 16, "name": "Plate"},
|
| 390 |
+
{"id": 17, "name": "Picture/Frame"},
|
| 391 |
+
{"id": 18, "name": "Helmet"},
|
| 392 |
+
{"id": 19, "name": "Book"},
|
| 393 |
+
{"id": 20, "name": "Gloves"},
|
| 394 |
+
{"id": 21, "name": "Storage box"},
|
| 395 |
+
{"id": 22, "name": "Boat"},
|
| 396 |
+
{"id": 23, "name": "Leather Shoes"},
|
| 397 |
+
{"id": 24, "name": "Flower"},
|
| 398 |
+
{"id": 25, "name": "Bench"},
|
| 399 |
+
{"id": 26, "name": "Potted Plant"},
|
| 400 |
+
{"id": 27, "name": "Bowl/Basin"},
|
| 401 |
+
{"id": 28, "name": "Flag"},
|
| 402 |
+
{"id": 29, "name": "Pillow"},
|
| 403 |
+
{"id": 30, "name": "Boots"},
|
| 404 |
+
{"id": 31, "name": "Vase"},
|
| 405 |
+
{"id": 32, "name": "Microphone"},
|
| 406 |
+
{"id": 33, "name": "Necklace"},
|
| 407 |
+
{"id": 34, "name": "Ring"},
|
| 408 |
+
{"id": 35, "name": "SUV"},
|
| 409 |
+
{"id": 36, "name": "Wine Glass"},
|
| 410 |
+
{"id": 37, "name": "Belt"},
|
| 411 |
+
{"id": 38, "name": "Moniter/TV"},
|
| 412 |
+
{"id": 39, "name": "Backpack"},
|
| 413 |
+
{"id": 40, "name": "Umbrella"},
|
| 414 |
+
{"id": 41, "name": "Traffic Light"},
|
| 415 |
+
{"id": 42, "name": "Speaker"},
|
| 416 |
+
{"id": 43, "name": "Watch"},
|
| 417 |
+
{"id": 44, "name": "Tie"},
|
| 418 |
+
{"id": 45, "name": "Trash bin Can"},
|
| 419 |
+
{"id": 46, "name": "Slippers"},
|
| 420 |
+
{"id": 47, "name": "Bicycle"},
|
| 421 |
+
{"id": 48, "name": "Stool"},
|
| 422 |
+
{"id": 49, "name": "Barrel/bucket"},
|
| 423 |
+
{"id": 50, "name": "Van"},
|
| 424 |
+
{"id": 51, "name": "Couch"},
|
| 425 |
+
{"id": 52, "name": "Sandals"},
|
| 426 |
+
{"id": 53, "name": "Bakset"},
|
| 427 |
+
{"id": 54, "name": "Drum"},
|
| 428 |
+
{"id": 55, "name": "Pen/Pencil"},
|
| 429 |
+
{"id": 56, "name": "Bus"},
|
| 430 |
+
{"id": 57, "name": "Wild Bird"},
|
| 431 |
+
{"id": 58, "name": "High Heels"},
|
| 432 |
+
{"id": 59, "name": "Motorcycle"},
|
| 433 |
+
{"id": 60, "name": "Guitar"},
|
| 434 |
+
{"id": 61, "name": "Carpet"},
|
| 435 |
+
{"id": 62, "name": "Cell Phone"},
|
| 436 |
+
{"id": 63, "name": "Bread"},
|
| 437 |
+
{"id": 64, "name": "Camera"},
|
| 438 |
+
{"id": 65, "name": "Canned"},
|
| 439 |
+
{"id": 66, "name": "Truck"},
|
| 440 |
+
{"id": 67, "name": "Traffic cone"},
|
| 441 |
+
{"id": 68, "name": "Cymbal"},
|
| 442 |
+
{"id": 69, "name": "Lifesaver"},
|
| 443 |
+
{"id": 70, "name": "Towel"},
|
| 444 |
+
{"id": 71, "name": "Stuffed Toy"},
|
| 445 |
+
{"id": 72, "name": "Candle"},
|
| 446 |
+
{"id": 73, "name": "Sailboat"},
|
| 447 |
+
{"id": 74, "name": "Laptop"},
|
| 448 |
+
{"id": 75, "name": "Awning"},
|
| 449 |
+
{"id": 76, "name": "Bed"},
|
| 450 |
+
{"id": 77, "name": "Faucet"},
|
| 451 |
+
{"id": 78, "name": "Tent"},
|
| 452 |
+
{"id": 79, "name": "Horse"},
|
| 453 |
+
{"id": 80, "name": "Mirror"},
|
| 454 |
+
{"id": 81, "name": "Power outlet"},
|
| 455 |
+
{"id": 82, "name": "Sink"},
|
| 456 |
+
{"id": 83, "name": "Apple"},
|
| 457 |
+
{"id": 84, "name": "Air Conditioner"},
|
| 458 |
+
{"id": 85, "name": "Knife"},
|
| 459 |
+
{"id": 86, "name": "Hockey Stick"},
|
| 460 |
+
{"id": 87, "name": "Paddle"},
|
| 461 |
+
{"id": 88, "name": "Pickup Truck"},
|
| 462 |
+
{"id": 89, "name": "Fork"},
|
| 463 |
+
{"id": 90, "name": "Traffic Sign"},
|
| 464 |
+
{"id": 91, "name": "Ballon"},
|
| 465 |
+
{"id": 92, "name": "Tripod"},
|
| 466 |
+
{"id": 93, "name": "Dog"},
|
| 467 |
+
{"id": 94, "name": "Spoon"},
|
| 468 |
+
{"id": 95, "name": "Clock"},
|
| 469 |
+
{"id": 96, "name": "Pot"},
|
| 470 |
+
{"id": 97, "name": "Cow"},
|
| 471 |
+
{"id": 98, "name": "Cake"},
|
| 472 |
+
{"id": 99, "name": "Dinning Table"},
|
| 473 |
+
{"id": 100, "name": "Sheep"},
|
| 474 |
+
{"id": 101, "name": "Hanger"},
|
| 475 |
+
{"id": 102, "name": "Blackboard/Whiteboard"},
|
| 476 |
+
{"id": 103, "name": "Napkin"},
|
| 477 |
+
{"id": 104, "name": "Other Fish"},
|
| 478 |
+
{"id": 105, "name": "Orange/Tangerine"},
|
| 479 |
+
{"id": 106, "name": "Toiletry"},
|
| 480 |
+
{"id": 107, "name": "Keyboard"},
|
| 481 |
+
{"id": 108, "name": "Tomato"},
|
| 482 |
+
{"id": 109, "name": "Lantern"},
|
| 483 |
+
{"id": 110, "name": "Machinery Vehicle"},
|
| 484 |
+
{"id": 111, "name": "Fan"},
|
| 485 |
+
{"id": 112, "name": "Green Vegetables"},
|
| 486 |
+
{"id": 113, "name": "Banana"},
|
| 487 |
+
{"id": 114, "name": "Baseball Glove"},
|
| 488 |
+
{"id": 115, "name": "Airplane"},
|
| 489 |
+
{"id": 116, "name": "Mouse"},
|
| 490 |
+
{"id": 117, "name": "Train"},
|
| 491 |
+
{"id": 118, "name": "Pumpkin"},
|
| 492 |
+
{"id": 119, "name": "Soccer"},
|
| 493 |
+
{"id": 120, "name": "Skiboard"},
|
| 494 |
+
{"id": 121, "name": "Luggage"},
|
| 495 |
+
{"id": 122, "name": "Nightstand"},
|
| 496 |
+
{"id": 123, "name": "Tea pot"},
|
| 497 |
+
{"id": 124, "name": "Telephone"},
|
| 498 |
+
{"id": 125, "name": "Trolley"},
|
| 499 |
+
{"id": 126, "name": "Head Phone"},
|
| 500 |
+
{"id": 127, "name": "Sports Car"},
|
| 501 |
+
{"id": 128, "name": "Stop Sign"},
|
| 502 |
+
{"id": 129, "name": "Dessert"},
|
| 503 |
+
{"id": 130, "name": "Scooter"},
|
| 504 |
+
{"id": 131, "name": "Stroller"},
|
| 505 |
+
{"id": 132, "name": "Crane"},
|
| 506 |
+
{"id": 133, "name": "Remote"},
|
| 507 |
+
{"id": 134, "name": "Refrigerator"},
|
| 508 |
+
{"id": 135, "name": "Oven"},
|
| 509 |
+
{"id": 136, "name": "Lemon"},
|
| 510 |
+
{"id": 137, "name": "Duck"},
|
| 511 |
+
{"id": 138, "name": "Baseball Bat"},
|
| 512 |
+
{"id": 139, "name": "Surveillance Camera"},
|
| 513 |
+
{"id": 140, "name": "Cat"},
|
| 514 |
+
{"id": 141, "name": "Jug"},
|
| 515 |
+
{"id": 142, "name": "Broccoli"},
|
| 516 |
+
{"id": 143, "name": "Piano"},
|
| 517 |
+
{"id": 144, "name": "Pizza"},
|
| 518 |
+
{"id": 145, "name": "Elephant"},
|
| 519 |
+
{"id": 146, "name": "Skateboard"},
|
| 520 |
+
{"id": 147, "name": "Surfboard"},
|
| 521 |
+
{"id": 148, "name": "Gun"},
|
| 522 |
+
{"id": 149, "name": "Skating and Skiing shoes"},
|
| 523 |
+
{"id": 150, "name": "Gas stove"},
|
| 524 |
+
{"id": 151, "name": "Donut"},
|
| 525 |
+
{"id": 152, "name": "Bow Tie"},
|
| 526 |
+
{"id": 153, "name": "Carrot"},
|
| 527 |
+
{"id": 154, "name": "Toilet"},
|
| 528 |
+
{"id": 155, "name": "Kite"},
|
| 529 |
+
{"id": 156, "name": "Strawberry"},
|
| 530 |
+
{"id": 157, "name": "Other Balls"},
|
| 531 |
+
{"id": 158, "name": "Shovel"},
|
| 532 |
+
{"id": 159, "name": "Pepper"},
|
| 533 |
+
{"id": 160, "name": "Computer Box"},
|
| 534 |
+
{"id": 161, "name": "Toilet Paper"},
|
| 535 |
+
{"id": 162, "name": "Cleaning Products"},
|
| 536 |
+
{"id": 163, "name": "Chopsticks"},
|
| 537 |
+
{"id": 164, "name": "Microwave"},
|
| 538 |
+
{"id": 165, "name": "Pigeon"},
|
| 539 |
+
{"id": 166, "name": "Baseball"},
|
| 540 |
+
{"id": 167, "name": "Cutting/chopping Board"},
|
| 541 |
+
{"id": 168, "name": "Coffee Table"},
|
| 542 |
+
{"id": 169, "name": "Side Table"},
|
| 543 |
+
{"id": 170, "name": "Scissors"},
|
| 544 |
+
{"id": 171, "name": "Marker"},
|
| 545 |
+
{"id": 172, "name": "Pie"},
|
| 546 |
+
{"id": 173, "name": "Ladder"},
|
| 547 |
+
{"id": 174, "name": "Snowboard"},
|
| 548 |
+
{"id": 175, "name": "Cookies"},
|
| 549 |
+
{"id": 176, "name": "Radiator"},
|
| 550 |
+
{"id": 177, "name": "Fire Hydrant"},
|
| 551 |
+
{"id": 178, "name": "Basketball"},
|
| 552 |
+
{"id": 179, "name": "Zebra"},
|
| 553 |
+
{"id": 180, "name": "Grape"},
|
| 554 |
+
{"id": 181, "name": "Giraffe"},
|
| 555 |
+
{"id": 182, "name": "Potato"},
|
| 556 |
+
{"id": 183, "name": "Sausage"},
|
| 557 |
+
{"id": 184, "name": "Tricycle"},
|
| 558 |
+
{"id": 185, "name": "Violin"},
|
| 559 |
+
{"id": 186, "name": "Egg"},
|
| 560 |
+
{"id": 187, "name": "Fire Extinguisher"},
|
| 561 |
+
{"id": 188, "name": "Candy"},
|
| 562 |
+
{"id": 189, "name": "Fire Truck"},
|
| 563 |
+
{"id": 190, "name": "Billards"},
|
| 564 |
+
{"id": 191, "name": "Converter"},
|
| 565 |
+
{"id": 192, "name": "Bathtub"},
|
| 566 |
+
{"id": 193, "name": "Wheelchair"},
|
| 567 |
+
{"id": 194, "name": "Golf Club"},
|
| 568 |
+
{"id": 195, "name": "Briefcase"},
|
| 569 |
+
{"id": 196, "name": "Cucumber"},
|
| 570 |
+
{"id": 197, "name": "Cigar/Cigarette "},
|
| 571 |
+
{"id": 198, "name": "Paint Brush"},
|
| 572 |
+
{"id": 199, "name": "Pear"},
|
| 573 |
+
{"id": 200, "name": "Heavy Truck"},
|
| 574 |
+
{"id": 201, "name": "Hamburger"},
|
| 575 |
+
{"id": 202, "name": "Extractor"},
|
| 576 |
+
{"id": 203, "name": "Extention Cord"},
|
| 577 |
+
{"id": 204, "name": "Tong"},
|
| 578 |
+
{"id": 205, "name": "Tennis Racket"},
|
| 579 |
+
{"id": 206, "name": "Folder"},
|
| 580 |
+
{"id": 207, "name": "American Football"},
|
| 581 |
+
{"id": 208, "name": "earphone"},
|
| 582 |
+
{"id": 209, "name": "Mask"},
|
| 583 |
+
{"id": 210, "name": "Kettle"},
|
| 584 |
+
{"id": 211, "name": "Tennis"},
|
| 585 |
+
{"id": 212, "name": "Ship"},
|
| 586 |
+
{"id": 213, "name": "Swing"},
|
| 587 |
+
{"id": 214, "name": "Coffee Machine"},
|
| 588 |
+
{"id": 215, "name": "Slide"},
|
| 589 |
+
{"id": 216, "name": "Carriage"},
|
| 590 |
+
{"id": 217, "name": "Onion"},
|
| 591 |
+
{"id": 218, "name": "Green beans"},
|
| 592 |
+
{"id": 219, "name": "Projector"},
|
| 593 |
+
{"id": 220, "name": "Frisbee"},
|
| 594 |
+
{"id": 221, "name": "Washing Machine/Drying Machine"},
|
| 595 |
+
{"id": 222, "name": "Chicken"},
|
| 596 |
+
{"id": 223, "name": "Printer"},
|
| 597 |
+
{"id": 224, "name": "Watermelon"},
|
| 598 |
+
{"id": 225, "name": "Saxophone"},
|
| 599 |
+
{"id": 226, "name": "Tissue"},
|
| 600 |
+
{"id": 227, "name": "Toothbrush"},
|
| 601 |
+
{"id": 228, "name": "Ice cream"},
|
| 602 |
+
{"id": 229, "name": "Hotair ballon"},
|
| 603 |
+
{"id": 230, "name": "Cello"},
|
| 604 |
+
{"id": 231, "name": "French Fries"},
|
| 605 |
+
{"id": 232, "name": "Scale"},
|
| 606 |
+
{"id": 233, "name": "Trophy"},
|
| 607 |
+
{"id": 234, "name": "Cabbage"},
|
| 608 |
+
{"id": 235, "name": "Hot dog"},
|
| 609 |
+
{"id": 236, "name": "Blender"},
|
| 610 |
+
{"id": 237, "name": "Peach"},
|
| 611 |
+
{"id": 238, "name": "Rice"},
|
| 612 |
+
{"id": 239, "name": "Wallet/Purse"},
|
| 613 |
+
{"id": 240, "name": "Volleyball"},
|
| 614 |
+
{"id": 241, "name": "Deer"},
|
| 615 |
+
{"id": 242, "name": "Goose"},
|
| 616 |
+
{"id": 243, "name": "Tape"},
|
| 617 |
+
{"id": 244, "name": "Tablet"},
|
| 618 |
+
{"id": 245, "name": "Cosmetics"},
|
| 619 |
+
{"id": 246, "name": "Trumpet"},
|
| 620 |
+
{"id": 247, "name": "Pineapple"},
|
| 621 |
+
{"id": 248, "name": "Golf Ball"},
|
| 622 |
+
{"id": 249, "name": "Ambulance"},
|
| 623 |
+
{"id": 250, "name": "Parking meter"},
|
| 624 |
+
{"id": 251, "name": "Mango"},
|
| 625 |
+
{"id": 252, "name": "Key"},
|
| 626 |
+
{"id": 253, "name": "Hurdle"},
|
| 627 |
+
{"id": 254, "name": "Fishing Rod"},
|
| 628 |
+
{"id": 255, "name": "Medal"},
|
| 629 |
+
{"id": 256, "name": "Flute"},
|
| 630 |
+
{"id": 257, "name": "Brush"},
|
| 631 |
+
{"id": 258, "name": "Penguin"},
|
| 632 |
+
{"id": 259, "name": "Megaphone"},
|
| 633 |
+
{"id": 260, "name": "Corn"},
|
| 634 |
+
{"id": 261, "name": "Lettuce"},
|
| 635 |
+
{"id": 262, "name": "Garlic"},
|
| 636 |
+
{"id": 263, "name": "Swan"},
|
| 637 |
+
{"id": 264, "name": "Helicopter"},
|
| 638 |
+
{"id": 265, "name": "Green Onion"},
|
| 639 |
+
{"id": 266, "name": "Sandwich"},
|
| 640 |
+
{"id": 267, "name": "Nuts"},
|
| 641 |
+
{"id": 268, "name": "Speed Limit Sign"},
|
| 642 |
+
{"id": 269, "name": "Induction Cooker"},
|
| 643 |
+
{"id": 270, "name": "Broom"},
|
| 644 |
+
{"id": 271, "name": "Trombone"},
|
| 645 |
+
{"id": 272, "name": "Plum"},
|
| 646 |
+
{"id": 273, "name": "Rickshaw"},
|
| 647 |
+
{"id": 274, "name": "Goldfish"},
|
| 648 |
+
{"id": 275, "name": "Kiwi fruit"},
|
| 649 |
+
{"id": 276, "name": "Router/modem"},
|
| 650 |
+
{"id": 277, "name": "Poker Card"},
|
| 651 |
+
{"id": 278, "name": "Toaster"},
|
| 652 |
+
{"id": 279, "name": "Shrimp"},
|
| 653 |
+
{"id": 280, "name": "Sushi"},
|
| 654 |
+
{"id": 281, "name": "Cheese"},
|
| 655 |
+
{"id": 282, "name": "Notepaper"},
|
| 656 |
+
{"id": 283, "name": "Cherry"},
|
| 657 |
+
{"id": 284, "name": "Pliers"},
|
| 658 |
+
{"id": 285, "name": "CD"},
|
| 659 |
+
{"id": 286, "name": "Pasta"},
|
| 660 |
+
{"id": 287, "name": "Hammer"},
|
| 661 |
+
{"id": 288, "name": "Cue"},
|
| 662 |
+
{"id": 289, "name": "Avocado"},
|
| 663 |
+
{"id": 290, "name": "Hamimelon"},
|
| 664 |
+
{"id": 291, "name": "Flask"},
|
| 665 |
+
{"id": 292, "name": "Mushroon"},
|
| 666 |
+
{"id": 293, "name": "Screwdriver"},
|
| 667 |
+
{"id": 294, "name": "Soap"},
|
| 668 |
+
{"id": 295, "name": "Recorder"},
|
| 669 |
+
{"id": 296, "name": "Bear"},
|
| 670 |
+
{"id": 297, "name": "Eggplant"},
|
| 671 |
+
{"id": 298, "name": "Board Eraser"},
|
| 672 |
+
{"id": 299, "name": "Coconut"},
|
| 673 |
+
{"id": 300, "name": "Tape Measur/ Ruler"},
|
| 674 |
+
{"id": 301, "name": "Pig"},
|
| 675 |
+
{"id": 302, "name": "Showerhead"},
|
| 676 |
+
{"id": 303, "name": "Globe"},
|
| 677 |
+
{"id": 304, "name": "Chips"},
|
| 678 |
+
{"id": 305, "name": "Steak"},
|
| 679 |
+
{"id": 306, "name": "Crosswalk Sign"},
|
| 680 |
+
{"id": 307, "name": "Stapler"},
|
| 681 |
+
{"id": 308, "name": "Campel"},
|
| 682 |
+
{"id": 309, "name": "Formula 1 "},
|
| 683 |
+
{"id": 310, "name": "Pomegranate"},
|
| 684 |
+
{"id": 311, "name": "Dishwasher"},
|
| 685 |
+
{"id": 312, "name": "Crab"},
|
| 686 |
+
{"id": 313, "name": "Hoverboard"},
|
| 687 |
+
{"id": 314, "name": "Meat ball"},
|
| 688 |
+
{"id": 315, "name": "Rice Cooker"},
|
| 689 |
+
{"id": 316, "name": "Tuba"},
|
| 690 |
+
{"id": 317, "name": "Calculator"},
|
| 691 |
+
{"id": 318, "name": "Papaya"},
|
| 692 |
+
{"id": 319, "name": "Antelope"},
|
| 693 |
+
{"id": 320, "name": "Parrot"},
|
| 694 |
+
{"id": 321, "name": "Seal"},
|
| 695 |
+
{"id": 322, "name": "Buttefly"},
|
| 696 |
+
{"id": 323, "name": "Dumbbell"},
|
| 697 |
+
{"id": 324, "name": "Donkey"},
|
| 698 |
+
{"id": 325, "name": "Lion"},
|
| 699 |
+
{"id": 326, "name": "Urinal"},
|
| 700 |
+
{"id": 327, "name": "Dolphin"},
|
| 701 |
+
{"id": 328, "name": "Electric Drill"},
|
| 702 |
+
{"id": 329, "name": "Hair Dryer"},
|
| 703 |
+
{"id": 330, "name": "Egg tart"},
|
| 704 |
+
{"id": 331, "name": "Jellyfish"},
|
| 705 |
+
{"id": 332, "name": "Treadmill"},
|
| 706 |
+
{"id": 333, "name": "Lighter"},
|
| 707 |
+
{"id": 334, "name": "Grapefruit"},
|
| 708 |
+
{"id": 335, "name": "Game board"},
|
| 709 |
+
{"id": 336, "name": "Mop"},
|
| 710 |
+
{"id": 337, "name": "Radish"},
|
| 711 |
+
{"id": 338, "name": "Baozi"},
|
| 712 |
+
{"id": 339, "name": "Target"},
|
| 713 |
+
{"id": 340, "name": "French"},
|
| 714 |
+
{"id": 341, "name": "Spring Rolls"},
|
| 715 |
+
{"id": 342, "name": "Monkey"},
|
| 716 |
+
{"id": 343, "name": "Rabbit"},
|
| 717 |
+
{"id": 344, "name": "Pencil Case"},
|
| 718 |
+
{"id": 345, "name": "Yak"},
|
| 719 |
+
{"id": 346, "name": "Red Cabbage"},
|
| 720 |
+
{"id": 347, "name": "Binoculars"},
|
| 721 |
+
{"id": 348, "name": "Asparagus"},
|
| 722 |
+
{"id": 349, "name": "Barbell"},
|
| 723 |
+
{"id": 350, "name": "Scallop"},
|
| 724 |
+
{"id": 351, "name": "Noddles"},
|
| 725 |
+
{"id": 352, "name": "Comb"},
|
| 726 |
+
{"id": 353, "name": "Dumpling"},
|
| 727 |
+
{"id": 354, "name": "Oyster"},
|
| 728 |
+
{"id": 355, "name": "Table Teniis paddle"},
|
| 729 |
+
{"id": 356, "name": "Cosmetics Brush/Eyeliner Pencil"},
|
| 730 |
+
{"id": 357, "name": "Chainsaw"},
|
| 731 |
+
{"id": 358, "name": "Eraser"},
|
| 732 |
+
{"id": 359, "name": "Lobster"},
|
| 733 |
+
{"id": 360, "name": "Durian"},
|
| 734 |
+
{"id": 361, "name": "Okra"},
|
| 735 |
+
{"id": 362, "name": "Lipstick"},
|
| 736 |
+
{"id": 363, "name": "Cosmetics Mirror"},
|
| 737 |
+
{"id": 364, "name": "Curling"},
|
| 738 |
+
{"id": 365, "name": "Table Tennis "},
|
| 739 |
+
]
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
def _get_builtin_metadata(key):
|
| 743 |
+
# return {}
|
| 744 |
+
if "fixname" in key:
|
| 745 |
+
id_to_name = {x["id"]: x["name"] for x in OBJECTS365_CATEGORIES_FIXNAME}
|
| 746 |
+
thing_dataset_id_to_contiguous_id = {
|
| 747 |
+
i + 1: i for i in range(len(OBJECTS365_CATEGORIES_FIXNAME))
|
| 748 |
+
}
|
| 749 |
+
else:
|
| 750 |
+
id_to_name = {x["id"]: x["name"] for x in OBJECTS365_CATEGORIES}
|
| 751 |
+
thing_dataset_id_to_contiguous_id = {i + 1: i for i in range(len(OBJECTS365_CATEGORIES))}
|
| 752 |
+
thing_classes = [id_to_name[k] for k in sorted(id_to_name)]
|
| 753 |
+
return {
|
| 754 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 755 |
+
"thing_classes": thing_classes,
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
|
| 759 |
+
_PREDEFINED_SPLITS_OBJECTS365 = {
|
| 760 |
+
"objects365_train": ("objects365/train", "objects365/annotations/objects365_train.json"),
|
| 761 |
+
"objects365_val": ("objects365/val", "objects365/annotations/objects365_val.json"),
|
| 762 |
+
"objects365_minival": ("objects365/val", "objects365/annotations/objects365_minival.json"),
|
| 763 |
+
"objects365_train_fixname": (
|
| 764 |
+
"objects365/train",
|
| 765 |
+
"objects365/annotations/objects365_train_fixname.json",
|
| 766 |
+
),
|
| 767 |
+
"objects365_val_fixname": (
|
| 768 |
+
"objects365/val",
|
| 769 |
+
"objects365/annotations/objects365_val_fixname.json",
|
| 770 |
+
),
|
| 771 |
+
"objects365_minival_fixname": (
|
| 772 |
+
"objects365/val",
|
| 773 |
+
"objects365/annotations/objects365_minival_fixname.json",
|
| 774 |
+
),
|
| 775 |
+
"objects365_train_fixname_fixmiss": (
|
| 776 |
+
"objects365/train",
|
| 777 |
+
"objects365/annotations/objects365_train_fixname_fixmiss.json",
|
| 778 |
+
),
|
| 779 |
+
"objects365_val_fixname_fixmiss": (
|
| 780 |
+
"objects365/val",
|
| 781 |
+
"objects365/annotations/objects365_val_fixname_fixmiss.json",
|
| 782 |
+
),
|
| 783 |
+
}
|
| 784 |
+
|
| 785 |
+
|
| 786 |
+
def register_all_objects365(root):
|
| 787 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_OBJECTS365.items():
|
| 788 |
+
register_coco_instances(
|
| 789 |
+
key,
|
| 790 |
+
_get_builtin_metadata(key),
|
| 791 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 792 |
+
os.path.join(root, image_root),
|
| 793 |
+
)
|
| 794 |
+
|
| 795 |
+
|
| 796 |
+
if __name__.endswith(".objects365"):
|
| 797 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 798 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 799 |
+
register_all_objects365(_root)
|
approach/ovod/APE/ape/data/datasets/odinw_categories.py
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ODINW_CATEGORIES = {
|
| 2 |
+
"AerialMaritimeDrone": [
|
| 3 |
+
{"id": 1, "name": "boat", "supercategory": "movable-objects"},
|
| 4 |
+
{"id": 2, "name": "car", "supercategory": "movable-objects"},
|
| 5 |
+
{"id": 3, "name": "dock", "supercategory": "movable-objects"},
|
| 6 |
+
{"id": 4, "name": "jetski", "supercategory": "movable-objects"},
|
| 7 |
+
{"id": 5, "name": "lift", "supercategory": "movable-objects"},
|
| 8 |
+
],
|
| 9 |
+
"AmericanSignLanguageLetters": [
|
| 10 |
+
{"id": 1, "name": "A", "supercategory": "Letters"},
|
| 11 |
+
{"id": 2, "name": "B", "supercategory": "Letters"},
|
| 12 |
+
{"id": 3, "name": "C", "supercategory": "Letters"},
|
| 13 |
+
{"id": 4, "name": "D", "supercategory": "Letters"},
|
| 14 |
+
{"id": 5, "name": "E", "supercategory": "Letters"},
|
| 15 |
+
{"id": 6, "name": "F", "supercategory": "Letters"},
|
| 16 |
+
{"id": 7, "name": "G", "supercategory": "Letters"},
|
| 17 |
+
{"id": 8, "name": "H", "supercategory": "Letters"},
|
| 18 |
+
{"id": 9, "name": "I", "supercategory": "Letters"},
|
| 19 |
+
{"id": 10, "name": "J", "supercategory": "Letters"},
|
| 20 |
+
{"id": 11, "name": "K", "supercategory": "Letters"},
|
| 21 |
+
{"id": 12, "name": "L", "supercategory": "Letters"},
|
| 22 |
+
{"id": 13, "name": "M", "supercategory": "Letters"},
|
| 23 |
+
{"id": 14, "name": "N", "supercategory": "Letters"},
|
| 24 |
+
{"id": 15, "name": "O", "supercategory": "Letters"},
|
| 25 |
+
{"id": 16, "name": "P", "supercategory": "Letters"},
|
| 26 |
+
{"id": 17, "name": "Q", "supercategory": "Letters"},
|
| 27 |
+
{"id": 18, "name": "R", "supercategory": "Letters"},
|
| 28 |
+
{"id": 19, "name": "S", "supercategory": "Letters"},
|
| 29 |
+
{"id": 20, "name": "T", "supercategory": "Letters"},
|
| 30 |
+
{"id": 21, "name": "U", "supercategory": "Letters"},
|
| 31 |
+
{"id": 22, "name": "V", "supercategory": "Letters"},
|
| 32 |
+
{"id": 23, "name": "W", "supercategory": "Letters"},
|
| 33 |
+
{"id": 24, "name": "X", "supercategory": "Letters"},
|
| 34 |
+
{"id": 25, "name": "Y", "supercategory": "Letters"},
|
| 35 |
+
{"id": 26, "name": "Z", "supercategory": "Letters"},
|
| 36 |
+
],
|
| 37 |
+
"Aquarium": [
|
| 38 |
+
{"id": 1, "name": "fish", "supercategory": "creatures"},
|
| 39 |
+
{"id": 2, "name": "jellyfish", "supercategory": "creatures"},
|
| 40 |
+
{"id": 3, "name": "penguin", "supercategory": "creatures"},
|
| 41 |
+
{"id": 4, "name": "puffin", "supercategory": "creatures"},
|
| 42 |
+
{"id": 5, "name": "shark", "supercategory": "creatures"},
|
| 43 |
+
{"id": 6, "name": "starfish", "supercategory": "creatures"},
|
| 44 |
+
{"id": 7, "name": "stingray", "supercategory": "creatures"},
|
| 45 |
+
],
|
| 46 |
+
"BCCD": [
|
| 47 |
+
{"id": 1, "name": "Platelets", "supercategory": "cells"},
|
| 48 |
+
{"id": 2, "name": "RBC", "supercategory": "cells"},
|
| 49 |
+
{"id": 3, "name": "WBC", "supercategory": "cells"},
|
| 50 |
+
],
|
| 51 |
+
"boggleBoards": [
|
| 52 |
+
{"id": 1, "name": "Q", "supercategory": "letters"},
|
| 53 |
+
{"id": 2, "name": "a", "supercategory": "letters"},
|
| 54 |
+
{"id": 3, "name": "an", "supercategory": "letters"},
|
| 55 |
+
{"id": 4, "name": "b", "supercategory": "letters"},
|
| 56 |
+
{"id": 5, "name": "c", "supercategory": "letters"},
|
| 57 |
+
{"id": 6, "name": "d", "supercategory": "letters"},
|
| 58 |
+
{"id": 7, "name": "e", "supercategory": "letters"},
|
| 59 |
+
{"id": 8, "name": "er", "supercategory": "letters"},
|
| 60 |
+
{"id": 9, "name": "f", "supercategory": "letters"},
|
| 61 |
+
{"id": 10, "name": "g", "supercategory": "letters"},
|
| 62 |
+
{"id": 11, "name": "h", "supercategory": "letters"},
|
| 63 |
+
{"id": 12, "name": "he", "supercategory": "letters"},
|
| 64 |
+
{"id": 13, "name": "i", "supercategory": "letters"},
|
| 65 |
+
{"id": 14, "name": "in", "supercategory": "letters"},
|
| 66 |
+
{"id": 15, "name": "j", "supercategory": "letters"},
|
| 67 |
+
{"id": 16, "name": "k", "supercategory": "letters"},
|
| 68 |
+
{"id": 17, "name": "l", "supercategory": "letters"},
|
| 69 |
+
{"id": 18, "name": "m", "supercategory": "letters"},
|
| 70 |
+
{"id": 19, "name": "n", "supercategory": "letters"},
|
| 71 |
+
{"id": 20, "name": "o", "supercategory": "letters"},
|
| 72 |
+
{"id": 21, "name": "o ", "supercategory": "letters"},
|
| 73 |
+
{"id": 22, "name": "p", "supercategory": "letters"},
|
| 74 |
+
{"id": 23, "name": "q", "supercategory": "letters"},
|
| 75 |
+
{"id": 24, "name": "qu", "supercategory": "letters"},
|
| 76 |
+
{"id": 25, "name": "r", "supercategory": "letters"},
|
| 77 |
+
{"id": 26, "name": "s", "supercategory": "letters"},
|
| 78 |
+
{"id": 27, "name": "t", "supercategory": "letters"},
|
| 79 |
+
{"id": 28, "name": "t\\", "supercategory": "letters"},
|
| 80 |
+
{"id": 29, "name": "th", "supercategory": "letters"},
|
| 81 |
+
{"id": 30, "name": "u", "supercategory": "letters"},
|
| 82 |
+
{"id": 31, "name": "v", "supercategory": "letters"},
|
| 83 |
+
{"id": 32, "name": "w", "supercategory": "letters"},
|
| 84 |
+
{"id": 33, "name": "wild", "supercategory": "letters"},
|
| 85 |
+
{"id": 34, "name": "x", "supercategory": "letters"},
|
| 86 |
+
{"id": 35, "name": "y", "supercategory": "letters"},
|
| 87 |
+
{"id": 36, "name": "z", "supercategory": "letters"},
|
| 88 |
+
],
|
| 89 |
+
"brackishUnderwater": [
|
| 90 |
+
{"id": 1, "name": "crab", "supercategory": "animals"},
|
| 91 |
+
{"id": 2, "name": "fish", "supercategory": "animals"},
|
| 92 |
+
{"id": 3, "name": "jellyfish", "supercategory": "animals"},
|
| 93 |
+
{"id": 4, "name": "shrimp", "supercategory": "animals"},
|
| 94 |
+
{"id": 5, "name": "small_fish", "supercategory": "animals"},
|
| 95 |
+
{"id": 6, "name": "starfish", "supercategory": "animals"},
|
| 96 |
+
],
|
| 97 |
+
"ChessPieces": [
|
| 98 |
+
{"id": 1, "name": "bishop", "supercategory": "pieces"},
|
| 99 |
+
{"id": 2, "name": "black-bishop", "supercategory": "pieces"},
|
| 100 |
+
{"id": 3, "name": "black-king", "supercategory": "pieces"},
|
| 101 |
+
{"id": 4, "name": "black-knight", "supercategory": "pieces"},
|
| 102 |
+
{"id": 5, "name": "black-pawn", "supercategory": "pieces"},
|
| 103 |
+
{"id": 6, "name": "black-queen", "supercategory": "pieces"},
|
| 104 |
+
{"id": 7, "name": "black-rook", "supercategory": "pieces"},
|
| 105 |
+
{"id": 8, "name": "white-bishop", "supercategory": "pieces"},
|
| 106 |
+
{"id": 9, "name": "white-king", "supercategory": "pieces"},
|
| 107 |
+
{"id": 10, "name": "white-knight", "supercategory": "pieces"},
|
| 108 |
+
{"id": 11, "name": "white-pawn", "supercategory": "pieces"},
|
| 109 |
+
{"id": 12, "name": "white-queen", "supercategory": "pieces"},
|
| 110 |
+
{"id": 13, "name": "white-rook", "supercategory": "pieces"},
|
| 111 |
+
],
|
| 112 |
+
"CottontailRabbits": [
|
| 113 |
+
{"id": 1, "name": "Cottontail-Rabbit", "supercategory": "Cottontail-Rabbit"}
|
| 114 |
+
],
|
| 115 |
+
"dice": [
|
| 116 |
+
{"id": 1, "name": "1", "supercategory": "dice"},
|
| 117 |
+
{"id": 2, "name": "2", "supercategory": "dice"},
|
| 118 |
+
{"id": 3, "name": "3", "supercategory": "dice"},
|
| 119 |
+
{"id": 4, "name": "4", "supercategory": "dice"},
|
| 120 |
+
{"id": 5, "name": "5", "supercategory": "dice"},
|
| 121 |
+
{"id": 6, "name": "6", "supercategory": "dice"},
|
| 122 |
+
],
|
| 123 |
+
"DroneControl": [
|
| 124 |
+
{"id": 1, "name": "follow", "supercategory": "actions"},
|
| 125 |
+
{"id": 2, "name": "follow_hand", "supercategory": "actions"},
|
| 126 |
+
{"id": 3, "name": "land", "supercategory": "actions"},
|
| 127 |
+
{"id": 4, "name": "land_hand", "supercategory": "actions"},
|
| 128 |
+
{"id": 5, "name": "null", "supercategory": "actions"},
|
| 129 |
+
{"id": 6, "name": "object", "supercategory": "actions"},
|
| 130 |
+
{"id": 7, "name": "takeoff", "supercategory": "actions"},
|
| 131 |
+
{"id": 8, "name": "takeoff-hand", "supercategory": "actions"},
|
| 132 |
+
],
|
| 133 |
+
"EgoHands-generic": [
|
| 134 |
+
{"id": 1, "name": "hand", "supercategory": "hands"},
|
| 135 |
+
],
|
| 136 |
+
"EgoHands-specific": [
|
| 137 |
+
{"id": 1, "name": "myleft", "supercategory": "hands"},
|
| 138 |
+
{"id": 2, "name": "myright", "supercategory": "hands"},
|
| 139 |
+
{"id": 3, "name": "yourleft", "supercategory": "hands"},
|
| 140 |
+
{"id": 4, "name": "yourright", "supercategory": "hands"},
|
| 141 |
+
],
|
| 142 |
+
"HardHatWorkers": [
|
| 143 |
+
{"id": 1, "name": "head", "supercategory": "Workers"},
|
| 144 |
+
{"id": 2, "name": "helmet", "supercategory": "Workers"},
|
| 145 |
+
{"id": 3, "name": "person", "supercategory": "Workers"},
|
| 146 |
+
],
|
| 147 |
+
"MaskWearing": [
|
| 148 |
+
{"id": 1, "name": "mask", "supercategory": "People"},
|
| 149 |
+
{"id": 2, "name": "no-mask", "supercategory": "People"},
|
| 150 |
+
],
|
| 151 |
+
"MountainDewCommercial": [
|
| 152 |
+
{"id": 1, "name": "bottle", "supercategory": "bottles"},
|
| 153 |
+
],
|
| 154 |
+
"NorthAmericaMushrooms": [
|
| 155 |
+
{"id": 1, "name": "CoW", "supercategory": "mushroom"},
|
| 156 |
+
{"id": 2, "name": "chanterelle", "supercategory": "mushroom"},
|
| 157 |
+
],
|
| 158 |
+
"openPoetryVision": [
|
| 159 |
+
{"id": 1, "name": "American Typewriter", "supercategory": "text"},
|
| 160 |
+
{"id": 2, "name": "Andale Mono", "supercategory": "text"},
|
| 161 |
+
{"id": 3, "name": "Apple Chancery", "supercategory": "text"},
|
| 162 |
+
{"id": 4, "name": "Arial", "supercategory": "text"},
|
| 163 |
+
{"id": 5, "name": "Avenir", "supercategory": "text"},
|
| 164 |
+
{"id": 6, "name": "Baskerville", "supercategory": "text"},
|
| 165 |
+
{"id": 7, "name": "Big Caslon", "supercategory": "text"},
|
| 166 |
+
{"id": 8, "name": "Bradley Hand", "supercategory": "text"},
|
| 167 |
+
{"id": 9, "name": "Brush Script MT", "supercategory": "text"},
|
| 168 |
+
{"id": 10, "name": "Chalkboard", "supercategory": "text"},
|
| 169 |
+
{"id": 11, "name": "Comic Sans MS", "supercategory": "text"},
|
| 170 |
+
{"id": 12, "name": "Copperplate", "supercategory": "text"},
|
| 171 |
+
{"id": 13, "name": "Courier", "supercategory": "text"},
|
| 172 |
+
{"id": 14, "name": "Didot", "supercategory": "text"},
|
| 173 |
+
{"id": 15, "name": "Futura", "supercategory": "text"},
|
| 174 |
+
{"id": 16, "name": "Geneva", "supercategory": "text"},
|
| 175 |
+
{"id": 17, "name": "Georgia", "supercategory": "text"},
|
| 176 |
+
{"id": 18, "name": "Gill Sans", "supercategory": "text"},
|
| 177 |
+
{"id": 19, "name": "Helvetica", "supercategory": "text"},
|
| 178 |
+
{"id": 20, "name": "Herculanum", "supercategory": "text"},
|
| 179 |
+
{"id": 21, "name": "Impact", "supercategory": "text"},
|
| 180 |
+
{"id": 22, "name": "Kefa", "supercategory": "text"},
|
| 181 |
+
{"id": 23, "name": "Lucida Grande", "supercategory": "text"},
|
| 182 |
+
{"id": 24, "name": "Luminari", "supercategory": "text"},
|
| 183 |
+
{"id": 25, "name": "Marker Felt", "supercategory": "text"},
|
| 184 |
+
{"id": 26, "name": "Menlo", "supercategory": "text"},
|
| 185 |
+
{"id": 27, "name": "Monaco", "supercategory": "text"},
|
| 186 |
+
{"id": 28, "name": "Noteworthy", "supercategory": "text"},
|
| 187 |
+
{"id": 29, "name": "Optima", "supercategory": "text"},
|
| 188 |
+
{"id": 30, "name": "PT Sans", "supercategory": "text"},
|
| 189 |
+
{"id": 31, "name": "PT Serif", "supercategory": "text"},
|
| 190 |
+
{"id": 32, "name": "Palatino", "supercategory": "text"},
|
| 191 |
+
{"id": 33, "name": "Papyrus", "supercategory": "text"},
|
| 192 |
+
{"id": 34, "name": "Phosphate", "supercategory": "text"},
|
| 193 |
+
{"id": 35, "name": "Rockwell", "supercategory": "text"},
|
| 194 |
+
{"id": 36, "name": "SF Pro", "supercategory": "text"},
|
| 195 |
+
{"id": 37, "name": "SignPainter", "supercategory": "text"},
|
| 196 |
+
{"id": 38, "name": "Skia", "supercategory": "text"},
|
| 197 |
+
{"id": 39, "name": "Snell Roundhand", "supercategory": "text"},
|
| 198 |
+
{"id": 40, "name": "Tahoma", "supercategory": "text"},
|
| 199 |
+
{"id": 41, "name": "Times New Roman", "supercategory": "text"},
|
| 200 |
+
{"id": 42, "name": "Trebuchet MS", "supercategory": "text"},
|
| 201 |
+
{"id": 43, "name": "Verdana", "supercategory": "text"},
|
| 202 |
+
],
|
| 203 |
+
"OxfordPets-by-breed": [
|
| 204 |
+
{"id": 1, "name": "cat-Abyssinian", "supercategory": "pets"},
|
| 205 |
+
{"id": 2, "name": "cat-Bengal", "supercategory": "pets"},
|
| 206 |
+
{"id": 3, "name": "cat-Birman", "supercategory": "pets"},
|
| 207 |
+
{"id": 4, "name": "cat-Bombay", "supercategory": "pets"},
|
| 208 |
+
{"id": 5, "name": "cat-British_Shorthair", "supercategory": "pets"},
|
| 209 |
+
{"id": 6, "name": "cat-Egyptian_Mau", "supercategory": "pets"},
|
| 210 |
+
{"id": 7, "name": "cat-Maine_Coon", "supercategory": "pets"},
|
| 211 |
+
{"id": 8, "name": "cat-Persian", "supercategory": "pets"},
|
| 212 |
+
{"id": 9, "name": "cat-Ragdoll", "supercategory": "pets"},
|
| 213 |
+
{"id": 10, "name": "cat-Russian_Blue", "supercategory": "pets"},
|
| 214 |
+
{"id": 11, "name": "cat-Siamese", "supercategory": "pets"},
|
| 215 |
+
{"id": 12, "name": "cat-Sphynx", "supercategory": "pets"},
|
| 216 |
+
{"id": 13, "name": "dog-american_bulldog", "supercategory": "pets"},
|
| 217 |
+
{"id": 14, "name": "dog-american_pit_bull_terrier", "supercategory": "pets"},
|
| 218 |
+
{"id": 15, "name": "dog-basset_hound", "supercategory": "pets"},
|
| 219 |
+
{"id": 16, "name": "dog-beagle", "supercategory": "pets"},
|
| 220 |
+
{"id": 17, "name": "dog-boxer", "supercategory": "pets"},
|
| 221 |
+
{"id": 18, "name": "dog-chihuahua", "supercategory": "pets"},
|
| 222 |
+
{"id": 19, "name": "dog-english_cocker_spaniel", "supercategory": "pets"},
|
| 223 |
+
{"id": 20, "name": "dog-english_setter", "supercategory": "pets"},
|
| 224 |
+
{"id": 21, "name": "dog-german_shorthaired", "supercategory": "pets"},
|
| 225 |
+
{"id": 22, "name": "dog-great_pyrenees", "supercategory": "pets"},
|
| 226 |
+
{"id": 23, "name": "dog-havanese", "supercategory": "pets"},
|
| 227 |
+
{"id": 24, "name": "dog-japanese_chin", "supercategory": "pets"},
|
| 228 |
+
{"id": 25, "name": "dog-keeshond", "supercategory": "pets"},
|
| 229 |
+
{"id": 26, "name": "dog-leonberger", "supercategory": "pets"},
|
| 230 |
+
{"id": 27, "name": "dog-miniature_pinscher", "supercategory": "pets"},
|
| 231 |
+
{"id": 28, "name": "dog-newfoundland", "supercategory": "pets"},
|
| 232 |
+
{"id": 29, "name": "dog-pomeranian", "supercategory": "pets"},
|
| 233 |
+
{"id": 30, "name": "dog-pug", "supercategory": "pets"},
|
| 234 |
+
{"id": 31, "name": "dog-saint_bernard", "supercategory": "pets"},
|
| 235 |
+
{"id": 32, "name": "dog-samoyed", "supercategory": "pets"},
|
| 236 |
+
{"id": 33, "name": "dog-scottish_terrier", "supercategory": "pets"},
|
| 237 |
+
{"id": 34, "name": "dog-shiba_inu", "supercategory": "pets"},
|
| 238 |
+
{"id": 35, "name": "dog-staffordshire_bull_terrier", "supercategory": "pets"},
|
| 239 |
+
{"id": 36, "name": "dog-wheaten_terrier", "supercategory": "pets"},
|
| 240 |
+
{"id": 37, "name": "dog-yorkshire_terrier", "supercategory": "pets"},
|
| 241 |
+
],
|
| 242 |
+
"OxfordPets-by-species": [
|
| 243 |
+
{"id": 1, "name": "cat", "supercategory": "pets"},
|
| 244 |
+
{"id": 2, "name": "dog", "supercategory": "pets"},
|
| 245 |
+
],
|
| 246 |
+
"Packages": [{"id": 1, "name": "package", "supercategory": "packages"}],
|
| 247 |
+
"PascalVOC": [
|
| 248 |
+
{"id": 1, "name": "aeroplane", "supercategory": "VOC"},
|
| 249 |
+
{"id": 2, "name": "bicycle", "supercategory": "VOC"},
|
| 250 |
+
{"id": 3, "name": "bird", "supercategory": "VOC"},
|
| 251 |
+
{"id": 4, "name": "boat", "supercategory": "VOC"},
|
| 252 |
+
{"id": 5, "name": "bottle", "supercategory": "VOC"},
|
| 253 |
+
{"id": 6, "name": "bus", "supercategory": "VOC"},
|
| 254 |
+
{"id": 7, "name": "car", "supercategory": "VOC"},
|
| 255 |
+
{"id": 8, "name": "cat", "supercategory": "VOC"},
|
| 256 |
+
{"id": 9, "name": "chair", "supercategory": "VOC"},
|
| 257 |
+
{"id": 10, "name": "cow", "supercategory": "VOC"},
|
| 258 |
+
{"id": 11, "name": "diningtable", "supercategory": "VOC"},
|
| 259 |
+
{"id": 12, "name": "dog", "supercategory": "VOC"},
|
| 260 |
+
{"id": 13, "name": "horse", "supercategory": "VOC"},
|
| 261 |
+
{"id": 14, "name": "motorbike", "supercategory": "VOC"},
|
| 262 |
+
{"id": 15, "name": "person", "supercategory": "VOC"},
|
| 263 |
+
{"id": 16, "name": "pottedplant", "supercategory": "VOC"},
|
| 264 |
+
{"id": 17, "name": "sheep", "supercategory": "VOC"},
|
| 265 |
+
{"id": 18, "name": "sofa", "supercategory": "VOC"},
|
| 266 |
+
{"id": 19, "name": "train", "supercategory": "VOC"},
|
| 267 |
+
{"id": 20, "name": "tvmonitor", "supercategory": "VOC"},
|
| 268 |
+
],
|
| 269 |
+
"pistols": [
|
| 270 |
+
{"id": 1, "name": "pistol", "supercategory": "Guns"},
|
| 271 |
+
],
|
| 272 |
+
"PKLot": [
|
| 273 |
+
{"id": 1, "name": "space-empty", "supercategory": "spaces"},
|
| 274 |
+
{"id": 2, "name": "space-occupied", "supercategory": "spaces"},
|
| 275 |
+
],
|
| 276 |
+
"plantdoc": [
|
| 277 |
+
{"id": 1, "name": "Apple Scab Leaf", "supercategory": "leaves"},
|
| 278 |
+
{"id": 2, "name": "Apple leaf", "supercategory": "leaves"},
|
| 279 |
+
{"id": 3, "name": "Apple rust leaf", "supercategory": "leaves"},
|
| 280 |
+
{"id": 4, "name": "Bell_pepper leaf", "supercategory": "leaves"},
|
| 281 |
+
{"id": 5, "name": "Bell_pepper leaf spot", "supercategory": "leaves"},
|
| 282 |
+
{"id": 6, "name": "Blueberry leaf", "supercategory": "leaves"},
|
| 283 |
+
{"id": 7, "name": "Cherry leaf", "supercategory": "leaves"},
|
| 284 |
+
{"id": 8, "name": "Corn Gray leaf spot", "supercategory": "leaves"},
|
| 285 |
+
{"id": 9, "name": "Corn leaf blight", "supercategory": "leaves"},
|
| 286 |
+
{"id": 10, "name": "Corn rust leaf", "supercategory": "leaves"},
|
| 287 |
+
{"id": 11, "name": "Peach leaf", "supercategory": "leaves"},
|
| 288 |
+
{"id": 12, "name": "Potato leaf", "supercategory": "leaves"},
|
| 289 |
+
{"id": 13, "name": "Potato leaf early blight", "supercategory": "leaves"},
|
| 290 |
+
{"id": 14, "name": "Potato leaf late blight", "supercategory": "leaves"},
|
| 291 |
+
{"id": 15, "name": "Raspberry leaf", "supercategory": "leaves"},
|
| 292 |
+
{"id": 16, "name": "Soyabean leaf", "supercategory": "leaves"},
|
| 293 |
+
{"id": 17, "name": "Soybean leaf", "supercategory": "leaves"},
|
| 294 |
+
{"id": 18, "name": "Squash Powdery mildew leaf", "supercategory": "leaves"},
|
| 295 |
+
{"id": 19, "name": "Strawberry leaf", "supercategory": "leaves"},
|
| 296 |
+
{"id": 20, "name": "Tomato Early blight leaf", "supercategory": "leaves"},
|
| 297 |
+
{"id": 21, "name": "Tomato Septoria leaf spot", "supercategory": "leaves"},
|
| 298 |
+
{"id": 22, "name": "Tomato leaf", "supercategory": "leaves"},
|
| 299 |
+
{"id": 23, "name": "Tomato leaf bacterial spot", "supercategory": "leaves"},
|
| 300 |
+
{"id": 24, "name": "Tomato leaf late blight", "supercategory": "leaves"},
|
| 301 |
+
{"id": 25, "name": "Tomato leaf mosaic virus", "supercategory": "leaves"},
|
| 302 |
+
{"id": 26, "name": "Tomato leaf yellow virus", "supercategory": "leaves"},
|
| 303 |
+
{"id": 27, "name": "Tomato mold leaf", "supercategory": "leaves"},
|
| 304 |
+
{"id": 28, "name": "Tomato two spotted spider mites leaf", "supercategory": "leaves"},
|
| 305 |
+
{"id": 29, "name": "grape leaf", "supercategory": "leaves"},
|
| 306 |
+
{"id": 30, "name": "grape leaf black rot", "supercategory": "leaves"},
|
| 307 |
+
],
|
| 308 |
+
"pothole": [
|
| 309 |
+
{"id": 1, "name": "pothole", "supercategory": "potholes"},
|
| 310 |
+
],
|
| 311 |
+
"Raccoon": [
|
| 312 |
+
{"id": 1, "name": "raccoon", "supercategory": "raccoons"},
|
| 313 |
+
],
|
| 314 |
+
"selfdrivingCar": [
|
| 315 |
+
{"id": 1, "name": "biker", "supercategory": "obstacles"},
|
| 316 |
+
{"id": 2, "name": "car", "supercategory": "obstacles"},
|
| 317 |
+
{"id": 3, "name": "pedestrian", "supercategory": "obstacles"},
|
| 318 |
+
{"id": 4, "name": "trafficLight", "supercategory": "obstacles"},
|
| 319 |
+
{"id": 5, "name": "trafficLight-Green", "supercategory": "obstacles"},
|
| 320 |
+
{"id": 6, "name": "trafficLight-GreenLeft", "supercategory": "obstacles"},
|
| 321 |
+
{"id": 7, "name": "trafficLight-Red", "supercategory": "obstacles"},
|
| 322 |
+
{"id": 8, "name": "trafficLight-RedLeft", "supercategory": "obstacles"},
|
| 323 |
+
{"id": 9, "name": "trafficLight-Yellow", "supercategory": "obstacles"},
|
| 324 |
+
{"id": 10, "name": "trafficLight-YellowLeft", "supercategory": "obstacles"},
|
| 325 |
+
{"id": 11, "name": "truck", "supercategory": "obstacles"},
|
| 326 |
+
],
|
| 327 |
+
"ShellfishOpenImages": [
|
| 328 |
+
{"id": 1, "name": "Crab", "supercategory": "shellfish"},
|
| 329 |
+
{"id": 2, "name": "Lobster", "supercategory": "shellfish"},
|
| 330 |
+
{"id": 3, "name": "Shrimp", "supercategory": "shellfish"},
|
| 331 |
+
],
|
| 332 |
+
"ThermalCheetah": [
|
| 333 |
+
{"id": 1, "name": "cheetah", "supercategory": "cheetah"},
|
| 334 |
+
{"id": 2, "name": "human", "supercategory": "cheetah"},
|
| 335 |
+
],
|
| 336 |
+
"thermalDogsAndPeople": [
|
| 337 |
+
{"id": 1, "name": "dog", "supercategory": "dogs-person"},
|
| 338 |
+
{"id": 2, "name": "person", "supercategory": "dogs-person"},
|
| 339 |
+
],
|
| 340 |
+
"UnoCards": [
|
| 341 |
+
{"id": 1, "name": "0", "supercategory": "Card-Types"},
|
| 342 |
+
{"id": 2, "name": "1", "supercategory": "Card-Types"},
|
| 343 |
+
{"id": 3, "name": "2", "supercategory": "Card-Types"},
|
| 344 |
+
{"id": 4, "name": "3", "supercategory": "Card-Types"},
|
| 345 |
+
{"id": 5, "name": "4", "supercategory": "Card-Types"},
|
| 346 |
+
{"id": 6, "name": "5", "supercategory": "Card-Types"},
|
| 347 |
+
{"id": 7, "name": "6", "supercategory": "Card-Types"},
|
| 348 |
+
{"id": 8, "name": "7", "supercategory": "Card-Types"},
|
| 349 |
+
{"id": 9, "name": "8", "supercategory": "Card-Types"},
|
| 350 |
+
{"id": 10, "name": "9", "supercategory": "Card-Types"},
|
| 351 |
+
{"id": 11, "name": "10", "supercategory": "Card-Types"},
|
| 352 |
+
{"id": 12, "name": "11", "supercategory": "Card-Types"},
|
| 353 |
+
{"id": 13, "name": "12", "supercategory": "Card-Types"},
|
| 354 |
+
{"id": 14, "name": "13", "supercategory": "Card-Types"},
|
| 355 |
+
{"id": 15, "name": "14", "supercategory": "Card-Types"},
|
| 356 |
+
],
|
| 357 |
+
"VehiclesOpenImages": [
|
| 358 |
+
{"id": 1, "name": "Ambulance", "supercategory": "vehicles"},
|
| 359 |
+
{"id": 2, "name": "Bus", "supercategory": "vehicles"},
|
| 360 |
+
{"id": 3, "name": "Car", "supercategory": "vehicles"},
|
| 361 |
+
{"id": 4, "name": "Motorcycle", "supercategory": "vehicles"},
|
| 362 |
+
{"id": 5, "name": "Truck", "supercategory": "vehicles"},
|
| 363 |
+
],
|
| 364 |
+
"websiteScreenshots": [
|
| 365 |
+
{"id": 1, "name": "button", "supercategory": "elements"},
|
| 366 |
+
{"id": 2, "name": "field", "supercategory": "elements"},
|
| 367 |
+
{"id": 3, "name": "heading", "supercategory": "elements"},
|
| 368 |
+
{"id": 4, "name": "iframe", "supercategory": "elements"},
|
| 369 |
+
{"id": 5, "name": "image", "supercategory": "elements"},
|
| 370 |
+
{"id": 6, "name": "label", "supercategory": "elements"},
|
| 371 |
+
{"id": 7, "name": "link", "supercategory": "elements"},
|
| 372 |
+
{"id": 8, "name": "text", "supercategory": "elements"},
|
| 373 |
+
],
|
| 374 |
+
"WildfireSmoke": [
|
| 375 |
+
{"id": 1, "name": "smoke", "supercategory": "Smoke"},
|
| 376 |
+
],
|
| 377 |
+
}
|
approach/ovod/APE/ape/data/datasets/odinw_instance.py
ADDED
|
@@ -0,0 +1,824 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import io
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
import pycocotools.mask as mask_util
|
| 7 |
+
|
| 8 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 9 |
+
from detectron2.structures import BoxMode
|
| 10 |
+
from detectron2.utils.file_io import PathManager
|
| 11 |
+
from fvcore.common.timer import Timer
|
| 12 |
+
|
| 13 |
+
from .odinw_categories import ODINW_CATEGORIES
|
| 14 |
+
from .odinw_prompts import ODINW_PROMPTS
|
| 15 |
+
|
| 16 |
+
logger = logging.getLogger(__name__)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def load_coco_json(json_file, image_root, dataset_name=None, extra_annotation_keys=None):
|
| 20 |
+
"""
|
| 21 |
+
Load a json file with COCO's instances annotation format.
|
| 22 |
+
Currently supports instance detection, instance segmentation,
|
| 23 |
+
and person keypoints annotations.
|
| 24 |
+
|
| 25 |
+
Args:
|
| 26 |
+
json_file (str): full path to the json file in COCO instances annotation format.
|
| 27 |
+
image_root (str or path-like): the directory where the images in this json file exists.
|
| 28 |
+
dataset_name (str or None): the name of the dataset (e.g., coco_2017_train).
|
| 29 |
+
When provided, this function will also do the following:
|
| 30 |
+
|
| 31 |
+
* Put "thing_classes" into the metadata associated with this dataset.
|
| 32 |
+
* Map the category ids into a contiguous range (needed by standard dataset format),
|
| 33 |
+
and add "thing_dataset_id_to_contiguous_id" to the metadata associated
|
| 34 |
+
with this dataset.
|
| 35 |
+
|
| 36 |
+
This option should usually be provided, unless users need to load
|
| 37 |
+
the original json content and apply more processing manually.
|
| 38 |
+
extra_annotation_keys (list[str]): list of per-annotation keys that should also be
|
| 39 |
+
loaded into the dataset dict (besides "iscrowd", "bbox", "keypoints",
|
| 40 |
+
"category_id", "segmentation"). The values for these keys will be returned as-is.
|
| 41 |
+
For example, the densepose annotations are loaded in this way.
|
| 42 |
+
|
| 43 |
+
Returns:
|
| 44 |
+
list[dict]: a list of dicts in Detectron2 standard dataset dicts format (See
|
| 45 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ ) when `dataset_name` is not None.
|
| 46 |
+
If `dataset_name` is None, the returned `category_ids` may be
|
| 47 |
+
incontiguous and may not conform to the Detectron2 standard format.
|
| 48 |
+
|
| 49 |
+
Notes:
|
| 50 |
+
1. This function does not read the image files.
|
| 51 |
+
The results do not have the "image" field.
|
| 52 |
+
"""
|
| 53 |
+
from pycocotools.coco import COCO
|
| 54 |
+
|
| 55 |
+
timer = Timer()
|
| 56 |
+
json_file = PathManager.get_local_path(json_file)
|
| 57 |
+
with contextlib.redirect_stdout(io.StringIO()):
|
| 58 |
+
coco_api = COCO(json_file)
|
| 59 |
+
if timer.seconds() > 1:
|
| 60 |
+
logger.info("Loading {} takes {:.2f} seconds.".format(json_file, timer.seconds()))
|
| 61 |
+
|
| 62 |
+
id_map = None
|
| 63 |
+
if dataset_name is not None:
|
| 64 |
+
meta = MetadataCatalog.get(dataset_name)
|
| 65 |
+
cat_ids = sorted(coco_api.getCatIds())
|
| 66 |
+
# cats = coco_api.loadCats(cat_ids)
|
| 67 |
+
# The categories in a custom json file may not be sorted.
|
| 68 |
+
# thing_classes = [c["name"] for c in sorted(cats, key=lambda x: x["id"])]
|
| 69 |
+
# meta.thing_classes = thing_classes
|
| 70 |
+
|
| 71 |
+
# In COCO, certain category ids are artificially removed,
|
| 72 |
+
# and by convention they are always ignored.
|
| 73 |
+
# We deal with COCO's id issue and translate
|
| 74 |
+
# the category ids to contiguous ids in [0, 80).
|
| 75 |
+
|
| 76 |
+
# It works by looking at the "categories" field in the json, therefore
|
| 77 |
+
# if users' own json also have incontiguous ids, we'll
|
| 78 |
+
# apply this mapping as well but print a warning.
|
| 79 |
+
if not (min(cat_ids) == 1 and max(cat_ids) == len(cat_ids)):
|
| 80 |
+
if "coco" not in dataset_name:
|
| 81 |
+
logger.warning(
|
| 82 |
+
"""
|
| 83 |
+
Category ids in annotations are not in [1, #categories]! We'll apply a mapping for you.
|
| 84 |
+
"""
|
| 85 |
+
)
|
| 86 |
+
id_map = {v: i for i, v in enumerate(cat_ids)}
|
| 87 |
+
meta.thing_dataset_id_to_contiguous_id = id_map
|
| 88 |
+
|
| 89 |
+
# sort indices for reproducible results
|
| 90 |
+
img_ids = sorted(coco_api.imgs.keys())
|
| 91 |
+
# imgs is a list of dicts, each looks something like:
|
| 92 |
+
# {'license': 4,
|
| 93 |
+
# 'url': 'http://farm6.staticflickr.com/5454/9413846304_881d5e5c3b_z.jpg',
|
| 94 |
+
# 'file_name': 'COCO_val2014_000000001268.jpg',
|
| 95 |
+
# 'height': 427,
|
| 96 |
+
# 'width': 640,
|
| 97 |
+
# 'date_captured': '2013-11-17 05:57:24',
|
| 98 |
+
# 'id': 1268}
|
| 99 |
+
imgs = coco_api.loadImgs(img_ids)
|
| 100 |
+
# anns is a list[list[dict]], where each dict is an annotation
|
| 101 |
+
# record for an object. The inner list enumerates the objects in an image
|
| 102 |
+
# and the outer list enumerates over images. Example of anns[0]:
|
| 103 |
+
# [{'segmentation': [[192.81,
|
| 104 |
+
# 247.09,
|
| 105 |
+
# ...
|
| 106 |
+
# 219.03,
|
| 107 |
+
# 249.06]],
|
| 108 |
+
# 'area': 1035.749,
|
| 109 |
+
# 'iscrowd': 0,
|
| 110 |
+
# 'image_id': 1268,
|
| 111 |
+
# 'bbox': [192.81, 224.8, 74.73, 33.43],
|
| 112 |
+
# 'category_id': 16,
|
| 113 |
+
# 'id': 42986},
|
| 114 |
+
# ...]
|
| 115 |
+
anns = [coco_api.imgToAnns[img_id] for img_id in img_ids]
|
| 116 |
+
total_num_valid_anns = sum([len(x) for x in anns])
|
| 117 |
+
total_num_anns = len(coco_api.anns)
|
| 118 |
+
if total_num_valid_anns < total_num_anns:
|
| 119 |
+
logger.warning(
|
| 120 |
+
f"{json_file} contains {total_num_anns} annotations, but only "
|
| 121 |
+
f"{total_num_valid_anns} of them match to images in the file."
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
if "minival" not in json_file:
|
| 125 |
+
# The popular valminusminival & minival annotations for COCO2014 contain this bug.
|
| 126 |
+
# However the ratio of buggy annotations there is tiny and does not affect accuracy.
|
| 127 |
+
# Therefore we explicitly white-list them.
|
| 128 |
+
ann_ids = [ann["id"] for anns_per_image in anns for ann in anns_per_image]
|
| 129 |
+
assert len(set(ann_ids)) == len(ann_ids), "Annotation ids in '{}' are not unique!".format(
|
| 130 |
+
json_file
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
imgs_anns = list(zip(imgs, anns))
|
| 134 |
+
logger.info("Loaded {} images in COCO format from {}".format(len(imgs_anns), json_file))
|
| 135 |
+
|
| 136 |
+
dataset_dicts = []
|
| 137 |
+
|
| 138 |
+
ann_keys = ["iscrowd", "bbox", "keypoints", "category_id"] + (extra_annotation_keys or [])
|
| 139 |
+
|
| 140 |
+
num_instances_without_valid_segmentation = 0
|
| 141 |
+
|
| 142 |
+
for (img_dict, anno_dict_list) in imgs_anns:
|
| 143 |
+
record = {}
|
| 144 |
+
record["file_name"] = os.path.join(image_root, img_dict["file_name"])
|
| 145 |
+
# record["height"] = img_dict["height"]
|
| 146 |
+
# record["width"] = img_dict["width"]
|
| 147 |
+
image_id = record["image_id"] = img_dict["id"]
|
| 148 |
+
|
| 149 |
+
objs = []
|
| 150 |
+
for anno in anno_dict_list:
|
| 151 |
+
# Check that the image_id in this annotation is the same as
|
| 152 |
+
# the image_id we're looking at.
|
| 153 |
+
# This fails only when the data parsing logic or the annotation file is buggy.
|
| 154 |
+
|
| 155 |
+
# The original COCO valminusminival2014 & minival2014 annotation files
|
| 156 |
+
# actually contains bugs that, together with certain ways of using COCO API,
|
| 157 |
+
# can trigger this assertion.
|
| 158 |
+
assert anno["image_id"] == image_id
|
| 159 |
+
|
| 160 |
+
assert anno.get("ignore", 0) == 0, '"ignore" in COCO json file is not supported.'
|
| 161 |
+
|
| 162 |
+
obj = {key: anno[key] for key in ann_keys if key in anno}
|
| 163 |
+
if "bbox" in obj and len(obj["bbox"]) == 0:
|
| 164 |
+
raise ValueError(
|
| 165 |
+
f"One annotation of image {image_id} contains empty 'bbox' value! "
|
| 166 |
+
"This json does not have valid COCO format."
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
segm = anno.get("segmentation", None)
|
| 170 |
+
if segm: # either list[list[float]] or dict(RLE)
|
| 171 |
+
if isinstance(segm, dict):
|
| 172 |
+
if isinstance(segm["counts"], list):
|
| 173 |
+
# convert to compressed RLE
|
| 174 |
+
segm = mask_util.frPyObjects(segm, *segm["size"])
|
| 175 |
+
else:
|
| 176 |
+
# filter out invalid polygons (< 3 points)
|
| 177 |
+
segm = [poly for poly in segm if len(poly) % 2 == 0 and len(poly) >= 6]
|
| 178 |
+
if len(segm) == 0:
|
| 179 |
+
num_instances_without_valid_segmentation += 1
|
| 180 |
+
continue # ignore this instance
|
| 181 |
+
obj["segmentation"] = segm
|
| 182 |
+
|
| 183 |
+
keypts = anno.get("keypoints", None)
|
| 184 |
+
if keypts: # list[int]
|
| 185 |
+
for idx, v in enumerate(keypts):
|
| 186 |
+
if idx % 3 != 2:
|
| 187 |
+
# COCO's segmentation coordinates are floating points in [0, H or W],
|
| 188 |
+
# but keypoint coordinates are integers in [0, H-1 or W-1]
|
| 189 |
+
# Therefore we assume the coordinates are "pixel indices" and
|
| 190 |
+
# add 0.5 to convert to floating point coordinates.
|
| 191 |
+
keypts[idx] = v + 0.5
|
| 192 |
+
obj["keypoints"] = keypts
|
| 193 |
+
|
| 194 |
+
obj["bbox_mode"] = BoxMode.XYWH_ABS
|
| 195 |
+
if id_map:
|
| 196 |
+
annotation_category_id = obj["category_id"]
|
| 197 |
+
try:
|
| 198 |
+
obj["category_id"] = id_map[annotation_category_id]
|
| 199 |
+
except KeyError as e:
|
| 200 |
+
raise KeyError(
|
| 201 |
+
f"Encountered category_id={annotation_category_id} "
|
| 202 |
+
"but this id does not exist in 'categories' of the json file."
|
| 203 |
+
) from e
|
| 204 |
+
objs.append(obj)
|
| 205 |
+
record["annotations"] = objs
|
| 206 |
+
dataset_dicts.append(record)
|
| 207 |
+
|
| 208 |
+
if num_instances_without_valid_segmentation > 0:
|
| 209 |
+
logger.warning(
|
| 210 |
+
"Filtered out {} instances without valid segmentation. ".format(
|
| 211 |
+
num_instances_without_valid_segmentation
|
| 212 |
+
)
|
| 213 |
+
+ "There might be issues in your dataset generation process. Please "
|
| 214 |
+
"check https://detectron2.readthedocs.io/en/latest/tutorials/datasets.html carefully"
|
| 215 |
+
)
|
| 216 |
+
return dataset_dicts
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
def register_coco_instances(name, metadata, json_file, image_root):
|
| 220 |
+
"""
|
| 221 |
+
Register a dataset in COCO's json annotation format for
|
| 222 |
+
instance detection, instance segmentation and keypoint detection.
|
| 223 |
+
(i.e., Type 1 and 2 in http://cocodataset.org/#format-data.
|
| 224 |
+
`instances*.json` and `person_keypoints*.json` in the dataset).
|
| 225 |
+
|
| 226 |
+
This is an example of how to register a new dataset.
|
| 227 |
+
You can do something similar to this function, to register new datasets.
|
| 228 |
+
|
| 229 |
+
Args:
|
| 230 |
+
name (str): the name that identifies a dataset, e.g. "coco_2014_train".
|
| 231 |
+
metadata (dict): extra metadata associated with this dataset. You can
|
| 232 |
+
leave it as an empty dict.
|
| 233 |
+
json_file (str): path to the json instance annotation file.
|
| 234 |
+
image_root (str or path-like): directory which contains all the images.
|
| 235 |
+
"""
|
| 236 |
+
assert isinstance(name, str), name
|
| 237 |
+
assert isinstance(json_file, (str, os.PathLike)), json_file
|
| 238 |
+
assert isinstance(image_root, (str, os.PathLike)), image_root
|
| 239 |
+
# 1. register a function which returns dicts
|
| 240 |
+
DatasetCatalog.register(name, lambda: load_coco_json(json_file, image_root, name))
|
| 241 |
+
|
| 242 |
+
# 2. Optionally, add metadata about this dataset,
|
| 243 |
+
# since they might be useful in evaluation, visualization or logging
|
| 244 |
+
MetadataCatalog.get(name).set(
|
| 245 |
+
json_file=json_file, image_root=image_root, evaluator_type="coco", **metadata
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
_PREDEFINED_SPLITS_ODINW = {
|
| 250 |
+
"odinw_AerialMaritimeDrone_large": {
|
| 251 |
+
"odinw_AerialMaritimeDrone_large_train": (
|
| 252 |
+
"odinw/AerialMaritimeDrone/large/train/",
|
| 253 |
+
"odinw/AerialMaritimeDrone/large/train/annotations_without_background_converted.json",
|
| 254 |
+
),
|
| 255 |
+
"odinw_AerialMaritimeDrone_large_val": (
|
| 256 |
+
"odinw/AerialMaritimeDrone/large/valid/",
|
| 257 |
+
"odinw/AerialMaritimeDrone/large/valid/annotations_without_background_converted.json",
|
| 258 |
+
),
|
| 259 |
+
"odinw_AerialMaritimeDrone_large_test": (
|
| 260 |
+
"odinw/AerialMaritimeDrone/large/test/",
|
| 261 |
+
"odinw/AerialMaritimeDrone/large/test/annotations_without_background_converted.json",
|
| 262 |
+
),
|
| 263 |
+
},
|
| 264 |
+
"odinw_AerialMaritimeDrone_tiled": {
|
| 265 |
+
"odinw_AerialMaritimeDrone_tiled_train": (
|
| 266 |
+
"odinw/AerialMaritimeDrone/tiled/train/",
|
| 267 |
+
"odinw/AerialMaritimeDrone/tiled/train/annotations_without_background_converted.json",
|
| 268 |
+
),
|
| 269 |
+
"odinw_AerialMaritimeDrone_tiled_val": (
|
| 270 |
+
"odinw/AerialMaritimeDrone/tiled/valid/",
|
| 271 |
+
"odinw/AerialMaritimeDrone/tiled/valid/annotations_without_background_converted.json",
|
| 272 |
+
),
|
| 273 |
+
"odinw_AerialMaritimeDrone_tiled_test": (
|
| 274 |
+
"odinw/AerialMaritimeDrone/tiled/test/",
|
| 275 |
+
"odinw/AerialMaritimeDrone/tiled/test/annotations_without_background_converted.json",
|
| 276 |
+
),
|
| 277 |
+
},
|
| 278 |
+
"odinw_AmericanSignLanguageLetters_American_Sign_Language_Letters.v1-v1.coco": {
|
| 279 |
+
"odinw_AmericanSignLanguageLetters_American_Sign_Language_Letters.v1-v1.coco_train": (
|
| 280 |
+
"odinw/AmericanSignLanguageLetters/American Sign Language Letters.v1-v1.coco/train/",
|
| 281 |
+
"odinw/AmericanSignLanguageLetters/American Sign Language Letters.v1-v1.coco/train/annotations_without_background_converted.json",
|
| 282 |
+
),
|
| 283 |
+
"odinw_AmericanSignLanguageLetters_American_Sign_Language_Letters.v1-v1.coco_val": (
|
| 284 |
+
"odinw/AmericanSignLanguageLetters/American Sign Language Letters.v1-v1.coco/valid/",
|
| 285 |
+
"odinw/AmericanSignLanguageLetters/American Sign Language Letters.v1-v1.coco/valid/annotations_without_background_converted.json",
|
| 286 |
+
),
|
| 287 |
+
"odinw_AmericanSignLanguageLetters_American_Sign_Language_Letters.v1-v1.coco_test": (
|
| 288 |
+
"odinw/AmericanSignLanguageLetters/American Sign Language Letters.v1-v1.coco/test/",
|
| 289 |
+
"odinw/AmericanSignLanguageLetters/American Sign Language Letters.v1-v1.coco/test/annotations_without_background_converted.json",
|
| 290 |
+
),
|
| 291 |
+
},
|
| 292 |
+
"odinw_Aquarium_Aquarium_Combined.v2-raw-1024.coco": {
|
| 293 |
+
"odinw_Aquarium_Aquarium_Combined.v2-raw-1024.coco_train": (
|
| 294 |
+
"odinw/Aquarium/Aquarium Combined.v2-raw-1024.coco/train/",
|
| 295 |
+
"odinw/Aquarium/Aquarium Combined.v2-raw-1024.coco/train/annotations_without_background_converted.json",
|
| 296 |
+
),
|
| 297 |
+
"odinw_Aquarium_Aquarium_Combined.v2-raw-1024.coco_val": (
|
| 298 |
+
"odinw/Aquarium/Aquarium Combined.v2-raw-1024.coco/valid/",
|
| 299 |
+
"odinw/Aquarium/Aquarium Combined.v2-raw-1024.coco/valid/annotations_without_background_converted.json",
|
| 300 |
+
),
|
| 301 |
+
"odinw_Aquarium_Aquarium_Combined.v2-raw-1024.coco_test": (
|
| 302 |
+
"odinw/Aquarium/Aquarium Combined.v2-raw-1024.coco/test/",
|
| 303 |
+
"odinw/Aquarium/Aquarium Combined.v2-raw-1024.coco/test/annotations_without_background_converted.json",
|
| 304 |
+
),
|
| 305 |
+
},
|
| 306 |
+
"odinw_BCCD_BCCD.v3-raw.coco": {
|
| 307 |
+
"odinw_BCCD_BCCD.v3-raw.coco_train": (
|
| 308 |
+
"odinw/BCCD/BCCD.v3-raw.coco/train/",
|
| 309 |
+
"odinw/BCCD/BCCD.v3-raw.coco/train/annotations_without_background_converted.json",
|
| 310 |
+
),
|
| 311 |
+
"odinw_BCCD_BCCD.v3-raw.coco_val": (
|
| 312 |
+
"odinw/BCCD/BCCD.v3-raw.coco/valid/",
|
| 313 |
+
"odinw/BCCD/BCCD.v3-raw.coco/valid/annotations_without_background_converted.json",
|
| 314 |
+
),
|
| 315 |
+
"odinw_BCCD_BCCD.v3-raw.coco_test": (
|
| 316 |
+
"odinw/BCCD/BCCD.v3-raw.coco/test/",
|
| 317 |
+
"odinw/BCCD/BCCD.v3-raw.coco/test/annotations_without_background_converted.json",
|
| 318 |
+
),
|
| 319 |
+
},
|
| 320 |
+
"odinw_boggleBoards_416x416AutoOrient_export_": {
|
| 321 |
+
"odinw_boggleBoards_416x416AutoOrient_export_train": (
|
| 322 |
+
"odinw/boggleBoards/416x416AutoOrient/export/",
|
| 323 |
+
"odinw/boggleBoards/416x416AutoOrient/export/train_annotations_without_background_converted.json",
|
| 324 |
+
),
|
| 325 |
+
"odinw_boggleBoards_416x416AutoOrient_export_val": (
|
| 326 |
+
"odinw/boggleBoards/416x416AutoOrient/export/",
|
| 327 |
+
"odinw/boggleBoards/416x416AutoOrient/export/val_annotations_without_background_converted.json",
|
| 328 |
+
),
|
| 329 |
+
"odinw_boggleBoards_416x416AutoOrient_export_test": (
|
| 330 |
+
"odinw/boggleBoards/416x416AutoOrient/export/",
|
| 331 |
+
"odinw/boggleBoards/416x416AutoOrient/export/test_annotations_without_background_converted.json",
|
| 332 |
+
),
|
| 333 |
+
},
|
| 334 |
+
"odinw_brackishUnderwater_960x540": {
|
| 335 |
+
"odinw_brackishUnderwater_960x540_train": (
|
| 336 |
+
"odinw/brackishUnderwater/960x540/train/",
|
| 337 |
+
"odinw/brackishUnderwater/960x540/train/annotations_without_background_converted.json",
|
| 338 |
+
),
|
| 339 |
+
"odinw_brackishUnderwater_960x540_val": (
|
| 340 |
+
"odinw/brackishUnderwater/960x540/valid/",
|
| 341 |
+
"odinw/brackishUnderwater/960x540/valid/annotations_without_background_converted.json",
|
| 342 |
+
),
|
| 343 |
+
"odinw_brackishUnderwater_960x540_minival": (
|
| 344 |
+
"odinw/brackishUnderwater/960x540/mini_val/",
|
| 345 |
+
"odinw/brackishUnderwater/960x540/mini_val/annotations_without_background_converted.json",
|
| 346 |
+
),
|
| 347 |
+
"odinw_brackishUnderwater_960x540_test": (
|
| 348 |
+
"odinw/brackishUnderwater/960x540/test/",
|
| 349 |
+
"odinw/brackishUnderwater/960x540/test/annotations_without_background_converted.json",
|
| 350 |
+
),
|
| 351 |
+
},
|
| 352 |
+
"odinw_ChessPieces_Chess_Pieces.v23-raw.coco": {
|
| 353 |
+
"odinw_ChessPieces_Chess_Pieces.v23-raw.coco_train": (
|
| 354 |
+
"odinw/ChessPieces/Chess Pieces.v23-raw.coco/train/",
|
| 355 |
+
"odinw/ChessPieces/Chess Pieces.v23-raw.coco/train/annotations_without_background_converted.json",
|
| 356 |
+
),
|
| 357 |
+
"odinw_ChessPieces_Chess_Pieces.v23-raw.coco_val": (
|
| 358 |
+
"odinw/ChessPieces/Chess Pieces.v23-raw.coco/valid/",
|
| 359 |
+
"odinw/ChessPieces/Chess Pieces.v23-raw.coco/valid/annotations_without_background_converted.json",
|
| 360 |
+
),
|
| 361 |
+
"odinw_ChessPieces_Chess_Pieces.v23-raw.coco_test": (
|
| 362 |
+
"odinw/ChessPieces/Chess Pieces.v23-raw.coco/test/",
|
| 363 |
+
"odinw/ChessPieces/Chess Pieces.v23-raw.coco/test/annotations_without_background_converted.json",
|
| 364 |
+
),
|
| 365 |
+
},
|
| 366 |
+
"odinw_CottontailRabbits": {
|
| 367 |
+
"odinw_CottontailRabbits_train": (
|
| 368 |
+
"odinw/CottontailRabbits/train/",
|
| 369 |
+
"odinw/CottontailRabbits/train/annotations_without_background_converted.json",
|
| 370 |
+
),
|
| 371 |
+
"odinw_CottontailRabbits_val": (
|
| 372 |
+
"odinw/CottontailRabbits/valid/",
|
| 373 |
+
"odinw/CottontailRabbits/valid/annotations_without_background_converted.json",
|
| 374 |
+
),
|
| 375 |
+
"odinw_CottontailRabbits_test": (
|
| 376 |
+
"odinw/CottontailRabbits/test/",
|
| 377 |
+
"odinw/CottontailRabbits/test/annotations_without_background_converted.json",
|
| 378 |
+
),
|
| 379 |
+
},
|
| 380 |
+
"odinw_dice_mediumColor_export": {
|
| 381 |
+
"odinw_dice_mediumColor_export_train": (
|
| 382 |
+
"odinw/dice/mediumColor/export/",
|
| 383 |
+
"odinw/dice/mediumColor/export/train_annotations_without_background_converted.json",
|
| 384 |
+
),
|
| 385 |
+
"odinw_dice_mediumColor_export_val": (
|
| 386 |
+
"odinw/dice/mediumColor/export/",
|
| 387 |
+
"odinw/dice/mediumColor/export/val_annotations_without_background_converted.json",
|
| 388 |
+
),
|
| 389 |
+
"odinw_dice_mediumColor_export_test": (
|
| 390 |
+
"odinw/dice/mediumColor/export/",
|
| 391 |
+
"odinw/dice/mediumColor/export/test_annotations_without_background_converted.json",
|
| 392 |
+
),
|
| 393 |
+
},
|
| 394 |
+
"odinw_DroneControl_Drone_Control.v3-raw.coco": {
|
| 395 |
+
"odinw_DroneControl_Drone_Control.v3-raw.coco_train": (
|
| 396 |
+
"odinw/DroneControl/Drone Control.v3-raw.coco/train/",
|
| 397 |
+
"odinw/DroneControl/Drone Control.v3-raw.coco/train/annotations_without_background_converted.json",
|
| 398 |
+
),
|
| 399 |
+
"odinw_DroneControl_Drone_Control.v3-raw.coco_val": (
|
| 400 |
+
"odinw/DroneControl/Drone Control.v3-raw.coco/valid/",
|
| 401 |
+
"odinw/DroneControl/Drone Control.v3-raw.coco/valid/annotations_without_background_converted.json",
|
| 402 |
+
),
|
| 403 |
+
"odinw_DroneControl_Drone_Control.v3-raw.coco_minival": (
|
| 404 |
+
"odinw/DroneControl/Drone Control.v3-raw.coco/mini_val/",
|
| 405 |
+
"odinw/DroneControl/Drone Control.v3-raw.coco/mini_val/annotations_without_background_converted.json",
|
| 406 |
+
),
|
| 407 |
+
"odinw_DroneControl_Drone_Control.v3-raw.coco_test": (
|
| 408 |
+
"odinw/DroneControl/Drone Control.v3-raw.coco/test/",
|
| 409 |
+
"odinw/DroneControl/Drone Control.v3-raw.coco/test/annotations_without_background_converted.json",
|
| 410 |
+
),
|
| 411 |
+
},
|
| 412 |
+
"odinw_EgoHands-generic": {
|
| 413 |
+
"odinw_EgoHands_generic_train": (
|
| 414 |
+
"odinw/EgoHands/generic/train/",
|
| 415 |
+
"odinw/EgoHands/generic/train/annotations_without_background_converted.json",
|
| 416 |
+
),
|
| 417 |
+
"odinw_EgoHands_generic_val": (
|
| 418 |
+
"odinw/EgoHands/generic/valid/",
|
| 419 |
+
"odinw/EgoHands/generic/valid/annotations_without_background_converted.json",
|
| 420 |
+
),
|
| 421 |
+
"odinw_EgoHands_generic_minival": (
|
| 422 |
+
"odinw/EgoHands/generic/mini_val/",
|
| 423 |
+
"odinw/EgoHands/generic/mini_val/annotations_without_background_converted.json",
|
| 424 |
+
),
|
| 425 |
+
"odinw_EgoHands_generic_test": (
|
| 426 |
+
"odinw/EgoHands/generic/test/",
|
| 427 |
+
"odinw/EgoHands/generic/test/annotations_without_background_converted.json",
|
| 428 |
+
),
|
| 429 |
+
},
|
| 430 |
+
"odinw_EgoHands-specific": {
|
| 431 |
+
"odinw_EgoHands_specific_train": (
|
| 432 |
+
"odinw/EgoHands/specific/train/",
|
| 433 |
+
"odinw/EgoHands/specific/train/annotations_without_background_converted.json",
|
| 434 |
+
),
|
| 435 |
+
"odinw_EgoHands_specific_val": (
|
| 436 |
+
"odinw/EgoHands/specific/valid/",
|
| 437 |
+
"odinw/EgoHands/specific/valid/annotations_without_background_converted.json",
|
| 438 |
+
),
|
| 439 |
+
"odinw_EgoHands_specific_minival": (
|
| 440 |
+
"odinw/EgoHands/specific/mini_val/",
|
| 441 |
+
"odinw/EgoHands/specific/mini_val/annotations_without_background_converted.json",
|
| 442 |
+
),
|
| 443 |
+
"odinw_EgoHands_specific_test": (
|
| 444 |
+
"odinw/EgoHands/specific/test/",
|
| 445 |
+
"odinw/EgoHands/specific/test/annotations_without_background_converted.json",
|
| 446 |
+
),
|
| 447 |
+
},
|
| 448 |
+
"odinw_HardHatWorkers_raw": {
|
| 449 |
+
"odinw_HardHatWorkers_raw_train": (
|
| 450 |
+
"odinw/HardHatWorkers/raw/train/",
|
| 451 |
+
"odinw/HardHatWorkers/raw/train/annotations_without_background_converted.json",
|
| 452 |
+
),
|
| 453 |
+
"odinw_HardHatWorkers_raw_val": (
|
| 454 |
+
"odinw/HardHatWorkers/raw/valid/",
|
| 455 |
+
"odinw/HardHatWorkers/raw/valid/annotations_without_background_converted.json",
|
| 456 |
+
),
|
| 457 |
+
"odinw_HardHatWorkers_raw_test": (
|
| 458 |
+
"odinw/HardHatWorkers/raw/test/",
|
| 459 |
+
"odinw/HardHatWorkers/raw/test/annotations_without_background_converted.json",
|
| 460 |
+
),
|
| 461 |
+
},
|
| 462 |
+
"odinw_MaskWearing_raw": {
|
| 463 |
+
"odinw_MaskWearing_raw_train": (
|
| 464 |
+
"odinw/MaskWearing/raw/train/",
|
| 465 |
+
"odinw/MaskWearing/raw/train/annotations_without_background_converted.json",
|
| 466 |
+
),
|
| 467 |
+
"odinw_MaskWearing_raw_val": (
|
| 468 |
+
"odinw/MaskWearing/raw/valid/",
|
| 469 |
+
"odinw/MaskWearing/raw/valid/annotations_without_background_converted.json",
|
| 470 |
+
),
|
| 471 |
+
"odinw_MaskWearing_raw_test": (
|
| 472 |
+
"odinw/MaskWearing/raw/test/",
|
| 473 |
+
"odinw/MaskWearing/raw/test/annotations_without_background_converted.json",
|
| 474 |
+
),
|
| 475 |
+
},
|
| 476 |
+
"odinw_MountainDewCommercial": {
|
| 477 |
+
"odinw_MountainDewCommercial_train": (
|
| 478 |
+
"odinw/MountainDewCommercial/train/",
|
| 479 |
+
"odinw/MountainDewCommercial/train/annotations_without_background_converted.json",
|
| 480 |
+
),
|
| 481 |
+
"odinw_MountainDewCommercial_val": (
|
| 482 |
+
"odinw/MountainDewCommercial/valid/",
|
| 483 |
+
"odinw/MountainDewCommercial/valid/annotations_without_background_converted.json",
|
| 484 |
+
),
|
| 485 |
+
"odinw_MountainDewCommercial_test": (
|
| 486 |
+
"odinw/MountainDewCommercial/test/",
|
| 487 |
+
"odinw/MountainDewCommercial/test/annotations_without_background_converted.json",
|
| 488 |
+
),
|
| 489 |
+
},
|
| 490 |
+
"odinw_NorthAmericaMushrooms_North_American_Mushrooms.v1-416x416.coco": {
|
| 491 |
+
"odinw_NorthAmericaMushrooms_North_American_Mushrooms.v1-416x416.coco_train": (
|
| 492 |
+
"odinw/NorthAmericaMushrooms/North American Mushrooms.v1-416x416.coco/train/",
|
| 493 |
+
"odinw/NorthAmericaMushrooms/North American Mushrooms.v1-416x416.coco/train/annotations_without_background_converted.json",
|
| 494 |
+
),
|
| 495 |
+
"odinw_NorthAmericaMushrooms_North_American_Mushrooms.v1-416x416.coco_val": (
|
| 496 |
+
"odinw/NorthAmericaMushrooms/North American Mushrooms.v1-416x416.coco/valid/",
|
| 497 |
+
"odinw/NorthAmericaMushrooms/North American Mushrooms.v1-416x416.coco/valid/annotations_without_background_converted.json",
|
| 498 |
+
),
|
| 499 |
+
"odinw_NorthAmericaMushrooms_North_American_Mushrooms.v1-416x416.coco_test": (
|
| 500 |
+
"odinw/NorthAmericaMushrooms/North American Mushrooms.v1-416x416.coco/test/",
|
| 501 |
+
"odinw/NorthAmericaMushrooms/North American Mushrooms.v1-416x416.coco/test/annotations_without_background_converted.json",
|
| 502 |
+
),
|
| 503 |
+
},
|
| 504 |
+
"odinw_openPoetryVision_512x512": {
|
| 505 |
+
"odinw_openPoetryVision_512x512_train": (
|
| 506 |
+
"odinw/openPoetryVision/512x512/train/",
|
| 507 |
+
"odinw/openPoetryVision/512x512/train/annotations_without_background_converted.json",
|
| 508 |
+
),
|
| 509 |
+
"odinw_openPoetryVision_512x512_val": (
|
| 510 |
+
"odinw/openPoetryVision/512x512/valid/",
|
| 511 |
+
"odinw/openPoetryVision/512x512/valid/annotations_without_background_converted.json",
|
| 512 |
+
),
|
| 513 |
+
"odinw_openPoetryVision_512x512_minival": (
|
| 514 |
+
"odinw/openPoetryVision/512x512/mini_val/",
|
| 515 |
+
"odinw/openPoetryVision/512x512/mini_val/annotations_without_background_converted.json",
|
| 516 |
+
),
|
| 517 |
+
"odinw_openPoetryVision_512x512_test": (
|
| 518 |
+
"odinw/openPoetryVision/512x512/test/",
|
| 519 |
+
"odinw/openPoetryVision/512x512/test/annotations_without_background_converted.json",
|
| 520 |
+
),
|
| 521 |
+
},
|
| 522 |
+
"odinw_OxfordPets-by-breed": {
|
| 523 |
+
"odinw_OxfordPets_by-breed_train": (
|
| 524 |
+
"odinw/OxfordPets/by-breed/train/",
|
| 525 |
+
"odinw/OxfordPets/by-breed/train/annotations_without_background_converted.json",
|
| 526 |
+
),
|
| 527 |
+
"odinw_OxfordPets_by-breed_val": (
|
| 528 |
+
"odinw/OxfordPets/by-breed/valid/",
|
| 529 |
+
"odinw/OxfordPets/by-breed/valid/annotations_without_background_converted.json",
|
| 530 |
+
),
|
| 531 |
+
"odinw_OxfordPets_by-breed_minival": (
|
| 532 |
+
"odinw/OxfordPets/by-breed/mini_val/",
|
| 533 |
+
"odinw/OxfordPets/by-breed/mini_val/annotations_without_background_converted.json",
|
| 534 |
+
),
|
| 535 |
+
"odinw_OxfordPets_by-breed_test": (
|
| 536 |
+
"odinw/OxfordPets/by-breed/test/",
|
| 537 |
+
"odinw/OxfordPets/by-breed/test/annotations_without_background_converted.json",
|
| 538 |
+
),
|
| 539 |
+
},
|
| 540 |
+
"odinw_OxfordPets-by-species": {
|
| 541 |
+
"odinw_OxfordPets_by-species_train": (
|
| 542 |
+
"odinw/OxfordPets/by-species/train/",
|
| 543 |
+
"odinw/OxfordPets/by-species/train/annotations_without_background_converted.json",
|
| 544 |
+
),
|
| 545 |
+
"odinw_OxfordPets_by-species_val": (
|
| 546 |
+
"odinw/OxfordPets/by-species/valid/",
|
| 547 |
+
"odinw/OxfordPets/by-species/valid/annotations_without_background_converted.json",
|
| 548 |
+
),
|
| 549 |
+
"odinw_OxfordPets_by-species_minival": (
|
| 550 |
+
"odinw/OxfordPets/by-species/mini_val/",
|
| 551 |
+
"odinw/OxfordPets/by-species/mini_val/annotations_without_background_converted.json",
|
| 552 |
+
),
|
| 553 |
+
"odinw_OxfordPets_by-species_test": (
|
| 554 |
+
"odinw/OxfordPets/by-species/test/",
|
| 555 |
+
"odinw/OxfordPets/by-species/test/annotations_without_background_converted.json",
|
| 556 |
+
),
|
| 557 |
+
},
|
| 558 |
+
"odinw_Packages_Raw": {
|
| 559 |
+
"odinw_Packages_Raw_train": (
|
| 560 |
+
"odinw/Packages/Raw/train/",
|
| 561 |
+
"odinw/Packages/Raw/train/annotations_without_background_converted.json",
|
| 562 |
+
),
|
| 563 |
+
"odinw_Packages_Raw_val": (
|
| 564 |
+
"odinw/Packages/Raw/valid/",
|
| 565 |
+
"odinw/Packages/Raw/valid/annotations_without_background_converted.json",
|
| 566 |
+
),
|
| 567 |
+
"odinw_Packages_Raw_test": (
|
| 568 |
+
"odinw/Packages/Raw/test/",
|
| 569 |
+
"odinw/Packages/Raw/test/annotations_without_background_converted.json",
|
| 570 |
+
# "odinw/Packages/Raw/test/_annotations.coco_converted.json",
|
| 571 |
+
),
|
| 572 |
+
},
|
| 573 |
+
"odinw_PascalVOC": {
|
| 574 |
+
"odinw_PascalVOC_train": (
|
| 575 |
+
"odinw/PascalVOC/train/",
|
| 576 |
+
"odinw/PascalVOC/train/annotations_without_background_converted.json",
|
| 577 |
+
),
|
| 578 |
+
"odinw_PascalVOC_val": (
|
| 579 |
+
"odinw/PascalVOC/valid/",
|
| 580 |
+
"odinw/PascalVOC/valid/annotations_without_background_converted.json",
|
| 581 |
+
),
|
| 582 |
+
},
|
| 583 |
+
"odinw_pistols_export": {
|
| 584 |
+
"odinw_pistols_export_train": (
|
| 585 |
+
"odinw/pistols/export/",
|
| 586 |
+
"odinw/pistols/export/train_annotations_without_background_converted.json",
|
| 587 |
+
),
|
| 588 |
+
"odinw_pistols_export_val": (
|
| 589 |
+
"odinw/pistols/export/",
|
| 590 |
+
"odinw/pistols/export/val_annotations_without_background_converted.json",
|
| 591 |
+
),
|
| 592 |
+
"odinw_pistols_export_test": (
|
| 593 |
+
"odinw/pistols/export/",
|
| 594 |
+
"odinw/pistols/export/test_annotations_without_background_converted.json",
|
| 595 |
+
),
|
| 596 |
+
},
|
| 597 |
+
"odinw_PKLot_640": {
|
| 598 |
+
"odinw_PKLot_640_train": (
|
| 599 |
+
"odinw/PKLot/640/train/",
|
| 600 |
+
"odinw/PKLot/640/train/annotations_without_background_converted.json",
|
| 601 |
+
),
|
| 602 |
+
"odinw_PKLot_640_val": (
|
| 603 |
+
"odinw/PKLot/640/valid/",
|
| 604 |
+
"odinw/PKLot/640/valid/annotations_without_background_converted.json",
|
| 605 |
+
),
|
| 606 |
+
"odinw_PKLot_640_minival": (
|
| 607 |
+
"odinw/PKLot/640/mini_val/",
|
| 608 |
+
"odinw/PKLot/640/mini_val/annotations_without_background_converted.json",
|
| 609 |
+
),
|
| 610 |
+
"odinw_PKLot_640_test": (
|
| 611 |
+
"odinw/PKLot/640/test/",
|
| 612 |
+
"odinw/PKLot/640/test/annotations_without_background_converted.json",
|
| 613 |
+
),
|
| 614 |
+
},
|
| 615 |
+
"odinw_plantdoc_100x100": {
|
| 616 |
+
"odinw_plantdoc_100x100_train": (
|
| 617 |
+
"odinw/plantdoc/100x100/train/",
|
| 618 |
+
"odinw/plantdoc/100x100/train/annotations_without_background_converted.json",
|
| 619 |
+
),
|
| 620 |
+
"odinw_plantdoc_100x100_val": (
|
| 621 |
+
"odinw/plantdoc/100x100/valid/",
|
| 622 |
+
"odinw/plantdoc/100x100/valid/annotations_without_background_converted.json",
|
| 623 |
+
),
|
| 624 |
+
"odinw_plantdoc_100x100_test": (
|
| 625 |
+
"odinw/plantdoc/100x100/test/",
|
| 626 |
+
"odinw/plantdoc/100x100/test/annotations_without_background_converted.json",
|
| 627 |
+
),
|
| 628 |
+
},
|
| 629 |
+
"odinw_plantdoc_416x416": {
|
| 630 |
+
"odinw_plantdoc_416x416_train": (
|
| 631 |
+
"odinw/plantdoc/416x416/train/",
|
| 632 |
+
"odinw/plantdoc/416x416/train/annotations_without_background_converted.json",
|
| 633 |
+
),
|
| 634 |
+
"odinw_plantdoc_416x416_val": (
|
| 635 |
+
"odinw/plantdoc/416x416/valid/",
|
| 636 |
+
"odinw/plantdoc/416x416/valid/annotations_without_background_converted.json",
|
| 637 |
+
),
|
| 638 |
+
"odinw_plantdoc_416x416_test": (
|
| 639 |
+
"odinw/plantdoc/416x416/test/",
|
| 640 |
+
"odinw/plantdoc/416x416/test/annotations_without_background_converted.json",
|
| 641 |
+
),
|
| 642 |
+
},
|
| 643 |
+
"odinw_pothole": {
|
| 644 |
+
"odinw_pothole_train": (
|
| 645 |
+
"odinw/pothole/train/",
|
| 646 |
+
"odinw/pothole/train/annotations_without_background_converted.json",
|
| 647 |
+
),
|
| 648 |
+
"odinw_pothole_val": (
|
| 649 |
+
"odinw/pothole/valid/",
|
| 650 |
+
"odinw/pothole/valid/annotations_without_background_converted.json",
|
| 651 |
+
),
|
| 652 |
+
"odinw_pothole_test": (
|
| 653 |
+
"odinw/pothole/test/",
|
| 654 |
+
"odinw/pothole/test/annotations_without_background_converted.json",
|
| 655 |
+
),
|
| 656 |
+
},
|
| 657 |
+
"odinw_Raccoon_Raccoon.v2-raw.coco": {
|
| 658 |
+
"odinw_Raccoon_Raccoon.v2-raw.coco_train": (
|
| 659 |
+
"odinw/Raccoon/Raccoon.v2-raw.coco/train/",
|
| 660 |
+
"odinw/Raccoon/Raccoon.v2-raw.coco/train/annotations_without_background_converted.json",
|
| 661 |
+
),
|
| 662 |
+
"odinw_Raccoon_Raccoon.v2-raw.coco_val": (
|
| 663 |
+
"odinw/Raccoon/Raccoon.v2-raw.coco/valid/",
|
| 664 |
+
"odinw/Raccoon/Raccoon.v2-raw.coco/valid/annotations_without_background_converted.json",
|
| 665 |
+
),
|
| 666 |
+
"odinw_Raccoon_Raccoon.v2-raw.coco_test": (
|
| 667 |
+
"odinw/Raccoon/Raccoon.v2-raw.coco/test/",
|
| 668 |
+
"odinw/Raccoon/Raccoon.v2-raw.coco/test/annotations_without_background_converted.json",
|
| 669 |
+
),
|
| 670 |
+
},
|
| 671 |
+
"odinw_selfdrivingCar_fixedLarge_export": {
|
| 672 |
+
"odinw_selfdrivingCar_fixedLarge_export_train": (
|
| 673 |
+
"odinw/selfdrivingCar/fixedLarge/export/",
|
| 674 |
+
"odinw/selfdrivingCar/fixedLarge/export/train_annotations_without_background_converted.json",
|
| 675 |
+
),
|
| 676 |
+
"odinw_selfdrivingCar_fixedLarge_export_val": (
|
| 677 |
+
"odinw/selfdrivingCar/fixedLarge/export/",
|
| 678 |
+
"odinw/selfdrivingCar/fixedLarge/export/val_annotations_without_background_converted.json",
|
| 679 |
+
),
|
| 680 |
+
"odinw_selfdrivingCar_fixedLarge_export_test": (
|
| 681 |
+
"odinw/selfdrivingCar/fixedLarge/export/",
|
| 682 |
+
"odinw/selfdrivingCar/fixedLarge/export/test_annotations_without_background_converted.json",
|
| 683 |
+
),
|
| 684 |
+
},
|
| 685 |
+
"odinw_ShellfishOpenImages_raw": {
|
| 686 |
+
"odinw_ShellfishOpenImages_raw_train": (
|
| 687 |
+
"odinw/ShellfishOpenImages/raw/train/",
|
| 688 |
+
"odinw/ShellfishOpenImages/raw/train/annotations_without_background_converted.json",
|
| 689 |
+
),
|
| 690 |
+
"odinw_ShellfishOpenImages_raw_val": (
|
| 691 |
+
"odinw/ShellfishOpenImages/raw/valid/",
|
| 692 |
+
"odinw/ShellfishOpenImages/raw/valid/annotations_without_background_converted.json",
|
| 693 |
+
),
|
| 694 |
+
"odinw_ShellfishOpenImages_raw_test": (
|
| 695 |
+
"odinw/ShellfishOpenImages/raw/test/",
|
| 696 |
+
"odinw/ShellfishOpenImages/raw/test/annotations_without_background_converted.json",
|
| 697 |
+
),
|
| 698 |
+
},
|
| 699 |
+
"odinw_ThermalCheetah": {
|
| 700 |
+
"odinw_ThermalCheetah_train": (
|
| 701 |
+
"odinw/ThermalCheetah/train/",
|
| 702 |
+
"odinw/ThermalCheetah/train/annotations_without_background_converted.json",
|
| 703 |
+
),
|
| 704 |
+
"odinw_ThermalCheetah_val": (
|
| 705 |
+
"odinw/ThermalCheetah/valid/",
|
| 706 |
+
"odinw/ThermalCheetah/valid/annotations_without_background_converted.json",
|
| 707 |
+
),
|
| 708 |
+
"odinw_ThermalCheetah_test": (
|
| 709 |
+
"odinw/ThermalCheetah/test/",
|
| 710 |
+
"odinw/ThermalCheetah/test/annotations_without_background_converted.json",
|
| 711 |
+
),
|
| 712 |
+
},
|
| 713 |
+
"odinw_thermalDogsAndPeople": {
|
| 714 |
+
"odinw_thermalDogsAndPeople_train": (
|
| 715 |
+
"odinw/thermalDogsAndPeople/train/",
|
| 716 |
+
"odinw/thermalDogsAndPeople/train/annotations_without_background_converted.json",
|
| 717 |
+
),
|
| 718 |
+
"odinw_thermalDogsAndPeople_val": (
|
| 719 |
+
"odinw/thermalDogsAndPeople/valid/",
|
| 720 |
+
"odinw/thermalDogsAndPeople/valid/annotations_without_background_converted.json",
|
| 721 |
+
),
|
| 722 |
+
"odinw_thermalDogsAndPeople_test": (
|
| 723 |
+
"odinw/thermalDogsAndPeople/test/",
|
| 724 |
+
"odinw/thermalDogsAndPeople/test/annotations_without_background_converted.json",
|
| 725 |
+
),
|
| 726 |
+
},
|
| 727 |
+
"odinw_UnoCards_raw": {
|
| 728 |
+
"odinw_UnoCards_raw_train": (
|
| 729 |
+
"odinw/UnoCards/raw/train/",
|
| 730 |
+
"odinw/UnoCards/raw/train/annotations_without_background_converted.json",
|
| 731 |
+
),
|
| 732 |
+
"odinw_UnoCards_raw_val": (
|
| 733 |
+
"odinw/UnoCards/raw/valid/",
|
| 734 |
+
"odinw/UnoCards/raw/valid/annotations_without_background_converted.json",
|
| 735 |
+
),
|
| 736 |
+
"odinw_UnoCards_raw_minival": (
|
| 737 |
+
"odinw/UnoCards/raw/mini_val/",
|
| 738 |
+
"odinw/UnoCards/raw/mini_val/annotations_without_background_converted.json",
|
| 739 |
+
),
|
| 740 |
+
"odinw_UnoCards_raw_test": (
|
| 741 |
+
"odinw/UnoCards/raw/test/",
|
| 742 |
+
"odinw/UnoCards/raw/test/annotations_without_background_converted.json",
|
| 743 |
+
),
|
| 744 |
+
},
|
| 745 |
+
"odinw_VehiclesOpenImages_416x416": {
|
| 746 |
+
"odinw_VehiclesOpenImages_416x416_train": (
|
| 747 |
+
"odinw/VehiclesOpenImages/416x416/train/",
|
| 748 |
+
"odinw/VehiclesOpenImages/416x416/train/annotations_without_background_converted.json",
|
| 749 |
+
),
|
| 750 |
+
"odinw_VehiclesOpenImages_416x416_val": (
|
| 751 |
+
"odinw/VehiclesOpenImages/416x416/valid/",
|
| 752 |
+
"odinw/VehiclesOpenImages/416x416/valid/annotations_without_background_converted.json",
|
| 753 |
+
),
|
| 754 |
+
"odinw_VehiclesOpenImages_416x416_minival": (
|
| 755 |
+
"odinw/VehiclesOpenImages/416x416/mini_val/",
|
| 756 |
+
"odinw/VehiclesOpenImages/416x416/mini_val/annotations_without_background_converted.json",
|
| 757 |
+
),
|
| 758 |
+
"odinw_VehiclesOpenImages_416x416_test": (
|
| 759 |
+
"odinw/VehiclesOpenImages/416x416/test/",
|
| 760 |
+
"odinw/VehiclesOpenImages/416x416/test/annotations_without_background_converted.json",
|
| 761 |
+
),
|
| 762 |
+
},
|
| 763 |
+
"odinw_websiteScreenshots": {
|
| 764 |
+
"odinw_websiteScreenshots_train": (
|
| 765 |
+
"odinw/websiteScreenshots/train/",
|
| 766 |
+
"odinw/websiteScreenshots/train/annotations_without_background_converted.json",
|
| 767 |
+
),
|
| 768 |
+
"odinw_websiteScreenshots_val": (
|
| 769 |
+
"odinw/websiteScreenshots/valid/",
|
| 770 |
+
"odinw/websiteScreenshots/valid/annotations_without_background_converted.json",
|
| 771 |
+
),
|
| 772 |
+
"odinw_websiteScreenshots_minival": (
|
| 773 |
+
"odinw/websiteScreenshots/mini_val/",
|
| 774 |
+
"odinw/websiteScreenshots/mini_val/annotations_without_background_converted.json",
|
| 775 |
+
),
|
| 776 |
+
"odinw_websiteScreenshots_test": (
|
| 777 |
+
"odinw/websiteScreenshots/test/",
|
| 778 |
+
"odinw/websiteScreenshots/test/annotations_without_background_converted.json",
|
| 779 |
+
),
|
| 780 |
+
},
|
| 781 |
+
"odinw_WildfireSmoke": {
|
| 782 |
+
"odinw_WildfireSmoke_train": (
|
| 783 |
+
"odinw/WildfireSmoke/train/",
|
| 784 |
+
"odinw/WildfireSmoke/train/annotations_without_background_converted.json",
|
| 785 |
+
),
|
| 786 |
+
"odinw_WildfireSmoke_val": (
|
| 787 |
+
"odinw/WildfireSmoke/valid/",
|
| 788 |
+
"odinw/WildfireSmoke/valid/annotations_without_background_converted.json",
|
| 789 |
+
),
|
| 790 |
+
"odinw_WildfireSmoke_test": (
|
| 791 |
+
"odinw/WildfireSmoke/test/",
|
| 792 |
+
"odinw/WildfireSmoke/test/annotations_without_background_converted.json",
|
| 793 |
+
),
|
| 794 |
+
},
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
|
| 798 |
+
def _get_builtin_metadata(name):
|
| 799 |
+
meta = {}
|
| 800 |
+
if name.split("_")[1] in ODINW_PROMPTS:
|
| 801 |
+
meta["thing_classes"] = [
|
| 802 |
+
ODINW_PROMPTS[name.split("_")[1]](m["name"])
|
| 803 |
+
for m in ODINW_CATEGORIES[name.split("_")[1]]
|
| 804 |
+
]
|
| 805 |
+
else:
|
| 806 |
+
meta["thing_classes"] = [m["name"] for m in ODINW_CATEGORIES[name.split("_")[1]]]
|
| 807 |
+
return meta
|
| 808 |
+
|
| 809 |
+
|
| 810 |
+
def register_all_odinw(root):
|
| 811 |
+
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_ODINW.items():
|
| 812 |
+
for key, (image_root, json_file) in splits_per_dataset.items():
|
| 813 |
+
register_coco_instances(
|
| 814 |
+
key,
|
| 815 |
+
_get_builtin_metadata(dataset_name),
|
| 816 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 817 |
+
os.path.join(root, image_root),
|
| 818 |
+
)
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
if __name__.endswith(".odinw_instance"):
|
| 822 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 823 |
+
_root = os.getenv("DATASET", "datasets")
|
| 824 |
+
register_all_odinw(_root)
|
approach/ovod/APE/ape/data/datasets/odinw_prompts.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ODINW_PROMPTS = {
|
| 2 |
+
"AerialMaritimeDrone": lambda name: "a ship" if name == "boat" else name,
|
| 3 |
+
"AmericanSignLanguageLetters": lambda name: "hand gesture '{}'".format(name),
|
| 4 |
+
"BCCD": lambda name: "Red-Blood-Cell-(RBC)"
|
| 5 |
+
if name == "RBC"
|
| 6 |
+
else "White-Blood-Cell-(WBC)"
|
| 7 |
+
if name == "WBC"
|
| 8 |
+
else "Blood-Platelet-Cell-(BPC)"
|
| 9 |
+
if name == "Platelets"
|
| 10 |
+
else name,
|
| 11 |
+
"boggleBoards": lambda name: "letter '{}'".format(name.upper()),
|
| 12 |
+
"brackishUnderwater": lambda name: "big_fish" if name == "fish" else name,
|
| 13 |
+
"ChessPieces": lambda name: "chess piece {}".format(name),
|
| 14 |
+
"dice": lambda name: "dice {}".format(name),
|
| 15 |
+
"DroneControl": lambda name: "body gesture '{}'".format(name),
|
| 16 |
+
"EgoHands-specific": lambda name: "{} hand".format(name),
|
| 17 |
+
# "EgoHands-specific": lambda name: "my left hand"
|
| 18 |
+
# if name == "myleft"
|
| 19 |
+
# else "my right hand"
|
| 20 |
+
# if name == "myright"
|
| 21 |
+
# else "your right hand"
|
| 22 |
+
# if name == "yourright"
|
| 23 |
+
# else "your left hand"
|
| 24 |
+
# if name == "yourleft"
|
| 25 |
+
# else name,
|
| 26 |
+
"HardHatWorkers": lambda name: "human head wearing a helmet"
|
| 27 |
+
if name == "helmet"
|
| 28 |
+
else "human head"
|
| 29 |
+
if name == "head"
|
| 30 |
+
else name,
|
| 31 |
+
"MaskWearing": lambda name: "human head wearing a mask"
|
| 32 |
+
if name == "mask"
|
| 33 |
+
else "human head"
|
| 34 |
+
if name == "no-mask"
|
| 35 |
+
else name,
|
| 36 |
+
"MountainDewCommercial": lambda name: "small {}".format(name),
|
| 37 |
+
"NorthAmericaMushrooms": lambda name: "mushroom {}".format(name),
|
| 38 |
+
"openPoetryVision": lambda name: "some text with font {}".format(name),
|
| 39 |
+
"OxfordPets-by-breed": lambda name: "head of {}".format(name),
|
| 40 |
+
"OxfordPets-by-species": lambda name: "head of {}".format(name),
|
| 41 |
+
"PKLot": lambda name: "{} parking slot".format(name),
|
| 42 |
+
"pothole": lambda name: "broken {}".format(name),
|
| 43 |
+
"ThermalCheetah": lambda name: "person" if name == "human" else name,
|
| 44 |
+
"UnoCards": lambda name: "Arabic numerals 0"
|
| 45 |
+
if name == "0"
|
| 46 |
+
else "Arabic numerals 1"
|
| 47 |
+
if name == "1"
|
| 48 |
+
else "Arabic numerals +4"
|
| 49 |
+
if name == "2"
|
| 50 |
+
else "Arabic numerals +2"
|
| 51 |
+
if name == "3"
|
| 52 |
+
else "two arrows"
|
| 53 |
+
if name == "4"
|
| 54 |
+
else "cross cycle"
|
| 55 |
+
if name == "5"
|
| 56 |
+
else "colorful cycle"
|
| 57 |
+
if name == "6"
|
| 58 |
+
else "Arabic numerals 2"
|
| 59 |
+
if name == "7"
|
| 60 |
+
else "Arabic numerals 3"
|
| 61 |
+
if name == "8"
|
| 62 |
+
else "Arabic numerals 4"
|
| 63 |
+
if name == "9"
|
| 64 |
+
else "Arabic numerals 5"
|
| 65 |
+
if name == "10"
|
| 66 |
+
else "Arabic numerals 6"
|
| 67 |
+
if name == "11"
|
| 68 |
+
else "Arabic numerals 7"
|
| 69 |
+
if name == "12"
|
| 70 |
+
else "Arabic numerals 8"
|
| 71 |
+
if name == "13"
|
| 72 |
+
else "Arabic numerals 9"
|
| 73 |
+
if name == "14"
|
| 74 |
+
else name,
|
| 75 |
+
}
|
approach/ovod/APE/ape/data/datasets/oid.py
ADDED
|
@@ -0,0 +1,1573 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import io
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 7 |
+
|
| 8 |
+
from .coco import custom_load_coco_json
|
| 9 |
+
from .openimages_v6_category_image_count import OPENIMAGES_v6_CATEGORY_IMAGE_COUNT
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def register_oid_instances(name, metadata, json_file, image_root):
|
| 13 |
+
"""
|
| 14 |
+
Register a dataset in COCO's json annotation format for
|
| 15 |
+
instance detection, instance segmentation and keypoint detection.
|
| 16 |
+
(i.e., Type 1 and 2 in http://cocodataset.org/#format-data.
|
| 17 |
+
`instances*.json` and `person_keypoints*.json` in the dataset).
|
| 18 |
+
|
| 19 |
+
This is an example of how to register a new dataset.
|
| 20 |
+
You can do something similar to this function, to register new datasets.
|
| 21 |
+
|
| 22 |
+
Args:
|
| 23 |
+
name (str): the name that identifies a dataset, e.g. "coco_2014_train".
|
| 24 |
+
metadata (dict): extra metadata associated with this dataset. You can
|
| 25 |
+
leave it as an empty dict.
|
| 26 |
+
json_file (str): path to the json instance annotation file.
|
| 27 |
+
image_root (str or path-like): directory which contains all the images.
|
| 28 |
+
"""
|
| 29 |
+
assert isinstance(name, str), name
|
| 30 |
+
assert isinstance(json_file, (str, os.PathLike)), json_file
|
| 31 |
+
assert isinstance(image_root, (str, os.PathLike)), image_root
|
| 32 |
+
# 1. register a function which returns dicts
|
| 33 |
+
DatasetCatalog.register(name, lambda: custom_load_coco_json(json_file, image_root, name))
|
| 34 |
+
|
| 35 |
+
# 2. Optionally, add metadata about this dataset,
|
| 36 |
+
# since they might be useful in evaluation, visualization or logging
|
| 37 |
+
MetadataCatalog.get(name).set(
|
| 38 |
+
json_file=json_file, image_root=image_root, evaluator_type="oid", **metadata
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
OPENIMAGES_2019_CATEGORIES = [
|
| 43 |
+
{"id": 1, "name": "Infant bed", "freebase_id": "/m/061hd_"},
|
| 44 |
+
{"id": 2, "name": "Rose", "freebase_id": "/m/06m11"},
|
| 45 |
+
{"id": 3, "name": "Flag", "freebase_id": "/m/03120"},
|
| 46 |
+
{"id": 4, "name": "Flashlight", "freebase_id": "/m/01kb5b"},
|
| 47 |
+
{"id": 5, "name": "Sea turtle", "freebase_id": "/m/0120dh"},
|
| 48 |
+
{"id": 6, "name": "Camera", "freebase_id": "/m/0dv5r"},
|
| 49 |
+
{"id": 7, "name": "Animal", "freebase_id": "/m/0jbk"},
|
| 50 |
+
{"id": 8, "name": "Glove", "freebase_id": "/m/0174n1"},
|
| 51 |
+
{"id": 9, "name": "Crocodile", "freebase_id": "/m/09f_2"},
|
| 52 |
+
{"id": 10, "name": "Cattle", "freebase_id": "/m/01xq0k1"},
|
| 53 |
+
{"id": 11, "name": "House", "freebase_id": "/m/03jm5"},
|
| 54 |
+
{"id": 12, "name": "Guacamole", "freebase_id": "/m/02g30s"},
|
| 55 |
+
{"id": 13, "name": "Penguin", "freebase_id": "/m/05z6w"},
|
| 56 |
+
{"id": 14, "name": "Vehicle registration plate", "freebase_id": "/m/01jfm_"},
|
| 57 |
+
{"id": 15, "name": "Bench", "freebase_id": "/m/076lb9"},
|
| 58 |
+
{"id": 16, "name": "Ladybug", "freebase_id": "/m/0gj37"},
|
| 59 |
+
{"id": 17, "name": "Human nose", "freebase_id": "/m/0k0pj"},
|
| 60 |
+
{"id": 18, "name": "Watermelon", "freebase_id": "/m/0kpqd"},
|
| 61 |
+
{"id": 19, "name": "Flute", "freebase_id": "/m/0l14j_"},
|
| 62 |
+
{"id": 20, "name": "Butterfly", "freebase_id": "/m/0cyf8"},
|
| 63 |
+
{"id": 21, "name": "Washing machine", "freebase_id": "/m/0174k2"},
|
| 64 |
+
{"id": 22, "name": "Raccoon", "freebase_id": "/m/0dq75"},
|
| 65 |
+
{"id": 23, "name": "Segway", "freebase_id": "/m/076bq"},
|
| 66 |
+
{"id": 24, "name": "Taco", "freebase_id": "/m/07crc"},
|
| 67 |
+
{"id": 25, "name": "Jellyfish", "freebase_id": "/m/0d8zb"},
|
| 68 |
+
{"id": 26, "name": "Cake", "freebase_id": "/m/0fszt"},
|
| 69 |
+
{"id": 27, "name": "Pen", "freebase_id": "/m/0k1tl"},
|
| 70 |
+
{"id": 28, "name": "Cannon", "freebase_id": "/m/020kz"},
|
| 71 |
+
{"id": 29, "name": "Bread", "freebase_id": "/m/09728"},
|
| 72 |
+
{"id": 30, "name": "Tree", "freebase_id": "/m/07j7r"},
|
| 73 |
+
{"id": 31, "name": "Shellfish", "freebase_id": "/m/0fbdv"},
|
| 74 |
+
{"id": 32, "name": "Bed", "freebase_id": "/m/03ssj5"},
|
| 75 |
+
{"id": 33, "name": "Hamster", "freebase_id": "/m/03qrc"},
|
| 76 |
+
{"id": 34, "name": "Hat", "freebase_id": "/m/02dl1y"},
|
| 77 |
+
{"id": 35, "name": "Toaster", "freebase_id": "/m/01k6s3"},
|
| 78 |
+
{"id": 36, "name": "Sombrero", "freebase_id": "/m/02jfl0"},
|
| 79 |
+
{"id": 37, "name": "Tiara", "freebase_id": "/m/01krhy"},
|
| 80 |
+
{"id": 38, "name": "Bowl", "freebase_id": "/m/04kkgm"},
|
| 81 |
+
{"id": 39, "name": "Dragonfly", "freebase_id": "/m/0ft9s"},
|
| 82 |
+
{"id": 40, "name": "Moths and butterflies", "freebase_id": "/m/0d_2m"},
|
| 83 |
+
{"id": 41, "name": "Antelope", "freebase_id": "/m/0czz2"},
|
| 84 |
+
{"id": 42, "name": "Vegetable", "freebase_id": "/m/0f4s2w"},
|
| 85 |
+
{"id": 43, "name": "Torch", "freebase_id": "/m/07dd4"},
|
| 86 |
+
{"id": 44, "name": "Building", "freebase_id": "/m/0cgh4"},
|
| 87 |
+
{"id": 45, "name": "Power plugs and sockets", "freebase_id": "/m/03bbps"},
|
| 88 |
+
{"id": 46, "name": "Blender", "freebase_id": "/m/02pjr4"},
|
| 89 |
+
{"id": 47, "name": "Billiard table", "freebase_id": "/m/04p0qw"},
|
| 90 |
+
{"id": 48, "name": "Cutting board", "freebase_id": "/m/02pdsw"},
|
| 91 |
+
{"id": 49, "name": "Bronze sculpture", "freebase_id": "/m/01yx86"},
|
| 92 |
+
{"id": 50, "name": "Turtle", "freebase_id": "/m/09dzg"},
|
| 93 |
+
{"id": 51, "name": "Broccoli", "freebase_id": "/m/0hkxq"},
|
| 94 |
+
{"id": 52, "name": "Tiger", "freebase_id": "/m/07dm6"},
|
| 95 |
+
{"id": 53, "name": "Mirror", "freebase_id": "/m/054_l"},
|
| 96 |
+
{"id": 54, "name": "Bear", "freebase_id": "/m/01dws"},
|
| 97 |
+
{"id": 55, "name": "Zucchini", "freebase_id": "/m/027pcv"},
|
| 98 |
+
{"id": 56, "name": "Dress", "freebase_id": "/m/01d40f"},
|
| 99 |
+
{"id": 57, "name": "Volleyball", "freebase_id": "/m/02rgn06"},
|
| 100 |
+
{"id": 58, "name": "Guitar", "freebase_id": "/m/0342h"},
|
| 101 |
+
{"id": 59, "name": "Reptile", "freebase_id": "/m/06bt6"},
|
| 102 |
+
{"id": 60, "name": "Golf cart", "freebase_id": "/m/0323sq"},
|
| 103 |
+
{"id": 61, "name": "Tart", "freebase_id": "/m/02zvsm"},
|
| 104 |
+
{"id": 62, "name": "Fedora", "freebase_id": "/m/02fq_6"},
|
| 105 |
+
{"id": 63, "name": "Carnivore", "freebase_id": "/m/01lrl"},
|
| 106 |
+
{"id": 64, "name": "Car", "freebase_id": "/m/0k4j"},
|
| 107 |
+
{"id": 65, "name": "Lighthouse", "freebase_id": "/m/04h7h"},
|
| 108 |
+
{"id": 66, "name": "Coffeemaker", "freebase_id": "/m/07xyvk"},
|
| 109 |
+
{"id": 67, "name": "Food processor", "freebase_id": "/m/03y6mg"},
|
| 110 |
+
{"id": 68, "name": "Truck", "freebase_id": "/m/07r04"},
|
| 111 |
+
{"id": 69, "name": "Bookcase", "freebase_id": "/m/03__z0"},
|
| 112 |
+
{"id": 70, "name": "Surfboard", "freebase_id": "/m/019w40"},
|
| 113 |
+
{"id": 71, "name": "Footwear", "freebase_id": "/m/09j5n"},
|
| 114 |
+
{"id": 72, "name": "Bench", "freebase_id": "/m/0cvnqh"},
|
| 115 |
+
{"id": 73, "name": "Necklace", "freebase_id": "/m/01llwg"},
|
| 116 |
+
{"id": 74, "name": "Flower", "freebase_id": "/m/0c9ph5"},
|
| 117 |
+
{"id": 75, "name": "Radish", "freebase_id": "/m/015x5n"},
|
| 118 |
+
{"id": 76, "name": "Marine mammal", "freebase_id": "/m/0gd2v"},
|
| 119 |
+
{"id": 77, "name": "Frying pan", "freebase_id": "/m/04v6l4"},
|
| 120 |
+
{"id": 78, "name": "Tap", "freebase_id": "/m/02jz0l"},
|
| 121 |
+
{"id": 79, "name": "Peach", "freebase_id": "/m/0dj6p"},
|
| 122 |
+
{"id": 80, "name": "Knife", "freebase_id": "/m/04ctx"},
|
| 123 |
+
{"id": 81, "name": "Handbag", "freebase_id": "/m/080hkjn"},
|
| 124 |
+
{"id": 82, "name": "Laptop", "freebase_id": "/m/01c648"},
|
| 125 |
+
{"id": 83, "name": "Tent", "freebase_id": "/m/01j61q"},
|
| 126 |
+
{"id": 84, "name": "Ambulance", "freebase_id": "/m/012n7d"},
|
| 127 |
+
{"id": 85, "name": "Christmas tree", "freebase_id": "/m/025nd"},
|
| 128 |
+
{"id": 86, "name": "Eagle", "freebase_id": "/m/09csl"},
|
| 129 |
+
{"id": 87, "name": "Limousine", "freebase_id": "/m/01lcw4"},
|
| 130 |
+
{"id": 88, "name": "Kitchen & dining room table", "freebase_id": "/m/0h8n5zk"},
|
| 131 |
+
{"id": 89, "name": "Polar bear", "freebase_id": "/m/0633h"},
|
| 132 |
+
{"id": 90, "name": "Tower", "freebase_id": "/m/01fdzj"},
|
| 133 |
+
{"id": 91, "name": "Football", "freebase_id": "/m/01226z"},
|
| 134 |
+
{"id": 92, "name": "Willow", "freebase_id": "/m/0mw_6"},
|
| 135 |
+
{"id": 93, "name": "Human head", "freebase_id": "/m/04hgtk"},
|
| 136 |
+
{"id": 94, "name": "Stop sign", "freebase_id": "/m/02pv19"},
|
| 137 |
+
{"id": 95, "name": "Banana", "freebase_id": "/m/09qck"},
|
| 138 |
+
{"id": 96, "name": "Mixer", "freebase_id": "/m/063rgb"},
|
| 139 |
+
{"id": 97, "name": "Binoculars", "freebase_id": "/m/0lt4_"},
|
| 140 |
+
{"id": 98, "name": "Dessert", "freebase_id": "/m/0270h"},
|
| 141 |
+
{"id": 99, "name": "Bee", "freebase_id": "/m/01h3n"},
|
| 142 |
+
{"id": 100, "name": "Chair", "freebase_id": "/m/01mzpv"},
|
| 143 |
+
{"id": 101, "name": "Wood-burning stove", "freebase_id": "/m/04169hn"},
|
| 144 |
+
{"id": 102, "name": "Flowerpot", "freebase_id": "/m/0fm3zh"},
|
| 145 |
+
{"id": 103, "name": "Beaker", "freebase_id": "/m/0d20w4"},
|
| 146 |
+
{"id": 104, "name": "Oyster", "freebase_id": "/m/0_cp5"},
|
| 147 |
+
{"id": 105, "name": "Woodpecker", "freebase_id": "/m/01dy8n"},
|
| 148 |
+
{"id": 106, "name": "Harp", "freebase_id": "/m/03m5k"},
|
| 149 |
+
{"id": 107, "name": "Bathtub", "freebase_id": "/m/03dnzn"},
|
| 150 |
+
{"id": 108, "name": "Wall clock", "freebase_id": "/m/0h8mzrc"},
|
| 151 |
+
{"id": 109, "name": "Sports uniform", "freebase_id": "/m/0h8mhzd"},
|
| 152 |
+
{"id": 110, "name": "Rhinoceros", "freebase_id": "/m/03d443"},
|
| 153 |
+
{"id": 111, "name": "Beehive", "freebase_id": "/m/01gllr"},
|
| 154 |
+
{"id": 112, "name": "Cupboard", "freebase_id": "/m/0642b4"},
|
| 155 |
+
{"id": 113, "name": "Chicken", "freebase_id": "/m/09b5t"},
|
| 156 |
+
{"id": 114, "name": "Man", "freebase_id": "/m/04yx4"},
|
| 157 |
+
{"id": 115, "name": "Blue jay", "freebase_id": "/m/01f8m5"},
|
| 158 |
+
{"id": 116, "name": "Cucumber", "freebase_id": "/m/015x4r"},
|
| 159 |
+
{"id": 117, "name": "Balloon", "freebase_id": "/m/01j51"},
|
| 160 |
+
{"id": 118, "name": "Kite", "freebase_id": "/m/02zt3"},
|
| 161 |
+
{"id": 119, "name": "Fireplace", "freebase_id": "/m/03tw93"},
|
| 162 |
+
{"id": 120, "name": "Lantern", "freebase_id": "/m/01jfsr"},
|
| 163 |
+
{"id": 121, "name": "Missile", "freebase_id": "/m/04ylt"},
|
| 164 |
+
{"id": 122, "name": "Book", "freebase_id": "/m/0bt_c3"},
|
| 165 |
+
{"id": 123, "name": "Spoon", "freebase_id": "/m/0cmx8"},
|
| 166 |
+
{"id": 124, "name": "Grapefruit", "freebase_id": "/m/0hqkz"},
|
| 167 |
+
{"id": 125, "name": "Squirrel", "freebase_id": "/m/071qp"},
|
| 168 |
+
{"id": 126, "name": "Orange", "freebase_id": "/m/0cyhj_"},
|
| 169 |
+
{"id": 127, "name": "Coat", "freebase_id": "/m/01xygc"},
|
| 170 |
+
{"id": 128, "name": "Punching bag", "freebase_id": "/m/0420v5"},
|
| 171 |
+
{"id": 129, "name": "Zebra", "freebase_id": "/m/0898b"},
|
| 172 |
+
{"id": 130, "name": "Billboard", "freebase_id": "/m/01knjb"},
|
| 173 |
+
{"id": 131, "name": "Bicycle", "freebase_id": "/m/0199g"},
|
| 174 |
+
{"id": 132, "name": "Door handle", "freebase_id": "/m/03c7gz"},
|
| 175 |
+
{"id": 133, "name": "Mechanical fan", "freebase_id": "/m/02x984l"},
|
| 176 |
+
{"id": 134, "name": "Ring binder", "freebase_id": "/m/04zwwv"},
|
| 177 |
+
{"id": 135, "name": "Table", "freebase_id": "/m/04bcr3"},
|
| 178 |
+
{"id": 136, "name": "Parrot", "freebase_id": "/m/0gv1x"},
|
| 179 |
+
{"id": 137, "name": "Sock", "freebase_id": "/m/01nq26"},
|
| 180 |
+
{"id": 138, "name": "Vase", "freebase_id": "/m/02s195"},
|
| 181 |
+
{"id": 139, "name": "Weapon", "freebase_id": "/m/083kb"},
|
| 182 |
+
{"id": 140, "name": "Shotgun", "freebase_id": "/m/06nrc"},
|
| 183 |
+
{"id": 141, "name": "Glasses", "freebase_id": "/m/0jyfg"},
|
| 184 |
+
{"id": 142, "name": "Seahorse", "freebase_id": "/m/0nybt"},
|
| 185 |
+
{"id": 143, "name": "Belt", "freebase_id": "/m/0176mf"},
|
| 186 |
+
{"id": 144, "name": "Watercraft", "freebase_id": "/m/01rzcn"},
|
| 187 |
+
{"id": 145, "name": "Window", "freebase_id": "/m/0d4v4"},
|
| 188 |
+
{"id": 146, "name": "Giraffe", "freebase_id": "/m/03bk1"},
|
| 189 |
+
{"id": 147, "name": "Lion", "freebase_id": "/m/096mb"},
|
| 190 |
+
{"id": 148, "name": "Tire", "freebase_id": "/m/0h9mv"},
|
| 191 |
+
{"id": 149, "name": "Vehicle", "freebase_id": "/m/07yv9"},
|
| 192 |
+
{"id": 150, "name": "Canoe", "freebase_id": "/m/0ph39"},
|
| 193 |
+
{"id": 151, "name": "Tie", "freebase_id": "/m/01rkbr"},
|
| 194 |
+
{"id": 152, "name": "Shelf", "freebase_id": "/m/0gjbg72"},
|
| 195 |
+
{"id": 153, "name": "Picture frame", "freebase_id": "/m/06z37_"},
|
| 196 |
+
{"id": 154, "name": "Printer", "freebase_id": "/m/01m4t"},
|
| 197 |
+
{"id": 155, "name": "Human leg", "freebase_id": "/m/035r7c"},
|
| 198 |
+
{"id": 156, "name": "Boat", "freebase_id": "/m/019jd"},
|
| 199 |
+
{"id": 157, "name": "Slow cooker", "freebase_id": "/m/02tsc9"},
|
| 200 |
+
{"id": 158, "name": "Croissant", "freebase_id": "/m/015wgc"},
|
| 201 |
+
{"id": 159, "name": "Candle", "freebase_id": "/m/0c06p"},
|
| 202 |
+
{"id": 160, "name": "Pancake", "freebase_id": "/m/01dwwc"},
|
| 203 |
+
{"id": 161, "name": "Pillow", "freebase_id": "/m/034c16"},
|
| 204 |
+
{"id": 162, "name": "Coin", "freebase_id": "/m/0242l"},
|
| 205 |
+
{"id": 163, "name": "Stretcher", "freebase_id": "/m/02lbcq"},
|
| 206 |
+
{"id": 164, "name": "Sandal", "freebase_id": "/m/03nfch"},
|
| 207 |
+
{"id": 165, "name": "Woman", "freebase_id": "/m/03bt1vf"},
|
| 208 |
+
{"id": 166, "name": "Stairs", "freebase_id": "/m/01lynh"},
|
| 209 |
+
{"id": 167, "name": "Harpsichord", "freebase_id": "/m/03q5t"},
|
| 210 |
+
{"id": 168, "name": "Stool", "freebase_id": "/m/0fqt361"},
|
| 211 |
+
{"id": 169, "name": "Bus", "freebase_id": "/m/01bjv"},
|
| 212 |
+
{"id": 170, "name": "Suitcase", "freebase_id": "/m/01s55n"},
|
| 213 |
+
{"id": 171, "name": "Human mouth", "freebase_id": "/m/0283dt1"},
|
| 214 |
+
{"id": 172, "name": "Juice", "freebase_id": "/m/01z1kdw"},
|
| 215 |
+
{"id": 173, "name": "Skull", "freebase_id": "/m/016m2d"},
|
| 216 |
+
{"id": 174, "name": "Door", "freebase_id": "/m/02dgv"},
|
| 217 |
+
{"id": 175, "name": "Violin", "freebase_id": "/m/07y_7"},
|
| 218 |
+
{"id": 176, "name": "Chopsticks", "freebase_id": "/m/01_5g"},
|
| 219 |
+
{"id": 177, "name": "Digital clock", "freebase_id": "/m/06_72j"},
|
| 220 |
+
{"id": 178, "name": "Sunflower", "freebase_id": "/m/0ftb8"},
|
| 221 |
+
{"id": 179, "name": "Leopard", "freebase_id": "/m/0c29q"},
|
| 222 |
+
{"id": 180, "name": "Bell pepper", "freebase_id": "/m/0jg57"},
|
| 223 |
+
{"id": 181, "name": "Harbor seal", "freebase_id": "/m/02l8p9"},
|
| 224 |
+
{"id": 182, "name": "Snake", "freebase_id": "/m/078jl"},
|
| 225 |
+
{"id": 183, "name": "Sewing machine", "freebase_id": "/m/0llzx"},
|
| 226 |
+
{"id": 184, "name": "Goose", "freebase_id": "/m/0dbvp"},
|
| 227 |
+
{"id": 185, "name": "Helicopter", "freebase_id": "/m/09ct_"},
|
| 228 |
+
{"id": 186, "name": "Seat belt", "freebase_id": "/m/0dkzw"},
|
| 229 |
+
{"id": 187, "name": "Coffee cup", "freebase_id": "/m/02p5f1q"},
|
| 230 |
+
{"id": 188, "name": "Microwave oven", "freebase_id": "/m/0fx9l"},
|
| 231 |
+
{"id": 189, "name": "Hot dog", "freebase_id": "/m/01b9xk"},
|
| 232 |
+
{"id": 190, "name": "Countertop", "freebase_id": "/m/0b3fp9"},
|
| 233 |
+
{"id": 191, "name": "Serving tray", "freebase_id": "/m/0h8n27j"},
|
| 234 |
+
{"id": 192, "name": "Dog bed", "freebase_id": "/m/0h8n6f9"},
|
| 235 |
+
{"id": 193, "name": "Beer", "freebase_id": "/m/01599"},
|
| 236 |
+
{"id": 194, "name": "Sunglasses", "freebase_id": "/m/017ftj"},
|
| 237 |
+
{"id": 195, "name": "Golf ball", "freebase_id": "/m/044r5d"},
|
| 238 |
+
{"id": 196, "name": "Waffle", "freebase_id": "/m/01dwsz"},
|
| 239 |
+
{"id": 197, "name": "Palm tree", "freebase_id": "/m/0cdl1"},
|
| 240 |
+
{"id": 198, "name": "Trumpet", "freebase_id": "/m/07gql"},
|
| 241 |
+
{"id": 199, "name": "Ruler", "freebase_id": "/m/0hdln"},
|
| 242 |
+
{"id": 200, "name": "Helmet", "freebase_id": "/m/0zvk5"},
|
| 243 |
+
{"id": 201, "name": "Ladder", "freebase_id": "/m/012w5l"},
|
| 244 |
+
{"id": 202, "name": "Office building", "freebase_id": "/m/021sj1"},
|
| 245 |
+
{"id": 203, "name": "Tablet computer", "freebase_id": "/m/0bh9flk"},
|
| 246 |
+
{"id": 204, "name": "Toilet paper", "freebase_id": "/m/09gtd"},
|
| 247 |
+
{"id": 205, "name": "Pomegranate", "freebase_id": "/m/0jwn_"},
|
| 248 |
+
{"id": 206, "name": "Skirt", "freebase_id": "/m/02wv6h6"},
|
| 249 |
+
{"id": 207, "name": "Gas stove", "freebase_id": "/m/02wv84t"},
|
| 250 |
+
{"id": 208, "name": "Cookie", "freebase_id": "/m/021mn"},
|
| 251 |
+
{"id": 209, "name": "Cart", "freebase_id": "/m/018p4k"},
|
| 252 |
+
{"id": 210, "name": "Raven", "freebase_id": "/m/06j2d"},
|
| 253 |
+
{"id": 211, "name": "Egg", "freebase_id": "/m/033cnk"},
|
| 254 |
+
{"id": 212, "name": "Burrito", "freebase_id": "/m/01j3zr"},
|
| 255 |
+
{"id": 213, "name": "Goat", "freebase_id": "/m/03fwl"},
|
| 256 |
+
{"id": 214, "name": "Kitchen knife", "freebase_id": "/m/058qzx"},
|
| 257 |
+
{"id": 215, "name": "Skateboard", "freebase_id": "/m/06_fw"},
|
| 258 |
+
{"id": 216, "name": "Salt and pepper shakers", "freebase_id": "/m/02x8cch"},
|
| 259 |
+
{"id": 217, "name": "Lynx", "freebase_id": "/m/04g2r"},
|
| 260 |
+
{"id": 218, "name": "Boot", "freebase_id": "/m/01b638"},
|
| 261 |
+
{"id": 219, "name": "Platter", "freebase_id": "/m/099ssp"},
|
| 262 |
+
{"id": 220, "name": "Ski", "freebase_id": "/m/071p9"},
|
| 263 |
+
{"id": 221, "name": "Swimwear", "freebase_id": "/m/01gkx_"},
|
| 264 |
+
{"id": 222, "name": "Swimming pool", "freebase_id": "/m/0b_rs"},
|
| 265 |
+
{"id": 223, "name": "Drinking straw", "freebase_id": "/m/03v5tg"},
|
| 266 |
+
{"id": 224, "name": "Wrench", "freebase_id": "/m/01j5ks"},
|
| 267 |
+
{"id": 225, "name": "Drum", "freebase_id": "/m/026t6"},
|
| 268 |
+
{"id": 226, "name": "Ant", "freebase_id": "/m/0_k2"},
|
| 269 |
+
{"id": 227, "name": "Human ear", "freebase_id": "/m/039xj_"},
|
| 270 |
+
{"id": 228, "name": "Headphones", "freebase_id": "/m/01b7fy"},
|
| 271 |
+
{"id": 229, "name": "Fountain", "freebase_id": "/m/0220r2"},
|
| 272 |
+
{"id": 230, "name": "Bird", "freebase_id": "/m/015p6"},
|
| 273 |
+
{"id": 231, "name": "Jeans", "freebase_id": "/m/0fly7"},
|
| 274 |
+
{"id": 232, "name": "Television", "freebase_id": "/m/07c52"},
|
| 275 |
+
{"id": 233, "name": "Crab", "freebase_id": "/m/0n28_"},
|
| 276 |
+
{"id": 234, "name": "Microphone", "freebase_id": "/m/0hg7b"},
|
| 277 |
+
{"id": 235, "name": "Home appliance", "freebase_id": "/m/019dx1"},
|
| 278 |
+
{"id": 236, "name": "Snowplow", "freebase_id": "/m/04vv5k"},
|
| 279 |
+
{"id": 237, "name": "Beetle", "freebase_id": "/m/020jm"},
|
| 280 |
+
{"id": 238, "name": "Artichoke", "freebase_id": "/m/047v4b"},
|
| 281 |
+
{"id": 239, "name": "Jet ski", "freebase_id": "/m/01xs3r"},
|
| 282 |
+
{"id": 240, "name": "Stationary bicycle", "freebase_id": "/m/03kt2w"},
|
| 283 |
+
{"id": 241, "name": "Human hair", "freebase_id": "/m/03q69"},
|
| 284 |
+
{"id": 242, "name": "Brown bear", "freebase_id": "/m/01dxs"},
|
| 285 |
+
{"id": 243, "name": "Starfish", "freebase_id": "/m/01h8tj"},
|
| 286 |
+
{"id": 244, "name": "Fork", "freebase_id": "/m/0dt3t"},
|
| 287 |
+
{"id": 245, "name": "Lobster", "freebase_id": "/m/0cjq5"},
|
| 288 |
+
{"id": 246, "name": "Corded phone", "freebase_id": "/m/0h8lkj8"},
|
| 289 |
+
{"id": 247, "name": "Drink", "freebase_id": "/m/0271t"},
|
| 290 |
+
{"id": 248, "name": "Saucer", "freebase_id": "/m/03q5c7"},
|
| 291 |
+
{"id": 249, "name": "Carrot", "freebase_id": "/m/0fj52s"},
|
| 292 |
+
{"id": 250, "name": "Insect", "freebase_id": "/m/03vt0"},
|
| 293 |
+
{"id": 251, "name": "Clock", "freebase_id": "/m/01x3z"},
|
| 294 |
+
{"id": 252, "name": "Castle", "freebase_id": "/m/0d5gx"},
|
| 295 |
+
{"id": 253, "name": "Tennis racket", "freebase_id": "/m/0h8my_4"},
|
| 296 |
+
{"id": 254, "name": "Ceiling fan", "freebase_id": "/m/03ldnb"},
|
| 297 |
+
{"id": 255, "name": "Asparagus", "freebase_id": "/m/0cjs7"},
|
| 298 |
+
{"id": 256, "name": "Jaguar", "freebase_id": "/m/0449p"},
|
| 299 |
+
{"id": 257, "name": "Musical instrument", "freebase_id": "/m/04szw"},
|
| 300 |
+
{"id": 258, "name": "Train", "freebase_id": "/m/07jdr"},
|
| 301 |
+
{"id": 259, "name": "Cat", "freebase_id": "/m/01yrx"},
|
| 302 |
+
{"id": 260, "name": "Rifle", "freebase_id": "/m/06c54"},
|
| 303 |
+
{"id": 261, "name": "Dumbbell", "freebase_id": "/m/04h8sr"},
|
| 304 |
+
{"id": 262, "name": "Mobile phone", "freebase_id": "/m/050k8"},
|
| 305 |
+
{"id": 263, "name": "Taxi", "freebase_id": "/m/0pg52"},
|
| 306 |
+
{"id": 264, "name": "Shower", "freebase_id": "/m/02f9f_"},
|
| 307 |
+
{"id": 265, "name": "Pitcher", "freebase_id": "/m/054fyh"},
|
| 308 |
+
{"id": 266, "name": "Lemon", "freebase_id": "/m/09k_b"},
|
| 309 |
+
{"id": 267, "name": "Invertebrate", "freebase_id": "/m/03xxp"},
|
| 310 |
+
{"id": 268, "name": "Turkey", "freebase_id": "/m/0jly1"},
|
| 311 |
+
{"id": 269, "name": "High heels", "freebase_id": "/m/06k2mb"},
|
| 312 |
+
{"id": 270, "name": "Bust", "freebase_id": "/m/04yqq2"},
|
| 313 |
+
{"id": 271, "name": "Elephant", "freebase_id": "/m/0bwd_0j"},
|
| 314 |
+
{"id": 272, "name": "Scarf", "freebase_id": "/m/02h19r"},
|
| 315 |
+
{"id": 273, "name": "Barrel", "freebase_id": "/m/02zn6n"},
|
| 316 |
+
{"id": 274, "name": "Trombone", "freebase_id": "/m/07c6l"},
|
| 317 |
+
{"id": 275, "name": "Pumpkin", "freebase_id": "/m/05zsy"},
|
| 318 |
+
{"id": 276, "name": "Box", "freebase_id": "/m/025dyy"},
|
| 319 |
+
{"id": 277, "name": "Tomato", "freebase_id": "/m/07j87"},
|
| 320 |
+
{"id": 278, "name": "Frog", "freebase_id": "/m/09ld4"},
|
| 321 |
+
{"id": 279, "name": "Bidet", "freebase_id": "/m/01vbnl"},
|
| 322 |
+
{"id": 280, "name": "Human face", "freebase_id": "/m/0dzct"},
|
| 323 |
+
{"id": 281, "name": "Houseplant", "freebase_id": "/m/03fp41"},
|
| 324 |
+
{"id": 282, "name": "Van", "freebase_id": "/m/0h2r6"},
|
| 325 |
+
{"id": 283, "name": "Shark", "freebase_id": "/m/0by6g"},
|
| 326 |
+
{"id": 284, "name": "Ice cream", "freebase_id": "/m/0cxn2"},
|
| 327 |
+
{"id": 285, "name": "Swim cap", "freebase_id": "/m/04tn4x"},
|
| 328 |
+
{"id": 286, "name": "Falcon", "freebase_id": "/m/0f6wt"},
|
| 329 |
+
{"id": 287, "name": "Ostrich", "freebase_id": "/m/05n4y"},
|
| 330 |
+
{"id": 288, "name": "Handgun", "freebase_id": "/m/0gxl3"},
|
| 331 |
+
{"id": 289, "name": "Whiteboard", "freebase_id": "/m/02d9qx"},
|
| 332 |
+
{"id": 290, "name": "Lizard", "freebase_id": "/m/04m9y"},
|
| 333 |
+
{"id": 291, "name": "Pasta", "freebase_id": "/m/05z55"},
|
| 334 |
+
{"id": 292, "name": "Snowmobile", "freebase_id": "/m/01x3jk"},
|
| 335 |
+
{"id": 293, "name": "Light bulb", "freebase_id": "/m/0h8l4fh"},
|
| 336 |
+
{"id": 294, "name": "Window blind", "freebase_id": "/m/031b6r"},
|
| 337 |
+
{"id": 295, "name": "Muffin", "freebase_id": "/m/01tcjp"},
|
| 338 |
+
{"id": 296, "name": "Pretzel", "freebase_id": "/m/01f91_"},
|
| 339 |
+
{"id": 297, "name": "Computer monitor", "freebase_id": "/m/02522"},
|
| 340 |
+
{"id": 298, "name": "Horn", "freebase_id": "/m/0319l"},
|
| 341 |
+
{"id": 299, "name": "Furniture", "freebase_id": "/m/0c_jw"},
|
| 342 |
+
{"id": 300, "name": "Sandwich", "freebase_id": "/m/0l515"},
|
| 343 |
+
{"id": 301, "name": "Fox", "freebase_id": "/m/0306r"},
|
| 344 |
+
{"id": 302, "name": "Convenience store", "freebase_id": "/m/0crjs"},
|
| 345 |
+
{"id": 303, "name": "Fish", "freebase_id": "/m/0ch_cf"},
|
| 346 |
+
{"id": 304, "name": "Fruit", "freebase_id": "/m/02xwb"},
|
| 347 |
+
{"id": 305, "name": "Earrings", "freebase_id": "/m/01r546"},
|
| 348 |
+
{"id": 306, "name": "Curtain", "freebase_id": "/m/03rszm"},
|
| 349 |
+
{"id": 307, "name": "Grape", "freebase_id": "/m/0388q"},
|
| 350 |
+
{"id": 308, "name": "Sofa bed", "freebase_id": "/m/03m3pdh"},
|
| 351 |
+
{"id": 309, "name": "Horse", "freebase_id": "/m/03k3r"},
|
| 352 |
+
{"id": 310, "name": "Luggage and bags", "freebase_id": "/m/0hf58v5"},
|
| 353 |
+
{"id": 311, "name": "Desk", "freebase_id": "/m/01y9k5"},
|
| 354 |
+
{"id": 312, "name": "Crutch", "freebase_id": "/m/05441v"},
|
| 355 |
+
{"id": 313, "name": "Bicycle helmet", "freebase_id": "/m/03p3bw"},
|
| 356 |
+
{"id": 314, "name": "Tick", "freebase_id": "/m/0175cv"},
|
| 357 |
+
{"id": 315, "name": "Airplane", "freebase_id": "/m/0cmf2"},
|
| 358 |
+
{"id": 316, "name": "Canary", "freebase_id": "/m/0ccs93"},
|
| 359 |
+
{"id": 317, "name": "Spatula", "freebase_id": "/m/02d1br"},
|
| 360 |
+
{"id": 318, "name": "Watch", "freebase_id": "/m/0gjkl"},
|
| 361 |
+
{"id": 319, "name": "Lily", "freebase_id": "/m/0jqgx"},
|
| 362 |
+
{"id": 320, "name": "Kitchen appliance", "freebase_id": "/m/0h99cwc"},
|
| 363 |
+
{"id": 321, "name": "Filing cabinet", "freebase_id": "/m/047j0r"},
|
| 364 |
+
{"id": 322, "name": "Aircraft", "freebase_id": "/m/0k5j"},
|
| 365 |
+
{"id": 323, "name": "Cake stand", "freebase_id": "/m/0h8n6ft"},
|
| 366 |
+
{"id": 324, "name": "Candy", "freebase_id": "/m/0gm28"},
|
| 367 |
+
{"id": 325, "name": "Sink", "freebase_id": "/m/0130jx"},
|
| 368 |
+
{"id": 326, "name": "Mouse", "freebase_id": "/m/04rmv"},
|
| 369 |
+
{"id": 327, "name": "Wine", "freebase_id": "/m/081qc"},
|
| 370 |
+
{"id": 328, "name": "Wheelchair", "freebase_id": "/m/0qmmr"},
|
| 371 |
+
{"id": 329, "name": "Goldfish", "freebase_id": "/m/03fj2"},
|
| 372 |
+
{"id": 330, "name": "Refrigerator", "freebase_id": "/m/040b_t"},
|
| 373 |
+
{"id": 331, "name": "French fries", "freebase_id": "/m/02y6n"},
|
| 374 |
+
{"id": 332, "name": "Drawer", "freebase_id": "/m/0fqfqc"},
|
| 375 |
+
{"id": 333, "name": "Treadmill", "freebase_id": "/m/030610"},
|
| 376 |
+
{"id": 334, "name": "Picnic basket", "freebase_id": "/m/07kng9"},
|
| 377 |
+
{"id": 335, "name": "Dice", "freebase_id": "/m/029b3"},
|
| 378 |
+
{"id": 336, "name": "Cabbage", "freebase_id": "/m/0fbw6"},
|
| 379 |
+
{"id": 337, "name": "Football helmet", "freebase_id": "/m/07qxg_"},
|
| 380 |
+
{"id": 338, "name": "Pig", "freebase_id": "/m/068zj"},
|
| 381 |
+
{"id": 339, "name": "Person", "freebase_id": "/m/01g317"},
|
| 382 |
+
{"id": 340, "name": "Shorts", "freebase_id": "/m/01bfm9"},
|
| 383 |
+
{"id": 341, "name": "Gondola", "freebase_id": "/m/02068x"},
|
| 384 |
+
{"id": 342, "name": "Honeycomb", "freebase_id": "/m/0fz0h"},
|
| 385 |
+
{"id": 343, "name": "Doughnut", "freebase_id": "/m/0jy4k"},
|
| 386 |
+
{"id": 344, "name": "Chest of drawers", "freebase_id": "/m/05kyg_"},
|
| 387 |
+
{"id": 345, "name": "Land vehicle", "freebase_id": "/m/01prls"},
|
| 388 |
+
{"id": 346, "name": "Bat", "freebase_id": "/m/01h44"},
|
| 389 |
+
{"id": 347, "name": "Monkey", "freebase_id": "/m/08pbxl"},
|
| 390 |
+
{"id": 348, "name": "Dagger", "freebase_id": "/m/02gzp"},
|
| 391 |
+
{"id": 349, "name": "Tableware", "freebase_id": "/m/04brg2"},
|
| 392 |
+
{"id": 350, "name": "Human foot", "freebase_id": "/m/031n1"},
|
| 393 |
+
{"id": 351, "name": "Mug", "freebase_id": "/m/02jvh9"},
|
| 394 |
+
{"id": 352, "name": "Alarm clock", "freebase_id": "/m/046dlr"},
|
| 395 |
+
{"id": 353, "name": "Pressure cooker", "freebase_id": "/m/0h8ntjv"},
|
| 396 |
+
{"id": 354, "name": "Human hand", "freebase_id": "/m/0k65p"},
|
| 397 |
+
{"id": 355, "name": "Tortoise", "freebase_id": "/m/011k07"},
|
| 398 |
+
{"id": 356, "name": "Baseball glove", "freebase_id": "/m/03grzl"},
|
| 399 |
+
{"id": 357, "name": "Sword", "freebase_id": "/m/06y5r"},
|
| 400 |
+
{"id": 358, "name": "Pear", "freebase_id": "/m/061_f"},
|
| 401 |
+
{"id": 359, "name": "Miniskirt", "freebase_id": "/m/01cmb2"},
|
| 402 |
+
{"id": 360, "name": "Traffic sign", "freebase_id": "/m/01mqdt"},
|
| 403 |
+
{"id": 361, "name": "Girl", "freebase_id": "/m/05r655"},
|
| 404 |
+
{"id": 362, "name": "Roller skates", "freebase_id": "/m/02p3w7d"},
|
| 405 |
+
{"id": 363, "name": "Dinosaur", "freebase_id": "/m/029tx"},
|
| 406 |
+
{"id": 364, "name": "Porch", "freebase_id": "/m/04m6gz"},
|
| 407 |
+
{"id": 365, "name": "Human beard", "freebase_id": "/m/015h_t"},
|
| 408 |
+
{"id": 366, "name": "Submarine sandwich", "freebase_id": "/m/06pcq"},
|
| 409 |
+
{"id": 367, "name": "Screwdriver", "freebase_id": "/m/01bms0"},
|
| 410 |
+
{"id": 368, "name": "Strawberry", "freebase_id": "/m/07fbm7"},
|
| 411 |
+
{"id": 369, "name": "Wine glass", "freebase_id": "/m/09tvcd"},
|
| 412 |
+
{"id": 370, "name": "Seafood", "freebase_id": "/m/06nwz"},
|
| 413 |
+
{"id": 371, "name": "Racket", "freebase_id": "/m/0dv9c"},
|
| 414 |
+
{"id": 372, "name": "Wheel", "freebase_id": "/m/083wq"},
|
| 415 |
+
{"id": 373, "name": "Sea lion", "freebase_id": "/m/0gd36"},
|
| 416 |
+
{"id": 374, "name": "Toy", "freebase_id": "/m/0138tl"},
|
| 417 |
+
{"id": 375, "name": "Tea", "freebase_id": "/m/07clx"},
|
| 418 |
+
{"id": 376, "name": "Tennis ball", "freebase_id": "/m/05ctyq"},
|
| 419 |
+
{"id": 377, "name": "Waste container", "freebase_id": "/m/0bjyj5"},
|
| 420 |
+
{"id": 378, "name": "Mule", "freebase_id": "/m/0dbzx"},
|
| 421 |
+
{"id": 379, "name": "Cricket ball", "freebase_id": "/m/02ctlc"},
|
| 422 |
+
{"id": 380, "name": "Pineapple", "freebase_id": "/m/0fp6w"},
|
| 423 |
+
{"id": 381, "name": "Coconut", "freebase_id": "/m/0djtd"},
|
| 424 |
+
{"id": 382, "name": "Doll", "freebase_id": "/m/0167gd"},
|
| 425 |
+
{"id": 383, "name": "Coffee table", "freebase_id": "/m/078n6m"},
|
| 426 |
+
{"id": 384, "name": "Snowman", "freebase_id": "/m/0152hh"},
|
| 427 |
+
{"id": 385, "name": "Lavender", "freebase_id": "/m/04gth"},
|
| 428 |
+
{"id": 386, "name": "Shrimp", "freebase_id": "/m/0ll1f78"},
|
| 429 |
+
{"id": 387, "name": "Maple", "freebase_id": "/m/0cffdh"},
|
| 430 |
+
{"id": 388, "name": "Cowboy hat", "freebase_id": "/m/025rp__"},
|
| 431 |
+
{"id": 389, "name": "Goggles", "freebase_id": "/m/02_n6y"},
|
| 432 |
+
{"id": 390, "name": "Rugby ball", "freebase_id": "/m/0wdt60w"},
|
| 433 |
+
{"id": 391, "name": "Caterpillar", "freebase_id": "/m/0cydv"},
|
| 434 |
+
{"id": 392, "name": "Poster", "freebase_id": "/m/01n5jq"},
|
| 435 |
+
{"id": 393, "name": "Rocket", "freebase_id": "/m/09rvcxw"},
|
| 436 |
+
{"id": 394, "name": "Organ", "freebase_id": "/m/013y1f"},
|
| 437 |
+
{"id": 395, "name": "Saxophone", "freebase_id": "/m/06ncr"},
|
| 438 |
+
{"id": 396, "name": "Traffic light", "freebase_id": "/m/015qff"},
|
| 439 |
+
{"id": 397, "name": "Cocktail", "freebase_id": "/m/024g6"},
|
| 440 |
+
{"id": 398, "name": "Plastic bag", "freebase_id": "/m/05gqfk"},
|
| 441 |
+
{"id": 399, "name": "Squash", "freebase_id": "/m/0dv77"},
|
| 442 |
+
{"id": 400, "name": "Mushroom", "freebase_id": "/m/052sf"},
|
| 443 |
+
{"id": 401, "name": "Hamburger", "freebase_id": "/m/0cdn1"},
|
| 444 |
+
{"id": 402, "name": "Light switch", "freebase_id": "/m/03jbxj"},
|
| 445 |
+
{"id": 403, "name": "Parachute", "freebase_id": "/m/0cyfs"},
|
| 446 |
+
{"id": 404, "name": "Teddy bear", "freebase_id": "/m/0kmg4"},
|
| 447 |
+
{"id": 405, "name": "Winter melon", "freebase_id": "/m/02cvgx"},
|
| 448 |
+
{"id": 406, "name": "Deer", "freebase_id": "/m/09kx5"},
|
| 449 |
+
{"id": 407, "name": "Musical keyboard", "freebase_id": "/m/057cc"},
|
| 450 |
+
{"id": 408, "name": "Plumbing fixture", "freebase_id": "/m/02pkr5"},
|
| 451 |
+
{"id": 409, "name": "Scoreboard", "freebase_id": "/m/057p5t"},
|
| 452 |
+
{"id": 410, "name": "Baseball bat", "freebase_id": "/m/03g8mr"},
|
| 453 |
+
{"id": 411, "name": "Envelope", "freebase_id": "/m/0frqm"},
|
| 454 |
+
{"id": 412, "name": "Adhesive tape", "freebase_id": "/m/03m3vtv"},
|
| 455 |
+
{"id": 413, "name": "Briefcase", "freebase_id": "/m/0584n8"},
|
| 456 |
+
{"id": 414, "name": "Paddle", "freebase_id": "/m/014y4n"},
|
| 457 |
+
{"id": 415, "name": "Bow and arrow", "freebase_id": "/m/01g3x7"},
|
| 458 |
+
{"id": 416, "name": "Telephone", "freebase_id": "/m/07cx4"},
|
| 459 |
+
{"id": 417, "name": "Sheep", "freebase_id": "/m/07bgp"},
|
| 460 |
+
{"id": 418, "name": "Jacket", "freebase_id": "/m/032b3c"},
|
| 461 |
+
{"id": 419, "name": "Boy", "freebase_id": "/m/01bl7v"},
|
| 462 |
+
{"id": 420, "name": "Pizza", "freebase_id": "/m/0663v"},
|
| 463 |
+
{"id": 421, "name": "Otter", "freebase_id": "/m/0cn6p"},
|
| 464 |
+
{"id": 422, "name": "Office supplies", "freebase_id": "/m/02rdsp"},
|
| 465 |
+
{"id": 423, "name": "Couch", "freebase_id": "/m/02crq1"},
|
| 466 |
+
{"id": 424, "name": "Cello", "freebase_id": "/m/01xqw"},
|
| 467 |
+
{"id": 425, "name": "Bull", "freebase_id": "/m/0cnyhnx"},
|
| 468 |
+
{"id": 426, "name": "Camel", "freebase_id": "/m/01x_v"},
|
| 469 |
+
{"id": 427, "name": "Ball", "freebase_id": "/m/018xm"},
|
| 470 |
+
{"id": 428, "name": "Duck", "freebase_id": "/m/09ddx"},
|
| 471 |
+
{"id": 429, "name": "Whale", "freebase_id": "/m/084zz"},
|
| 472 |
+
{"id": 430, "name": "Shirt", "freebase_id": "/m/01n4qj"},
|
| 473 |
+
{"id": 431, "name": "Tank", "freebase_id": "/m/07cmd"},
|
| 474 |
+
{"id": 432, "name": "Motorcycle", "freebase_id": "/m/04_sv"},
|
| 475 |
+
{"id": 433, "name": "Accordion", "freebase_id": "/m/0mkg"},
|
| 476 |
+
{"id": 434, "name": "Owl", "freebase_id": "/m/09d5_"},
|
| 477 |
+
{"id": 435, "name": "Porcupine", "freebase_id": "/m/0c568"},
|
| 478 |
+
{"id": 436, "name": "Sun hat", "freebase_id": "/m/02wbtzl"},
|
| 479 |
+
{"id": 437, "name": "Nail", "freebase_id": "/m/05bm6"},
|
| 480 |
+
{"id": 438, "name": "Scissors", "freebase_id": "/m/01lsmm"},
|
| 481 |
+
{"id": 439, "name": "Swan", "freebase_id": "/m/0dftk"},
|
| 482 |
+
{"id": 440, "name": "Lamp", "freebase_id": "/m/0dtln"},
|
| 483 |
+
{"id": 441, "name": "Crown", "freebase_id": "/m/0nl46"},
|
| 484 |
+
{"id": 442, "name": "Piano", "freebase_id": "/m/05r5c"},
|
| 485 |
+
{"id": 443, "name": "Sculpture", "freebase_id": "/m/06msq"},
|
| 486 |
+
{"id": 444, "name": "Cheetah", "freebase_id": "/m/0cd4d"},
|
| 487 |
+
{"id": 445, "name": "Oboe", "freebase_id": "/m/05kms"},
|
| 488 |
+
{"id": 446, "name": "Tin can", "freebase_id": "/m/02jnhm"},
|
| 489 |
+
{"id": 447, "name": "Mango", "freebase_id": "/m/0fldg"},
|
| 490 |
+
{"id": 448, "name": "Tripod", "freebase_id": "/m/073bxn"},
|
| 491 |
+
{"id": 449, "name": "Oven", "freebase_id": "/m/029bxz"},
|
| 492 |
+
{"id": 450, "name": "Mouse", "freebase_id": "/m/020lf"},
|
| 493 |
+
{"id": 451, "name": "Barge", "freebase_id": "/m/01btn"},
|
| 494 |
+
{"id": 452, "name": "Coffee", "freebase_id": "/m/02vqfm"},
|
| 495 |
+
{"id": 453, "name": "Snowboard", "freebase_id": "/m/06__v"},
|
| 496 |
+
{"id": 454, "name": "Common fig", "freebase_id": "/m/043nyj"},
|
| 497 |
+
{"id": 455, "name": "Salad", "freebase_id": "/m/0grw1"},
|
| 498 |
+
{"id": 456, "name": "Marine invertebrates", "freebase_id": "/m/03hl4l9"},
|
| 499 |
+
{"id": 457, "name": "Umbrella", "freebase_id": "/m/0hnnb"},
|
| 500 |
+
{"id": 458, "name": "Kangaroo", "freebase_id": "/m/04c0y"},
|
| 501 |
+
{"id": 459, "name": "Human arm", "freebase_id": "/m/0dzf4"},
|
| 502 |
+
{"id": 460, "name": "Measuring cup", "freebase_id": "/m/07v9_z"},
|
| 503 |
+
{"id": 461, "name": "Snail", "freebase_id": "/m/0f9_l"},
|
| 504 |
+
{"id": 462, "name": "Loveseat", "freebase_id": "/m/0703r8"},
|
| 505 |
+
{"id": 463, "name": "Suit", "freebase_id": "/m/01xyhv"},
|
| 506 |
+
{"id": 464, "name": "Teapot", "freebase_id": "/m/01fh4r"},
|
| 507 |
+
{"id": 465, "name": "Bottle", "freebase_id": "/m/04dr76w"},
|
| 508 |
+
{"id": 466, "name": "Alpaca", "freebase_id": "/m/0pcr"},
|
| 509 |
+
{"id": 467, "name": "Kettle", "freebase_id": "/m/03s_tn"},
|
| 510 |
+
{"id": 468, "name": "Trousers", "freebase_id": "/m/07mhn"},
|
| 511 |
+
{"id": 469, "name": "Popcorn", "freebase_id": "/m/01hrv5"},
|
| 512 |
+
{"id": 470, "name": "Centipede", "freebase_id": "/m/019h78"},
|
| 513 |
+
{"id": 471, "name": "Spider", "freebase_id": "/m/09kmb"},
|
| 514 |
+
{"id": 472, "name": "Sparrow", "freebase_id": "/m/0h23m"},
|
| 515 |
+
{"id": 473, "name": "Plate", "freebase_id": "/m/050gv4"},
|
| 516 |
+
{"id": 474, "name": "Bagel", "freebase_id": "/m/01fb_0"},
|
| 517 |
+
{"id": 475, "name": "Personal care", "freebase_id": "/m/02w3_ws"},
|
| 518 |
+
{"id": 476, "name": "Apple", "freebase_id": "/m/014j1m"},
|
| 519 |
+
{"id": 477, "name": "Brassiere", "freebase_id": "/m/01gmv2"},
|
| 520 |
+
{"id": 478, "name": "Bathroom cabinet", "freebase_id": "/m/04y4h8h"},
|
| 521 |
+
{"id": 479, "name": "studio couch", "freebase_id": "/m/026qbn5"},
|
| 522 |
+
{"id": 480, "name": "Computer keyboard", "freebase_id": "/m/01m2v"},
|
| 523 |
+
{"id": 481, "name": "Table tennis racket", "freebase_id": "/m/05_5p_0"},
|
| 524 |
+
{"id": 482, "name": "Sushi", "freebase_id": "/m/07030"},
|
| 525 |
+
{"id": 483, "name": "Cabinetry", "freebase_id": "/m/01s105"},
|
| 526 |
+
{"id": 484, "name": "Street light", "freebase_id": "/m/033rq4"},
|
| 527 |
+
{"id": 485, "name": "Towel", "freebase_id": "/m/0162_1"},
|
| 528 |
+
{"id": 486, "name": "Nightstand", "freebase_id": "/m/02z51p"},
|
| 529 |
+
{"id": 487, "name": "Rabbit", "freebase_id": "/m/06mf6"},
|
| 530 |
+
{"id": 488, "name": "Dolphin", "freebase_id": "/m/02hj4"},
|
| 531 |
+
{"id": 489, "name": "Dog", "freebase_id": "/m/0bt9lr"},
|
| 532 |
+
{"id": 490, "name": "Jug", "freebase_id": "/m/08hvt4"},
|
| 533 |
+
{"id": 491, "name": "Wok", "freebase_id": "/m/084rd"},
|
| 534 |
+
{"id": 492, "name": "Fire hydrant", "freebase_id": "/m/01pns0"},
|
| 535 |
+
{"id": 493, "name": "Human eye", "freebase_id": "/m/014sv8"},
|
| 536 |
+
{"id": 494, "name": "Skyscraper", "freebase_id": "/m/079cl"},
|
| 537 |
+
{"id": 495, "name": "Backpack", "freebase_id": "/m/01940j"},
|
| 538 |
+
{"id": 496, "name": "Potato", "freebase_id": "/m/05vtc"},
|
| 539 |
+
{"id": 497, "name": "Paper towel", "freebase_id": "/m/02w3r3"},
|
| 540 |
+
{"id": 498, "name": "Lifejacket", "freebase_id": "/m/054xkw"},
|
| 541 |
+
{"id": 499, "name": "Bicycle wheel", "freebase_id": "/m/01bqk0"},
|
| 542 |
+
{"id": 500, "name": "Toilet", "freebase_id": "/m/09g1w"},
|
| 543 |
+
]
|
| 544 |
+
|
| 545 |
+
|
| 546 |
+
OPENIMAGES_V6_CATEGORIES = [
|
| 547 |
+
{"id": 1, "name": "Tortoise", "freebase_id": "/m/011k07"},
|
| 548 |
+
{"id": 2, "name": "Container", "freebase_id": "/m/011q46kg"},
|
| 549 |
+
{"id": 3, "name": "Magpie", "freebase_id": "/m/012074"},
|
| 550 |
+
{"id": 4, "name": "Sea turtle", "freebase_id": "/m/0120dh"},
|
| 551 |
+
{"id": 5, "name": "Football", "freebase_id": "/m/01226z"},
|
| 552 |
+
{"id": 6, "name": "Ambulance", "freebase_id": "/m/012n7d"},
|
| 553 |
+
{"id": 7, "name": "Ladder", "freebase_id": "/m/012w5l"},
|
| 554 |
+
{"id": 8, "name": "Toothbrush", "freebase_id": "/m/012xff"},
|
| 555 |
+
{"id": 9, "name": "Syringe", "freebase_id": "/m/012ysf"},
|
| 556 |
+
{"id": 10, "name": "Sink", "freebase_id": "/m/0130jx"},
|
| 557 |
+
{"id": 11, "name": "Toy", "freebase_id": "/m/0138tl"},
|
| 558 |
+
{"id": 12, "name": "Organ (Musical Instrument)", "freebase_id": "/m/013y1f"},
|
| 559 |
+
{"id": 13, "name": "Cassette deck", "freebase_id": "/m/01432t"},
|
| 560 |
+
{"id": 14, "name": "Apple", "freebase_id": "/m/014j1m"},
|
| 561 |
+
{"id": 15, "name": "Human eye", "freebase_id": "/m/014sv8"},
|
| 562 |
+
{"id": 16, "name": "Cosmetics", "freebase_id": "/m/014trl"},
|
| 563 |
+
{"id": 17, "name": "Paddle", "freebase_id": "/m/014y4n"},
|
| 564 |
+
{"id": 18, "name": "Snowman", "freebase_id": "/m/0152hh"},
|
| 565 |
+
{"id": 19, "name": "Beer", "freebase_id": "/m/01599"},
|
| 566 |
+
{"id": 20, "name": "Chopsticks", "freebase_id": "/m/01_5g"},
|
| 567 |
+
{"id": 21, "name": "Human beard", "freebase_id": "/m/015h_t"},
|
| 568 |
+
{"id": 22, "name": "Bird", "freebase_id": "/m/015p6"},
|
| 569 |
+
{"id": 23, "name": "Parking meter", "freebase_id": "/m/015qbp"},
|
| 570 |
+
{"id": 24, "name": "Traffic light", "freebase_id": "/m/015qff"},
|
| 571 |
+
{"id": 25, "name": "Croissant", "freebase_id": "/m/015wgc"},
|
| 572 |
+
{"id": 26, "name": "Cucumber", "freebase_id": "/m/015x4r"},
|
| 573 |
+
{"id": 27, "name": "Radish", "freebase_id": "/m/015x5n"},
|
| 574 |
+
{"id": 28, "name": "Towel", "freebase_id": "/m/0162_1"},
|
| 575 |
+
{"id": 29, "name": "Doll", "freebase_id": "/m/0167gd"},
|
| 576 |
+
{"id": 30, "name": "Skull", "freebase_id": "/m/016m2d"},
|
| 577 |
+
{"id": 31, "name": "Washing machine", "freebase_id": "/m/0174k2"},
|
| 578 |
+
{"id": 32, "name": "Glove", "freebase_id": "/m/0174n1"},
|
| 579 |
+
{"id": 33, "name": "Tick", "freebase_id": "/m/0175cv"},
|
| 580 |
+
{"id": 34, "name": "Belt", "freebase_id": "/m/0176mf"},
|
| 581 |
+
{"id": 35, "name": "Sunglasses", "freebase_id": "/m/017ftj"},
|
| 582 |
+
{"id": 36, "name": "Banjo", "freebase_id": "/m/018j2"},
|
| 583 |
+
{"id": 37, "name": "Cart", "freebase_id": "/m/018p4k"},
|
| 584 |
+
{"id": 38, "name": "Ball", "freebase_id": "/m/018xm"},
|
| 585 |
+
{"id": 39, "name": "Backpack", "freebase_id": "/m/01940j"},
|
| 586 |
+
{"id": 40, "name": "Bicycle", "freebase_id": "/m/0199g"},
|
| 587 |
+
{"id": 41, "name": "Home appliance", "freebase_id": "/m/019dx1"},
|
| 588 |
+
{"id": 42, "name": "Centipede", "freebase_id": "/m/019h78"},
|
| 589 |
+
{"id": 43, "name": "Boat", "freebase_id": "/m/019jd"},
|
| 590 |
+
{"id": 44, "name": "Surfboard", "freebase_id": "/m/019w40"},
|
| 591 |
+
{"id": 45, "name": "Boot", "freebase_id": "/m/01b638"},
|
| 592 |
+
{"id": 46, "name": "Headphones", "freebase_id": "/m/01b7fy"},
|
| 593 |
+
{"id": 47, "name": "Hot dog", "freebase_id": "/m/01b9xk"},
|
| 594 |
+
{"id": 48, "name": "Shorts", "freebase_id": "/m/01bfm9"},
|
| 595 |
+
{"id": 49, "name": "Fast food", "freebase_id": "/m/01_bhs"},
|
| 596 |
+
{"id": 50, "name": "Bus", "freebase_id": "/m/01bjv"},
|
| 597 |
+
{"id": 51, "name": "Boy", "freebase_id": "/m/01bl7v"},
|
| 598 |
+
{"id": 52, "name": "Screwdriver", "freebase_id": "/m/01bms0"},
|
| 599 |
+
{"id": 53, "name": "Bicycle wheel", "freebase_id": "/m/01bqk0"},
|
| 600 |
+
{"id": 54, "name": "Barge", "freebase_id": "/m/01btn"},
|
| 601 |
+
{"id": 55, "name": "Laptop", "freebase_id": "/m/01c648"},
|
| 602 |
+
{"id": 56, "name": "Miniskirt", "freebase_id": "/m/01cmb2"},
|
| 603 |
+
{"id": 57, "name": "Drill (Tool)", "freebase_id": "/m/01d380"},
|
| 604 |
+
{"id": 58, "name": "Dress", "freebase_id": "/m/01d40f"},
|
| 605 |
+
{"id": 59, "name": "Bear", "freebase_id": "/m/01dws"},
|
| 606 |
+
{"id": 60, "name": "Waffle", "freebase_id": "/m/01dwsz"},
|
| 607 |
+
{"id": 61, "name": "Pancake", "freebase_id": "/m/01dwwc"},
|
| 608 |
+
{"id": 62, "name": "Brown bear", "freebase_id": "/m/01dxs"},
|
| 609 |
+
{"id": 63, "name": "Woodpecker", "freebase_id": "/m/01dy8n"},
|
| 610 |
+
{"id": 64, "name": "Blue jay", "freebase_id": "/m/01f8m5"},
|
| 611 |
+
{"id": 65, "name": "Pretzel", "freebase_id": "/m/01f91_"},
|
| 612 |
+
{"id": 66, "name": "Bagel", "freebase_id": "/m/01fb_0"},
|
| 613 |
+
{"id": 67, "name": "Tower", "freebase_id": "/m/01fdzj"},
|
| 614 |
+
{"id": 68, "name": "Teapot", "freebase_id": "/m/01fh4r"},
|
| 615 |
+
{"id": 69, "name": "Person", "freebase_id": "/m/01g317"},
|
| 616 |
+
{"id": 70, "name": "Bow and arrow", "freebase_id": "/m/01g3x7"},
|
| 617 |
+
{"id": 71, "name": "Swimwear", "freebase_id": "/m/01gkx_"},
|
| 618 |
+
{"id": 72, "name": "Beehive", "freebase_id": "/m/01gllr"},
|
| 619 |
+
{"id": 73, "name": "Brassiere", "freebase_id": "/m/01gmv2"},
|
| 620 |
+
{"id": 74, "name": "Bee", "freebase_id": "/m/01h3n"},
|
| 621 |
+
{"id": 75, "name": "Bat (Animal)", "freebase_id": "/m/01h44"},
|
| 622 |
+
{"id": 76, "name": "Starfish", "freebase_id": "/m/01h8tj"},
|
| 623 |
+
{"id": 77, "name": "Popcorn", "freebase_id": "/m/01hrv5"},
|
| 624 |
+
{"id": 78, "name": "Burrito", "freebase_id": "/m/01j3zr"},
|
| 625 |
+
{"id": 79, "name": "Chainsaw", "freebase_id": "/m/01j4z9"},
|
| 626 |
+
{"id": 80, "name": "Balloon", "freebase_id": "/m/01j51"},
|
| 627 |
+
{"id": 81, "name": "Wrench", "freebase_id": "/m/01j5ks"},
|
| 628 |
+
{"id": 82, "name": "Tent", "freebase_id": "/m/01j61q"},
|
| 629 |
+
{"id": 83, "name": "Vehicle registration plate", "freebase_id": "/m/01jfm_"},
|
| 630 |
+
{"id": 84, "name": "Lantern", "freebase_id": "/m/01jfsr"},
|
| 631 |
+
{"id": 85, "name": "Toaster", "freebase_id": "/m/01k6s3"},
|
| 632 |
+
{"id": 86, "name": "Flashlight", "freebase_id": "/m/01kb5b"},
|
| 633 |
+
{"id": 87, "name": "Billboard", "freebase_id": "/m/01knjb"},
|
| 634 |
+
{"id": 88, "name": "Tiara", "freebase_id": "/m/01krhy"},
|
| 635 |
+
{"id": 89, "name": "Limousine", "freebase_id": "/m/01lcw4"},
|
| 636 |
+
{"id": 90, "name": "Necklace", "freebase_id": "/m/01llwg"},
|
| 637 |
+
{"id": 91, "name": "Carnivore", "freebase_id": "/m/01lrl"},
|
| 638 |
+
{"id": 92, "name": "Scissors", "freebase_id": "/m/01lsmm"},
|
| 639 |
+
{"id": 93, "name": "Stairs", "freebase_id": "/m/01lynh"},
|
| 640 |
+
{"id": 94, "name": "Computer keyboard", "freebase_id": "/m/01m2v"},
|
| 641 |
+
{"id": 95, "name": "Printer", "freebase_id": "/m/01m4t"},
|
| 642 |
+
{"id": 96, "name": "Traffic sign", "freebase_id": "/m/01mqdt"},
|
| 643 |
+
{"id": 97, "name": "Chair", "freebase_id": "/m/01mzpv"},
|
| 644 |
+
{"id": 98, "name": "Shirt", "freebase_id": "/m/01n4qj"},
|
| 645 |
+
{"id": 99, "name": "Poster", "freebase_id": "/m/01n5jq"},
|
| 646 |
+
{"id": 100, "name": "Cheese", "freebase_id": "/m/01nkt"},
|
| 647 |
+
{"id": 101, "name": "Sock", "freebase_id": "/m/01nq26"},
|
| 648 |
+
{"id": 102, "name": "Fire hydrant", "freebase_id": "/m/01pns0"},
|
| 649 |
+
{"id": 103, "name": "Land vehicle", "freebase_id": "/m/01prls"},
|
| 650 |
+
{"id": 104, "name": "Earrings", "freebase_id": "/m/01r546"},
|
| 651 |
+
{"id": 105, "name": "Tie", "freebase_id": "/m/01rkbr"},
|
| 652 |
+
{"id": 106, "name": "Watercraft", "freebase_id": "/m/01rzcn"},
|
| 653 |
+
{"id": 107, "name": "Cabinetry", "freebase_id": "/m/01s105"},
|
| 654 |
+
{"id": 108, "name": "Suitcase", "freebase_id": "/m/01s55n"},
|
| 655 |
+
{"id": 109, "name": "Muffin", "freebase_id": "/m/01tcjp"},
|
| 656 |
+
{"id": 110, "name": "Bidet", "freebase_id": "/m/01vbnl"},
|
| 657 |
+
{"id": 111, "name": "Snack", "freebase_id": "/m/01ww8y"},
|
| 658 |
+
{"id": 112, "name": "Snowmobile", "freebase_id": "/m/01x3jk"},
|
| 659 |
+
{"id": 113, "name": "Clock", "freebase_id": "/m/01x3z"},
|
| 660 |
+
{"id": 114, "name": "Medical equipment", "freebase_id": "/m/01xgg_"},
|
| 661 |
+
{"id": 115, "name": "Cattle", "freebase_id": "/m/01xq0k1"},
|
| 662 |
+
{"id": 116, "name": "Cello", "freebase_id": "/m/01xqw"},
|
| 663 |
+
{"id": 117, "name": "Jet ski", "freebase_id": "/m/01xs3r"},
|
| 664 |
+
{"id": 118, "name": "Camel", "freebase_id": "/m/01x_v"},
|
| 665 |
+
{"id": 119, "name": "Coat", "freebase_id": "/m/01xygc"},
|
| 666 |
+
{"id": 120, "name": "Suit", "freebase_id": "/m/01xyhv"},
|
| 667 |
+
{"id": 121, "name": "Desk", "freebase_id": "/m/01y9k5"},
|
| 668 |
+
{"id": 122, "name": "Cat", "freebase_id": "/m/01yrx"},
|
| 669 |
+
{"id": 123, "name": "Bronze sculpture", "freebase_id": "/m/01yx86"},
|
| 670 |
+
{"id": 124, "name": "Juice", "freebase_id": "/m/01z1kdw"},
|
| 671 |
+
{"id": 125, "name": "Gondola", "freebase_id": "/m/02068x"},
|
| 672 |
+
{"id": 126, "name": "Beetle", "freebase_id": "/m/020jm"},
|
| 673 |
+
{"id": 127, "name": "Cannon", "freebase_id": "/m/020kz"},
|
| 674 |
+
{"id": 128, "name": "Computer mouse", "freebase_id": "/m/020lf"},
|
| 675 |
+
{"id": 129, "name": "Cookie", "freebase_id": "/m/021mn"},
|
| 676 |
+
{"id": 130, "name": "Office building", "freebase_id": "/m/021sj1"},
|
| 677 |
+
{"id": 131, "name": "Fountain", "freebase_id": "/m/0220r2"},
|
| 678 |
+
{"id": 132, "name": "Coin", "freebase_id": "/m/0242l"},
|
| 679 |
+
{"id": 133, "name": "Calculator", "freebase_id": "/m/024d2"},
|
| 680 |
+
{"id": 134, "name": "Cocktail", "freebase_id": "/m/024g6"},
|
| 681 |
+
{"id": 135, "name": "Computer monitor", "freebase_id": "/m/02522"},
|
| 682 |
+
{"id": 136, "name": "Box", "freebase_id": "/m/025dyy"},
|
| 683 |
+
{"id": 137, "name": "Stapler", "freebase_id": "/m/025fsf"},
|
| 684 |
+
{"id": 138, "name": "Christmas tree", "freebase_id": "/m/025nd"},
|
| 685 |
+
{"id": 139, "name": "Cowboy hat", "freebase_id": "/m/025rp__"},
|
| 686 |
+
{"id": 140, "name": "Hiking equipment", "freebase_id": "/m/0268lbt"},
|
| 687 |
+
{"id": 141, "name": "Studio couch", "freebase_id": "/m/026qbn5"},
|
| 688 |
+
{"id": 142, "name": "Drum", "freebase_id": "/m/026t6"},
|
| 689 |
+
{"id": 143, "name": "Dessert", "freebase_id": "/m/0270h"},
|
| 690 |
+
{"id": 144, "name": "Wine rack", "freebase_id": "/m/0271qf7"},
|
| 691 |
+
{"id": 145, "name": "Drink", "freebase_id": "/m/0271t"},
|
| 692 |
+
{"id": 146, "name": "Zucchini", "freebase_id": "/m/027pcv"},
|
| 693 |
+
{"id": 147, "name": "Ladle", "freebase_id": "/m/027rl48"},
|
| 694 |
+
{"id": 148, "name": "Human mouth", "freebase_id": "/m/0283dt1"},
|
| 695 |
+
{"id": 149, "name": "Dairy Product", "freebase_id": "/m/0284d"},
|
| 696 |
+
{"id": 150, "name": "Dice", "freebase_id": "/m/029b3"},
|
| 697 |
+
{"id": 151, "name": "Oven", "freebase_id": "/m/029bxz"},
|
| 698 |
+
{"id": 152, "name": "Dinosaur", "freebase_id": "/m/029tx"},
|
| 699 |
+
{"id": 153, "name": "Ratchet (Device)", "freebase_id": "/m/02bm9n"},
|
| 700 |
+
{"id": 154, "name": "Couch", "freebase_id": "/m/02crq1"},
|
| 701 |
+
{"id": 155, "name": "Cricket ball", "freebase_id": "/m/02ctlc"},
|
| 702 |
+
{"id": 156, "name": "Winter melon", "freebase_id": "/m/02cvgx"},
|
| 703 |
+
{"id": 157, "name": "Spatula", "freebase_id": "/m/02d1br"},
|
| 704 |
+
{"id": 158, "name": "Whiteboard", "freebase_id": "/m/02d9qx"},
|
| 705 |
+
{"id": 159, "name": "Pencil sharpener", "freebase_id": "/m/02ddwp"},
|
| 706 |
+
{"id": 160, "name": "Door", "freebase_id": "/m/02dgv"},
|
| 707 |
+
{"id": 161, "name": "Hat", "freebase_id": "/m/02dl1y"},
|
| 708 |
+
{"id": 162, "name": "Shower", "freebase_id": "/m/02f9f_"},
|
| 709 |
+
{"id": 163, "name": "Eraser", "freebase_id": "/m/02fh7f"},
|
| 710 |
+
{"id": 164, "name": "Fedora", "freebase_id": "/m/02fq_6"},
|
| 711 |
+
{"id": 165, "name": "Guacamole", "freebase_id": "/m/02g30s"},
|
| 712 |
+
{"id": 166, "name": "Dagger", "freebase_id": "/m/02gzp"},
|
| 713 |
+
{"id": 167, "name": "Scarf", "freebase_id": "/m/02h19r"},
|
| 714 |
+
{"id": 168, "name": "Dolphin", "freebase_id": "/m/02hj4"},
|
| 715 |
+
{"id": 169, "name": "Sombrero", "freebase_id": "/m/02jfl0"},
|
| 716 |
+
{"id": 170, "name": "Tin can", "freebase_id": "/m/02jnhm"},
|
| 717 |
+
{"id": 171, "name": "Mug", "freebase_id": "/m/02jvh9"},
|
| 718 |
+
{"id": 172, "name": "Tap", "freebase_id": "/m/02jz0l"},
|
| 719 |
+
{"id": 173, "name": "Harbor seal", "freebase_id": "/m/02l8p9"},
|
| 720 |
+
{"id": 174, "name": "Stretcher", "freebase_id": "/m/02lbcq"},
|
| 721 |
+
{"id": 175, "name": "Can opener", "freebase_id": "/m/02mqfb"},
|
| 722 |
+
{"id": 176, "name": "Goggles", "freebase_id": "/m/02_n6y"},
|
| 723 |
+
{"id": 177, "name": "Human body", "freebase_id": "/m/02p0tk3"},
|
| 724 |
+
{"id": 178, "name": "Roller skates", "freebase_id": "/m/02p3w7d"},
|
| 725 |
+
{"id": 179, "name": "Coffee cup", "freebase_id": "/m/02p5f1q"},
|
| 726 |
+
{"id": 180, "name": "Cutting board", "freebase_id": "/m/02pdsw"},
|
| 727 |
+
{"id": 181, "name": "Blender", "freebase_id": "/m/02pjr4"},
|
| 728 |
+
{"id": 182, "name": "Plumbing fixture", "freebase_id": "/m/02pkr5"},
|
| 729 |
+
{"id": 183, "name": "Stop sign", "freebase_id": "/m/02pv19"},
|
| 730 |
+
{"id": 184, "name": "Office supplies", "freebase_id": "/m/02rdsp"},
|
| 731 |
+
{"id": 185, "name": "Volleyball (Ball)", "freebase_id": "/m/02rgn06"},
|
| 732 |
+
{"id": 186, "name": "Vase", "freebase_id": "/m/02s195"},
|
| 733 |
+
{"id": 187, "name": "Slow cooker", "freebase_id": "/m/02tsc9"},
|
| 734 |
+
{"id": 188, "name": "Wardrobe", "freebase_id": "/m/02vkqh8"},
|
| 735 |
+
{"id": 189, "name": "Coffee", "freebase_id": "/m/02vqfm"},
|
| 736 |
+
{"id": 190, "name": "Whisk", "freebase_id": "/m/02vwcm"},
|
| 737 |
+
{"id": 191, "name": "Paper towel", "freebase_id": "/m/02w3r3"},
|
| 738 |
+
{"id": 192, "name": "Personal care", "freebase_id": "/m/02w3_ws"},
|
| 739 |
+
{"id": 193, "name": "Food", "freebase_id": "/m/02wbm"},
|
| 740 |
+
{"id": 194, "name": "Sun hat", "freebase_id": "/m/02wbtzl"},
|
| 741 |
+
{"id": 195, "name": "Tree house", "freebase_id": "/m/02wg_p"},
|
| 742 |
+
{"id": 196, "name": "Flying disc", "freebase_id": "/m/02wmf"},
|
| 743 |
+
{"id": 197, "name": "Skirt", "freebase_id": "/m/02wv6h6"},
|
| 744 |
+
{"id": 198, "name": "Gas stove", "freebase_id": "/m/02wv84t"},
|
| 745 |
+
{"id": 199, "name": "Salt and pepper shakers", "freebase_id": "/m/02x8cch"},
|
| 746 |
+
{"id": 200, "name": "Mechanical fan", "freebase_id": "/m/02x984l"},
|
| 747 |
+
{"id": 201, "name": "Face powder", "freebase_id": "/m/02xb7qb"},
|
| 748 |
+
{"id": 202, "name": "Fax", "freebase_id": "/m/02xqq"},
|
| 749 |
+
{"id": 203, "name": "Fruit", "freebase_id": "/m/02xwb"},
|
| 750 |
+
{"id": 204, "name": "French fries", "freebase_id": "/m/02y6n"},
|
| 751 |
+
{"id": 205, "name": "Nightstand", "freebase_id": "/m/02z51p"},
|
| 752 |
+
{"id": 206, "name": "Barrel", "freebase_id": "/m/02zn6n"},
|
| 753 |
+
{"id": 207, "name": "Kite", "freebase_id": "/m/02zt3"},
|
| 754 |
+
{"id": 208, "name": "Tart", "freebase_id": "/m/02zvsm"},
|
| 755 |
+
{"id": 209, "name": "Treadmill", "freebase_id": "/m/030610"},
|
| 756 |
+
{"id": 210, "name": "Fox", "freebase_id": "/m/0306r"},
|
| 757 |
+
{"id": 211, "name": "Flag", "freebase_id": "/m/03120"},
|
| 758 |
+
{"id": 212, "name": "French horn", "freebase_id": "/m/0319l"},
|
| 759 |
+
{"id": 213, "name": "Window blind", "freebase_id": "/m/031b6r"},
|
| 760 |
+
{"id": 214, "name": "Human foot", "freebase_id": "/m/031n1"},
|
| 761 |
+
{"id": 215, "name": "Golf cart", "freebase_id": "/m/0323sq"},
|
| 762 |
+
{"id": 216, "name": "Jacket", "freebase_id": "/m/032b3c"},
|
| 763 |
+
{"id": 217, "name": "Egg (Food)", "freebase_id": "/m/033cnk"},
|
| 764 |
+
{"id": 218, "name": "Street light", "freebase_id": "/m/033rq4"},
|
| 765 |
+
{"id": 219, "name": "Guitar", "freebase_id": "/m/0342h"},
|
| 766 |
+
{"id": 220, "name": "Pillow", "freebase_id": "/m/034c16"},
|
| 767 |
+
{"id": 221, "name": "Human leg", "freebase_id": "/m/035r7c"},
|
| 768 |
+
{"id": 222, "name": "Isopod", "freebase_id": "/m/035vxb"},
|
| 769 |
+
{"id": 223, "name": "Grape", "freebase_id": "/m/0388q"},
|
| 770 |
+
{"id": 224, "name": "Human ear", "freebase_id": "/m/039xj_"},
|
| 771 |
+
{"id": 225, "name": "Power plugs and sockets", "freebase_id": "/m/03bbps"},
|
| 772 |
+
{"id": 226, "name": "Panda", "freebase_id": "/m/03bj1"},
|
| 773 |
+
{"id": 227, "name": "Giraffe", "freebase_id": "/m/03bk1"},
|
| 774 |
+
{"id": 228, "name": "Woman", "freebase_id": "/m/03bt1vf"},
|
| 775 |
+
{"id": 229, "name": "Door handle", "freebase_id": "/m/03c7gz"},
|
| 776 |
+
{"id": 230, "name": "Rhinoceros", "freebase_id": "/m/03d443"},
|
| 777 |
+
{"id": 231, "name": "Bathtub", "freebase_id": "/m/03dnzn"},
|
| 778 |
+
{"id": 232, "name": "Goldfish", "freebase_id": "/m/03fj2"},
|
| 779 |
+
{"id": 233, "name": "Houseplant", "freebase_id": "/m/03fp41"},
|
| 780 |
+
{"id": 234, "name": "Goat", "freebase_id": "/m/03fwl"},
|
| 781 |
+
{"id": 235, "name": "Baseball bat", "freebase_id": "/m/03g8mr"},
|
| 782 |
+
{"id": 236, "name": "Baseball glove", "freebase_id": "/m/03grzl"},
|
| 783 |
+
{"id": 237, "name": "Mixing bowl", "freebase_id": "/m/03hj559"},
|
| 784 |
+
{"id": 238, "name": "Marine invertebrates", "freebase_id": "/m/03hl4l9"},
|
| 785 |
+
{"id": 239, "name": "Kitchen utensil", "freebase_id": "/m/03hlz0c"},
|
| 786 |
+
{"id": 240, "name": "Light switch", "freebase_id": "/m/03jbxj"},
|
| 787 |
+
{"id": 241, "name": "House", "freebase_id": "/m/03jm5"},
|
| 788 |
+
{"id": 242, "name": "Horse", "freebase_id": "/m/03k3r"},
|
| 789 |
+
{"id": 243, "name": "Stationary bicycle", "freebase_id": "/m/03kt2w"},
|
| 790 |
+
{"id": 244, "name": "Hammer", "freebase_id": "/m/03l9g"},
|
| 791 |
+
{"id": 245, "name": "Ceiling fan", "freebase_id": "/m/03ldnb"},
|
| 792 |
+
{"id": 246, "name": "Sofa bed", "freebase_id": "/m/03m3pdh"},
|
| 793 |
+
{"id": 247, "name": "Adhesive tape", "freebase_id": "/m/03m3vtv"},
|
| 794 |
+
{"id": 248, "name": "Harp", "freebase_id": "/m/03m5k"},
|
| 795 |
+
{"id": 249, "name": "Sandal", "freebase_id": "/m/03nfch"},
|
| 796 |
+
{"id": 250, "name": "Bicycle helmet", "freebase_id": "/m/03p3bw"},
|
| 797 |
+
{"id": 251, "name": "Saucer", "freebase_id": "/m/03q5c7"},
|
| 798 |
+
{"id": 252, "name": "Harpsichord", "freebase_id": "/m/03q5t"},
|
| 799 |
+
{"id": 253, "name": "Human hair", "freebase_id": "/m/03q69"},
|
| 800 |
+
{"id": 254, "name": "Heater", "freebase_id": "/m/03qhv5"},
|
| 801 |
+
{"id": 255, "name": "Harmonica", "freebase_id": "/m/03qjg"},
|
| 802 |
+
{"id": 256, "name": "Hamster", "freebase_id": "/m/03qrc"},
|
| 803 |
+
{"id": 257, "name": "Curtain", "freebase_id": "/m/03rszm"},
|
| 804 |
+
{"id": 258, "name": "Bed", "freebase_id": "/m/03ssj5"},
|
| 805 |
+
{"id": 259, "name": "Kettle", "freebase_id": "/m/03s_tn"},
|
| 806 |
+
{"id": 260, "name": "Fireplace", "freebase_id": "/m/03tw93"},
|
| 807 |
+
{"id": 261, "name": "Scale", "freebase_id": "/m/03txqz"},
|
| 808 |
+
{"id": 262, "name": "Drinking straw", "freebase_id": "/m/03v5tg"},
|
| 809 |
+
{"id": 263, "name": "Insect", "freebase_id": "/m/03vt0"},
|
| 810 |
+
{"id": 264, "name": "Hair dryer", "freebase_id": "/m/03wvsk"},
|
| 811 |
+
{"id": 265, "name": "Kitchenware", "freebase_id": "/m/03_wxk"},
|
| 812 |
+
{"id": 266, "name": "Indoor rower", "freebase_id": "/m/03wym"},
|
| 813 |
+
{"id": 267, "name": "Invertebrate", "freebase_id": "/m/03xxp"},
|
| 814 |
+
{"id": 268, "name": "Food processor", "freebase_id": "/m/03y6mg"},
|
| 815 |
+
{"id": 269, "name": "Bookcase", "freebase_id": "/m/03__z0"},
|
| 816 |
+
{"id": 270, "name": "Refrigerator", "freebase_id": "/m/040b_t"},
|
| 817 |
+
{"id": 271, "name": "Wood-burning stove", "freebase_id": "/m/04169hn"},
|
| 818 |
+
{"id": 272, "name": "Punching bag", "freebase_id": "/m/0420v5"},
|
| 819 |
+
{"id": 273, "name": "Common fig", "freebase_id": "/m/043nyj"},
|
| 820 |
+
{"id": 274, "name": "Cocktail shaker", "freebase_id": "/m/0440zs"},
|
| 821 |
+
{"id": 275, "name": "Jaguar (Animal)", "freebase_id": "/m/0449p"},
|
| 822 |
+
{"id": 276, "name": "Golf ball", "freebase_id": "/m/044r5d"},
|
| 823 |
+
{"id": 277, "name": "Fashion accessory", "freebase_id": "/m/0463sg"},
|
| 824 |
+
{"id": 278, "name": "Alarm clock", "freebase_id": "/m/046dlr"},
|
| 825 |
+
{"id": 279, "name": "Filing cabinet", "freebase_id": "/m/047j0r"},
|
| 826 |
+
{"id": 280, "name": "Artichoke", "freebase_id": "/m/047v4b"},
|
| 827 |
+
{"id": 281, "name": "Table", "freebase_id": "/m/04bcr3"},
|
| 828 |
+
{"id": 282, "name": "Tableware", "freebase_id": "/m/04brg2"},
|
| 829 |
+
{"id": 283, "name": "Kangaroo", "freebase_id": "/m/04c0y"},
|
| 830 |
+
{"id": 284, "name": "Koala", "freebase_id": "/m/04cp_"},
|
| 831 |
+
{"id": 285, "name": "Knife", "freebase_id": "/m/04ctx"},
|
| 832 |
+
{"id": 286, "name": "Bottle", "freebase_id": "/m/04dr76w"},
|
| 833 |
+
{"id": 287, "name": "Bottle opener", "freebase_id": "/m/04f5ws"},
|
| 834 |
+
{"id": 288, "name": "Lynx", "freebase_id": "/m/04g2r"},
|
| 835 |
+
{"id": 289, "name": "Lavender (Plant)", "freebase_id": "/m/04gth"},
|
| 836 |
+
{"id": 290, "name": "Lighthouse", "freebase_id": "/m/04h7h"},
|
| 837 |
+
{"id": 291, "name": "Dumbbell", "freebase_id": "/m/04h8sr"},
|
| 838 |
+
{"id": 292, "name": "Human head", "freebase_id": "/m/04hgtk"},
|
| 839 |
+
{"id": 293, "name": "Bowl", "freebase_id": "/m/04kkgm"},
|
| 840 |
+
{"id": 294, "name": "Humidifier", "freebase_id": "/m/04lvq_"},
|
| 841 |
+
{"id": 295, "name": "Porch", "freebase_id": "/m/04m6gz"},
|
| 842 |
+
{"id": 296, "name": "Lizard", "freebase_id": "/m/04m9y"},
|
| 843 |
+
{"id": 297, "name": "Billiard table", "freebase_id": "/m/04p0qw"},
|
| 844 |
+
{"id": 298, "name": "Mammal", "freebase_id": "/m/04rky"},
|
| 845 |
+
{"id": 299, "name": "Mouse", "freebase_id": "/m/04rmv"},
|
| 846 |
+
{"id": 300, "name": "Motorcycle", "freebase_id": "/m/04_sv"},
|
| 847 |
+
{"id": 301, "name": "Musical instrument", "freebase_id": "/m/04szw"},
|
| 848 |
+
{"id": 302, "name": "Swim cap", "freebase_id": "/m/04tn4x"},
|
| 849 |
+
{"id": 303, "name": "Frying pan", "freebase_id": "/m/04v6l4"},
|
| 850 |
+
{"id": 304, "name": "Snowplow", "freebase_id": "/m/04vv5k"},
|
| 851 |
+
{"id": 305, "name": "Bathroom cabinet", "freebase_id": "/m/04y4h8h"},
|
| 852 |
+
{"id": 306, "name": "Missile", "freebase_id": "/m/04ylt"},
|
| 853 |
+
{"id": 307, "name": "Bust", "freebase_id": "/m/04yqq2"},
|
| 854 |
+
{"id": 308, "name": "Man", "freebase_id": "/m/04yx4"},
|
| 855 |
+
{"id": 309, "name": "Waffle iron", "freebase_id": "/m/04z4wx"},
|
| 856 |
+
{"id": 310, "name": "Milk", "freebase_id": "/m/04zpv"},
|
| 857 |
+
{"id": 311, "name": "Ring binder", "freebase_id": "/m/04zwwv"},
|
| 858 |
+
{"id": 312, "name": "Plate", "freebase_id": "/m/050gv4"},
|
| 859 |
+
{"id": 313, "name": "Mobile phone", "freebase_id": "/m/050k8"},
|
| 860 |
+
{"id": 314, "name": "Baked goods", "freebase_id": "/m/052lwg6"},
|
| 861 |
+
{"id": 315, "name": "Mushroom", "freebase_id": "/m/052sf"},
|
| 862 |
+
{"id": 316, "name": "Crutch", "freebase_id": "/m/05441v"},
|
| 863 |
+
{"id": 317, "name": "Pitcher (Container)", "freebase_id": "/m/054fyh"},
|
| 864 |
+
{"id": 318, "name": "Mirror", "freebase_id": "/m/054_l"},
|
| 865 |
+
{"id": 319, "name": "Personal flotation device", "freebase_id": "/m/054xkw"},
|
| 866 |
+
{"id": 320, "name": "Table tennis racket", "freebase_id": "/m/05_5p_0"},
|
| 867 |
+
{"id": 321, "name": "Pencil case", "freebase_id": "/m/05676x"},
|
| 868 |
+
{"id": 322, "name": "Musical keyboard", "freebase_id": "/m/057cc"},
|
| 869 |
+
{"id": 323, "name": "Scoreboard", "freebase_id": "/m/057p5t"},
|
| 870 |
+
{"id": 324, "name": "Briefcase", "freebase_id": "/m/0584n8"},
|
| 871 |
+
{"id": 325, "name": "Kitchen knife", "freebase_id": "/m/058qzx"},
|
| 872 |
+
{"id": 326, "name": "Nail (Construction)", "freebase_id": "/m/05bm6"},
|
| 873 |
+
{"id": 327, "name": "Tennis ball", "freebase_id": "/m/05ctyq"},
|
| 874 |
+
{"id": 328, "name": "Plastic bag", "freebase_id": "/m/05gqfk"},
|
| 875 |
+
{"id": 329, "name": "Oboe", "freebase_id": "/m/05kms"},
|
| 876 |
+
{"id": 330, "name": "Chest of drawers", "freebase_id": "/m/05kyg_"},
|
| 877 |
+
{"id": 331, "name": "Ostrich", "freebase_id": "/m/05n4y"},
|
| 878 |
+
{"id": 332, "name": "Piano", "freebase_id": "/m/05r5c"},
|
| 879 |
+
{"id": 333, "name": "Girl", "freebase_id": "/m/05r655"},
|
| 880 |
+
{"id": 334, "name": "Plant", "freebase_id": "/m/05s2s"},
|
| 881 |
+
{"id": 335, "name": "Potato", "freebase_id": "/m/05vtc"},
|
| 882 |
+
{"id": 336, "name": "Hair spray", "freebase_id": "/m/05w9t9"},
|
| 883 |
+
{"id": 337, "name": "Sports equipment", "freebase_id": "/m/05y5lj"},
|
| 884 |
+
{"id": 338, "name": "Pasta", "freebase_id": "/m/05z55"},
|
| 885 |
+
{"id": 339, "name": "Penguin", "freebase_id": "/m/05z6w"},
|
| 886 |
+
{"id": 340, "name": "Pumpkin", "freebase_id": "/m/05zsy"},
|
| 887 |
+
{"id": 341, "name": "Pear", "freebase_id": "/m/061_f"},
|
| 888 |
+
{"id": 342, "name": "Infant bed", "freebase_id": "/m/061hd_"},
|
| 889 |
+
{"id": 343, "name": "Polar bear", "freebase_id": "/m/0633h"},
|
| 890 |
+
{"id": 344, "name": "Mixer", "freebase_id": "/m/063rgb"},
|
| 891 |
+
{"id": 345, "name": "Cupboard", "freebase_id": "/m/0642b4"},
|
| 892 |
+
{"id": 346, "name": "Jacuzzi", "freebase_id": "/m/065h6l"},
|
| 893 |
+
{"id": 347, "name": "Pizza", "freebase_id": "/m/0663v"},
|
| 894 |
+
{"id": 348, "name": "Digital clock", "freebase_id": "/m/06_72j"},
|
| 895 |
+
{"id": 349, "name": "Pig", "freebase_id": "/m/068zj"},
|
| 896 |
+
{"id": 350, "name": "Reptile", "freebase_id": "/m/06bt6"},
|
| 897 |
+
{"id": 351, "name": "Rifle", "freebase_id": "/m/06c54"},
|
| 898 |
+
{"id": 352, "name": "Lipstick", "freebase_id": "/m/06c7f7"},
|
| 899 |
+
{"id": 353, "name": "Skateboard", "freebase_id": "/m/06_fw"},
|
| 900 |
+
{"id": 354, "name": "Raven", "freebase_id": "/m/06j2d"},
|
| 901 |
+
{"id": 355, "name": "High heels", "freebase_id": "/m/06k2mb"},
|
| 902 |
+
{"id": 356, "name": "Red panda", "freebase_id": "/m/06l9r"},
|
| 903 |
+
{"id": 357, "name": "Rose", "freebase_id": "/m/06m11"},
|
| 904 |
+
{"id": 358, "name": "Rabbit", "freebase_id": "/m/06mf6"},
|
| 905 |
+
{"id": 359, "name": "Sculpture", "freebase_id": "/m/06msq"},
|
| 906 |
+
{"id": 360, "name": "Saxophone", "freebase_id": "/m/06ncr"},
|
| 907 |
+
{"id": 361, "name": "Shotgun", "freebase_id": "/m/06nrc"},
|
| 908 |
+
{"id": 362, "name": "Seafood", "freebase_id": "/m/06nwz"},
|
| 909 |
+
{"id": 363, "name": "Submarine sandwich", "freebase_id": "/m/06pcq"},
|
| 910 |
+
{"id": 364, "name": "Snowboard", "freebase_id": "/m/06__v"},
|
| 911 |
+
{"id": 365, "name": "Sword", "freebase_id": "/m/06y5r"},
|
| 912 |
+
{"id": 366, "name": "Picture frame", "freebase_id": "/m/06z37_"},
|
| 913 |
+
{"id": 367, "name": "Sushi", "freebase_id": "/m/07030"},
|
| 914 |
+
{"id": 368, "name": "Loveseat", "freebase_id": "/m/0703r8"},
|
| 915 |
+
{"id": 369, "name": "Ski", "freebase_id": "/m/071p9"},
|
| 916 |
+
{"id": 370, "name": "Squirrel", "freebase_id": "/m/071qp"},
|
| 917 |
+
{"id": 371, "name": "Tripod", "freebase_id": "/m/073bxn"},
|
| 918 |
+
{"id": 372, "name": "Stethoscope", "freebase_id": "/m/073g6"},
|
| 919 |
+
{"id": 373, "name": "Submarine", "freebase_id": "/m/074d1"},
|
| 920 |
+
{"id": 374, "name": "Scorpion", "freebase_id": "/m/0755b"},
|
| 921 |
+
{"id": 375, "name": "Segway", "freebase_id": "/m/076bq"},
|
| 922 |
+
{"id": 376, "name": "Training bench", "freebase_id": "/m/076lb9"},
|
| 923 |
+
{"id": 377, "name": "Snake", "freebase_id": "/m/078jl"},
|
| 924 |
+
{"id": 378, "name": "Coffee table", "freebase_id": "/m/078n6m"},
|
| 925 |
+
{"id": 379, "name": "Skyscraper", "freebase_id": "/m/079cl"},
|
| 926 |
+
{"id": 380, "name": "Sheep", "freebase_id": "/m/07bgp"},
|
| 927 |
+
{"id": 381, "name": "Television", "freebase_id": "/m/07c52"},
|
| 928 |
+
{"id": 382, "name": "Trombone", "freebase_id": "/m/07c6l"},
|
| 929 |
+
{"id": 383, "name": "Tea", "freebase_id": "/m/07clx"},
|
| 930 |
+
{"id": 384, "name": "Tank", "freebase_id": "/m/07cmd"},
|
| 931 |
+
{"id": 385, "name": "Taco", "freebase_id": "/m/07crc"},
|
| 932 |
+
{"id": 386, "name": "Telephone", "freebase_id": "/m/07cx4"},
|
| 933 |
+
{"id": 387, "name": "Torch", "freebase_id": "/m/07dd4"},
|
| 934 |
+
{"id": 388, "name": "Tiger", "freebase_id": "/m/07dm6"},
|
| 935 |
+
{"id": 389, "name": "Strawberry", "freebase_id": "/m/07fbm7"},
|
| 936 |
+
{"id": 390, "name": "Trumpet", "freebase_id": "/m/07gql"},
|
| 937 |
+
{"id": 391, "name": "Tree", "freebase_id": "/m/07j7r"},
|
| 938 |
+
{"id": 392, "name": "Tomato", "freebase_id": "/m/07j87"},
|
| 939 |
+
{"id": 393, "name": "Train", "freebase_id": "/m/07jdr"},
|
| 940 |
+
{"id": 394, "name": "Tool", "freebase_id": "/m/07k1x"},
|
| 941 |
+
{"id": 395, "name": "Picnic basket", "freebase_id": "/m/07kng9"},
|
| 942 |
+
{"id": 396, "name": "Cooking spray", "freebase_id": "/m/07mcwg"},
|
| 943 |
+
{"id": 397, "name": "Trousers", "freebase_id": "/m/07mhn"},
|
| 944 |
+
{"id": 398, "name": "Bowling equipment", "freebase_id": "/m/07pj7bq"},
|
| 945 |
+
{"id": 399, "name": "Football helmet", "freebase_id": "/m/07qxg_"},
|
| 946 |
+
{"id": 400, "name": "Truck", "freebase_id": "/m/07r04"},
|
| 947 |
+
{"id": 401, "name": "Measuring cup", "freebase_id": "/m/07v9_z"},
|
| 948 |
+
{"id": 402, "name": "Coffeemaker", "freebase_id": "/m/07xyvk"},
|
| 949 |
+
{"id": 403, "name": "Violin", "freebase_id": "/m/07y_7"},
|
| 950 |
+
{"id": 404, "name": "Vehicle", "freebase_id": "/m/07yv9"},
|
| 951 |
+
{"id": 405, "name": "Handbag", "freebase_id": "/m/080hkjn"},
|
| 952 |
+
{"id": 406, "name": "Paper cutter", "freebase_id": "/m/080n7g"},
|
| 953 |
+
{"id": 407, "name": "Wine", "freebase_id": "/m/081qc"},
|
| 954 |
+
{"id": 408, "name": "Weapon", "freebase_id": "/m/083kb"},
|
| 955 |
+
{"id": 409, "name": "Wheel", "freebase_id": "/m/083wq"},
|
| 956 |
+
{"id": 410, "name": "Worm", "freebase_id": "/m/084hf"},
|
| 957 |
+
{"id": 411, "name": "Wok", "freebase_id": "/m/084rd"},
|
| 958 |
+
{"id": 412, "name": "Whale", "freebase_id": "/m/084zz"},
|
| 959 |
+
{"id": 413, "name": "Zebra", "freebase_id": "/m/0898b"},
|
| 960 |
+
{"id": 414, "name": "Auto part", "freebase_id": "/m/08dz3q"},
|
| 961 |
+
{"id": 415, "name": "Jug", "freebase_id": "/m/08hvt4"},
|
| 962 |
+
{"id": 416, "name": "Pizza cutter", "freebase_id": "/m/08ks85"},
|
| 963 |
+
{"id": 417, "name": "Cream", "freebase_id": "/m/08p92x"},
|
| 964 |
+
{"id": 418, "name": "Monkey", "freebase_id": "/m/08pbxl"},
|
| 965 |
+
{"id": 419, "name": "Lion", "freebase_id": "/m/096mb"},
|
| 966 |
+
{"id": 420, "name": "Bread", "freebase_id": "/m/09728"},
|
| 967 |
+
{"id": 421, "name": "Platter", "freebase_id": "/m/099ssp"},
|
| 968 |
+
{"id": 422, "name": "Chicken", "freebase_id": "/m/09b5t"},
|
| 969 |
+
{"id": 423, "name": "Eagle", "freebase_id": "/m/09csl"},
|
| 970 |
+
{"id": 424, "name": "Helicopter", "freebase_id": "/m/09ct_"},
|
| 971 |
+
{"id": 425, "name": "Owl", "freebase_id": "/m/09d5_"},
|
| 972 |
+
{"id": 426, "name": "Duck", "freebase_id": "/m/09ddx"},
|
| 973 |
+
{"id": 427, "name": "Turtle", "freebase_id": "/m/09dzg"},
|
| 974 |
+
{"id": 428, "name": "Hippopotamus", "freebase_id": "/m/09f20"},
|
| 975 |
+
{"id": 429, "name": "Crocodile", "freebase_id": "/m/09f_2"},
|
| 976 |
+
{"id": 430, "name": "Toilet", "freebase_id": "/m/09g1w"},
|
| 977 |
+
{"id": 431, "name": "Toilet paper", "freebase_id": "/m/09gtd"},
|
| 978 |
+
{"id": 432, "name": "Squid", "freebase_id": "/m/09gys"},
|
| 979 |
+
{"id": 433, "name": "Clothing", "freebase_id": "/m/09j2d"},
|
| 980 |
+
{"id": 434, "name": "Footwear", "freebase_id": "/m/09j5n"},
|
| 981 |
+
{"id": 435, "name": "Lemon", "freebase_id": "/m/09k_b"},
|
| 982 |
+
{"id": 436, "name": "Spider", "freebase_id": "/m/09kmb"},
|
| 983 |
+
{"id": 437, "name": "Deer", "freebase_id": "/m/09kx5"},
|
| 984 |
+
{"id": 438, "name": "Frog", "freebase_id": "/m/09ld4"},
|
| 985 |
+
{"id": 439, "name": "Banana", "freebase_id": "/m/09qck"},
|
| 986 |
+
{"id": 440, "name": "Rocket", "freebase_id": "/m/09rvcxw"},
|
| 987 |
+
{"id": 441, "name": "Wine glass", "freebase_id": "/m/09tvcd"},
|
| 988 |
+
{"id": 442, "name": "Countertop", "freebase_id": "/m/0b3fp9"},
|
| 989 |
+
{"id": 443, "name": "Tablet computer", "freebase_id": "/m/0bh9flk"},
|
| 990 |
+
{"id": 444, "name": "Waste container", "freebase_id": "/m/0bjyj5"},
|
| 991 |
+
{"id": 445, "name": "Swimming pool", "freebase_id": "/m/0b_rs"},
|
| 992 |
+
{"id": 446, "name": "Dog", "freebase_id": "/m/0bt9lr"},
|
| 993 |
+
{"id": 447, "name": "Book", "freebase_id": "/m/0bt_c3"},
|
| 994 |
+
{"id": 448, "name": "Elephant", "freebase_id": "/m/0bwd_0j"},
|
| 995 |
+
{"id": 449, "name": "Shark", "freebase_id": "/m/0by6g"},
|
| 996 |
+
{"id": 450, "name": "Candle", "freebase_id": "/m/0c06p"},
|
| 997 |
+
{"id": 451, "name": "Leopard", "freebase_id": "/m/0c29q"},
|
| 998 |
+
{"id": 452, "name": "Axe", "freebase_id": "/m/0c2jj"},
|
| 999 |
+
{"id": 453, "name": "Hand dryer", "freebase_id": "/m/0c3m8g"},
|
| 1000 |
+
{"id": 454, "name": "Soap dispenser", "freebase_id": "/m/0c3mkw"},
|
| 1001 |
+
{"id": 455, "name": "Porcupine", "freebase_id": "/m/0c568"},
|
| 1002 |
+
{"id": 456, "name": "Flower", "freebase_id": "/m/0c9ph5"},
|
| 1003 |
+
{"id": 457, "name": "Canary", "freebase_id": "/m/0ccs93"},
|
| 1004 |
+
{"id": 458, "name": "Cheetah", "freebase_id": "/m/0cd4d"},
|
| 1005 |
+
{"id": 459, "name": "Palm tree", "freebase_id": "/m/0cdl1"},
|
| 1006 |
+
{"id": 460, "name": "Hamburger", "freebase_id": "/m/0cdn1"},
|
| 1007 |
+
{"id": 461, "name": "Maple", "freebase_id": "/m/0cffdh"},
|
| 1008 |
+
{"id": 462, "name": "Building", "freebase_id": "/m/0cgh4"},
|
| 1009 |
+
{"id": 463, "name": "Fish", "freebase_id": "/m/0ch_cf"},
|
| 1010 |
+
{"id": 464, "name": "Lobster", "freebase_id": "/m/0cjq5"},
|
| 1011 |
+
{"id": 465, "name": "Garden Asparagus", "freebase_id": "/m/0cjs7"},
|
| 1012 |
+
{"id": 466, "name": "Furniture", "freebase_id": "/m/0c_jw"},
|
| 1013 |
+
{"id": 467, "name": "Hedgehog", "freebase_id": "/m/0cl4p"},
|
| 1014 |
+
{"id": 468, "name": "Airplane", "freebase_id": "/m/0cmf2"},
|
| 1015 |
+
{"id": 469, "name": "Spoon", "freebase_id": "/m/0cmx8"},
|
| 1016 |
+
{"id": 470, "name": "Otter", "freebase_id": "/m/0cn6p"},
|
| 1017 |
+
{"id": 471, "name": "Bull", "freebase_id": "/m/0cnyhnx"},
|
| 1018 |
+
{"id": 472, "name": "Oyster", "freebase_id": "/m/0_cp5"},
|
| 1019 |
+
{"id": 473, "name": "Horizontal bar", "freebase_id": "/m/0cqn2"},
|
| 1020 |
+
{"id": 474, "name": "Convenience store", "freebase_id": "/m/0crjs"},
|
| 1021 |
+
{"id": 475, "name": "Bomb", "freebase_id": "/m/0ct4f"},
|
| 1022 |
+
{"id": 476, "name": "Bench", "freebase_id": "/m/0cvnqh"},
|
| 1023 |
+
{"id": 477, "name": "Ice cream", "freebase_id": "/m/0cxn2"},
|
| 1024 |
+
{"id": 478, "name": "Caterpillar", "freebase_id": "/m/0cydv"},
|
| 1025 |
+
{"id": 479, "name": "Butterfly", "freebase_id": "/m/0cyf8"},
|
| 1026 |
+
{"id": 480, "name": "Parachute", "freebase_id": "/m/0cyfs"},
|
| 1027 |
+
{"id": 481, "name": "Orange", "freebase_id": "/m/0cyhj_"},
|
| 1028 |
+
{"id": 482, "name": "Antelope", "freebase_id": "/m/0czz2"},
|
| 1029 |
+
{"id": 483, "name": "Beaker", "freebase_id": "/m/0d20w4"},
|
| 1030 |
+
{"id": 484, "name": "Moths and butterflies", "freebase_id": "/m/0d_2m"},
|
| 1031 |
+
{"id": 485, "name": "Window", "freebase_id": "/m/0d4v4"},
|
| 1032 |
+
{"id": 486, "name": "Closet", "freebase_id": "/m/0d4w1"},
|
| 1033 |
+
{"id": 487, "name": "Castle", "freebase_id": "/m/0d5gx"},
|
| 1034 |
+
{"id": 488, "name": "Jellyfish", "freebase_id": "/m/0d8zb"},
|
| 1035 |
+
{"id": 489, "name": "Goose", "freebase_id": "/m/0dbvp"},
|
| 1036 |
+
{"id": 490, "name": "Mule", "freebase_id": "/m/0dbzx"},
|
| 1037 |
+
{"id": 491, "name": "Swan", "freebase_id": "/m/0dftk"},
|
| 1038 |
+
{"id": 492, "name": "Peach", "freebase_id": "/m/0dj6p"},
|
| 1039 |
+
{"id": 493, "name": "Coconut", "freebase_id": "/m/0djtd"},
|
| 1040 |
+
{"id": 494, "name": "Seat belt", "freebase_id": "/m/0dkzw"},
|
| 1041 |
+
{"id": 495, "name": "Raccoon", "freebase_id": "/m/0dq75"},
|
| 1042 |
+
{"id": 496, "name": "Chisel", "freebase_id": "/m/0_dqb"},
|
| 1043 |
+
{"id": 497, "name": "Fork", "freebase_id": "/m/0dt3t"},
|
| 1044 |
+
{"id": 498, "name": "Lamp", "freebase_id": "/m/0dtln"},
|
| 1045 |
+
{"id": 499, "name": "Camera", "freebase_id": "/m/0dv5r"},
|
| 1046 |
+
{"id": 500, "name": "Squash (Plant)", "freebase_id": "/m/0dv77"},
|
| 1047 |
+
{"id": 501, "name": "Racket", "freebase_id": "/m/0dv9c"},
|
| 1048 |
+
{"id": 502, "name": "Human face", "freebase_id": "/m/0dzct"},
|
| 1049 |
+
{"id": 503, "name": "Human arm", "freebase_id": "/m/0dzf4"},
|
| 1050 |
+
{"id": 504, "name": "Vegetable", "freebase_id": "/m/0f4s2w"},
|
| 1051 |
+
{"id": 505, "name": "Diaper", "freebase_id": "/m/0f571"},
|
| 1052 |
+
{"id": 506, "name": "Unicycle", "freebase_id": "/m/0f6nr"},
|
| 1053 |
+
{"id": 507, "name": "Falcon", "freebase_id": "/m/0f6wt"},
|
| 1054 |
+
{"id": 508, "name": "Chime", "freebase_id": "/m/0f8s22"},
|
| 1055 |
+
{"id": 509, "name": "Snail", "freebase_id": "/m/0f9_l"},
|
| 1056 |
+
{"id": 510, "name": "Shellfish", "freebase_id": "/m/0fbdv"},
|
| 1057 |
+
{"id": 511, "name": "Cabbage", "freebase_id": "/m/0fbw6"},
|
| 1058 |
+
{"id": 512, "name": "Carrot", "freebase_id": "/m/0fj52s"},
|
| 1059 |
+
{"id": 513, "name": "Mango", "freebase_id": "/m/0fldg"},
|
| 1060 |
+
{"id": 514, "name": "Jeans", "freebase_id": "/m/0fly7"},
|
| 1061 |
+
{"id": 515, "name": "Flowerpot", "freebase_id": "/m/0fm3zh"},
|
| 1062 |
+
{"id": 516, "name": "Pineapple", "freebase_id": "/m/0fp6w"},
|
| 1063 |
+
{"id": 517, "name": "Drawer", "freebase_id": "/m/0fqfqc"},
|
| 1064 |
+
{"id": 518, "name": "Stool", "freebase_id": "/m/0fqt361"},
|
| 1065 |
+
{"id": 519, "name": "Envelope", "freebase_id": "/m/0frqm"},
|
| 1066 |
+
{"id": 520, "name": "Cake", "freebase_id": "/m/0fszt"},
|
| 1067 |
+
{"id": 521, "name": "Dragonfly", "freebase_id": "/m/0ft9s"},
|
| 1068 |
+
{"id": 522, "name": "Common sunflower", "freebase_id": "/m/0ftb8"},
|
| 1069 |
+
{"id": 523, "name": "Microwave oven", "freebase_id": "/m/0fx9l"},
|
| 1070 |
+
{"id": 524, "name": "Honeycomb", "freebase_id": "/m/0fz0h"},
|
| 1071 |
+
{"id": 525, "name": "Marine mammal", "freebase_id": "/m/0gd2v"},
|
| 1072 |
+
{"id": 526, "name": "Sea lion", "freebase_id": "/m/0gd36"},
|
| 1073 |
+
{"id": 527, "name": "Ladybug", "freebase_id": "/m/0gj37"},
|
| 1074 |
+
{"id": 528, "name": "Shelf", "freebase_id": "/m/0gjbg72"},
|
| 1075 |
+
{"id": 529, "name": "Watch", "freebase_id": "/m/0gjkl"},
|
| 1076 |
+
{"id": 530, "name": "Candy", "freebase_id": "/m/0gm28"},
|
| 1077 |
+
{"id": 531, "name": "Salad", "freebase_id": "/m/0grw1"},
|
| 1078 |
+
{"id": 532, "name": "Parrot", "freebase_id": "/m/0gv1x"},
|
| 1079 |
+
{"id": 533, "name": "Handgun", "freebase_id": "/m/0gxl3"},
|
| 1080 |
+
{"id": 534, "name": "Sparrow", "freebase_id": "/m/0h23m"},
|
| 1081 |
+
{"id": 535, "name": "Van", "freebase_id": "/m/0h2r6"},
|
| 1082 |
+
{"id": 536, "name": "Grinder", "freebase_id": "/m/0h8jyh6"},
|
| 1083 |
+
{"id": 537, "name": "Spice rack", "freebase_id": "/m/0h8kx63"},
|
| 1084 |
+
{"id": 538, "name": "Light bulb", "freebase_id": "/m/0h8l4fh"},
|
| 1085 |
+
{"id": 539, "name": "Corded phone", "freebase_id": "/m/0h8lkj8"},
|
| 1086 |
+
{"id": 540, "name": "Sports uniform", "freebase_id": "/m/0h8mhzd"},
|
| 1087 |
+
{"id": 541, "name": "Tennis racket", "freebase_id": "/m/0h8my_4"},
|
| 1088 |
+
{"id": 542, "name": "Wall clock", "freebase_id": "/m/0h8mzrc"},
|
| 1089 |
+
{"id": 543, "name": "Serving tray", "freebase_id": "/m/0h8n27j"},
|
| 1090 |
+
{"id": 544, "name": "Kitchen & dining room table", "freebase_id": "/m/0h8n5zk"},
|
| 1091 |
+
{"id": 545, "name": "Dog bed", "freebase_id": "/m/0h8n6f9"},
|
| 1092 |
+
{"id": 546, "name": "Cake stand", "freebase_id": "/m/0h8n6ft"},
|
| 1093 |
+
{"id": 547, "name": "Cat furniture", "freebase_id": "/m/0h8nm9j"},
|
| 1094 |
+
{"id": 548, "name": "Bathroom accessory", "freebase_id": "/m/0h8nr_l"},
|
| 1095 |
+
{"id": 549, "name": "Facial tissue holder", "freebase_id": "/m/0h8nsvg"},
|
| 1096 |
+
{"id": 550, "name": "Pressure cooker", "freebase_id": "/m/0h8ntjv"},
|
| 1097 |
+
{"id": 551, "name": "Kitchen appliance", "freebase_id": "/m/0h99cwc"},
|
| 1098 |
+
{"id": 552, "name": "Tire", "freebase_id": "/m/0h9mv"},
|
| 1099 |
+
{"id": 553, "name": "Ruler", "freebase_id": "/m/0hdln"},
|
| 1100 |
+
{"id": 554, "name": "Luggage and bags", "freebase_id": "/m/0hf58v5"},
|
| 1101 |
+
{"id": 555, "name": "Microphone", "freebase_id": "/m/0hg7b"},
|
| 1102 |
+
{"id": 556, "name": "Broccoli", "freebase_id": "/m/0hkxq"},
|
| 1103 |
+
{"id": 557, "name": "Umbrella", "freebase_id": "/m/0hnnb"},
|
| 1104 |
+
{"id": 558, "name": "Pastry", "freebase_id": "/m/0hnyx"},
|
| 1105 |
+
{"id": 559, "name": "Grapefruit", "freebase_id": "/m/0hqkz"},
|
| 1106 |
+
{"id": 560, "name": "Band-aid", "freebase_id": "/m/0j496"},
|
| 1107 |
+
{"id": 561, "name": "Animal", "freebase_id": "/m/0jbk"},
|
| 1108 |
+
{"id": 562, "name": "Bell pepper", "freebase_id": "/m/0jg57"},
|
| 1109 |
+
{"id": 563, "name": "Turkey", "freebase_id": "/m/0jly1"},
|
| 1110 |
+
{"id": 564, "name": "Lily", "freebase_id": "/m/0jqgx"},
|
| 1111 |
+
{"id": 565, "name": "Pomegranate", "freebase_id": "/m/0jwn_"},
|
| 1112 |
+
{"id": 566, "name": "Doughnut", "freebase_id": "/m/0jy4k"},
|
| 1113 |
+
{"id": 567, "name": "Glasses", "freebase_id": "/m/0jyfg"},
|
| 1114 |
+
{"id": 568, "name": "Human nose", "freebase_id": "/m/0k0pj"},
|
| 1115 |
+
{"id": 569, "name": "Pen", "freebase_id": "/m/0k1tl"},
|
| 1116 |
+
{"id": 570, "name": "Ant", "freebase_id": "/m/0_k2"},
|
| 1117 |
+
{"id": 571, "name": "Car", "freebase_id": "/m/0k4j"},
|
| 1118 |
+
{"id": 572, "name": "Aircraft", "freebase_id": "/m/0k5j"},
|
| 1119 |
+
{"id": 573, "name": "Human hand", "freebase_id": "/m/0k65p"},
|
| 1120 |
+
{"id": 574, "name": "Skunk", "freebase_id": "/m/0km7z"},
|
| 1121 |
+
{"id": 575, "name": "Teddy bear", "freebase_id": "/m/0kmg4"},
|
| 1122 |
+
{"id": 576, "name": "Watermelon", "freebase_id": "/m/0kpqd"},
|
| 1123 |
+
{"id": 577, "name": "Cantaloupe", "freebase_id": "/m/0kpt_"},
|
| 1124 |
+
{"id": 578, "name": "Dishwasher", "freebase_id": "/m/0ky7b"},
|
| 1125 |
+
{"id": 579, "name": "Flute", "freebase_id": "/m/0l14j_"},
|
| 1126 |
+
{"id": 580, "name": "Balance beam", "freebase_id": "/m/0l3ms"},
|
| 1127 |
+
{"id": 581, "name": "Sandwich", "freebase_id": "/m/0l515"},
|
| 1128 |
+
{"id": 582, "name": "Shrimp", "freebase_id": "/m/0ll1f78"},
|
| 1129 |
+
{"id": 583, "name": "Sewing machine", "freebase_id": "/m/0llzx"},
|
| 1130 |
+
{"id": 584, "name": "Binoculars", "freebase_id": "/m/0lt4_"},
|
| 1131 |
+
{"id": 585, "name": "Rays and skates", "freebase_id": "/m/0m53l"},
|
| 1132 |
+
{"id": 586, "name": "Ipod", "freebase_id": "/m/0mcx2"},
|
| 1133 |
+
{"id": 587, "name": "Accordion", "freebase_id": "/m/0mkg"},
|
| 1134 |
+
{"id": 588, "name": "Willow", "freebase_id": "/m/0mw_6"},
|
| 1135 |
+
{"id": 589, "name": "Crab", "freebase_id": "/m/0n28_"},
|
| 1136 |
+
{"id": 590, "name": "Crown", "freebase_id": "/m/0nl46"},
|
| 1137 |
+
{"id": 591, "name": "Seahorse", "freebase_id": "/m/0nybt"},
|
| 1138 |
+
{"id": 592, "name": "Perfume", "freebase_id": "/m/0p833"},
|
| 1139 |
+
{"id": 593, "name": "Alpaca", "freebase_id": "/m/0pcr"},
|
| 1140 |
+
{"id": 594, "name": "Taxi", "freebase_id": "/m/0pg52"},
|
| 1141 |
+
{"id": 595, "name": "Canoe", "freebase_id": "/m/0ph39"},
|
| 1142 |
+
{"id": 596, "name": "Remote control", "freebase_id": "/m/0qjjc"},
|
| 1143 |
+
{"id": 597, "name": "Wheelchair", "freebase_id": "/m/0qmmr"},
|
| 1144 |
+
{"id": 598, "name": "Rugby ball", "freebase_id": "/m/0wdt60w"},
|
| 1145 |
+
{"id": 599, "name": "Armadillo", "freebase_id": "/m/0xfy"},
|
| 1146 |
+
{"id": 600, "name": "Maracas", "freebase_id": "/m/0xzly"},
|
| 1147 |
+
{"id": 601, "name": "Helmet", "freebase_id": "/m/0zvk5"},
|
| 1148 |
+
]
|
| 1149 |
+
|
| 1150 |
+
categories_seg = [
|
| 1151 |
+
{"id": 1, "name": "Screwdriver", "freebase_id": "/m/01bms0"},
|
| 1152 |
+
{"id": 2, "name": "Light switch", "freebase_id": "/m/03jbxj"},
|
| 1153 |
+
{"id": 3, "name": "Doughnut", "freebase_id": "/m/0jy4k"},
|
| 1154 |
+
{"id": 4, "name": "Toilet paper", "freebase_id": "/m/09gtd"},
|
| 1155 |
+
{"id": 5, "name": "Wrench", "freebase_id": "/m/01j5ks"},
|
| 1156 |
+
{"id": 6, "name": "Toaster", "freebase_id": "/m/01k6s3"},
|
| 1157 |
+
{"id": 7, "name": "Tennis ball", "freebase_id": "/m/05ctyq"},
|
| 1158 |
+
{"id": 8, "name": "Radish", "freebase_id": "/m/015x5n"},
|
| 1159 |
+
{"id": 9, "name": "Pomegranate", "freebase_id": "/m/0jwn_"},
|
| 1160 |
+
{"id": 10, "name": "Kite", "freebase_id": "/m/02zt3"},
|
| 1161 |
+
{"id": 11, "name": "Table tennis racket", "freebase_id": "/m/05_5p_0"},
|
| 1162 |
+
{"id": 12, "name": "Hamster", "freebase_id": "/m/03qrc"},
|
| 1163 |
+
{"id": 13, "name": "Barge", "freebase_id": "/m/01btn"},
|
| 1164 |
+
{"id": 14, "name": "Shower", "freebase_id": "/m/02f9f_"},
|
| 1165 |
+
{"id": 15, "name": "Printer", "freebase_id": "/m/01m4t"},
|
| 1166 |
+
{"id": 16, "name": "Snowmobile", "freebase_id": "/m/01x3jk"},
|
| 1167 |
+
{"id": 17, "name": "Fire hydrant", "freebase_id": "/m/01pns0"},
|
| 1168 |
+
{"id": 18, "name": "Limousine", "freebase_id": "/m/01lcw4"},
|
| 1169 |
+
{"id": 19, "name": "Whale", "freebase_id": "/m/084zz"},
|
| 1170 |
+
{"id": 20, "name": "Microwave oven", "freebase_id": "/m/0fx9l"},
|
| 1171 |
+
{"id": 21, "name": "Asparagus", "freebase_id": "/m/0cjs7"},
|
| 1172 |
+
{"id": 22, "name": "Lion", "freebase_id": "/m/096mb"},
|
| 1173 |
+
{"id": 23, "name": "Spatula", "freebase_id": "/m/02d1br"},
|
| 1174 |
+
{"id": 24, "name": "Torch", "freebase_id": "/m/07dd4"},
|
| 1175 |
+
{"id": 25, "name": "Volleyball", "freebase_id": "/m/02rgn06"},
|
| 1176 |
+
{"id": 26, "name": "Ambulance", "freebase_id": "/m/012n7d"},
|
| 1177 |
+
{"id": 27, "name": "Chopsticks", "freebase_id": "/m/01_5g"},
|
| 1178 |
+
{"id": 28, "name": "Raccoon", "freebase_id": "/m/0dq75"},
|
| 1179 |
+
{"id": 29, "name": "Blue jay", "freebase_id": "/m/01f8m5"},
|
| 1180 |
+
{"id": 30, "name": "Lynx", "freebase_id": "/m/04g2r"},
|
| 1181 |
+
{"id": 31, "name": "Dice", "freebase_id": "/m/029b3"},
|
| 1182 |
+
{"id": 32, "name": "Filing cabinet", "freebase_id": "/m/047j0r"},
|
| 1183 |
+
{"id": 33, "name": "Ruler", "freebase_id": "/m/0hdln"},
|
| 1184 |
+
{"id": 34, "name": "Power plugs and sockets", "freebase_id": "/m/03bbps"},
|
| 1185 |
+
{"id": 35, "name": "Bell pepper", "freebase_id": "/m/0jg57"},
|
| 1186 |
+
{"id": 36, "name": "Binoculars", "freebase_id": "/m/0lt4_"},
|
| 1187 |
+
{"id": 37, "name": "Pretzel", "freebase_id": "/m/01f91_"},
|
| 1188 |
+
{"id": 38, "name": "Hot dog", "freebase_id": "/m/01b9xk"},
|
| 1189 |
+
{"id": 39, "name": "Missile", "freebase_id": "/m/04ylt"},
|
| 1190 |
+
{"id": 40, "name": "Common fig", "freebase_id": "/m/043nyj"},
|
| 1191 |
+
{"id": 41, "name": "Croissant", "freebase_id": "/m/015wgc"},
|
| 1192 |
+
{"id": 42, "name": "Adhesive tape", "freebase_id": "/m/03m3vtv"},
|
| 1193 |
+
{"id": 43, "name": "Slow cooker", "freebase_id": "/m/02tsc9"},
|
| 1194 |
+
{"id": 44, "name": "Dog bed", "freebase_id": "/m/0h8n6f9"},
|
| 1195 |
+
{"id": 45, "name": "Harpsichord", "freebase_id": "/m/03q5t"},
|
| 1196 |
+
{"id": 46, "name": "Billiard table", "freebase_id": "/m/04p0qw"},
|
| 1197 |
+
{"id": 47, "name": "Alpaca", "freebase_id": "/m/0pcr"},
|
| 1198 |
+
{"id": 48, "name": "Harbor seal", "freebase_id": "/m/02l8p9"},
|
| 1199 |
+
{"id": 49, "name": "Grape", "freebase_id": "/m/0388q"},
|
| 1200 |
+
{"id": 50, "name": "Nail", "freebase_id": "/m/05bm6"},
|
| 1201 |
+
{"id": 51, "name": "Paper towel", "freebase_id": "/m/02w3r3"},
|
| 1202 |
+
{"id": 52, "name": "Alarm clock", "freebase_id": "/m/046dlr"},
|
| 1203 |
+
{"id": 53, "name": "Guacamole", "freebase_id": "/m/02g30s"},
|
| 1204 |
+
{"id": 54, "name": "Starfish", "freebase_id": "/m/01h8tj"},
|
| 1205 |
+
{"id": 55, "name": "Zebra", "freebase_id": "/m/0898b"},
|
| 1206 |
+
{"id": 56, "name": "Segway", "freebase_id": "/m/076bq"},
|
| 1207 |
+
{"id": 57, "name": "Sea turtle", "freebase_id": "/m/0120dh"},
|
| 1208 |
+
{"id": 58, "name": "Scissors", "freebase_id": "/m/01lsmm"},
|
| 1209 |
+
{"id": 59, "name": "Rhinoceros", "freebase_id": "/m/03d443"},
|
| 1210 |
+
{"id": 60, "name": "Kangaroo", "freebase_id": "/m/04c0y"},
|
| 1211 |
+
{"id": 61, "name": "Jaguar", "freebase_id": "/m/0449p"},
|
| 1212 |
+
{"id": 62, "name": "Leopard", "freebase_id": "/m/0c29q"},
|
| 1213 |
+
{"id": 63, "name": "Dumbbell", "freebase_id": "/m/04h8sr"},
|
| 1214 |
+
{"id": 64, "name": "Envelope", "freebase_id": "/m/0frqm"},
|
| 1215 |
+
{"id": 65, "name": "Winter melon", "freebase_id": "/m/02cvgx"},
|
| 1216 |
+
{"id": 66, "name": "Teapot", "freebase_id": "/m/01fh4r"},
|
| 1217 |
+
{"id": 67, "name": "Camel", "freebase_id": "/m/01x_v"},
|
| 1218 |
+
{"id": 68, "name": "Beaker", "freebase_id": "/m/0d20w4"},
|
| 1219 |
+
{"id": 69, "name": "Brown bear", "freebase_id": "/m/01dxs"},
|
| 1220 |
+
{"id": 70, "name": "Toilet", "freebase_id": "/m/09g1w"},
|
| 1221 |
+
{"id": 71, "name": "Teddy bear", "freebase_id": "/m/0kmg4"},
|
| 1222 |
+
{"id": 72, "name": "Briefcase", "freebase_id": "/m/0584n8"},
|
| 1223 |
+
{"id": 73, "name": "Stop sign", "freebase_id": "/m/02pv19"},
|
| 1224 |
+
{"id": 74, "name": "Tiger", "freebase_id": "/m/07dm6"},
|
| 1225 |
+
{"id": 75, "name": "Cabbage", "freebase_id": "/m/0fbw6"},
|
| 1226 |
+
{"id": 76, "name": "Giraffe", "freebase_id": "/m/03bk1"},
|
| 1227 |
+
{"id": 77, "name": "Polar bear", "freebase_id": "/m/0633h"},
|
| 1228 |
+
{"id": 78, "name": "Shark", "freebase_id": "/m/0by6g"},
|
| 1229 |
+
{"id": 79, "name": "Rabbit", "freebase_id": "/m/06mf6"},
|
| 1230 |
+
{"id": 80, "name": "Swim cap", "freebase_id": "/m/04tn4x"},
|
| 1231 |
+
{"id": 81, "name": "Pressure cooker", "freebase_id": "/m/0h8ntjv"},
|
| 1232 |
+
{"id": 82, "name": "Kitchen knife", "freebase_id": "/m/058qzx"},
|
| 1233 |
+
{"id": 83, "name": "Submarine sandwich", "freebase_id": "/m/06pcq"},
|
| 1234 |
+
{"id": 84, "name": "Flashlight", "freebase_id": "/m/01kb5b"},
|
| 1235 |
+
{"id": 85, "name": "Penguin", "freebase_id": "/m/05z6w"},
|
| 1236 |
+
{"id": 86, "name": "Snake", "freebase_id": "/m/078jl"},
|
| 1237 |
+
{"id": 87, "name": "Zucchini", "freebase_id": "/m/027pcv"},
|
| 1238 |
+
{"id": 88, "name": "Bat", "freebase_id": "/m/01h44"},
|
| 1239 |
+
{"id": 89, "name": "Food processor", "freebase_id": "/m/03y6mg"},
|
| 1240 |
+
{"id": 90, "name": "Ostrich", "freebase_id": "/m/05n4y"},
|
| 1241 |
+
{"id": 91, "name": "Sea lion", "freebase_id": "/m/0gd36"},
|
| 1242 |
+
{"id": 92, "name": "Goldfish", "freebase_id": "/m/03fj2"},
|
| 1243 |
+
{"id": 93, "name": "Elephant", "freebase_id": "/m/0bwd_0j"},
|
| 1244 |
+
{"id": 94, "name": "Rocket", "freebase_id": "/m/09rvcxw"},
|
| 1245 |
+
{"id": 95, "name": "Mouse", "freebase_id": "/m/04rmv"},
|
| 1246 |
+
{"id": 96, "name": "Oyster", "freebase_id": "/m/0_cp5"},
|
| 1247 |
+
{"id": 97, "name": "Digital clock", "freebase_id": "/m/06_72j"},
|
| 1248 |
+
{"id": 98, "name": "Otter", "freebase_id": "/m/0cn6p"},
|
| 1249 |
+
{"id": 99, "name": "Dolphin", "freebase_id": "/m/02hj4"},
|
| 1250 |
+
{"id": 100, "name": "Punching bag", "freebase_id": "/m/0420v5"},
|
| 1251 |
+
{"id": 101, "name": "Corded phone", "freebase_id": "/m/0h8lkj8"},
|
| 1252 |
+
{"id": 102, "name": "Tennis racket", "freebase_id": "/m/0h8my_4"},
|
| 1253 |
+
{"id": 103, "name": "Pancake", "freebase_id": "/m/01dwwc"},
|
| 1254 |
+
{"id": 104, "name": "Mango", "freebase_id": "/m/0fldg"},
|
| 1255 |
+
{"id": 105, "name": "Crocodile", "freebase_id": "/m/09f_2"},
|
| 1256 |
+
{"id": 106, "name": "Waffle", "freebase_id": "/m/01dwsz"},
|
| 1257 |
+
{"id": 107, "name": "Computer mouse", "freebase_id": "/m/020lf"},
|
| 1258 |
+
{"id": 108, "name": "Kettle", "freebase_id": "/m/03s_tn"},
|
| 1259 |
+
{"id": 109, "name": "Tart", "freebase_id": "/m/02zvsm"},
|
| 1260 |
+
{"id": 110, "name": "Oven", "freebase_id": "/m/029bxz"},
|
| 1261 |
+
{"id": 111, "name": "Banana", "freebase_id": "/m/09qck"},
|
| 1262 |
+
{"id": 112, "name": "Cheetah", "freebase_id": "/m/0cd4d"},
|
| 1263 |
+
{"id": 113, "name": "Raven", "freebase_id": "/m/06j2d"},
|
| 1264 |
+
{"id": 114, "name": "Frying pan", "freebase_id": "/m/04v6l4"},
|
| 1265 |
+
{"id": 115, "name": "Pear", "freebase_id": "/m/061_f"},
|
| 1266 |
+
{"id": 116, "name": "Fox", "freebase_id": "/m/0306r"},
|
| 1267 |
+
{"id": 117, "name": "Skateboard", "freebase_id": "/m/06_fw"},
|
| 1268 |
+
{"id": 118, "name": "Rugby ball", "freebase_id": "/m/0wdt60w"},
|
| 1269 |
+
{"id": 119, "name": "Watermelon", "freebase_id": "/m/0kpqd"},
|
| 1270 |
+
{"id": 120, "name": "Flute", "freebase_id": "/m/0l14j_"},
|
| 1271 |
+
{"id": 121, "name": "Canary", "freebase_id": "/m/0ccs93"},
|
| 1272 |
+
{"id": 122, "name": "Door handle", "freebase_id": "/m/03c7gz"},
|
| 1273 |
+
{"id": 123, "name": "Saxophone", "freebase_id": "/m/06ncr"},
|
| 1274 |
+
{"id": 124, "name": "Burrito", "freebase_id": "/m/01j3zr"},
|
| 1275 |
+
{"id": 125, "name": "Suitcase", "freebase_id": "/m/01s55n"},
|
| 1276 |
+
{"id": 126, "name": "Roller skates", "freebase_id": "/m/02p3w7d"},
|
| 1277 |
+
{"id": 127, "name": "Dagger", "freebase_id": "/m/02gzp"},
|
| 1278 |
+
{"id": 128, "name": "Seat belt", "freebase_id": "/m/0dkzw"},
|
| 1279 |
+
{"id": 129, "name": "Washing machine", "freebase_id": "/m/0174k2"},
|
| 1280 |
+
{"id": 130, "name": "Jet ski", "freebase_id": "/m/01xs3r"},
|
| 1281 |
+
{"id": 131, "name": "Sombrero", "freebase_id": "/m/02jfl0"},
|
| 1282 |
+
{"id": 132, "name": "Pig", "freebase_id": "/m/068zj"},
|
| 1283 |
+
{"id": 133, "name": "Drinking straw", "freebase_id": "/m/03v5tg"},
|
| 1284 |
+
{"id": 134, "name": "Peach", "freebase_id": "/m/0dj6p"},
|
| 1285 |
+
{"id": 135, "name": "Tortoise", "freebase_id": "/m/011k07"},
|
| 1286 |
+
{"id": 136, "name": "Towel", "freebase_id": "/m/0162_1"},
|
| 1287 |
+
{"id": 137, "name": "Tablet computer", "freebase_id": "/m/0bh9flk"},
|
| 1288 |
+
{"id": 138, "name": "Cucumber", "freebase_id": "/m/015x4r"},
|
| 1289 |
+
{"id": 139, "name": "Mule", "freebase_id": "/m/0dbzx"},
|
| 1290 |
+
{"id": 140, "name": "Potato", "freebase_id": "/m/05vtc"},
|
| 1291 |
+
{"id": 141, "name": "Frog", "freebase_id": "/m/09ld4"},
|
| 1292 |
+
{"id": 142, "name": "Bear", "freebase_id": "/m/01dws"},
|
| 1293 |
+
{"id": 143, "name": "Lighthouse", "freebase_id": "/m/04h7h"},
|
| 1294 |
+
{"id": 144, "name": "Belt", "freebase_id": "/m/0176mf"},
|
| 1295 |
+
{"id": 145, "name": "Baseball bat", "freebase_id": "/m/03g8mr"},
|
| 1296 |
+
{"id": 146, "name": "Racket", "freebase_id": "/m/0dv9c"},
|
| 1297 |
+
{"id": 147, "name": "Sword", "freebase_id": "/m/06y5r"},
|
| 1298 |
+
{"id": 148, "name": "Bagel", "freebase_id": "/m/01fb_0"},
|
| 1299 |
+
{"id": 149, "name": "Goat", "freebase_id": "/m/03fwl"},
|
| 1300 |
+
{"id": 150, "name": "Lizard", "freebase_id": "/m/04m9y"},
|
| 1301 |
+
{"id": 151, "name": "Parrot", "freebase_id": "/m/0gv1x"},
|
| 1302 |
+
{"id": 152, "name": "Owl", "freebase_id": "/m/09d5_"},
|
| 1303 |
+
{"id": 153, "name": "Turkey", "freebase_id": "/m/0jly1"},
|
| 1304 |
+
{"id": 154, "name": "Cello", "freebase_id": "/m/01xqw"},
|
| 1305 |
+
{"id": 155, "name": "Knife", "freebase_id": "/m/04ctx"},
|
| 1306 |
+
{"id": 156, "name": "Handgun", "freebase_id": "/m/0gxl3"},
|
| 1307 |
+
{"id": 157, "name": "Carrot", "freebase_id": "/m/0fj52s"},
|
| 1308 |
+
{"id": 158, "name": "Hamburger", "freebase_id": "/m/0cdn1"},
|
| 1309 |
+
{"id": 159, "name": "Grapefruit", "freebase_id": "/m/0hqkz"},
|
| 1310 |
+
{"id": 160, "name": "Tap", "freebase_id": "/m/02jz0l"},
|
| 1311 |
+
{"id": 161, "name": "Tea", "freebase_id": "/m/07clx"},
|
| 1312 |
+
{"id": 162, "name": "Bull", "freebase_id": "/m/0cnyhnx"},
|
| 1313 |
+
{"id": 163, "name": "Turtle", "freebase_id": "/m/09dzg"},
|
| 1314 |
+
{"id": 164, "name": "Bust", "freebase_id": "/m/04yqq2"},
|
| 1315 |
+
{"id": 165, "name": "Monkey", "freebase_id": "/m/08pbxl"},
|
| 1316 |
+
{"id": 166, "name": "Wok", "freebase_id": "/m/084rd"},
|
| 1317 |
+
{"id": 167, "name": "Broccoli", "freebase_id": "/m/0hkxq"},
|
| 1318 |
+
{"id": 168, "name": "Pitcher", "freebase_id": "/m/054fyh"},
|
| 1319 |
+
{"id": 169, "name": "Whiteboard", "freebase_id": "/m/02d9qx"},
|
| 1320 |
+
{"id": 170, "name": "Squirrel", "freebase_id": "/m/071qp"},
|
| 1321 |
+
{"id": 171, "name": "Jug", "freebase_id": "/m/08hvt4"},
|
| 1322 |
+
{"id": 172, "name": "Woodpecker", "freebase_id": "/m/01dy8n"},
|
| 1323 |
+
{"id": 173, "name": "Pizza", "freebase_id": "/m/0663v"},
|
| 1324 |
+
{"id": 174, "name": "Surfboard", "freebase_id": "/m/019w40"},
|
| 1325 |
+
{"id": 175, "name": "Sofa bed", "freebase_id": "/m/03m3pdh"},
|
| 1326 |
+
{"id": 176, "name": "Sheep", "freebase_id": "/m/07bgp"},
|
| 1327 |
+
{"id": 177, "name": "Candle", "freebase_id": "/m/0c06p"},
|
| 1328 |
+
{"id": 178, "name": "Muffin", "freebase_id": "/m/01tcjp"},
|
| 1329 |
+
{"id": 179, "name": "Cookie", "freebase_id": "/m/021mn"},
|
| 1330 |
+
{"id": 180, "name": "Apple", "freebase_id": "/m/014j1m"},
|
| 1331 |
+
{"id": 181, "name": "Chest of drawers", "freebase_id": "/m/05kyg_"},
|
| 1332 |
+
{"id": 182, "name": "Skull", "freebase_id": "/m/016m2d"},
|
| 1333 |
+
{"id": 183, "name": "Chicken", "freebase_id": "/m/09b5t"},
|
| 1334 |
+
{"id": 184, "name": "Loveseat", "freebase_id": "/m/0703r8"},
|
| 1335 |
+
{"id": 185, "name": "Baseball glove", "freebase_id": "/m/03grzl"},
|
| 1336 |
+
{"id": 186, "name": "Piano", "freebase_id": "/m/05r5c"},
|
| 1337 |
+
{"id": 187, "name": "Waste container", "freebase_id": "/m/0bjyj5"},
|
| 1338 |
+
{"id": 188, "name": "Barrel", "freebase_id": "/m/02zn6n"},
|
| 1339 |
+
{"id": 189, "name": "Swan", "freebase_id": "/m/0dftk"},
|
| 1340 |
+
{"id": 190, "name": "Taxi", "freebase_id": "/m/0pg52"},
|
| 1341 |
+
{"id": 191, "name": "Lemon", "freebase_id": "/m/09k_b"},
|
| 1342 |
+
{"id": 192, "name": "Pumpkin", "freebase_id": "/m/05zsy"},
|
| 1343 |
+
{"id": 193, "name": "Sparrow", "freebase_id": "/m/0h23m"},
|
| 1344 |
+
{"id": 194, "name": "Orange", "freebase_id": "/m/0cyhj_"},
|
| 1345 |
+
{"id": 195, "name": "Tank", "freebase_id": "/m/07cmd"},
|
| 1346 |
+
{"id": 196, "name": "Sandwich", "freebase_id": "/m/0l515"},
|
| 1347 |
+
{"id": 197, "name": "Coffee", "freebase_id": "/m/02vqfm"},
|
| 1348 |
+
{"id": 198, "name": "Juice", "freebase_id": "/m/01z1kdw"},
|
| 1349 |
+
{"id": 199, "name": "Coin", "freebase_id": "/m/0242l"},
|
| 1350 |
+
{"id": 200, "name": "Pen", "freebase_id": "/m/0k1tl"},
|
| 1351 |
+
{"id": 201, "name": "Watch", "freebase_id": "/m/0gjkl"},
|
| 1352 |
+
{"id": 202, "name": "Eagle", "freebase_id": "/m/09csl"},
|
| 1353 |
+
{"id": 203, "name": "Goose", "freebase_id": "/m/0dbvp"},
|
| 1354 |
+
{"id": 204, "name": "Falcon", "freebase_id": "/m/0f6wt"},
|
| 1355 |
+
{"id": 205, "name": "Christmas tree", "freebase_id": "/m/025nd"},
|
| 1356 |
+
{"id": 206, "name": "Sunflower", "freebase_id": "/m/0ftb8"},
|
| 1357 |
+
{"id": 207, "name": "Vase", "freebase_id": "/m/02s195"},
|
| 1358 |
+
{"id": 208, "name": "Football", "freebase_id": "/m/01226z"},
|
| 1359 |
+
{"id": 209, "name": "Canoe", "freebase_id": "/m/0ph39"},
|
| 1360 |
+
{"id": 210, "name": "High heels", "freebase_id": "/m/06k2mb"},
|
| 1361 |
+
{"id": 211, "name": "Spoon", "freebase_id": "/m/0cmx8"},
|
| 1362 |
+
{"id": 212, "name": "Mug", "freebase_id": "/m/02jvh9"},
|
| 1363 |
+
{"id": 213, "name": "Swimwear", "freebase_id": "/m/01gkx_"},
|
| 1364 |
+
{"id": 214, "name": "Duck", "freebase_id": "/m/09ddx"},
|
| 1365 |
+
{"id": 215, "name": "Cat", "freebase_id": "/m/01yrx"},
|
| 1366 |
+
{"id": 216, "name": "Tomato", "freebase_id": "/m/07j87"},
|
| 1367 |
+
{"id": 217, "name": "Cocktail", "freebase_id": "/m/024g6"},
|
| 1368 |
+
{"id": 218, "name": "Clock", "freebase_id": "/m/01x3z"},
|
| 1369 |
+
{"id": 219, "name": "Cowboy hat", "freebase_id": "/m/025rp__"},
|
| 1370 |
+
{"id": 220, "name": "Miniskirt", "freebase_id": "/m/01cmb2"},
|
| 1371 |
+
{"id": 221, "name": "Cattle", "freebase_id": "/m/01xq0k1"},
|
| 1372 |
+
{"id": 222, "name": "Strawberry", "freebase_id": "/m/07fbm7"},
|
| 1373 |
+
{"id": 223, "name": "Bronze sculpture", "freebase_id": "/m/01yx86"},
|
| 1374 |
+
{"id": 224, "name": "Pillow", "freebase_id": "/m/034c16"},
|
| 1375 |
+
{"id": 225, "name": "Squash", "freebase_id": "/m/0dv77"},
|
| 1376 |
+
{"id": 226, "name": "Traffic light", "freebase_id": "/m/015qff"},
|
| 1377 |
+
{"id": 227, "name": "Saucer", "freebase_id": "/m/03q5c7"},
|
| 1378 |
+
{"id": 228, "name": "Reptile", "freebase_id": "/m/06bt6"},
|
| 1379 |
+
{"id": 229, "name": "Cake", "freebase_id": "/m/0fszt"},
|
| 1380 |
+
{"id": 230, "name": "Plastic bag", "freebase_id": "/m/05gqfk"},
|
| 1381 |
+
{"id": 231, "name": "Studio couch", "freebase_id": "/m/026qbn5"},
|
| 1382 |
+
{"id": 232, "name": "Beer", "freebase_id": "/m/01599"},
|
| 1383 |
+
{"id": 233, "name": "Scarf", "freebase_id": "/m/02h19r"},
|
| 1384 |
+
{"id": 234, "name": "Coffee cup", "freebase_id": "/m/02p5f1q"},
|
| 1385 |
+
{"id": 235, "name": "Wine", "freebase_id": "/m/081qc"},
|
| 1386 |
+
{"id": 236, "name": "Mushroom", "freebase_id": "/m/052sf"},
|
| 1387 |
+
{"id": 237, "name": "Traffic sign", "freebase_id": "/m/01mqdt"},
|
| 1388 |
+
{"id": 238, "name": "Camera", "freebase_id": "/m/0dv5r"},
|
| 1389 |
+
{"id": 239, "name": "Rose", "freebase_id": "/m/06m11"},
|
| 1390 |
+
{"id": 240, "name": "Couch", "freebase_id": "/m/02crq1"},
|
| 1391 |
+
{"id": 241, "name": "Handbag", "freebase_id": "/m/080hkjn"},
|
| 1392 |
+
{"id": 242, "name": "Fedora", "freebase_id": "/m/02fq_6"},
|
| 1393 |
+
{"id": 243, "name": "Sock", "freebase_id": "/m/01nq26"},
|
| 1394 |
+
{"id": 244, "name": "Computer keyboard", "freebase_id": "/m/01m2v"},
|
| 1395 |
+
{"id": 245, "name": "Mobile phone", "freebase_id": "/m/050k8"},
|
| 1396 |
+
{"id": 246, "name": "Ball", "freebase_id": "/m/018xm"},
|
| 1397 |
+
{"id": 247, "name": "Balloon", "freebase_id": "/m/01j51"},
|
| 1398 |
+
{"id": 248, "name": "Horse", "freebase_id": "/m/03k3r"},
|
| 1399 |
+
{"id": 249, "name": "Boot", "freebase_id": "/m/01b638"},
|
| 1400 |
+
{"id": 250, "name": "Fish", "freebase_id": "/m/0ch_cf"},
|
| 1401 |
+
{"id": 251, "name": "Backpack", "freebase_id": "/m/01940j"},
|
| 1402 |
+
{"id": 252, "name": "Skirt", "freebase_id": "/m/02wv6h6"},
|
| 1403 |
+
{"id": 253, "name": "Van", "freebase_id": "/m/0h2r6"},
|
| 1404 |
+
{"id": 254, "name": "Bread", "freebase_id": "/m/09728"},
|
| 1405 |
+
{"id": 255, "name": "Glove", "freebase_id": "/m/0174n1"},
|
| 1406 |
+
{"id": 256, "name": "Dog", "freebase_id": "/m/0bt9lr"},
|
| 1407 |
+
{"id": 257, "name": "Airplane", "freebase_id": "/m/0cmf2"},
|
| 1408 |
+
{"id": 258, "name": "Motorcycle", "freebase_id": "/m/04_sv"},
|
| 1409 |
+
{"id": 259, "name": "Drink", "freebase_id": "/m/0271t"},
|
| 1410 |
+
{"id": 260, "name": "Book", "freebase_id": "/m/0bt_c3"},
|
| 1411 |
+
{"id": 261, "name": "Train", "freebase_id": "/m/07jdr"},
|
| 1412 |
+
{"id": 262, "name": "Flower", "freebase_id": "/m/0c9ph5"},
|
| 1413 |
+
{"id": 263, "name": "Carnivore", "freebase_id": "/m/01lrl"},
|
| 1414 |
+
{"id": 264, "name": "Human ear", "freebase_id": "/m/039xj_"},
|
| 1415 |
+
{"id": 265, "name": "Toy", "freebase_id": "/m/0138tl"},
|
| 1416 |
+
{"id": 266, "name": "Box", "freebase_id": "/m/025dyy"},
|
| 1417 |
+
{"id": 267, "name": "Truck", "freebase_id": "/m/07r04"},
|
| 1418 |
+
{"id": 268, "name": "Wheel", "freebase_id": "/m/083wq"},
|
| 1419 |
+
{"id": 269, "name": "Aircraft", "freebase_id": "/m/0k5j"},
|
| 1420 |
+
{"id": 270, "name": "Bus", "freebase_id": "/m/01bjv"},
|
| 1421 |
+
{"id": 271, "name": "Human mouth", "freebase_id": "/m/0283dt1"},
|
| 1422 |
+
{"id": 272, "name": "Sculpture", "freebase_id": "/m/06msq"},
|
| 1423 |
+
{"id": 273, "name": "Shirt", "freebase_id": "/m/01n4qj"},
|
| 1424 |
+
{"id": 274, "name": "Hat", "freebase_id": "/m/02dl1y"},
|
| 1425 |
+
{"id": 275, "name": "Vehicle registration plate", "freebase_id": "/m/01jfm_"},
|
| 1426 |
+
{"id": 276, "name": "Guitar", "freebase_id": "/m/0342h"},
|
| 1427 |
+
{"id": 277, "name": "Sun hat", "freebase_id": "/m/02wbtzl"},
|
| 1428 |
+
{"id": 278, "name": "Bottle", "freebase_id": "/m/04dr76w"},
|
| 1429 |
+
{"id": 279, "name": "Luggage and bags", "freebase_id": "/m/0hf58v5"},
|
| 1430 |
+
{"id": 280, "name": "Trousers", "freebase_id": "/m/07mhn"},
|
| 1431 |
+
{"id": 281, "name": "Bicycle wheel", "freebase_id": "/m/01bqk0"},
|
| 1432 |
+
{"id": 282, "name": "Suit", "freebase_id": "/m/01xyhv"},
|
| 1433 |
+
{"id": 283, "name": "Bowl", "freebase_id": "/m/04kkgm"},
|
| 1434 |
+
{"id": 284, "name": "Man", "freebase_id": "/m/04yx4"},
|
| 1435 |
+
{"id": 285, "name": "Flowerpot", "freebase_id": "/m/0fm3zh"},
|
| 1436 |
+
{"id": 286, "name": "Laptop", "freebase_id": "/m/01c648"},
|
| 1437 |
+
{"id": 287, "name": "Boy", "freebase_id": "/m/01bl7v"},
|
| 1438 |
+
{"id": 288, "name": "Picture frame", "freebase_id": "/m/06z37_"},
|
| 1439 |
+
{"id": 289, "name": "Bird", "freebase_id": "/m/015p6"},
|
| 1440 |
+
{"id": 290, "name": "Car", "freebase_id": "/m/0k4j"},
|
| 1441 |
+
{"id": 291, "name": "Shorts", "freebase_id": "/m/01bfm9"},
|
| 1442 |
+
{"id": 292, "name": "Woman", "freebase_id": "/m/03bt1vf"},
|
| 1443 |
+
{"id": 293, "name": "Platter", "freebase_id": "/m/099ssp"},
|
| 1444 |
+
{"id": 294, "name": "Tie", "freebase_id": "/m/01rkbr"},
|
| 1445 |
+
{"id": 295, "name": "Girl", "freebase_id": "/m/05r655"},
|
| 1446 |
+
{"id": 296, "name": "Skyscraper", "freebase_id": "/m/079cl"},
|
| 1447 |
+
{"id": 297, "name": "Person", "freebase_id": "/m/01g317"},
|
| 1448 |
+
{"id": 298, "name": "Flag", "freebase_id": "/m/03120"},
|
| 1449 |
+
{"id": 299, "name": "Jeans", "freebase_id": "/m/0fly7"},
|
| 1450 |
+
{"id": 300, "name": "Dress", "freebase_id": "/m/01d40f"},
|
| 1451 |
+
]
|
| 1452 |
+
|
| 1453 |
+
|
| 1454 |
+
def _get_builtin_metadata(cats, class_image_count=None):
|
| 1455 |
+
id_to_name = {x["id"]: x["name"] for x in cats}
|
| 1456 |
+
thing_dataset_id_to_contiguous_id = {i + 1: i for i in range(len(cats))}
|
| 1457 |
+
thing_classes = [x["name"] for x in sorted(cats, key=lambda x: x["id"])]
|
| 1458 |
+
return {
|
| 1459 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 1460 |
+
"thing_classes": thing_classes,
|
| 1461 |
+
"class_image_count": class_image_count,
|
| 1462 |
+
}
|
| 1463 |
+
|
| 1464 |
+
|
| 1465 |
+
_PREDEFINED_SPLITS_OID = {
|
| 1466 |
+
"oid_train": ("oid/images/train/", "oid/annotations/oid_challenge_2019_train_bbox.json"),
|
| 1467 |
+
"oid_val": ("oid/images/validation/", "oid/annotations/oid_challenge_2019_val.json"),
|
| 1468 |
+
"oid_val_expanded": (
|
| 1469 |
+
"oid/images/validation/",
|
| 1470 |
+
"oid/annotations/oid_challenge_2019_val_expanded.json",
|
| 1471 |
+
),
|
| 1472 |
+
"oid_kaggle_test": ("oid/images/test/", "oid/annotations/oid_kaggle_test_image_info.json"),
|
| 1473 |
+
}
|
| 1474 |
+
|
| 1475 |
+
|
| 1476 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_OID.items():
|
| 1477 |
+
register_oid_instances(
|
| 1478 |
+
key,
|
| 1479 |
+
_get_builtin_metadata(OPENIMAGES_2019_CATEGORIES),
|
| 1480 |
+
os.path.join("datasets", json_file) if "://" not in json_file else json_file,
|
| 1481 |
+
os.path.join("datasets", image_root),
|
| 1482 |
+
)
|
| 1483 |
+
|
| 1484 |
+
_PREDEFINED_SPLITS_OID_SEG = {
|
| 1485 |
+
"oid_seg_train": ("oid/images/train/", "oid/annotations/openimages_instances_train.json"),
|
| 1486 |
+
"oid_seg_val": ("oid/images/validation/", "oid/annotations/openimages_instances_val.json"),
|
| 1487 |
+
"oid_seg_kaggle_test": (
|
| 1488 |
+
"oid/images/test/",
|
| 1489 |
+
"oid/annotations/openimages_instances_kaggle_test_image_info.json",
|
| 1490 |
+
),
|
| 1491 |
+
}
|
| 1492 |
+
|
| 1493 |
+
|
| 1494 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_OID_SEG.items():
|
| 1495 |
+
register_oid_instances(
|
| 1496 |
+
key,
|
| 1497 |
+
_get_builtin_metadata(categories_seg),
|
| 1498 |
+
os.path.join("datasets", json_file) if "://" not in json_file else json_file,
|
| 1499 |
+
os.path.join("datasets", image_root),
|
| 1500 |
+
)
|
| 1501 |
+
|
| 1502 |
+
|
| 1503 |
+
_PREDEFINED_SPLITS_OPENIMAGES_DETECTION = {
|
| 1504 |
+
"openimages_challenge_2019_train": (
|
| 1505 |
+
"openimages/train/",
|
| 1506 |
+
"openimages/annotations/openimages_challenge_2019_train_bbox.json",
|
| 1507 |
+
),
|
| 1508 |
+
"openimages_challenge_2019_val": (
|
| 1509 |
+
"openimages/validation/",
|
| 1510 |
+
"openimages/annotations/openimages_challenge_2019_val_bbox.json",
|
| 1511 |
+
),
|
| 1512 |
+
}
|
| 1513 |
+
|
| 1514 |
+
|
| 1515 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_OPENIMAGES_DETECTION.items():
|
| 1516 |
+
register_oid_instances(
|
| 1517 |
+
key,
|
| 1518 |
+
_get_builtin_metadata(OPENIMAGES_2019_CATEGORIES),
|
| 1519 |
+
os.path.join("datasets", json_file) if "://" not in json_file else json_file,
|
| 1520 |
+
os.path.join("datasets", image_root),
|
| 1521 |
+
)
|
| 1522 |
+
|
| 1523 |
+
|
| 1524 |
+
_PREDEFINED_SPLITS_OPENIMAGES_V6_DETECTION = {
|
| 1525 |
+
"openimages_v6_train_bbox": (
|
| 1526 |
+
"openimages/train/",
|
| 1527 |
+
"openimages/annotations/openimages_v6_train_bbox.json",
|
| 1528 |
+
),
|
| 1529 |
+
"openimages_v6_train_bbox_nogroup": (
|
| 1530 |
+
"openimages/train/",
|
| 1531 |
+
"openimages/annotations/openimages_v6_train_bbox_nogroup.json",
|
| 1532 |
+
),
|
| 1533 |
+
"openimages_v6_val_bbox": (
|
| 1534 |
+
"openimages/validation/",
|
| 1535 |
+
"openimages/annotations/openimages_v6_val_bbox.json",
|
| 1536 |
+
),
|
| 1537 |
+
"openimages_v6_val_bbox_nogroup": (
|
| 1538 |
+
"openimages/validation/",
|
| 1539 |
+
"openimages/annotations/openimages_v6_val_bbox_nogroup.json",
|
| 1540 |
+
),
|
| 1541 |
+
"openimages_v6_train_instance": (
|
| 1542 |
+
"openimages/train/",
|
| 1543 |
+
"openimages/annotations/openimages_v6_train_instance.json",
|
| 1544 |
+
),
|
| 1545 |
+
"openimages_v6_val_instance": (
|
| 1546 |
+
"openimages/validation/",
|
| 1547 |
+
"openimages/annotations/openimages_v6_val_instance.json",
|
| 1548 |
+
),
|
| 1549 |
+
"openimages_v6_train_bbox_instance": (
|
| 1550 |
+
"openimages/train/",
|
| 1551 |
+
"openimages/annotations/openimages_v6_train_bbox_instance.json",
|
| 1552 |
+
),
|
| 1553 |
+
"openimages_v6_val_bbox_instance": (
|
| 1554 |
+
"openimages/validation/",
|
| 1555 |
+
"openimages/annotations/openimages_v6_val_bbox_instance.json",
|
| 1556 |
+
),
|
| 1557 |
+
}
|
| 1558 |
+
|
| 1559 |
+
|
| 1560 |
+
def register_all_oid(root):
|
| 1561 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_OPENIMAGES_V6_DETECTION.items():
|
| 1562 |
+
register_oid_instances(
|
| 1563 |
+
key,
|
| 1564 |
+
_get_builtin_metadata(OPENIMAGES_V6_CATEGORIES, OPENIMAGES_v6_CATEGORY_IMAGE_COUNT),
|
| 1565 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 1566 |
+
os.path.join(root, image_root),
|
| 1567 |
+
)
|
| 1568 |
+
|
| 1569 |
+
|
| 1570 |
+
if __name__.endswith(".oid"):
|
| 1571 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 1572 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 1573 |
+
register_all_oid(_root)
|
approach/ovod/APE/ape/data/datasets/openimages_v6_category_image_count.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
OPENIMAGES_v6_CATEGORY_IMAGE_COUNT = [{"id": 1, "name": "Tortoise", "freebase_id": "/m/011k07", "image_count": 1151, "instance_count": 1678}, {"id": 2, "name": "Container", "freebase_id": "/m/011q46kg", "image_count": 0, "instance_count": 0}, {"id": 3, "name": "Magpie", "freebase_id": "/m/012074", "image_count": 100, "instance_count": 117}, {"id": 4, "name": "Sea turtle", "freebase_id": "/m/0120dh", "image_count": 664, "instance_count": 999}, {"id": 5, "name": "Football", "freebase_id": "/m/01226z", "image_count": 2727, "instance_count": 3150}, {"id": 6, "name": "Ambulance", "freebase_id": "/m/012n7d", "image_count": 305, "instance_count": 391}, {"id": 7, "name": "Ladder", "freebase_id": "/m/012w5l", "image_count": 679, "instance_count": 895}, {"id": 8, "name": "Toothbrush", "freebase_id": "/m/012xff", "image_count": 106, "instance_count": 202}, {"id": 9, "name": "Syringe", "freebase_id": "/m/012ysf", "image_count": 92, "instance_count": 124}, {"id": 10, "name": "Sink", "freebase_id": "/m/0130jx", "image_count": 1165, "instance_count": 1327}, {"id": 11, "name": "Toy", "freebase_id": "/m/0138tl", "image_count": 13584, "instance_count": 43916}, {"id": 12, "name": "Organ (Musical Instrument)", "freebase_id": "/m/013y1f", "image_count": 366, "instance_count": 386}, {"id": 13, "name": "Cassette deck", "freebase_id": "/m/01432t", "image_count": 49, "instance_count": 66}, {"id": 14, "name": "Apple", "freebase_id": "/m/014j1m", "image_count": 630, "instance_count": 1624}, {"id": 15, "name": "Human eye", "freebase_id": "/m/014sv8", "image_count": 20295, "instance_count": 58440}, {"id": 16, "name": "Cosmetics", "freebase_id": "/m/014trl", "image_count": 790, "instance_count": 2090}, {"id": 17, "name": "Paddle", "freebase_id": "/m/014y4n", "image_count": 1705, "instance_count": 4598}, {"id": 18, "name": "Snowman", "freebase_id": "/m/0152hh", "image_count": 497, "instance_count": 696}, {"id": 19, "name": "Beer", "freebase_id": "/m/01599", "image_count": 4063, "instance_count": 7841}, {"id": 20, "name": "Chopsticks", "freebase_id": "/m/01_5g", "image_count": 353, "instance_count": 448}, {"id": 21, "name": "Human beard", "freebase_id": "/m/015h_t", "image_count": 2530, "instance_count": 2845}, {"id": 22, "name": "Bird", "freebase_id": "/m/015p6", "image_count": 15042, "instance_count": 32316}, {"id": 23, "name": "Parking meter", "freebase_id": "/m/015qbp", "image_count": 176, "instance_count": 208}, {"id": 24, "name": "Traffic light", "freebase_id": "/m/015qff", "image_count": 1188, "instance_count": 4663}, {"id": 25, "name": "Croissant", "freebase_id": "/m/015wgc", "image_count": 167, "instance_count": 307}, {"id": 26, "name": "Cucumber", "freebase_id": "/m/015x4r", "image_count": 200, "instance_count": 477}, {"id": 27, "name": "Radish", "freebase_id": "/m/015x5n", "image_count": 80, "instance_count": 325}, {"id": 28, "name": "Towel", "freebase_id": "/m/0162_1", "image_count": 118, "instance_count": 202}, {"id": 29, "name": "Doll", "freebase_id": "/m/0167gd", "image_count": 3049, "instance_count": 5446}, {"id": 30, "name": "Skull", "freebase_id": "/m/016m2d", "image_count": 1407, "instance_count": 2340}, {"id": 31, "name": "Washing machine", "freebase_id": "/m/0174k2", "image_count": 299, "instance_count": 593}, {"id": 32, "name": "Glove", "freebase_id": "/m/0174n1", "image_count": 656, "instance_count": 1071}, {"id": 33, "name": "Tick", "freebase_id": "/m/0175cv", "image_count": 95, "instance_count": 127}, {"id": 34, "name": "Belt", "freebase_id": "/m/0176mf", "image_count": 341, "instance_count": 411}, {"id": 35, "name": "Sunglasses", "freebase_id": "/m/017ftj", "image_count": 12875, "instance_count": 19324}, {"id": 36, "name": "Banjo", "freebase_id": "/m/018j2", "image_count": 235, "instance_count": 253}, {"id": 37, "name": "Cart", "freebase_id": "/m/018p4k", "image_count": 1376, "instance_count": 1910}, {"id": 38, "name": "Ball", "freebase_id": "/m/018xm", "image_count": 2479, "instance_count": 4943}, {"id": 39, "name": "Backpack", "freebase_id": "/m/01940j", "image_count": 598, "instance_count": 966}, {"id": 40, "name": "Bicycle", "freebase_id": "/m/0199g", "image_count": 11536, "instance_count": 21840}, {"id": 41, "name": "Home appliance", "freebase_id": "/m/019dx1", "image_count": 893, "instance_count": 1732}, {"id": 42, "name": "Centipede", "freebase_id": "/m/019h78", "image_count": 231, "instance_count": 275}, {"id": 43, "name": "Boat", "freebase_id": "/m/019jd", "image_count": 19756, "instance_count": 54017}, {"id": 44, "name": "Surfboard", "freebase_id": "/m/019w40", "image_count": 1641, "instance_count": 2427}, {"id": 45, "name": "Boot", "freebase_id": "/m/01b638", "image_count": 1311, "instance_count": 2812}, {"id": 46, "name": "Headphones", "freebase_id": "/m/01b7fy", "image_count": 1028, "instance_count": 1193}, {"id": 47, "name": "Hot dog", "freebase_id": "/m/01b9xk", "image_count": 311, "instance_count": 405}, {"id": 48, "name": "Shorts", "freebase_id": "/m/01bfm9", "image_count": 5427, "instance_count": 12674}, {"id": 49, "name": "Fast food", "freebase_id": "/m/01_bhs", "image_count": 4621, "instance_count": 11599}, {"id": 50, "name": "Bus", "freebase_id": "/m/01bjv", "image_count": 5811, "instance_count": 9584}, {"id": 51, "name": "Boy", "freebase_id": "/m/01bl7v", "image_count": 36079, "instance_count": 61661}, {"id": 52, "name": "Screwdriver", "freebase_id": "/m/01bms0", "image_count": 46, "instance_count": 85}, {"id": 53, "name": "Bicycle wheel", "freebase_id": "/m/01bqk0", "image_count": 10655, "instance_count": 31513}, {"id": 54, "name": "Barge", "freebase_id": "/m/01btn", "image_count": 295, "instance_count": 690}, {"id": 55, "name": "Laptop", "freebase_id": "/m/01c648", "image_count": 5171, "instance_count": 8213}, {"id": 56, "name": "Miniskirt", "freebase_id": "/m/01cmb2", "image_count": 674, "instance_count": 851}, {"id": 57, "name": "Drill (Tool)", "freebase_id": "/m/01d380", "image_count": 169, "instance_count": 201}, {"id": 58, "name": "Dress", "freebase_id": "/m/01d40f", "image_count": 25529, "instance_count": 41137}, {"id": 59, "name": "Bear", "freebase_id": "/m/01dws", "image_count": 270, "instance_count": 326}, {"id": 60, "name": "Waffle", "freebase_id": "/m/01dwsz", "image_count": 327, "instance_count": 581}, {"id": 61, "name": "Pancake", "freebase_id": "/m/01dwwc", "image_count": 181, "instance_count": 437}, {"id": 62, "name": "Brown bear", "freebase_id": "/m/01dxs", "image_count": 403, "instance_count": 532}, {"id": 63, "name": "Woodpecker", "freebase_id": "/m/01dy8n", "image_count": 391, "instance_count": 480}, {"id": 64, "name": "Blue jay", "freebase_id": "/m/01f8m5", "image_count": 210, "instance_count": 233}, {"id": 65, "name": "Pretzel", "freebase_id": "/m/01f91_", "image_count": 123, "instance_count": 220}, {"id": 66, "name": "Bagel", "freebase_id": "/m/01fb_0", "image_count": 173, "instance_count": 374}, {"id": 67, "name": "Tower", "freebase_id": "/m/01fdzj", "image_count": 16337, "instance_count": 44982}, {"id": 68, "name": "Teapot", "freebase_id": "/m/01fh4r", "image_count": 448, "instance_count": 564}, {"id": 69, "name": "Person", "freebase_id": "/m/01g317", "image_count": 177356, "instance_count": 595849}, {"id": 70, "name": "Bow and arrow", "freebase_id": "/m/01g3x7", "image_count": 235, "instance_count": 459}, {"id": 71, "name": "Swimwear", "freebase_id": "/m/01gkx_", "image_count": 3084, "instance_count": 8645}, {"id": 72, "name": "Beehive", "freebase_id": "/m/01gllr", "image_count": 283, "instance_count": 327}, {"id": 73, "name": "Brassiere", "freebase_id": "/m/01gmv2", "image_count": 1146, "instance_count": 1567}, {"id": 74, "name": "Bee", "freebase_id": "/m/01h3n", "image_count": 2113, "instance_count": 4484}, {"id": 75, "name": "Bat (Animal)", "freebase_id": "/m/01h44", "image_count": 331, "instance_count": 490}, {"id": 76, "name": "Starfish", "freebase_id": "/m/01h8tj", "image_count": 409, "instance_count": 577}, {"id": 77, "name": "Popcorn", "freebase_id": "/m/01hrv5", "image_count": 179, "instance_count": 245}, {"id": 78, "name": "Burrito", "freebase_id": "/m/01j3zr", "image_count": 160, "instance_count": 251}, {"id": 79, "name": "Chainsaw", "freebase_id": "/m/01j4z9", "image_count": 100, "instance_count": 106}, {"id": 80, "name": "Balloon", "freebase_id": "/m/01j51", "image_count": 1691, "instance_count": 8440}, {"id": 81, "name": "Wrench", "freebase_id": "/m/01j5ks", "image_count": 54, "instance_count": 134}, {"id": 82, "name": "Tent", "freebase_id": "/m/01j61q", "image_count": 1588, "instance_count": 2929}, {"id": 83, "name": "Vehicle registration plate", "freebase_id": "/m/01jfm_", "image_count": 3956, "instance_count": 5420}, {"id": 84, "name": "Lantern", "freebase_id": "/m/01jfsr", "image_count": 555, "instance_count": 2221}, {"id": 85, "name": "Toaster", "freebase_id": "/m/01k6s3", "image_count": 56, "instance_count": 68}, {"id": 86, "name": "Flashlight", "freebase_id": "/m/01kb5b", "image_count": 60, "instance_count": 85}, {"id": 87, "name": "Billboard", "freebase_id": "/m/01knjb", "image_count": 2628, "instance_count": 6604}, {"id": 88, "name": "Tiara", "freebase_id": "/m/01krhy", "image_count": 330, "instance_count": 360}, {"id": 89, "name": "Limousine", "freebase_id": "/m/01lcw4", "image_count": 315, "instance_count": 346}, {"id": 90, "name": "Necklace", "freebase_id": "/m/01llwg", "image_count": 2122, "instance_count": 2537}, {"id": 91, "name": "Carnivore", "freebase_id": "/m/01lrl", "image_count": 1909, "instance_count": 2859}, {"id": 92, "name": "Scissors", "freebase_id": "/m/01lsmm", "image_count": 283, "instance_count": 388}, {"id": 93, "name": "Stairs", "freebase_id": "/m/01lynh", "image_count": 2057, "instance_count": 2501}, {"id": 94, "name": "Computer keyboard", "freebase_id": "/m/01m2v", "image_count": 3226, "instance_count": 4338}, {"id": 95, "name": "Printer", "freebase_id": "/m/01m4t", "image_count": 199, "instance_count": 252}, {"id": 96, "name": "Traffic sign", "freebase_id": "/m/01mqdt", "image_count": 1923, "instance_count": 4030}, {"id": 97, "name": "Chair", "freebase_id": "/m/01mzpv", "image_count": 19112, "instance_count": 87999}, {"id": 98, "name": "Shirt", "freebase_id": "/m/01n4qj", "image_count": 4971, "instance_count": 7016}, {"id": 99, "name": "Poster", "freebase_id": "/m/01n5jq", "image_count": 14231, "instance_count": 19811}, {"id": 100, "name": "Cheese", "freebase_id": "/m/01nkt", "image_count": 330, "instance_count": 1039}, {"id": 101, "name": "Sock", "freebase_id": "/m/01nq26", "image_count": 643, "instance_count": 1330}, {"id": 102, "name": "Fire hydrant", "freebase_id": "/m/01pns0", "image_count": 388, "instance_count": 412}, {"id": 103, "name": "Land vehicle", "freebase_id": "/m/01prls", "image_count": 20402, "instance_count": 45498}, {"id": 104, "name": "Earrings", "freebase_id": "/m/01r546", "image_count": 661, "instance_count": 1426}, {"id": 105, "name": "Tie", "freebase_id": "/m/01rkbr", "image_count": 7470, "instance_count": 10074}, {"id": 106, "name": "Watercraft", "freebase_id": "/m/01rzcn", "image_count": 2164, "instance_count": 4456}, {"id": 107, "name": "Cabinetry", "freebase_id": "/m/01s105", "image_count": 2011, "instance_count": 5908}, {"id": 108, "name": "Suitcase", "freebase_id": "/m/01s55n", "image_count": 367, "instance_count": 573}, {"id": 109, "name": "Muffin", "freebase_id": "/m/01tcjp", "image_count": 795, "instance_count": 2926}, {"id": 110, "name": "Bidet", "freebase_id": "/m/01vbnl", "image_count": 346, "instance_count": 406}, {"id": 111, "name": "Snack", "freebase_id": "/m/01ww8y", "image_count": 5792, "instance_count": 15326}, {"id": 112, "name": "Snowmobile", "freebase_id": "/m/01x3jk", "image_count": 161, "instance_count": 290}, {"id": 113, "name": "Clock", "freebase_id": "/m/01x3z", "image_count": 846, "instance_count": 1099}, {"id": 114, "name": "Medical equipment", "freebase_id": "/m/01xgg_", "image_count": 588, "instance_count": 1747}, {"id": 115, "name": "Cattle", "freebase_id": "/m/01xq0k1", "image_count": 1786, "instance_count": 6183}, {"id": 116, "name": "Cello", "freebase_id": "/m/01xqw", "image_count": 1230, "instance_count": 1802}, {"id": 117, "name": "Jet ski", "freebase_id": "/m/01xs3r", "image_count": 445, "instance_count": 518}, {"id": 118, "name": "Camel", "freebase_id": "/m/01x_v", "image_count": 632, "instance_count": 1136}, {"id": 119, "name": "Coat", "freebase_id": "/m/01xygc", "image_count": 3005, "instance_count": 5370}, {"id": 120, "name": "Suit", "freebase_id": "/m/01xyhv", "image_count": 39016, "instance_count": 91879}, {"id": 121, "name": "Desk", "freebase_id": "/m/01y9k5", "image_count": 8004, "instance_count": 9623}, {"id": 122, "name": "Cat", "freebase_id": "/m/01yrx", "image_count": 11569, "instance_count": 13979}, {"id": 123, "name": "Bronze sculpture", "freebase_id": "/m/01yx86", "image_count": 1928, "instance_count": 2312}, {"id": 124, "name": "Juice", "freebase_id": "/m/01z1kdw", "image_count": 1500, "instance_count": 2262}, {"id": 125, "name": "Gondola", "freebase_id": "/m/02068x", "image_count": 430, "instance_count": 1375}, {"id": 126, "name": "Beetle", "freebase_id": "/m/020jm", "image_count": 1763, "instance_count": 3256}, {"id": 127, "name": "Cannon", "freebase_id": "/m/020kz", "image_count": 612, "instance_count": 840}, {"id": 128, "name": "Computer mouse", "freebase_id": "/m/020lf", "image_count": 614, "instance_count": 724}, {"id": 129, "name": "Cookie", "freebase_id": "/m/021mn", "image_count": 552, "instance_count": 3012}, {"id": 130, "name": "Office building", "freebase_id": "/m/021sj1", "image_count": 4298, "instance_count": 4331}, {"id": 131, "name": "Fountain", "freebase_id": "/m/0220r2", "image_count": 1888, "instance_count": 2201}, {"id": 132, "name": "Coin", "freebase_id": "/m/0242l", "image_count": 1031, "instance_count": 2533}, {"id": 133, "name": "Calculator", "freebase_id": "/m/024d2", "image_count": 166, "instance_count": 202}, {"id": 134, "name": "Cocktail", "freebase_id": "/m/024g6", "image_count": 2320, "instance_count": 3886}, {"id": 135, "name": "Computer monitor", "freebase_id": "/m/02522", "image_count": 3117, "instance_count": 5551}, {"id": 136, "name": "Box", "freebase_id": "/m/025dyy", "image_count": 1897, "instance_count": 3928}, {"id": 137, "name": "Stapler", "freebase_id": "/m/025fsf", "image_count": 48, "instance_count": 58}, {"id": 138, "name": "Christmas tree", "freebase_id": "/m/025nd", "image_count": 2860, "instance_count": 3816}, {"id": 139, "name": "Cowboy hat", "freebase_id": "/m/025rp__", "image_count": 1727, "instance_count": 2430}, {"id": 140, "name": "Hiking equipment", "freebase_id": "/m/0268lbt", "image_count": 1522, "instance_count": 5428}, {"id": 141, "name": "Studio couch", "freebase_id": "/m/026qbn5", "image_count": 1010, "instance_count": 1694}, {"id": 142, "name": "Drum", "freebase_id": "/m/026t6", "image_count": 6693, "instance_count": 20291}, {"id": 143, "name": "Dessert", "freebase_id": "/m/0270h", "image_count": 6296, "instance_count": 15225}, {"id": 144, "name": "Wine rack", "freebase_id": "/m/0271qf7", "image_count": 92, "instance_count": 178}, {"id": 145, "name": "Drink", "freebase_id": "/m/0271t", "image_count": 13243, "instance_count": 29099}, {"id": 146, "name": "Zucchini", "freebase_id": "/m/027pcv", "image_count": 135, "instance_count": 442}, {"id": 147, "name": "Ladle", "freebase_id": "/m/027rl48", "image_count": 19, "instance_count": 53}, {"id": 148, "name": "Human mouth", "freebase_id": "/m/0283dt1", "image_count": 20878, "instance_count": 33204}, {"id": 149, "name": "Dairy Product", "freebase_id": "/m/0284d", "image_count": 2532, "instance_count": 5946}, {"id": 150, "name": "Dice", "freebase_id": "/m/029b3", "image_count": 180, "instance_count": 557}, {"id": 151, "name": "Oven", "freebase_id": "/m/029bxz", "image_count": 383, "instance_count": 477}, {"id": 152, "name": "Dinosaur", "freebase_id": "/m/029tx", "image_count": 947, "instance_count": 1464}, {"id": 153, "name": "Ratchet (Device)", "freebase_id": "/m/02bm9n", "image_count": 35, "instance_count": 200}, {"id": 154, "name": "Couch", "freebase_id": "/m/02crq1", "image_count": 3017, "instance_count": 3847}, {"id": 155, "name": "Cricket ball", "freebase_id": "/m/02ctlc", "image_count": 83, "instance_count": 107}, {"id": 156, "name": "Winter melon", "freebase_id": "/m/02cvgx", "image_count": 31, "instance_count": 31}, {"id": 157, "name": "Spatula", "freebase_id": "/m/02d1br", "image_count": 33, "instance_count": 50}, {"id": 158, "name": "Whiteboard", "freebase_id": "/m/02d9qx", "image_count": 885, "instance_count": 983}, {"id": 159, "name": "Pencil sharpener", "freebase_id": "/m/02ddwp", "image_count": 13, "instance_count": 21}, {"id": 160, "name": "Door", "freebase_id": "/m/02dgv", "image_count": 11793, "instance_count": 16893}, {"id": 161, "name": "Hat", "freebase_id": "/m/02dl1y", "image_count": 7366, "instance_count": 10747}, {"id": 162, "name": "Shower", "freebase_id": "/m/02f9f_", "image_count": 200, "instance_count": 229}, {"id": 163, "name": "Eraser", "freebase_id": "/m/02fh7f", "image_count": 24, "instance_count": 53}, {"id": 164, "name": "Fedora", "freebase_id": "/m/02fq_6", "image_count": 2660, "instance_count": 3231}, {"id": 165, "name": "Guacamole", "freebase_id": "/m/02g30s", "image_count": 156, "instance_count": 195}, {"id": 166, "name": "Dagger", "freebase_id": "/m/02gzp", "image_count": 258, "instance_count": 363}, {"id": 167, "name": "Scarf", "freebase_id": "/m/02h19r", "image_count": 1843, "instance_count": 2097}, {"id": 168, "name": "Dolphin", "freebase_id": "/m/02hj4", "image_count": 796, "instance_count": 1363}, {"id": 169, "name": "Sombrero", "freebase_id": "/m/02jfl0", "image_count": 439, "instance_count": 561}, {"id": 170, "name": "Tin can", "freebase_id": "/m/02jnhm", "image_count": 1059, "instance_count": 2175}, {"id": 171, "name": "Mug", "freebase_id": "/m/02jvh9", "image_count": 1466, "instance_count": 1969}, {"id": 172, "name": "Tap", "freebase_id": "/m/02jz0l", "image_count": 1031, "instance_count": 1463}, {"id": 173, "name": "Harbor seal", "freebase_id": "/m/02l8p9", "image_count": 745, "instance_count": 1319}, {"id": 174, "name": "Stretcher", "freebase_id": "/m/02lbcq", "image_count": 112, "instance_count": 163}, {"id": 175, "name": "Can opener", "freebase_id": "/m/02mqfb", "image_count": 6, "instance_count": 7}, {"id": 176, "name": "Goggles", "freebase_id": "/m/02_n6y", "image_count": 6447, "instance_count": 8292}, {"id": 177, "name": "Human body", "freebase_id": "/m/02p0tk3", "image_count": 34502, "instance_count": 102243}, {"id": 178, "name": "Roller skates", "freebase_id": "/m/02p3w7d", "image_count": 477, "instance_count": 3430}, {"id": 179, "name": "Coffee cup", "freebase_id": "/m/02p5f1q", "image_count": 3391, "instance_count": 4561}, {"id": 180, "name": "Cutting board", "freebase_id": "/m/02pdsw", "image_count": 167, "instance_count": 180}, {"id": 181, "name": "Blender", "freebase_id": "/m/02pjr4", "image_count": 133, "instance_count": 208}, {"id": 182, "name": "Plumbing fixture", "freebase_id": "/m/02pkr5", "image_count": 251, "instance_count": 461}, {"id": 183, "name": "Stop sign", "freebase_id": "/m/02pv19", "image_count": 318, "instance_count": 330}, {"id": 184, "name": "Office supplies", "freebase_id": "/m/02rdsp", "image_count": 1185, "instance_count": 5501}, {"id": 185, "name": "Volleyball (Ball)", "freebase_id": "/m/02rgn06", "image_count": 539, "instance_count": 610}, {"id": 186, "name": "Vase", "freebase_id": "/m/02s195", "image_count": 1067, "instance_count": 1653}, {"id": 187, "name": "Slow cooker", "freebase_id": "/m/02tsc9", "image_count": 89, "instance_count": 102}, {"id": 188, "name": "Wardrobe", "freebase_id": "/m/02vkqh8", "image_count": 169, "instance_count": 194}, {"id": 189, "name": "Coffee", "freebase_id": "/m/02vqfm", "image_count": 1731, "instance_count": 2060}, {"id": 190, "name": "Whisk", "freebase_id": "/m/02vwcm", "image_count": 157, "instance_count": 180}, {"id": 191, "name": "Paper towel", "freebase_id": "/m/02w3r3", "image_count": 123, "instance_count": 175}, {"id": 192, "name": "Personal care", "freebase_id": "/m/02w3_ws", "image_count": 115, "instance_count": 358}, {"id": 193, "name": "Food", "freebase_id": "/m/02wbm", "image_count": 15714, "instance_count": 43473}, {"id": 194, "name": "Sun hat", "freebase_id": "/m/02wbtzl", "image_count": 3547, "instance_count": 5325}, {"id": 195, "name": "Tree house", "freebase_id": "/m/02wg_p", "image_count": 85, "instance_count": 87}, {"id": 196, "name": "Flying disc", "freebase_id": "/m/02wmf", "image_count": 178, "instance_count": 201}, {"id": 197, "name": "Skirt", "freebase_id": "/m/02wv6h6", "image_count": 819, "instance_count": 1060}, {"id": 198, "name": "Gas stove", "freebase_id": "/m/02wv84t", "image_count": 369, "instance_count": 412}, {"id": 199, "name": "Salt and pepper shakers", "freebase_id": "/m/02x8cch", "image_count": 89, "instance_count": 167}, {"id": 200, "name": "Mechanical fan", "freebase_id": "/m/02x984l", "image_count": 542, "instance_count": 626}, {"id": 201, "name": "Face powder", "freebase_id": "/m/02xb7qb", "image_count": 45, "instance_count": 72}, {"id": 202, "name": "Fax", "freebase_id": "/m/02xqq", "image_count": 22, "instance_count": 28}, {"id": 203, "name": "Fruit", "freebase_id": "/m/02xwb", "image_count": 2074, "instance_count": 6691}, {"id": 204, "name": "French fries", "freebase_id": "/m/02y6n", "image_count": 64, "instance_count": 598}, {"id": 205, "name": "Nightstand", "freebase_id": "/m/02z51p", "image_count": 620, "instance_count": 917}, {"id": 206, "name": "Barrel", "freebase_id": "/m/02zn6n", "image_count": 368, "instance_count": 1227}, {"id": 207, "name": "Kite", "freebase_id": "/m/02zt3", "image_count": 313, "instance_count": 1373}, {"id": 208, "name": "Tart", "freebase_id": "/m/02zvsm", "image_count": 315, "instance_count": 579}, {"id": 209, "name": "Treadmill", "freebase_id": "/m/030610", "image_count": 90, "instance_count": 190}, {"id": 210, "name": "Fox", "freebase_id": "/m/0306r", "image_count": 404, "instance_count": 462}, {"id": 211, "name": "Flag", "freebase_id": "/m/03120", "image_count": 6289, "instance_count": 18394}, {"id": 212, "name": "French horn", "freebase_id": "/m/0319l", "image_count": 264, "instance_count": 874}, {"id": 213, "name": "Window blind", "freebase_id": "/m/031b6r", "image_count": 378, "instance_count": 535}, {"id": 214, "name": "Human foot", "freebase_id": "/m/031n1", "image_count": 920, "instance_count": 2034}, {"id": 215, "name": "Golf cart", "freebase_id": "/m/0323sq", "image_count": 240, "instance_count": 375}, {"id": 216, "name": "Jacket", "freebase_id": "/m/032b3c", "image_count": 10693, "instance_count": 20010}, {"id": 217, "name": "Egg (Food)", "freebase_id": "/m/033cnk", "image_count": 514, "instance_count": 1026}, {"id": 218, "name": "Street light", "freebase_id": "/m/033rq4", "image_count": 7025, "instance_count": 24201}, {"id": 219, "name": "Guitar", "freebase_id": "/m/0342h", "image_count": 16260, "instance_count": 23053}, {"id": 220, "name": "Pillow", "freebase_id": "/m/034c16", "image_count": 1183, "instance_count": 3280}, {"id": 221, "name": "Human leg", "freebase_id": "/m/035r7c", "image_count": 13140, "instance_count": 47109}, {"id": 222, "name": "Isopod", "freebase_id": "/m/035vxb", "image_count": 85, "instance_count": 141}, {"id": 223, "name": "Grape", "freebase_id": "/m/0388q", "image_count": 20, "instance_count": 161}, {"id": 224, "name": "Human ear", "freebase_id": "/m/039xj_", "image_count": 7339, "instance_count": 13645}, {"id": 225, "name": "Power plugs and sockets", "freebase_id": "/m/03bbps", "image_count": 139, "instance_count": 272}, {"id": 226, "name": "Panda", "freebase_id": "/m/03bj1", "image_count": 480, "instance_count": 706}, {"id": 227, "name": "Giraffe", "freebase_id": "/m/03bk1", "image_count": 680, "instance_count": 1024}, {"id": 228, "name": "Woman", "freebase_id": "/m/03bt1vf", "image_count": 211054, "instance_count": 519938}, {"id": 229, "name": "Door handle", "freebase_id": "/m/03c7gz", "image_count": 557, "instance_count": 716}, {"id": 230, "name": "Rhinoceros", "freebase_id": "/m/03d443", "image_count": 447, "instance_count": 611}, {"id": 231, "name": "Bathtub", "freebase_id": "/m/03dnzn", "image_count": 490, "instance_count": 501}, {"id": 232, "name": "Goldfish", "freebase_id": "/m/03fj2", "image_count": 325, "instance_count": 1409}, {"id": 233, "name": "Houseplant", "freebase_id": "/m/03fp41", "image_count": 5512, "instance_count": 11884}, {"id": 234, "name": "Goat", "freebase_id": "/m/03fwl", "image_count": 827, "instance_count": 1418}, {"id": 235, "name": "Baseball bat", "freebase_id": "/m/03g8mr", "image_count": 919, "instance_count": 1031}, {"id": 236, "name": "Baseball glove", "freebase_id": "/m/03grzl", "image_count": 1423, "instance_count": 2114}, {"id": 237, "name": "Mixing bowl", "freebase_id": "/m/03hj559", "image_count": 480, "instance_count": 761}, {"id": 238, "name": "Marine invertebrates", "freebase_id": "/m/03hl4l9", "image_count": 1335, "instance_count": 7073}, {"id": 239, "name": "Kitchen utensil", "freebase_id": "/m/03hlz0c", "image_count": 208, "instance_count": 390}, {"id": 240, "name": "Light switch", "freebase_id": "/m/03jbxj", "image_count": 78, "instance_count": 95}, {"id": 241, "name": "House", "freebase_id": "/m/03jm5", "image_count": 37094, "instance_count": 81831}, {"id": 242, "name": "Horse", "freebase_id": "/m/03k3r", "image_count": 5023, "instance_count": 9118}, {"id": 243, "name": "Stationary bicycle", "freebase_id": "/m/03kt2w", "image_count": 81, "instance_count": 226}, {"id": 244, "name": "Hammer", "freebase_id": "/m/03l9g", "image_count": 117, "instance_count": 136}, {"id": 245, "name": "Ceiling fan", "freebase_id": "/m/03ldnb", "image_count": 399, "instance_count": 442}, {"id": 246, "name": "Sofa bed", "freebase_id": "/m/03m3pdh", "image_count": 1031, "instance_count": 1360}, {"id": 247, "name": "Adhesive tape", "freebase_id": "/m/03m3vtv", "image_count": 94, "instance_count": 203}, {"id": 248, "name": "Harp", "freebase_id": "/m/03m5k", "image_count": 197, "instance_count": 227}, {"id": 249, "name": "Sandal", "freebase_id": "/m/03nfch", "image_count": 1214, "instance_count": 2617}, {"id": 250, "name": "Bicycle helmet", "freebase_id": "/m/03p3bw", "image_count": 2970, "instance_count": 6430}, {"id": 251, "name": "Saucer", "freebase_id": "/m/03q5c7", "image_count": 1388, "instance_count": 2349}, {"id": 252, "name": "Harpsichord", "freebase_id": "/m/03q5t", "image_count": 189, "instance_count": 206}, {"id": 253, "name": "Human hair", "freebase_id": "/m/03q69", "image_count": 43629, "instance_count": 125286}, {"id": 254, "name": "Heater", "freebase_id": "/m/03qhv5", "image_count": 32, "instance_count": 35}, {"id": 255, "name": "Harmonica", "freebase_id": "/m/03qjg", "image_count": 20, "instance_count": 38}, {"id": 256, "name": "Hamster", "freebase_id": "/m/03qrc", "image_count": 433, "instance_count": 518}, {"id": 257, "name": "Curtain", "freebase_id": "/m/03rszm", "image_count": 2271, "instance_count": 4094}, {"id": 258, "name": "Bed", "freebase_id": "/m/03ssj5", "image_count": 2667, "instance_count": 3172}, {"id": 259, "name": "Kettle", "freebase_id": "/m/03s_tn", "image_count": 418, "instance_count": 562}, {"id": 260, "name": "Fireplace", "freebase_id": "/m/03tw93", "image_count": 659, "instance_count": 685}, {"id": 261, "name": "Scale", "freebase_id": "/m/03txqz", "image_count": 130, "instance_count": 138}, {"id": 262, "name": "Drinking straw", "freebase_id": "/m/03v5tg", "image_count": 140, "instance_count": 236}, {"id": 263, "name": "Insect", "freebase_id": "/m/03vt0", "image_count": 5504, "instance_count": 7494}, {"id": 264, "name": "Hair dryer", "freebase_id": "/m/03wvsk", "image_count": 27, "instance_count": 27}, {"id": 265, "name": "Kitchenware", "freebase_id": "/m/03_wxk", "image_count": 0, "instance_count": 0}, {"id": 266, "name": "Indoor rower", "freebase_id": "/m/03wym", "image_count": 12, "instance_count": 13}, {"id": 267, "name": "Invertebrate", "freebase_id": "/m/03xxp", "image_count": 684, "instance_count": 1411}, {"id": 268, "name": "Food processor", "freebase_id": "/m/03y6mg", "image_count": 119, "instance_count": 176}, {"id": 269, "name": "Bookcase", "freebase_id": "/m/03__z0", "image_count": 781, "instance_count": 1155}, {"id": 270, "name": "Refrigerator", "freebase_id": "/m/040b_t", "image_count": 467, "instance_count": 506}, {"id": 271, "name": "Wood-burning stove", "freebase_id": "/m/04169hn", "image_count": 276, "instance_count": 289}, {"id": 272, "name": "Punching bag", "freebase_id": "/m/0420v5", "image_count": 117, "instance_count": 329}, {"id": 273, "name": "Common fig", "freebase_id": "/m/043nyj", "image_count": 65, "instance_count": 212}, {"id": 274, "name": "Cocktail shaker", "freebase_id": "/m/0440zs", "image_count": 23, "instance_count": 24}, {"id": 275, "name": "Jaguar (Animal)", "freebase_id": "/m/0449p", "image_count": 410, "instance_count": 468}, {"id": 276, "name": "Golf ball", "freebase_id": "/m/044r5d", "image_count": 279, "instance_count": 338}, {"id": 277, "name": "Fashion accessory", "freebase_id": "/m/0463sg", "image_count": 19718, "instance_count": 72153}, {"id": 278, "name": "Alarm clock", "freebase_id": "/m/046dlr", "image_count": 129, "instance_count": 162}, {"id": 279, "name": "Filing cabinet", "freebase_id": "/m/047j0r", "image_count": 119, "instance_count": 143}, {"id": 280, "name": "Artichoke", "freebase_id": "/m/047v4b", "image_count": 107, "instance_count": 217}, {"id": 281, "name": "Table", "freebase_id": "/m/04bcr3", "image_count": 35125, "instance_count": 63501}, {"id": 282, "name": "Tableware", "freebase_id": "/m/04brg2", "image_count": 3477, "instance_count": 20098}, {"id": 283, "name": "Kangaroo", "freebase_id": "/m/04c0y", "image_count": 379, "instance_count": 625}, {"id": 284, "name": "Koala", "freebase_id": "/m/04cp_", "image_count": 337, "instance_count": 379}, {"id": 285, "name": "Knife", "freebase_id": "/m/04ctx", "image_count": 569, "instance_count": 781}, {"id": 286, "name": "Bottle", "freebase_id": "/m/04dr76w", "image_count": 9697, "instance_count": 24636}, {"id": 287, "name": "Bottle opener", "freebase_id": "/m/04f5ws", "image_count": 17, "instance_count": 21}, {"id": 288, "name": "Lynx", "freebase_id": "/m/04g2r", "image_count": 191, "instance_count": 204}, {"id": 289, "name": "Lavender (Plant)", "freebase_id": "/m/04gth", "image_count": 230, "instance_count": 1711}, {"id": 290, "name": "Lighthouse", "freebase_id": "/m/04h7h", "image_count": 1285, "instance_count": 1334}, {"id": 291, "name": "Dumbbell", "freebase_id": "/m/04h8sr", "image_count": 82, "instance_count": 254}, {"id": 292, "name": "Human head", "freebase_id": "/m/04hgtk", "image_count": 39752, "instance_count": 109981}, {"id": 293, "name": "Bowl", "freebase_id": "/m/04kkgm", "image_count": 1178, "instance_count": 2754}, {"id": 294, "name": "Humidifier", "freebase_id": "/m/04lvq_", "image_count": 9, "instance_count": 11}, {"id": 295, "name": "Porch", "freebase_id": "/m/04m6gz", "image_count": 1740, "instance_count": 2379}, {"id": 296, "name": "Lizard", "freebase_id": "/m/04m9y", "image_count": 1702, "instance_count": 1954}, {"id": 297, "name": "Billiard table", "freebase_id": "/m/04p0qw", "image_count": 563, "instance_count": 765}, {"id": 298, "name": "Mammal", "freebase_id": "/m/04rky", "image_count": 23173, "instance_count": 81163}, {"id": 299, "name": "Mouse", "freebase_id": "/m/04rmv", "image_count": 662, "instance_count": 797}, {"id": 300, "name": "Motorcycle", "freebase_id": "/m/04_sv", "image_count": 5325, "instance_count": 9382}, {"id": 301, "name": "Musical instrument", "freebase_id": "/m/04szw", "image_count": 4253, "instance_count": 10878}, {"id": 302, "name": "Swim cap", "freebase_id": "/m/04tn4x", "image_count": 303, "instance_count": 584}, {"id": 303, "name": "Frying pan", "freebase_id": "/m/04v6l4", "image_count": 260, "instance_count": 324}, {"id": 304, "name": "Snowplow", "freebase_id": "/m/04vv5k", "image_count": 196, "instance_count": 252}, {"id": 305, "name": "Bathroom cabinet", "freebase_id": "/m/04y4h8h", "image_count": 256, "instance_count": 277}, {"id": 306, "name": "Missile", "freebase_id": "/m/04ylt", "image_count": 420, "instance_count": 581}, {"id": 307, "name": "Bust", "freebase_id": "/m/04yqq2", "image_count": 843, "instance_count": 985}, {"id": 308, "name": "Man", "freebase_id": "/m/04yx4", "image_count": 298992, "instance_count": 958133}, {"id": 309, "name": "Waffle iron", "freebase_id": "/m/04z4wx", "image_count": 22, "instance_count": 29}, {"id": 310, "name": "Milk", "freebase_id": "/m/04zpv", "image_count": 144, "instance_count": 195}, {"id": 311, "name": "Ring binder", "freebase_id": "/m/04zwwv", "image_count": 47, "instance_count": 82}, {"id": 312, "name": "Plate", "freebase_id": "/m/050gv4", "image_count": 1643, "instance_count": 3780}, {"id": 313, "name": "Mobile phone", "freebase_id": "/m/050k8", "image_count": 4145, "instance_count": 6051}, {"id": 314, "name": "Baked goods", "freebase_id": "/m/052lwg6", "image_count": 7485, "instance_count": 14300}, {"id": 315, "name": "Mushroom", "freebase_id": "/m/052sf", "image_count": 814, "instance_count": 1951}, {"id": 316, "name": "Crutch", "freebase_id": "/m/05441v", "image_count": 74, "instance_count": 136}, {"id": 317, "name": "Pitcher (Container)", "freebase_id": "/m/054fyh", "image_count": 252, "instance_count": 303}, {"id": 318, "name": "Mirror", "freebase_id": "/m/054_l", "image_count": 971, "instance_count": 1348}, {"id": 319, "name": "Personal flotation device", "freebase_id": "/m/054xkw", "image_count": 1025, "instance_count": 2793}, {"id": 320, "name": "Table tennis racket", "freebase_id": "/m/05_5p_0", "image_count": 566, "instance_count": 815}, {"id": 321, "name": "Pencil case", "freebase_id": "/m/05676x", "image_count": 89, "instance_count": 116}, {"id": 322, "name": "Musical keyboard", "freebase_id": "/m/057cc", "image_count": 1435, "instance_count": 1682}, {"id": 323, "name": "Scoreboard", "freebase_id": "/m/057p5t", "image_count": 347, "instance_count": 376}, {"id": 324, "name": "Briefcase", "freebase_id": "/m/0584n8", "image_count": 106, "instance_count": 135}, {"id": 325, "name": "Kitchen knife", "freebase_id": "/m/058qzx", "image_count": 240, "instance_count": 300}, {"id": 326, "name": "Nail (Construction)", "freebase_id": "/m/05bm6", "image_count": 118, "instance_count": 480}, {"id": 327, "name": "Tennis ball", "freebase_id": "/m/05ctyq", "image_count": 345, "instance_count": 426}, {"id": 328, "name": "Plastic bag", "freebase_id": "/m/05gqfk", "image_count": 391, "instance_count": 682}, {"id": 329, "name": "Oboe", "freebase_id": "/m/05kms", "image_count": 86, "instance_count": 137}, {"id": 330, "name": "Chest of drawers", "freebase_id": "/m/05kyg_", "image_count": 515, "instance_count": 650}, {"id": 331, "name": "Ostrich", "freebase_id": "/m/05n4y", "image_count": 303, "instance_count": 487}, {"id": 332, "name": "Piano", "freebase_id": "/m/05r5c", "image_count": 1184, "instance_count": 1301}, {"id": 333, "name": "Girl", "freebase_id": "/m/05r655", "image_count": 72741, "instance_count": 135861}, {"id": 334, "name": "Plant", "freebase_id": "/m/05s2s", "image_count": 17891, "instance_count": 62731}, {"id": 335, "name": "Potato", "freebase_id": "/m/05vtc", "image_count": 136, "instance_count": 274}, {"id": 336, "name": "Hair spray", "freebase_id": "/m/05w9t9", "image_count": 5, "instance_count": 9}, {"id": 337, "name": "Sports equipment", "freebase_id": "/m/05y5lj", "image_count": 6388, "instance_count": 25243}, {"id": 338, "name": "Pasta", "freebase_id": "/m/05z55", "image_count": 646, "instance_count": 654}, {"id": 339, "name": "Penguin", "freebase_id": "/m/05z6w", "image_count": 768, "instance_count": 3036}, {"id": 340, "name": "Pumpkin", "freebase_id": "/m/05zsy", "image_count": 1126, "instance_count": 3110}, {"id": 341, "name": "Pear", "freebase_id": "/m/061_f", "image_count": 224, "instance_count": 653}, {"id": 342, "name": "Infant bed", "freebase_id": "/m/061hd_", "image_count": 411, "instance_count": 444}, {"id": 343, "name": "Polar bear", "freebase_id": "/m/0633h", "image_count": 471, "instance_count": 630}, {"id": 344, "name": "Mixer", "freebase_id": "/m/063rgb", "image_count": 173, "instance_count": 207}, {"id": 345, "name": "Cupboard", "freebase_id": "/m/0642b4", "image_count": 531, "instance_count": 744}, {"id": 346, "name": "Jacuzzi", "freebase_id": "/m/065h6l", "image_count": 93, "instance_count": 94}, {"id": 347, "name": "Pizza", "freebase_id": "/m/0663v", "image_count": 1122, "instance_count": 1740}, {"id": 348, "name": "Digital clock", "freebase_id": "/m/06_72j", "image_count": 168, "instance_count": 198}, {"id": 349, "name": "Pig", "freebase_id": "/m/068zj", "image_count": 638, "instance_count": 1169}, {"id": 350, "name": "Reptile", "freebase_id": "/m/06bt6", "image_count": 413, "instance_count": 498}, {"id": 351, "name": "Rifle", "freebase_id": "/m/06c54", "image_count": 1548, "instance_count": 2153}, {"id": 352, "name": "Lipstick", "freebase_id": "/m/06c7f7", "image_count": 1063, "instance_count": 1276}, {"id": 353, "name": "Skateboard", "freebase_id": "/m/06_fw", "image_count": 907, "instance_count": 1485}, {"id": 354, "name": "Raven", "freebase_id": "/m/06j2d", "image_count": 377, "instance_count": 495}, {"id": 355, "name": "High heels", "freebase_id": "/m/06k2mb", "image_count": 1451, "instance_count": 2887}, {"id": 356, "name": "Red panda", "freebase_id": "/m/06l9r", "image_count": 287, "instance_count": 356}, {"id": 357, "name": "Rose", "freebase_id": "/m/06m11", "image_count": 3674, "instance_count": 8391}, {"id": 358, "name": "Rabbit", "freebase_id": "/m/06mf6", "image_count": 972, "instance_count": 1289}, {"id": 359, "name": "Sculpture", "freebase_id": "/m/06msq", "image_count": 14266, "instance_count": 26382}, {"id": 360, "name": "Saxophone", "freebase_id": "/m/06ncr", "image_count": 746, "instance_count": 980}, {"id": 361, "name": "Shotgun", "freebase_id": "/m/06nrc", "image_count": 406, "instance_count": 543}, {"id": 362, "name": "Seafood", "freebase_id": "/m/06nwz", "image_count": 543, "instance_count": 1021}, {"id": 363, "name": "Submarine sandwich", "freebase_id": "/m/06pcq", "image_count": 192, "instance_count": 222}, {"id": 364, "name": "Snowboard", "freebase_id": "/m/06__v", "image_count": 476, "instance_count": 717}, {"id": 365, "name": "Sword", "freebase_id": "/m/06y5r", "image_count": 385, "instance_count": 552}, {"id": 366, "name": "Picture frame", "freebase_id": "/m/06z37_", "image_count": 4917, "instance_count": 10425}, {"id": 367, "name": "Sushi", "freebase_id": "/m/07030", "image_count": 258, "instance_count": 773}, {"id": 368, "name": "Loveseat", "freebase_id": "/m/0703r8", "image_count": 465, "instance_count": 577}, {"id": 369, "name": "Ski", "freebase_id": "/m/071p9", "image_count": 931, "instance_count": 2075}, {"id": 370, "name": "Squirrel", "freebase_id": "/m/071qp", "image_count": 1506, "instance_count": 1590}, {"id": 371, "name": "Tripod", "freebase_id": "/m/073bxn", "image_count": 1067, "instance_count": 1281}, {"id": 372, "name": "Stethoscope", "freebase_id": "/m/073g6", "image_count": 74, "instance_count": 77}, {"id": 373, "name": "Submarine", "freebase_id": "/m/074d1", "image_count": 74, "instance_count": 80}, {"id": 374, "name": "Scorpion", "freebase_id": "/m/0755b", "image_count": 146, "instance_count": 179}, {"id": 375, "name": "Segway", "freebase_id": "/m/076bq", "image_count": 246, "instance_count": 494}, {"id": 376, "name": "Training bench", "freebase_id": "/m/076lb9", "image_count": 81, "instance_count": 149}, {"id": 377, "name": "Snake", "freebase_id": "/m/078jl", "image_count": 1112, "instance_count": 1292}, {"id": 378, "name": "Coffee table", "freebase_id": "/m/078n6m", "image_count": 2363, "instance_count": 4217}, {"id": 379, "name": "Skyscraper", "freebase_id": "/m/079cl", "image_count": 13904, "instance_count": 48273}, {"id": 380, "name": "Sheep", "freebase_id": "/m/07bgp", "image_count": 677, "instance_count": 1950}, {"id": 381, "name": "Television", "freebase_id": "/m/07c52", "image_count": 2487, "instance_count": 3340}, {"id": 382, "name": "Trombone", "freebase_id": "/m/07c6l", "image_count": 364, "instance_count": 639}, {"id": 383, "name": "Tea", "freebase_id": "/m/07clx", "image_count": 954, "instance_count": 1181}, {"id": 384, "name": "Tank", "freebase_id": "/m/07cmd", "image_count": 873, "instance_count": 1362}, {"id": 385, "name": "Taco", "freebase_id": "/m/07crc", "image_count": 306, "instance_count": 601}, {"id": 386, "name": "Telephone", "freebase_id": "/m/07cx4", "image_count": 211, "instance_count": 261}, {"id": 387, "name": "Torch", "freebase_id": "/m/07dd4", "image_count": 18, "instance_count": 20}, {"id": 388, "name": "Tiger", "freebase_id": "/m/07dm6", "image_count": 797, "instance_count": 963}, {"id": 389, "name": "Strawberry", "freebase_id": "/m/07fbm7", "image_count": 867, "instance_count": 5729}, {"id": 390, "name": "Trumpet", "freebase_id": "/m/07gql", "image_count": 696, "instance_count": 1160}, {"id": 391, "name": "Tree", "freebase_id": "/m/07j7r", "image_count": 106636, "instance_count": 375594}, {"id": 392, "name": "Tomato", "freebase_id": "/m/07j87", "image_count": 762, "instance_count": 3783}, {"id": 393, "name": "Train", "freebase_id": "/m/07jdr", "image_count": 7263, "instance_count": 9467}, {"id": 394, "name": "Tool", "freebase_id": "/m/07k1x", "image_count": 709, "instance_count": 1617}, {"id": 395, "name": "Picnic basket", "freebase_id": "/m/07kng9", "image_count": 241, "instance_count": 348}, {"id": 396, "name": "Cooking spray", "freebase_id": "/m/07mcwg", "image_count": 9, "instance_count": 42}, {"id": 397, "name": "Trousers", "freebase_id": "/m/07mhn", "image_count": 4002, "instance_count": 6654}, {"id": 398, "name": "Bowling equipment", "freebase_id": "/m/07pj7bq", "image_count": 245, "instance_count": 743}, {"id": 399, "name": "Football helmet", "freebase_id": "/m/07qxg_", "image_count": 1269, "instance_count": 5564}, {"id": 400, "name": "Truck", "freebase_id": "/m/07r04", "image_count": 6185, "instance_count": 9046}, {"id": 401, "name": "Measuring cup", "freebase_id": "/m/07v9_z", "image_count": 64, "instance_count": 73}, {"id": 402, "name": "Coffeemaker", "freebase_id": "/m/07xyvk", "image_count": 223, "instance_count": 311}, {"id": 403, "name": "Violin", "freebase_id": "/m/07y_7", "image_count": 1195, "instance_count": 2233}, {"id": 404, "name": "Vehicle", "freebase_id": "/m/07yv9", "image_count": 10989, "instance_count": 27848}, {"id": 405, "name": "Handbag", "freebase_id": "/m/080hkjn", "image_count": 1740, "instance_count": 2248}, {"id": 406, "name": "Paper cutter", "freebase_id": "/m/080n7g", "image_count": 3, "instance_count": 4}, {"id": 407, "name": "Wine", "freebase_id": "/m/081qc", "image_count": 3951, "instance_count": 9670}, {"id": 408, "name": "Weapon", "freebase_id": "/m/083kb", "image_count": 1383, "instance_count": 2360}, {"id": 409, "name": "Wheel", "freebase_id": "/m/083wq", "image_count": 58010, "instance_count": 226764}, {"id": 410, "name": "Worm", "freebase_id": "/m/084hf", "image_count": 183, "instance_count": 242}, {"id": 411, "name": "Wok", "freebase_id": "/m/084rd", "image_count": 330, "instance_count": 511}, {"id": 412, "name": "Whale", "freebase_id": "/m/084zz", "image_count": 672, "instance_count": 909}, {"id": 413, "name": "Zebra", "freebase_id": "/m/0898b", "image_count": 351, "instance_count": 555}, {"id": 414, "name": "Auto part", "freebase_id": "/m/08dz3q", "image_count": 2539, "instance_count": 5156}, {"id": 415, "name": "Jug", "freebase_id": "/m/08hvt4", "image_count": 343, "instance_count": 500}, {"id": 416, "name": "Pizza cutter", "freebase_id": "/m/08ks85", "image_count": 19, "instance_count": 20}, {"id": 417, "name": "Cream", "freebase_id": "/m/08p92x", "image_count": 68, "instance_count": 120}, {"id": 418, "name": "Monkey", "freebase_id": "/m/08pbxl", "image_count": 1774, "instance_count": 2484}, {"id": 419, "name": "Lion", "freebase_id": "/m/096mb", "image_count": 954, "instance_count": 1276}, {"id": 420, "name": "Bread", "freebase_id": "/m/09728", "image_count": 1280, "instance_count": 2639}, {"id": 421, "name": "Platter", "freebase_id": "/m/099ssp", "image_count": 986, "instance_count": 2243}, {"id": 422, "name": "Chicken", "freebase_id": "/m/09b5t", "image_count": 1153, "instance_count": 2229}, {"id": 423, "name": "Eagle", "freebase_id": "/m/09csl", "image_count": 1391, "instance_count": 1591}, {"id": 424, "name": "Helicopter", "freebase_id": "/m/09ct_", "image_count": 2179, "instance_count": 2715}, {"id": 425, "name": "Owl", "freebase_id": "/m/09d5_", "image_count": 1212, "instance_count": 1493}, {"id": 426, "name": "Duck", "freebase_id": "/m/09ddx", "image_count": 3773, "instance_count": 10447}, {"id": 427, "name": "Turtle", "freebase_id": "/m/09dzg", "image_count": 119, "instance_count": 165}, {"id": 428, "name": "Hippopotamus", "freebase_id": "/m/09f20", "image_count": 343, "instance_count": 571}, {"id": 429, "name": "Crocodile", "freebase_id": "/m/09f_2", "image_count": 606, "instance_count": 853}, {"id": 430, "name": "Toilet", "freebase_id": "/m/09g1w", "image_count": 811, "instance_count": 1033}, {"id": 431, "name": "Toilet paper", "freebase_id": "/m/09gtd", "image_count": 195, "instance_count": 313}, {"id": 432, "name": "Squid", "freebase_id": "/m/09gys", "image_count": 78, "instance_count": 137}, {"id": 433, "name": "Clothing", "freebase_id": "/m/09j2d", "image_count": 253553, "instance_count": 937287}, {"id": 434, "name": "Footwear", "freebase_id": "/m/09j5n", "image_count": 94846, "instance_count": 484352}, {"id": 435, "name": "Lemon", "freebase_id": "/m/09k_b", "image_count": 490, "instance_count": 1182}, {"id": 436, "name": "Spider", "freebase_id": "/m/09kmb", "image_count": 1621, "instance_count": 1930}, {"id": 437, "name": "Deer", "freebase_id": "/m/09kx5", "image_count": 1353, "instance_count": 2310}, {"id": 438, "name": "Frog", "freebase_id": "/m/09ld4", "image_count": 1248, "instance_count": 1465}, {"id": 439, "name": "Banana", "freebase_id": "/m/09qck", "image_count": 358, "instance_count": 667}, {"id": 440, "name": "Rocket", "freebase_id": "/m/09rvcxw", "image_count": 622, "instance_count": 890}, {"id": 441, "name": "Wine glass", "freebase_id": "/m/09tvcd", "image_count": 4101, "instance_count": 10326}, {"id": 442, "name": "Countertop", "freebase_id": "/m/0b3fp9", "image_count": 1608, "instance_count": 2240}, {"id": 443, "name": "Tablet computer", "freebase_id": "/m/0bh9flk", "image_count": 756, "instance_count": 936}, {"id": 444, "name": "Waste container", "freebase_id": "/m/0bjyj5", "image_count": 853, "instance_count": 1474}, {"id": 445, "name": "Swimming pool", "freebase_id": "/m/0b_rs", "image_count": 2872, "instance_count": 3057}, {"id": 446, "name": "Dog", "freebase_id": "/m/0bt9lr", "image_count": 18057, "instance_count": 24721}, {"id": 447, "name": "Book", "freebase_id": "/m/0bt_c3", "image_count": 3640, "instance_count": 7698}, {"id": 448, "name": "Elephant", "freebase_id": "/m/0bwd_0j", "image_count": 1225, "instance_count": 2263}, {"id": 449, "name": "Shark", "freebase_id": "/m/0by6g", "image_count": 486, "instance_count": 613}, {"id": 450, "name": "Candle", "freebase_id": "/m/0c06p", "image_count": 1005, "instance_count": 4531}, {"id": 451, "name": "Leopard", "freebase_id": "/m/0c29q", "image_count": 534, "instance_count": 613}, {"id": 452, "name": "Axe", "freebase_id": "/m/0c2jj", "image_count": 112, "instance_count": 145}, {"id": 453, "name": "Hand dryer", "freebase_id": "/m/0c3m8g", "image_count": 56, "instance_count": 70}, {"id": 454, "name": "Soap dispenser", "freebase_id": "/m/0c3mkw", "image_count": 58, "instance_count": 78}, {"id": 455, "name": "Porcupine", "freebase_id": "/m/0c568", "image_count": 182, "instance_count": 205}, {"id": 456, "name": "Flower", "freebase_id": "/m/0c9ph5", "image_count": 29498, "instance_count": 125304}, {"id": 457, "name": "Canary", "freebase_id": "/m/0ccs93", "image_count": 206, "instance_count": 322}, {"id": 458, "name": "Cheetah", "freebase_id": "/m/0cd4d", "image_count": 424, "instance_count": 533}, {"id": 459, "name": "Palm tree", "freebase_id": "/m/0cdl1", "image_count": 7987, "instance_count": 31443}, {"id": 460, "name": "Hamburger", "freebase_id": "/m/0cdn1", "image_count": 624, "instance_count": 835}, {"id": 461, "name": "Maple", "freebase_id": "/m/0cffdh", "image_count": 1628, "instance_count": 3515}, {"id": 462, "name": "Building", "freebase_id": "/m/0cgh4", "image_count": 64125, "instance_count": 102491}, {"id": 463, "name": "Fish", "freebase_id": "/m/0ch_cf", "image_count": 4327, "instance_count": 14862}, {"id": 464, "name": "Lobster", "freebase_id": "/m/0cjq5", "image_count": 261, "instance_count": 384}, {"id": 465, "name": "Garden Asparagus", "freebase_id": "/m/0cjs7", "image_count": 59, "instance_count": 84}, {"id": 466, "name": "Furniture", "freebase_id": "/m/0c_jw", "image_count": 11135, "instance_count": 27884}, {"id": 467, "name": "Hedgehog", "freebase_id": "/m/0cl4p", "image_count": 213, "instance_count": 235}, {"id": 468, "name": "Airplane", "freebase_id": "/m/0cmf2", "image_count": 11295, "instance_count": 19823}, {"id": 469, "name": "Spoon", "freebase_id": "/m/0cmx8", "image_count": 913, "instance_count": 1435}, {"id": 470, "name": "Otter", "freebase_id": "/m/0cn6p", "image_count": 439, "instance_count": 661}, {"id": 471, "name": "Bull", "freebase_id": "/m/0cnyhnx", "image_count": 829, "instance_count": 1187}, {"id": 472, "name": "Oyster", "freebase_id": "/m/0_cp5", "image_count": 235, "instance_count": 603}, {"id": 473, "name": "Horizontal bar", "freebase_id": "/m/0cqn2", "image_count": 48, "instance_count": 64}, {"id": 474, "name": "Convenience store", "freebase_id": "/m/0crjs", "image_count": 1233, "instance_count": 1240}, {"id": 475, "name": "Bomb", "freebase_id": "/m/0ct4f", "image_count": 6, "instance_count": 8}, {"id": 476, "name": "Bench", "freebase_id": "/m/0cvnqh", "image_count": 2085, "instance_count": 3801}, {"id": 477, "name": "Ice cream", "freebase_id": "/m/0cxn2", "image_count": 1331, "instance_count": 2451}, {"id": 478, "name": "Caterpillar", "freebase_id": "/m/0cydv", "image_count": 622, "instance_count": 779}, {"id": 479, "name": "Butterfly", "freebase_id": "/m/0cyf8", "image_count": 3871, "instance_count": 8739}, {"id": 480, "name": "Parachute", "freebase_id": "/m/0cyfs", "image_count": 974, "instance_count": 2342}, {"id": 481, "name": "Orange", "freebase_id": "/m/0cyhj_", "image_count": 653, "instance_count": 3820}, {"id": 482, "name": "Antelope", "freebase_id": "/m/0czz2", "image_count": 602, "instance_count": 1074}, {"id": 483, "name": "Beaker", "freebase_id": "/m/0d20w4", "image_count": 84, "instance_count": 165}, {"id": 484, "name": "Moths and butterflies", "freebase_id": "/m/0d_2m", "image_count": 1650, "instance_count": 1805}, {"id": 485, "name": "Window", "freebase_id": "/m/0d4v4", "image_count": 42733, "instance_count": 306327}, {"id": 486, "name": "Closet", "freebase_id": "/m/0d4w1", "image_count": 259, "instance_count": 452}, {"id": 487, "name": "Castle", "freebase_id": "/m/0d5gx", "image_count": 2649, "instance_count": 2987}, {"id": 488, "name": "Jellyfish", "freebase_id": "/m/0d8zb", "image_count": 632, "instance_count": 1626}, {"id": 489, "name": "Goose", "freebase_id": "/m/0dbvp", "image_count": 2052, "instance_count": 5910}, {"id": 490, "name": "Mule", "freebase_id": "/m/0dbzx", "image_count": 427, "instance_count": 770}, {"id": 491, "name": "Swan", "freebase_id": "/m/0dftk", "image_count": 1105, "instance_count": 2985}, {"id": 492, "name": "Peach", "freebase_id": "/m/0dj6p", "image_count": 86, "instance_count": 333}, {"id": 493, "name": "Coconut", "freebase_id": "/m/0djtd", "image_count": 81, "instance_count": 165}, {"id": 494, "name": "Seat belt", "freebase_id": "/m/0dkzw", "image_count": 311, "instance_count": 451}, {"id": 495, "name": "Raccoon", "freebase_id": "/m/0dq75", "image_count": 278, "instance_count": 336}, {"id": 496, "name": "Chisel", "freebase_id": "/m/0_dqb", "image_count": 20, "instance_count": 25}, {"id": 497, "name": "Fork", "freebase_id": "/m/0dt3t", "image_count": 885, "instance_count": 1442}, {"id": 498, "name": "Lamp", "freebase_id": "/m/0dtln", "image_count": 1420, "instance_count": 2912}, {"id": 499, "name": "Camera", "freebase_id": "/m/0dv5r", "image_count": 4726, "instance_count": 5933}, {"id": 500, "name": "Squash (Plant)", "freebase_id": "/m/0dv77", "image_count": 76, "instance_count": 157}, {"id": 501, "name": "Racket", "freebase_id": "/m/0dv9c", "image_count": 201, "instance_count": 236}, {"id": 502, "name": "Human face", "freebase_id": "/m/0dzct", "image_count": 286554, "instance_count": 762660}, {"id": 503, "name": "Human arm", "freebase_id": "/m/0dzf4", "image_count": 32749, "instance_count": 130607}, {"id": 504, "name": "Vegetable", "freebase_id": "/m/0f4s2w", "image_count": 1321, "instance_count": 4748}, {"id": 505, "name": "Diaper", "freebase_id": "/m/0f571", "image_count": 110, "instance_count": 146}, {"id": 506, "name": "Unicycle", "freebase_id": "/m/0f6nr", "image_count": 115, "instance_count": 159}, {"id": 507, "name": "Falcon", "freebase_id": "/m/0f6wt", "image_count": 1417, "instance_count": 1622}, {"id": 508, "name": "Chime", "freebase_id": "/m/0f8s22", "image_count": 21, "instance_count": 31}, {"id": 509, "name": "Snail", "freebase_id": "/m/0f9_l", "image_count": 552, "instance_count": 805}, {"id": 510, "name": "Shellfish", "freebase_id": "/m/0fbdv", "image_count": 245, "instance_count": 870}, {"id": 511, "name": "Cabbage", "freebase_id": "/m/0fbw6", "image_count": 98, "instance_count": 163}, {"id": 512, "name": "Carrot", "freebase_id": "/m/0fj52s", "image_count": 286, "instance_count": 699}, {"id": 513, "name": "Mango", "freebase_id": "/m/0fldg", "image_count": 57, "instance_count": 212}, {"id": 514, "name": "Jeans", "freebase_id": "/m/0fly7", "image_count": 24202, "instance_count": 56204}, {"id": 515, "name": "Flowerpot", "freebase_id": "/m/0fm3zh", "image_count": 4107, "instance_count": 9921}, {"id": 516, "name": "Pineapple", "freebase_id": "/m/0fp6w", "image_count": 230, "instance_count": 493}, {"id": 517, "name": "Drawer", "freebase_id": "/m/0fqfqc", "image_count": 617, "instance_count": 1892}, {"id": 518, "name": "Stool", "freebase_id": "/m/0fqt361", "image_count": 492, "instance_count": 1070}, {"id": 519, "name": "Envelope", "freebase_id": "/m/0frqm", "image_count": 116, "instance_count": 170}, {"id": 520, "name": "Cake", "freebase_id": "/m/0fszt", "image_count": 3076, "instance_count": 4100}, {"id": 521, "name": "Dragonfly", "freebase_id": "/m/0ft9s", "image_count": 1221, "instance_count": 1336}, {"id": 522, "name": "Common sunflower", "freebase_id": "/m/0ftb8", "image_count": 1419, "instance_count": 5807}, {"id": 523, "name": "Microwave oven", "freebase_id": "/m/0fx9l", "image_count": 337, "instance_count": 379}, {"id": 524, "name": "Honeycomb", "freebase_id": "/m/0fz0h", "image_count": 253, "instance_count": 272}, {"id": 525, "name": "Marine mammal", "freebase_id": "/m/0gd2v", "image_count": 873, "instance_count": 1428}, {"id": 526, "name": "Sea lion", "freebase_id": "/m/0gd36", "image_count": 737, "instance_count": 1406}, {"id": 527, "name": "Ladybug", "freebase_id": "/m/0gj37", "image_count": 519, "instance_count": 646}, {"id": 528, "name": "Shelf", "freebase_id": "/m/0gjbg72", "image_count": 2888, "instance_count": 9423}, {"id": 529, "name": "Watch", "freebase_id": "/m/0gjkl", "image_count": 1410, "instance_count": 1868}, {"id": 530, "name": "Candy", "freebase_id": "/m/0gm28", "image_count": 437, "instance_count": 1046}, {"id": 531, "name": "Salad", "freebase_id": "/m/0grw1", "image_count": 2241, "instance_count": 2576}, {"id": 532, "name": "Parrot", "freebase_id": "/m/0gv1x", "image_count": 1251, "instance_count": 1985}, {"id": 533, "name": "Handgun", "freebase_id": "/m/0gxl3", "image_count": 555, "instance_count": 710}, {"id": 534, "name": "Sparrow", "freebase_id": "/m/0h23m", "image_count": 1034, "instance_count": 1470}, {"id": 535, "name": "Van", "freebase_id": "/m/0h2r6", "image_count": 4349, "instance_count": 6200}, {"id": 536, "name": "Grinder", "freebase_id": "/m/0h8jyh6", "image_count": 10, "instance_count": 13}, {"id": 537, "name": "Spice rack", "freebase_id": "/m/0h8kx63", "image_count": 53, "instance_count": 105}, {"id": 538, "name": "Light bulb", "freebase_id": "/m/0h8l4fh", "image_count": 406, "instance_count": 1506}, {"id": 539, "name": "Corded phone", "freebase_id": "/m/0h8lkj8", "image_count": 344, "instance_count": 425}, {"id": 540, "name": "Sports uniform", "freebase_id": "/m/0h8mhzd", "image_count": 5416, "instance_count": 14241}, {"id": 541, "name": "Tennis racket", "freebase_id": "/m/0h8my_4", "image_count": 763, "instance_count": 884}, {"id": 542, "name": "Wall clock", "freebase_id": "/m/0h8mzrc", "image_count": 811, "instance_count": 983}, {"id": 543, "name": "Serving tray", "freebase_id": "/m/0h8n27j", "image_count": 99, "instance_count": 107}, {"id": 544, "name": "Kitchen & dining room table", "freebase_id": "/m/0h8n5zk", "image_count": 1495, "instance_count": 1597}, {"id": 545, "name": "Dog bed", "freebase_id": "/m/0h8n6f9", "image_count": 229, "instance_count": 253}, {"id": 546, "name": "Cake stand", "freebase_id": "/m/0h8n6ft", "image_count": 203, "instance_count": 276}, {"id": 547, "name": "Cat furniture", "freebase_id": "/m/0h8nm9j", "image_count": 180, "instance_count": 202}, {"id": 548, "name": "Bathroom accessory", "freebase_id": "/m/0h8nr_l", "image_count": 639, "instance_count": 2247}, {"id": 549, "name": "Facial tissue holder", "freebase_id": "/m/0h8nsvg", "image_count": 18, "instance_count": 19}, {"id": 550, "name": "Pressure cooker", "freebase_id": "/m/0h8ntjv", "image_count": 13, "instance_count": 14}, {"id": 551, "name": "Kitchen appliance", "freebase_id": "/m/0h99cwc", "image_count": 928, "instance_count": 3552}, {"id": 552, "name": "Tire", "freebase_id": "/m/0h9mv", "image_count": 23939, "instance_count": 83517}, {"id": 553, "name": "Ruler", "freebase_id": "/m/0hdln", "image_count": 230, "instance_count": 245}, {"id": 554, "name": "Luggage and bags", "freebase_id": "/m/0hf58v5", "image_count": 801, "instance_count": 1774}, {"id": 555, "name": "Microphone", "freebase_id": "/m/0hg7b", "image_count": 19830, "instance_count": 26336}, {"id": 556, "name": "Broccoli", "freebase_id": "/m/0hkxq", "image_count": 222, "instance_count": 712}, {"id": 557, "name": "Umbrella", "freebase_id": "/m/0hnnb", "image_count": 2273, "instance_count": 4705}, {"id": 558, "name": "Pastry", "freebase_id": "/m/0hnyx", "image_count": 642, "instance_count": 2094}, {"id": 559, "name": "Grapefruit", "freebase_id": "/m/0hqkz", "image_count": 297, "instance_count": 768}, {"id": 560, "name": "Band-aid", "freebase_id": "/m/0j496", "image_count": 20, "instance_count": 36}, {"id": 561, "name": "Animal", "freebase_id": "/m/0jbk", "image_count": 7214, "instance_count": 12475}, {"id": 562, "name": "Bell pepper", "freebase_id": "/m/0jg57", "image_count": 198, "instance_count": 490}, {"id": 563, "name": "Turkey", "freebase_id": "/m/0jly1", "image_count": 290, "instance_count": 570}, {"id": 564, "name": "Lily", "freebase_id": "/m/0jqgx", "image_count": 863, "instance_count": 1678}, {"id": 565, "name": "Pomegranate", "freebase_id": "/m/0jwn_", "image_count": 159, "instance_count": 343}, {"id": 566, "name": "Doughnut", "freebase_id": "/m/0jy4k", "image_count": 241, "instance_count": 552}, {"id": 567, "name": "Glasses", "freebase_id": "/m/0jyfg", "image_count": 38197, "instance_count": 50948}, {"id": 568, "name": "Human nose", "freebase_id": "/m/0k0pj", "image_count": 24508, "instance_count": 43663}, {"id": 569, "name": "Pen", "freebase_id": "/m/0k1tl", "image_count": 926, "instance_count": 1492}, {"id": 570, "name": "Ant", "freebase_id": "/m/0_k2", "image_count": 327, "instance_count": 784}, {"id": 571, "name": "Car", "freebase_id": "/m/0k4j", "image_count": 63478, "instance_count": 164003}, {"id": 572, "name": "Aircraft", "freebase_id": "/m/0k5j", "image_count": 1039, "instance_count": 1615}, {"id": 573, "name": "Human hand", "freebase_id": "/m/0k65p", "image_count": 18436, "instance_count": 51215}, {"id": 574, "name": "Skunk", "freebase_id": "/m/0km7z", "image_count": 36, "instance_count": 51}, {"id": 575, "name": "Teddy bear", "freebase_id": "/m/0kmg4", "image_count": 926, "instance_count": 1401}, {"id": 576, "name": "Watermelon", "freebase_id": "/m/0kpqd", "image_count": 255, "instance_count": 551}, {"id": 577, "name": "Cantaloupe", "freebase_id": "/m/0kpt_", "image_count": 69, "instance_count": 114}, {"id": 578, "name": "Dishwasher", "freebase_id": "/m/0ky7b", "image_count": 72, "instance_count": 74}, {"id": 579, "name": "Flute", "freebase_id": "/m/0l14j_", "image_count": 228, "instance_count": 340}, {"id": 580, "name": "Balance beam", "freebase_id": "/m/0l3ms", "image_count": 247, "instance_count": 309}, {"id": 581, "name": "Sandwich", "freebase_id": "/m/0l515", "image_count": 576, "instance_count": 831}, {"id": 582, "name": "Shrimp", "freebase_id": "/m/0ll1f78", "image_count": 373, "instance_count": 1344}, {"id": 583, "name": "Sewing machine", "freebase_id": "/m/0llzx", "image_count": 351, "instance_count": 425}, {"id": 584, "name": "Binoculars", "freebase_id": "/m/0lt4_", "image_count": 101, "instance_count": 115}, {"id": 585, "name": "Rays and skates", "freebase_id": "/m/0m53l", "image_count": 319, "instance_count": 479}, {"id": 586, "name": "Ipod", "freebase_id": "/m/0mcx2", "image_count": 403, "instance_count": 570}, {"id": 587, "name": "Accordion", "freebase_id": "/m/0mkg", "image_count": 774, "instance_count": 862}, {"id": 588, "name": "Willow", "freebase_id": "/m/0mw_6", "image_count": 26, "instance_count": 43}, {"id": 589, "name": "Crab", "freebase_id": "/m/0n28_", "image_count": 616, "instance_count": 828}, {"id": 590, "name": "Crown", "freebase_id": "/m/0nl46", "image_count": 514, "instance_count": 612}, {"id": 591, "name": "Seahorse", "freebase_id": "/m/0nybt", "image_count": 219, "instance_count": 284}, {"id": 592, "name": "Perfume", "freebase_id": "/m/0p833", "image_count": 193, "instance_count": 304}, {"id": 593, "name": "Alpaca", "freebase_id": "/m/0pcr", "image_count": 351, "instance_count": 593}, {"id": 594, "name": "Taxi", "freebase_id": "/m/0pg52", "image_count": 951, "instance_count": 2491}, {"id": 595, "name": "Canoe", "freebase_id": "/m/0ph39", "image_count": 1439, "instance_count": 2881}, {"id": 596, "name": "Remote control", "freebase_id": "/m/0qjjc", "image_count": 183, "instance_count": 221}, {"id": 597, "name": "Wheelchair", "freebase_id": "/m/0qmmr", "image_count": 737, "instance_count": 1181}, {"id": 598, "name": "Rugby ball", "freebase_id": "/m/0wdt60w", "image_count": 225, "instance_count": 244}, {"id": 599, "name": "Armadillo", "freebase_id": "/m/0xfy", "image_count": 42, "instance_count": 54}, {"id": 600, "name": "Maracas", "freebase_id": "/m/0xzly", "image_count": 3, "instance_count": 5}, {"id": 601, "name": "Helmet", "freebase_id": "/m/0zvk5", "image_count": 6360, "instance_count": 11798}]
|
| 2 |
+
# fmt: on
|
approach/ovod/APE/ape/data/datasets/pascal_voc_external.py
ADDED
|
@@ -0,0 +1,1217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 4 |
+
from detectron2.data.datasets import load_sem_seg
|
| 5 |
+
|
| 6 |
+
from .coco import custom_register_coco_instances
|
| 7 |
+
|
| 8 |
+
PASCAL_CTX_59_CATEGORIES = [
|
| 9 |
+
{"color": [180, 120, 120], "id": 0, "isthing": 0, "name": "aeroplane"},
|
| 10 |
+
{"color": [6, 230, 230], "id": 1, "isthing": 0, "name": "bag"},
|
| 11 |
+
{"color": [80, 50, 50], "id": 2, "isthing": 0, "name": "bed"},
|
| 12 |
+
{"color": [4, 200, 3], "id": 3, "isthing": 0, "name": "bedclothes"},
|
| 13 |
+
{"color": [120, 120, 80], "id": 4, "isthing": 0, "name": "bench"},
|
| 14 |
+
{"color": [140, 140, 140], "id": 5, "isthing": 0, "name": "bicycle"},
|
| 15 |
+
{"color": [204, 5, 255], "id": 6, "isthing": 0, "name": "bird"},
|
| 16 |
+
{"color": [230, 230, 230], "id": 7, "isthing": 0, "name": "boat"},
|
| 17 |
+
{"color": [4, 250, 7], "id": 8, "isthing": 0, "name": "book"},
|
| 18 |
+
{"color": [224, 5, 255], "id": 9, "isthing": 0, "name": "bottle"},
|
| 19 |
+
{"color": [235, 255, 7], "id": 10, "isthing": 0, "name": "building"},
|
| 20 |
+
{"color": [150, 5, 61], "id": 11, "isthing": 0, "name": "bus"},
|
| 21 |
+
{"color": [120, 120, 70], "id": 12, "isthing": 0, "name": "cabinet"},
|
| 22 |
+
{"color": [8, 255, 51], "id": 13, "isthing": 0, "name": "car"},
|
| 23 |
+
{"color": [255, 6, 82], "id": 14, "isthing": 0, "name": "cat"},
|
| 24 |
+
{"color": [143, 255, 140], "id": 15, "isthing": 0, "name": "ceiling"},
|
| 25 |
+
{"color": [204, 255, 4], "id": 16, "isthing": 0, "name": "chair"},
|
| 26 |
+
{"color": [255, 51, 7], "id": 17, "isthing": 0, "name": "cloth"},
|
| 27 |
+
{"color": [204, 70, 3], "id": 18, "isthing": 0, "name": "computer"},
|
| 28 |
+
{"color": [0, 102, 200], "id": 19, "isthing": 0, "name": "cow"},
|
| 29 |
+
{"color": [61, 230, 250], "id": 20, "isthing": 0, "name": "cup"},
|
| 30 |
+
{"color": [255, 6, 51], "id": 21, "isthing": 0, "name": "curtain"},
|
| 31 |
+
{"color": [11, 102, 255], "id": 22, "isthing": 0, "name": "dog"},
|
| 32 |
+
{"color": [255, 7, 71], "id": 23, "isthing": 0, "name": "door"},
|
| 33 |
+
{"color": [255, 9, 224], "id": 24, "isthing": 0, "name": "fence"},
|
| 34 |
+
{"color": [9, 7, 230], "id": 25, "isthing": 0, "name": "floor"},
|
| 35 |
+
{"color": [220, 220, 220], "id": 26, "isthing": 0, "name": "flower"},
|
| 36 |
+
{"color": [255, 9, 92], "id": 27, "isthing": 0, "name": "food"},
|
| 37 |
+
{"color": [112, 9, 255], "id": 28, "isthing": 0, "name": "grass"},
|
| 38 |
+
{"color": [8, 255, 214], "id": 29, "isthing": 0, "name": "ground"},
|
| 39 |
+
{"color": [7, 255, 224], "id": 30, "isthing": 0, "name": "horse"},
|
| 40 |
+
{"color": [255, 184, 6], "id": 31, "isthing": 0, "name": "keyboard"},
|
| 41 |
+
{"color": [10, 255, 71], "id": 32, "isthing": 0, "name": "light"},
|
| 42 |
+
{"color": [255, 41, 10], "id": 33, "isthing": 0, "name": "motorbike"},
|
| 43 |
+
{"color": [7, 255, 255], "id": 34, "isthing": 0, "name": "mountain"},
|
| 44 |
+
{"color": [224, 255, 8], "id": 35, "isthing": 0, "name": "mouse"},
|
| 45 |
+
{"color": [102, 8, 255], "id": 36, "isthing": 0, "name": "person"},
|
| 46 |
+
{"color": [255, 61, 6], "id": 37, "isthing": 0, "name": "plate"},
|
| 47 |
+
{"color": [255, 194, 7], "id": 38, "isthing": 0, "name": "platform"},
|
| 48 |
+
{"color": [255, 122, 8], "id": 39, "isthing": 0, "name": "pottedplant"},
|
| 49 |
+
{"color": [0, 255, 20], "id": 40, "isthing": 0, "name": "road"},
|
| 50 |
+
{"color": [255, 8, 41], "id": 41, "isthing": 0, "name": "rock"},
|
| 51 |
+
{"color": [255, 5, 153], "id": 42, "isthing": 0, "name": "sheep"},
|
| 52 |
+
{"color": [6, 51, 255], "id": 43, "isthing": 0, "name": "shelves"},
|
| 53 |
+
{"color": [235, 12, 255], "id": 44, "isthing": 0, "name": "sidewalk"},
|
| 54 |
+
{"color": [160, 150, 20], "id": 45, "isthing": 0, "name": "sign"},
|
| 55 |
+
{"color": [0, 163, 255], "id": 46, "isthing": 0, "name": "sky"},
|
| 56 |
+
{"color": [140, 140, 140], "id": 47, "isthing": 0, "name": "snow"},
|
| 57 |
+
{"color": [250, 10, 15], "id": 48, "isthing": 0, "name": "sofa"},
|
| 58 |
+
{"color": [20, 255, 0], "id": 49, "isthing": 0, "name": "diningtable"},
|
| 59 |
+
{"color": [31, 255, 0], "id": 50, "isthing": 0, "name": "track"},
|
| 60 |
+
{"color": [255, 31, 0], "id": 51, "isthing": 0, "name": "train"},
|
| 61 |
+
{"color": [255, 224, 0], "id": 52, "isthing": 0, "name": "tree"},
|
| 62 |
+
{"color": [153, 255, 0], "id": 53, "isthing": 0, "name": "truck"},
|
| 63 |
+
{"color": [0, 0, 255], "id": 54, "isthing": 0, "name": "tvmonitor"},
|
| 64 |
+
{"color": [255, 71, 0], "id": 55, "isthing": 0, "name": "wall"},
|
| 65 |
+
{"color": [0, 235, 255], "id": 56, "isthing": 0, "name": "water"},
|
| 66 |
+
{"color": [0, 173, 255], "id": 57, "isthing": 0, "name": "window"},
|
| 67 |
+
{"color": [31, 0, 255], "id": 58, "isthing": 0, "name": "wood"},
|
| 68 |
+
]
|
| 69 |
+
|
| 70 |
+
PASCAL_CTX_459_CATEGORIES = [
|
| 71 |
+
{"color": [120, 120, 120], "id": 0, "isthing": 0, "name": "accordion"},
|
| 72 |
+
{"color": [180, 120, 120], "id": 1, "isthing": 0, "name": "aeroplane"},
|
| 73 |
+
{"color": [6, 230, 230], "id": 2, "isthing": 0, "name": "air conditioner"},
|
| 74 |
+
{"color": [80, 50, 50], "id": 3, "isthing": 0, "name": "antenna"},
|
| 75 |
+
{"color": [4, 200, 3], "id": 4, "isthing": 0, "name": "artillery"},
|
| 76 |
+
{"color": [120, 120, 80], "id": 5, "isthing": 0, "name": "ashtray"},
|
| 77 |
+
{"color": [140, 140, 140], "id": 6, "isthing": 0, "name": "atrium"},
|
| 78 |
+
{"color": [204, 5, 255], "id": 7, "isthing": 0, "name": "baby carriage"},
|
| 79 |
+
{"color": [230, 230, 230], "id": 8, "isthing": 0, "name": "bag"},
|
| 80 |
+
{"color": [4, 250, 7], "id": 9, "isthing": 0, "name": "ball"},
|
| 81 |
+
{"color": [224, 5, 255], "id": 10, "isthing": 0, "name": "balloon"},
|
| 82 |
+
{"color": [235, 255, 7], "id": 11, "isthing": 0, "name": "bamboo weaving"},
|
| 83 |
+
{"color": [150, 5, 61], "id": 12, "isthing": 0, "name": "barrel"},
|
| 84 |
+
{"color": [120, 120, 70], "id": 13, "isthing": 0, "name": "baseball bat"},
|
| 85 |
+
{"color": [8, 255, 51], "id": 14, "isthing": 0, "name": "basket"},
|
| 86 |
+
{"color": [255, 6, 82], "id": 15, "isthing": 0, "name": "basketball backboard"},
|
| 87 |
+
{"color": [143, 255, 140], "id": 16, "isthing": 0, "name": "bathtub"},
|
| 88 |
+
{"color": [204, 255, 4], "id": 17, "isthing": 0, "name": "bed"},
|
| 89 |
+
{"color": [255, 51, 7], "id": 18, "isthing": 0, "name": "bedclothes"},
|
| 90 |
+
{"color": [204, 70, 3], "id": 19, "isthing": 0, "name": "beer"},
|
| 91 |
+
{"color": [0, 102, 200], "id": 20, "isthing": 0, "name": "bell"},
|
| 92 |
+
{"color": [61, 230, 250], "id": 21, "isthing": 0, "name": "bench"},
|
| 93 |
+
{"color": [255, 6, 51], "id": 22, "isthing": 0, "name": "bicycle"},
|
| 94 |
+
{"color": [11, 102, 255], "id": 23, "isthing": 0, "name": "binoculars"},
|
| 95 |
+
{"color": [255, 7, 71], "id": 24, "isthing": 0, "name": "bird"},
|
| 96 |
+
{"color": [255, 9, 224], "id": 25, "isthing": 0, "name": "bird cage"},
|
| 97 |
+
{"color": [9, 7, 230], "id": 26, "isthing": 0, "name": "bird feeder"},
|
| 98 |
+
{"color": [220, 220, 220], "id": 27, "isthing": 0, "name": "bird nest"},
|
| 99 |
+
{"color": [255, 9, 92], "id": 28, "isthing": 0, "name": "blackboard"},
|
| 100 |
+
{"color": [112, 9, 255], "id": 29, "isthing": 0, "name": "board"},
|
| 101 |
+
{"color": [8, 255, 214], "id": 30, "isthing": 0, "name": "boat"},
|
| 102 |
+
{"color": [7, 255, 224], "id": 31, "isthing": 0, "name": "bone"},
|
| 103 |
+
{"color": [255, 184, 6], "id": 32, "isthing": 0, "name": "book"},
|
| 104 |
+
{"color": [10, 255, 71], "id": 33, "isthing": 0, "name": "bottle"},
|
| 105 |
+
{"color": [255, 41, 10], "id": 34, "isthing": 0, "name": "bottle opener"},
|
| 106 |
+
{"color": [7, 255, 255], "id": 35, "isthing": 0, "name": "bowl"},
|
| 107 |
+
{"color": [224, 255, 8], "id": 36, "isthing": 0, "name": "box"},
|
| 108 |
+
{"color": [102, 8, 255], "id": 37, "isthing": 0, "name": "bracelet"},
|
| 109 |
+
{"color": [255, 61, 6], "id": 38, "isthing": 0, "name": "brick"},
|
| 110 |
+
{"color": [255, 194, 7], "id": 39, "isthing": 0, "name": "bridge"},
|
| 111 |
+
{"color": [255, 122, 8], "id": 40, "isthing": 0, "name": "broom"},
|
| 112 |
+
{"color": [0, 255, 20], "id": 41, "isthing": 0, "name": "brush"},
|
| 113 |
+
{"color": [255, 8, 41], "id": 42, "isthing": 0, "name": "bucket"},
|
| 114 |
+
{"color": [255, 5, 153], "id": 43, "isthing": 0, "name": "building"},
|
| 115 |
+
{"color": [6, 51, 255], "id": 44, "isthing": 0, "name": "bus"},
|
| 116 |
+
{"color": [235, 12, 255], "id": 45, "isthing": 0, "name": "cabinet"},
|
| 117 |
+
{"color": [160, 150, 20], "id": 46, "isthing": 0, "name": "cabinet door"},
|
| 118 |
+
{"color": [0, 163, 255], "id": 47, "isthing": 0, "name": "cage"},
|
| 119 |
+
{"color": [140, 140, 140], "id": 48, "isthing": 0, "name": "cake"},
|
| 120 |
+
{"color": [250, 10, 15], "id": 49, "isthing": 0, "name": "calculator"},
|
| 121 |
+
{"color": [20, 255, 0], "id": 50, "isthing": 0, "name": "calendar"},
|
| 122 |
+
{"color": [31, 255, 0], "id": 51, "isthing": 0, "name": "camel"},
|
| 123 |
+
{"color": [255, 31, 0], "id": 52, "isthing": 0, "name": "camera"},
|
| 124 |
+
{"color": [255, 224, 0], "id": 53, "isthing": 0, "name": "camera lens"},
|
| 125 |
+
{"color": [153, 255, 0], "id": 54, "isthing": 0, "name": "can"},
|
| 126 |
+
{"color": [0, 0, 255], "id": 55, "isthing": 0, "name": "candle"},
|
| 127 |
+
{"color": [255, 71, 0], "id": 56, "isthing": 0, "name": "candle holder"},
|
| 128 |
+
{"color": [0, 235, 255], "id": 57, "isthing": 0, "name": "cap"},
|
| 129 |
+
{"color": [0, 173, 255], "id": 58, "isthing": 0, "name": "car"},
|
| 130 |
+
{"color": [31, 0, 255], "id": 59, "isthing": 0, "name": "card"},
|
| 131 |
+
{"color": [120, 120, 120], "id": 60, "isthing": 0, "name": "cart"},
|
| 132 |
+
{"color": [180, 120, 120], "id": 61, "isthing": 0, "name": "case"},
|
| 133 |
+
{"color": [6, 230, 230], "id": 62, "isthing": 0, "name": "casette recorder"},
|
| 134 |
+
{"color": [80, 50, 50], "id": 63, "isthing": 0, "name": "cash register"},
|
| 135 |
+
{"color": [4, 200, 3], "id": 64, "isthing": 0, "name": "cat"},
|
| 136 |
+
{"color": [120, 120, 80], "id": 65, "isthing": 0, "name": "cd"},
|
| 137 |
+
{"color": [140, 140, 140], "id": 66, "isthing": 0, "name": "cd player"},
|
| 138 |
+
{"color": [204, 5, 255], "id": 67, "isthing": 0, "name": "ceiling"},
|
| 139 |
+
{"color": [230, 230, 230], "id": 68, "isthing": 0, "name": "cell phone"},
|
| 140 |
+
{"color": [4, 250, 7], "id": 69, "isthing": 0, "name": "cello"},
|
| 141 |
+
{"color": [224, 5, 255], "id": 70, "isthing": 0, "name": "chain"},
|
| 142 |
+
{"color": [235, 255, 7], "id": 71, "isthing": 0, "name": "chair"},
|
| 143 |
+
{"color": [150, 5, 61], "id": 72, "isthing": 0, "name": "chessboard"},
|
| 144 |
+
{"color": [120, 120, 70], "id": 73, "isthing": 0, "name": "chicken"},
|
| 145 |
+
{"color": [8, 255, 51], "id": 74, "isthing": 0, "name": "chopstick"},
|
| 146 |
+
{"color": [255, 6, 82], "id": 75, "isthing": 0, "name": "clip"},
|
| 147 |
+
{"color": [143, 255, 140], "id": 76, "isthing": 0, "name": "clippers"},
|
| 148 |
+
{"color": [204, 255, 4], "id": 77, "isthing": 0, "name": "clock"},
|
| 149 |
+
{"color": [255, 51, 7], "id": 78, "isthing": 0, "name": "closet"},
|
| 150 |
+
{"color": [204, 70, 3], "id": 79, "isthing": 0, "name": "cloth"},
|
| 151 |
+
{"color": [0, 102, 200], "id": 80, "isthing": 0, "name": "clothes tree"},
|
| 152 |
+
{"color": [61, 230, 250], "id": 81, "isthing": 0, "name": "coffee"},
|
| 153 |
+
{"color": [255, 6, 51], "id": 82, "isthing": 0, "name": "coffee machine"},
|
| 154 |
+
{"color": [11, 102, 255], "id": 83, "isthing": 0, "name": "comb"},
|
| 155 |
+
{"color": [255, 7, 71], "id": 84, "isthing": 0, "name": "computer"},
|
| 156 |
+
{"color": [255, 9, 224], "id": 85, "isthing": 0, "name": "concrete"},
|
| 157 |
+
{"color": [9, 7, 230], "id": 86, "isthing": 0, "name": "cone"},
|
| 158 |
+
{"color": [220, 220, 220], "id": 87, "isthing": 0, "name": "container"},
|
| 159 |
+
{"color": [255, 9, 92], "id": 88, "isthing": 0, "name": "control booth"},
|
| 160 |
+
{"color": [112, 9, 255], "id": 89, "isthing": 0, "name": "controller"},
|
| 161 |
+
{"color": [8, 255, 214], "id": 90, "isthing": 0, "name": "cooker"},
|
| 162 |
+
{"color": [7, 255, 224], "id": 91, "isthing": 0, "name": "copying machine"},
|
| 163 |
+
{"color": [255, 184, 6], "id": 92, "isthing": 0, "name": "coral"},
|
| 164 |
+
{"color": [10, 255, 71], "id": 93, "isthing": 0, "name": "cork"},
|
| 165 |
+
{"color": [255, 41, 10], "id": 94, "isthing": 0, "name": "corkscrew"},
|
| 166 |
+
{"color": [7, 255, 255], "id": 95, "isthing": 0, "name": "counter"},
|
| 167 |
+
{"color": [224, 255, 8], "id": 96, "isthing": 0, "name": "court"},
|
| 168 |
+
{"color": [102, 8, 255], "id": 97, "isthing": 0, "name": "cow"},
|
| 169 |
+
{"color": [255, 61, 6], "id": 98, "isthing": 0, "name": "crabstick"},
|
| 170 |
+
{"color": [255, 194, 7], "id": 99, "isthing": 0, "name": "crane"},
|
| 171 |
+
{"color": [255, 122, 8], "id": 100, "isthing": 0, "name": "crate"},
|
| 172 |
+
{"color": [0, 255, 20], "id": 101, "isthing": 0, "name": "cross"},
|
| 173 |
+
{"color": [255, 8, 41], "id": 102, "isthing": 0, "name": "crutch"},
|
| 174 |
+
{"color": [255, 5, 153], "id": 103, "isthing": 0, "name": "cup"},
|
| 175 |
+
{"color": [6, 51, 255], "id": 104, "isthing": 0, "name": "curtain"},
|
| 176 |
+
{"color": [235, 12, 255], "id": 105, "isthing": 0, "name": "cushion"},
|
| 177 |
+
{"color": [160, 150, 20], "id": 106, "isthing": 0, "name": "cutting board"},
|
| 178 |
+
{"color": [0, 163, 255], "id": 107, "isthing": 0, "name": "dais"},
|
| 179 |
+
{"color": [140, 140, 140], "id": 108, "isthing": 0, "name": "disc"},
|
| 180 |
+
{"color": [250, 10, 15], "id": 109, "isthing": 0, "name": "disc case"},
|
| 181 |
+
{"color": [20, 255, 0], "id": 110, "isthing": 0, "name": "dishwasher"},
|
| 182 |
+
{"color": [31, 255, 0], "id": 111, "isthing": 0, "name": "dock"},
|
| 183 |
+
{"color": [255, 31, 0], "id": 112, "isthing": 0, "name": "dog"},
|
| 184 |
+
{"color": [255, 224, 0], "id": 113, "isthing": 0, "name": "dolphin"},
|
| 185 |
+
{"color": [153, 255, 0], "id": 114, "isthing": 0, "name": "door"},
|
| 186 |
+
{"color": [0, 0, 255], "id": 115, "isthing": 0, "name": "drainer"},
|
| 187 |
+
{"color": [255, 71, 0], "id": 116, "isthing": 0, "name": "dray"},
|
| 188 |
+
{"color": [0, 235, 255], "id": 117, "isthing": 0, "name": "drink dispenser"},
|
| 189 |
+
{"color": [0, 173, 255], "id": 118, "isthing": 0, "name": "drinking machine"},
|
| 190 |
+
{"color": [31, 0, 255], "id": 119, "isthing": 0, "name": "drop"},
|
| 191 |
+
{"color": [120, 120, 120], "id": 120, "isthing": 0, "name": "drug"},
|
| 192 |
+
{"color": [180, 120, 120], "id": 121, "isthing": 0, "name": "drum"},
|
| 193 |
+
{"color": [6, 230, 230], "id": 122, "isthing": 0, "name": "drum kit"},
|
| 194 |
+
{"color": [80, 50, 50], "id": 123, "isthing": 0, "name": "duck"},
|
| 195 |
+
{"color": [4, 200, 3], "id": 124, "isthing": 0, "name": "dumbbell"},
|
| 196 |
+
{"color": [120, 120, 80], "id": 125, "isthing": 0, "name": "earphone"},
|
| 197 |
+
{"color": [140, 140, 140], "id": 126, "isthing": 0, "name": "earrings"},
|
| 198 |
+
{"color": [204, 5, 255], "id": 127, "isthing": 0, "name": "egg"},
|
| 199 |
+
{"color": [230, 230, 230], "id": 128, "isthing": 0, "name": "electric fan"},
|
| 200 |
+
{"color": [4, 250, 7], "id": 129, "isthing": 0, "name": "electric iron"},
|
| 201 |
+
{"color": [224, 5, 255], "id": 130, "isthing": 0, "name": "electric pot"},
|
| 202 |
+
{"color": [235, 255, 7], "id": 131, "isthing": 0, "name": "electric saw"},
|
| 203 |
+
{"color": [150, 5, 61], "id": 132, "isthing": 0, "name": "electronic keyboard"},
|
| 204 |
+
{"color": [120, 120, 70], "id": 133, "isthing": 0, "name": "engine"},
|
| 205 |
+
{"color": [8, 255, 51], "id": 134, "isthing": 0, "name": "envelope"},
|
| 206 |
+
{"color": [255, 6, 82], "id": 135, "isthing": 0, "name": "equipment"},
|
| 207 |
+
{"color": [143, 255, 140], "id": 136, "isthing": 0, "name": "escalator"},
|
| 208 |
+
{"color": [204, 255, 4], "id": 137, "isthing": 0, "name": "exhibition booth"},
|
| 209 |
+
{"color": [255, 51, 7], "id": 138, "isthing": 0, "name": "extinguisher"},
|
| 210 |
+
{"color": [204, 70, 3], "id": 139, "isthing": 0, "name": "eyeglass"},
|
| 211 |
+
{"color": [0, 102, 200], "id": 140, "isthing": 0, "name": "fan"},
|
| 212 |
+
{"color": [61, 230, 250], "id": 141, "isthing": 0, "name": "faucet"},
|
| 213 |
+
{"color": [255, 6, 51], "id": 142, "isthing": 0, "name": "fax machine"},
|
| 214 |
+
{"color": [11, 102, 255], "id": 143, "isthing": 0, "name": "fence"},
|
| 215 |
+
{"color": [255, 7, 71], "id": 144, "isthing": 0, "name": "ferris wheel"},
|
| 216 |
+
{"color": [255, 9, 224], "id": 145, "isthing": 0, "name": "fire extinguisher"},
|
| 217 |
+
{"color": [9, 7, 230], "id": 146, "isthing": 0, "name": "fire hydrant"},
|
| 218 |
+
{"color": [220, 220, 220], "id": 147, "isthing": 0, "name": "fire place"},
|
| 219 |
+
{"color": [255, 9, 92], "id": 148, "isthing": 0, "name": "fish"},
|
| 220 |
+
{"color": [112, 9, 255], "id": 149, "isthing": 0, "name": "fish tank"},
|
| 221 |
+
{"color": [8, 255, 214], "id": 150, "isthing": 0, "name": "fishbowl"},
|
| 222 |
+
{"color": [7, 255, 224], "id": 151, "isthing": 0, "name": "fishing net"},
|
| 223 |
+
{"color": [255, 184, 6], "id": 152, "isthing": 0, "name": "fishing pole"},
|
| 224 |
+
{"color": [10, 255, 71], "id": 153, "isthing": 0, "name": "flag"},
|
| 225 |
+
{"color": [255, 41, 10], "id": 154, "isthing": 0, "name": "flagstaff"},
|
| 226 |
+
{"color": [7, 255, 255], "id": 155, "isthing": 0, "name": "flame"},
|
| 227 |
+
{"color": [224, 255, 8], "id": 156, "isthing": 0, "name": "flashlight"},
|
| 228 |
+
{"color": [102, 8, 255], "id": 157, "isthing": 0, "name": "floor"},
|
| 229 |
+
{"color": [255, 61, 6], "id": 158, "isthing": 0, "name": "flower"},
|
| 230 |
+
{"color": [255, 194, 7], "id": 159, "isthing": 0, "name": "fly"},
|
| 231 |
+
{"color": [255, 122, 8], "id": 160, "isthing": 0, "name": "foam"},
|
| 232 |
+
{"color": [0, 255, 20], "id": 161, "isthing": 0, "name": "food"},
|
| 233 |
+
{"color": [255, 8, 41], "id": 162, "isthing": 0, "name": "footbridge"},
|
| 234 |
+
{"color": [255, 5, 153], "id": 163, "isthing": 0, "name": "forceps"},
|
| 235 |
+
{"color": [6, 51, 255], "id": 164, "isthing": 0, "name": "fork"},
|
| 236 |
+
{"color": [235, 12, 255], "id": 165, "isthing": 0, "name": "forklift"},
|
| 237 |
+
{"color": [160, 150, 20], "id": 166, "isthing": 0, "name": "fountain"},
|
| 238 |
+
{"color": [0, 163, 255], "id": 167, "isthing": 0, "name": "fox"},
|
| 239 |
+
{"color": [140, 140, 140], "id": 168, "isthing": 0, "name": "frame"},
|
| 240 |
+
{"color": [250, 10, 15], "id": 169, "isthing": 0, "name": "fridge"},
|
| 241 |
+
{"color": [20, 255, 0], "id": 170, "isthing": 0, "name": "frog"},
|
| 242 |
+
{"color": [31, 255, 0], "id": 171, "isthing": 0, "name": "fruit"},
|
| 243 |
+
{"color": [255, 31, 0], "id": 172, "isthing": 0, "name": "funnel"},
|
| 244 |
+
{"color": [255, 224, 0], "id": 173, "isthing": 0, "name": "furnace"},
|
| 245 |
+
{"color": [153, 255, 0], "id": 174, "isthing": 0, "name": "game controller"},
|
| 246 |
+
{"color": [0, 0, 255], "id": 175, "isthing": 0, "name": "game machine"},
|
| 247 |
+
{"color": [255, 71, 0], "id": 176, "isthing": 0, "name": "gas cylinder"},
|
| 248 |
+
{"color": [0, 235, 255], "id": 177, "isthing": 0, "name": "gas hood"},
|
| 249 |
+
{"color": [0, 173, 255], "id": 178, "isthing": 0, "name": "gas stove"},
|
| 250 |
+
{"color": [31, 0, 255], "id": 179, "isthing": 0, "name": "gift box"},
|
| 251 |
+
{"color": [120, 120, 120], "id": 180, "isthing": 0, "name": "glass"},
|
| 252 |
+
{"color": [180, 120, 120], "id": 181, "isthing": 0, "name": "glass marble"},
|
| 253 |
+
{"color": [6, 230, 230], "id": 182, "isthing": 0, "name": "globe"},
|
| 254 |
+
{"color": [80, 50, 50], "id": 183, "isthing": 0, "name": "glove"},
|
| 255 |
+
{"color": [4, 200, 3], "id": 184, "isthing": 0, "name": "goal"},
|
| 256 |
+
{"color": [120, 120, 80], "id": 185, "isthing": 0, "name": "grandstand"},
|
| 257 |
+
{"color": [140, 140, 140], "id": 186, "isthing": 0, "name": "grass"},
|
| 258 |
+
{"color": [204, 5, 255], "id": 187, "isthing": 0, "name": "gravestone"},
|
| 259 |
+
{"color": [230, 230, 230], "id": 188, "isthing": 0, "name": "ground"},
|
| 260 |
+
{"color": [4, 250, 7], "id": 189, "isthing": 0, "name": "guardrail"},
|
| 261 |
+
{"color": [224, 5, 255], "id": 190, "isthing": 0, "name": "guitar"},
|
| 262 |
+
{"color": [235, 255, 7], "id": 191, "isthing": 0, "name": "gun"},
|
| 263 |
+
{"color": [150, 5, 61], "id": 192, "isthing": 0, "name": "hammer"},
|
| 264 |
+
{"color": [120, 120, 70], "id": 193, "isthing": 0, "name": "hand cart"},
|
| 265 |
+
{"color": [8, 255, 51], "id": 194, "isthing": 0, "name": "handle"},
|
| 266 |
+
{"color": [255, 6, 82], "id": 195, "isthing": 0, "name": "handrail"},
|
| 267 |
+
{"color": [143, 255, 140], "id": 196, "isthing": 0, "name": "hanger"},
|
| 268 |
+
{"color": [204, 255, 4], "id": 197, "isthing": 0, "name": "hard disk drive"},
|
| 269 |
+
{"color": [255, 51, 7], "id": 198, "isthing": 0, "name": "hat"},
|
| 270 |
+
{"color": [204, 70, 3], "id": 199, "isthing": 0, "name": "hay"},
|
| 271 |
+
{"color": [0, 102, 200], "id": 200, "isthing": 0, "name": "headphone"},
|
| 272 |
+
{"color": [61, 230, 250], "id": 201, "isthing": 0, "name": "heater"},
|
| 273 |
+
{"color": [255, 6, 51], "id": 202, "isthing": 0, "name": "helicopter"},
|
| 274 |
+
{"color": [11, 102, 255], "id": 203, "isthing": 0, "name": "helmet"},
|
| 275 |
+
{"color": [255, 7, 71], "id": 204, "isthing": 0, "name": "holder"},
|
| 276 |
+
{"color": [255, 9, 224], "id": 205, "isthing": 0, "name": "hook"},
|
| 277 |
+
{"color": [9, 7, 230], "id": 206, "isthing": 0, "name": "horse"},
|
| 278 |
+
{"color": [220, 220, 220], "id": 207, "isthing": 0, "name": "horse-drawn carriage"},
|
| 279 |
+
{"color": [255, 9, 92], "id": 208, "isthing": 0, "name": "hot-air balloon"},
|
| 280 |
+
{"color": [112, 9, 255], "id": 209, "isthing": 0, "name": "hydrovalve"},
|
| 281 |
+
{"color": [8, 255, 214], "id": 210, "isthing": 0, "name": "ice"},
|
| 282 |
+
{"color": [7, 255, 224], "id": 211, "isthing": 0, "name": "inflator pump"},
|
| 283 |
+
{"color": [255, 184, 6], "id": 212, "isthing": 0, "name": "ipod"},
|
| 284 |
+
{"color": [10, 255, 71], "id": 213, "isthing": 0, "name": "iron"},
|
| 285 |
+
{"color": [255, 41, 10], "id": 214, "isthing": 0, "name": "ironing board"},
|
| 286 |
+
{"color": [7, 255, 255], "id": 215, "isthing": 0, "name": "jar"},
|
| 287 |
+
{"color": [224, 255, 8], "id": 216, "isthing": 0, "name": "kart"},
|
| 288 |
+
{"color": [102, 8, 255], "id": 217, "isthing": 0, "name": "kettle"},
|
| 289 |
+
{"color": [255, 61, 6], "id": 218, "isthing": 0, "name": "key"},
|
| 290 |
+
{"color": [255, 194, 7], "id": 219, "isthing": 0, "name": "keyboard"},
|
| 291 |
+
{"color": [255, 122, 8], "id": 220, "isthing": 0, "name": "kitchen range"},
|
| 292 |
+
{"color": [0, 255, 20], "id": 221, "isthing": 0, "name": "kite"},
|
| 293 |
+
{"color": [255, 8, 41], "id": 222, "isthing": 0, "name": "knife"},
|
| 294 |
+
{"color": [255, 5, 153], "id": 223, "isthing": 0, "name": "knife block"},
|
| 295 |
+
{"color": [6, 51, 255], "id": 224, "isthing": 0, "name": "ladder"},
|
| 296 |
+
{"color": [235, 12, 255], "id": 225, "isthing": 0, "name": "ladder truck"},
|
| 297 |
+
{"color": [160, 150, 20], "id": 226, "isthing": 0, "name": "ladle"},
|
| 298 |
+
{"color": [0, 163, 255], "id": 227, "isthing": 0, "name": "laptop"},
|
| 299 |
+
{"color": [140, 140, 140], "id": 228, "isthing": 0, "name": "leaves"},
|
| 300 |
+
{"color": [250, 10, 15], "id": 229, "isthing": 0, "name": "lid"},
|
| 301 |
+
{"color": [20, 255, 0], "id": 230, "isthing": 0, "name": "life buoy"},
|
| 302 |
+
{"color": [31, 255, 0], "id": 231, "isthing": 0, "name": "light"},
|
| 303 |
+
{"color": [255, 31, 0], "id": 232, "isthing": 0, "name": "light bulb"},
|
| 304 |
+
{"color": [255, 224, 0], "id": 233, "isthing": 0, "name": "lighter"},
|
| 305 |
+
{"color": [153, 255, 0], "id": 234, "isthing": 0, "name": "line"},
|
| 306 |
+
{"color": [0, 0, 255], "id": 235, "isthing": 0, "name": "lion"},
|
| 307 |
+
{"color": [255, 71, 0], "id": 236, "isthing": 0, "name": "lobster"},
|
| 308 |
+
{"color": [0, 235, 255], "id": 237, "isthing": 0, "name": "lock"},
|
| 309 |
+
{"color": [0, 173, 255], "id": 238, "isthing": 0, "name": "machine"},
|
| 310 |
+
{"color": [31, 0, 255], "id": 239, "isthing": 0, "name": "mailbox"},
|
| 311 |
+
{"color": [120, 120, 120], "id": 240, "isthing": 0, "name": "mannequin"},
|
| 312 |
+
{"color": [180, 120, 120], "id": 241, "isthing": 0, "name": "map"},
|
| 313 |
+
{"color": [6, 230, 230], "id": 242, "isthing": 0, "name": "mask"},
|
| 314 |
+
{"color": [80, 50, 50], "id": 243, "isthing": 0, "name": "mat"},
|
| 315 |
+
{"color": [4, 200, 3], "id": 244, "isthing": 0, "name": "match book"},
|
| 316 |
+
{"color": [120, 120, 80], "id": 245, "isthing": 0, "name": "mattress"},
|
| 317 |
+
{"color": [140, 140, 140], "id": 246, "isthing": 0, "name": "menu"},
|
| 318 |
+
{"color": [204, 5, 255], "id": 247, "isthing": 0, "name": "metal"},
|
| 319 |
+
{"color": [230, 230, 230], "id": 248, "isthing": 0, "name": "meter box"},
|
| 320 |
+
{"color": [4, 250, 7], "id": 249, "isthing": 0, "name": "microphone"},
|
| 321 |
+
{"color": [224, 5, 255], "id": 250, "isthing": 0, "name": "microwave"},
|
| 322 |
+
{"color": [235, 255, 7], "id": 251, "isthing": 0, "name": "mirror"},
|
| 323 |
+
{"color": [150, 5, 61], "id": 252, "isthing": 0, "name": "missile"},
|
| 324 |
+
{"color": [120, 120, 70], "id": 253, "isthing": 0, "name": "model"},
|
| 325 |
+
{"color": [8, 255, 51], "id": 254, "isthing": 0, "name": "money"},
|
| 326 |
+
{"color": [255, 6, 82], "id": 255, "isthing": 0, "name": "monkey"},
|
| 327 |
+
{"color": [143, 255, 140], "id": 256, "isthing": 0, "name": "mop"},
|
| 328 |
+
{"color": [204, 255, 4], "id": 257, "isthing": 0, "name": "motorbike"},
|
| 329 |
+
{"color": [255, 51, 7], "id": 258, "isthing": 0, "name": "mountain"},
|
| 330 |
+
{"color": [204, 70, 3], "id": 259, "isthing": 0, "name": "mouse"},
|
| 331 |
+
{"color": [0, 102, 200], "id": 260, "isthing": 0, "name": "mouse pad"},
|
| 332 |
+
{"color": [61, 230, 250], "id": 261, "isthing": 0, "name": "musical instrument"},
|
| 333 |
+
{"color": [255, 6, 51], "id": 262, "isthing": 0, "name": "napkin"},
|
| 334 |
+
{"color": [11, 102, 255], "id": 263, "isthing": 0, "name": "net"},
|
| 335 |
+
{"color": [255, 7, 71], "id": 264, "isthing": 0, "name": "newspaper"},
|
| 336 |
+
{"color": [255, 9, 224], "id": 265, "isthing": 0, "name": "oar"},
|
| 337 |
+
{"color": [9, 7, 230], "id": 266, "isthing": 0, "name": "ornament"},
|
| 338 |
+
{"color": [220, 220, 220], "id": 267, "isthing": 0, "name": "outlet"},
|
| 339 |
+
{"color": [255, 9, 92], "id": 268, "isthing": 0, "name": "oven"},
|
| 340 |
+
{"color": [112, 9, 255], "id": 269, "isthing": 0, "name": "oxygen bottle"},
|
| 341 |
+
{"color": [8, 255, 214], "id": 270, "isthing": 0, "name": "pack"},
|
| 342 |
+
{"color": [7, 255, 224], "id": 271, "isthing": 0, "name": "pan"},
|
| 343 |
+
{"color": [255, 184, 6], "id": 272, "isthing": 0, "name": "paper"},
|
| 344 |
+
{"color": [10, 255, 71], "id": 273, "isthing": 0, "name": "paper box"},
|
| 345 |
+
{"color": [255, 41, 10], "id": 274, "isthing": 0, "name": "paper cutter"},
|
| 346 |
+
{"color": [7, 255, 255], "id": 275, "isthing": 0, "name": "parachute"},
|
| 347 |
+
{"color": [224, 255, 8], "id": 276, "isthing": 0, "name": "parasol"},
|
| 348 |
+
{"color": [102, 8, 255], "id": 277, "isthing": 0, "name": "parterre"},
|
| 349 |
+
{"color": [255, 61, 6], "id": 278, "isthing": 0, "name": "patio"},
|
| 350 |
+
{"color": [255, 194, 7], "id": 279, "isthing": 0, "name": "pelage"},
|
| 351 |
+
{"color": [255, 122, 8], "id": 280, "isthing": 0, "name": "pen"},
|
| 352 |
+
{"color": [0, 255, 20], "id": 281, "isthing": 0, "name": "pen container"},
|
| 353 |
+
{"color": [255, 8, 41], "id": 282, "isthing": 0, "name": "pencil"},
|
| 354 |
+
{"color": [255, 5, 153], "id": 283, "isthing": 0, "name": "person"},
|
| 355 |
+
{"color": [6, 51, 255], "id": 284, "isthing": 0, "name": "photo"},
|
| 356 |
+
{"color": [235, 12, 255], "id": 285, "isthing": 0, "name": "piano"},
|
| 357 |
+
{"color": [160, 150, 20], "id": 286, "isthing": 0, "name": "picture"},
|
| 358 |
+
{"color": [0, 163, 255], "id": 287, "isthing": 0, "name": "pig"},
|
| 359 |
+
{"color": [140, 140, 140], "id": 288, "isthing": 0, "name": "pillar"},
|
| 360 |
+
{"color": [250, 10, 15], "id": 289, "isthing": 0, "name": "pillow"},
|
| 361 |
+
{"color": [20, 255, 0], "id": 290, "isthing": 0, "name": "pipe"},
|
| 362 |
+
{"color": [31, 255, 0], "id": 291, "isthing": 0, "name": "pitcher"},
|
| 363 |
+
{"color": [255, 31, 0], "id": 292, "isthing": 0, "name": "plant"},
|
| 364 |
+
{"color": [255, 224, 0], "id": 293, "isthing": 0, "name": "plastic"},
|
| 365 |
+
{"color": [153, 255, 0], "id": 294, "isthing": 0, "name": "plate"},
|
| 366 |
+
{"color": [0, 0, 255], "id": 295, "isthing": 0, "name": "platform"},
|
| 367 |
+
{"color": [255, 71, 0], "id": 296, "isthing": 0, "name": "player"},
|
| 368 |
+
{"color": [0, 235, 255], "id": 297, "isthing": 0, "name": "playground"},
|
| 369 |
+
{"color": [0, 173, 255], "id": 298, "isthing": 0, "name": "pliers"},
|
| 370 |
+
{"color": [31, 0, 255], "id": 299, "isthing": 0, "name": "plume"},
|
| 371 |
+
{"color": [120, 120, 120], "id": 300, "isthing": 0, "name": "poker"},
|
| 372 |
+
{"color": [180, 120, 120], "id": 301, "isthing": 0, "name": "poker chip"},
|
| 373 |
+
{"color": [6, 230, 230], "id": 302, "isthing": 0, "name": "pole"},
|
| 374 |
+
{"color": [80, 50, 50], "id": 303, "isthing": 0, "name": "pool table"},
|
| 375 |
+
{"color": [4, 200, 3], "id": 304, "isthing": 0, "name": "postcard"},
|
| 376 |
+
{"color": [120, 120, 80], "id": 305, "isthing": 0, "name": "poster"},
|
| 377 |
+
{"color": [140, 140, 140], "id": 306, "isthing": 0, "name": "pot"},
|
| 378 |
+
{"color": [204, 5, 255], "id": 307, "isthing": 0, "name": "pottedplant"},
|
| 379 |
+
{"color": [230, 230, 230], "id": 308, "isthing": 0, "name": "printer"},
|
| 380 |
+
{"color": [4, 250, 7], "id": 309, "isthing": 0, "name": "projector"},
|
| 381 |
+
{"color": [224, 5, 255], "id": 310, "isthing": 0, "name": "pumpkin"},
|
| 382 |
+
{"color": [235, 255, 7], "id": 311, "isthing": 0, "name": "rabbit"},
|
| 383 |
+
{"color": [150, 5, 61], "id": 312, "isthing": 0, "name": "racket"},
|
| 384 |
+
{"color": [120, 120, 70], "id": 313, "isthing": 0, "name": "radiator"},
|
| 385 |
+
{"color": [8, 255, 51], "id": 314, "isthing": 0, "name": "radio"},
|
| 386 |
+
{"color": [255, 6, 82], "id": 315, "isthing": 0, "name": "rail"},
|
| 387 |
+
{"color": [143, 255, 140], "id": 316, "isthing": 0, "name": "rake"},
|
| 388 |
+
{"color": [204, 255, 4], "id": 317, "isthing": 0, "name": "ramp"},
|
| 389 |
+
{"color": [255, 51, 7], "id": 318, "isthing": 0, "name": "range hood"},
|
| 390 |
+
{"color": [204, 70, 3], "id": 319, "isthing": 0, "name": "receiver"},
|
| 391 |
+
{"color": [0, 102, 200], "id": 320, "isthing": 0, "name": "recorder"},
|
| 392 |
+
{"color": [61, 230, 250], "id": 321, "isthing": 0, "name": "recreational machines"},
|
| 393 |
+
{"color": [255, 6, 51], "id": 322, "isthing": 0, "name": "remote control"},
|
| 394 |
+
{"color": [11, 102, 255], "id": 323, "isthing": 0, "name": "road"},
|
| 395 |
+
{"color": [255, 7, 71], "id": 324, "isthing": 0, "name": "robot"},
|
| 396 |
+
{"color": [255, 9, 224], "id": 325, "isthing": 0, "name": "rock"},
|
| 397 |
+
{"color": [9, 7, 230], "id": 326, "isthing": 0, "name": "rocket"},
|
| 398 |
+
{"color": [220, 220, 220], "id": 327, "isthing": 0, "name": "rocking horse"},
|
| 399 |
+
{"color": [255, 9, 92], "id": 328, "isthing": 0, "name": "rope"},
|
| 400 |
+
{"color": [112, 9, 255], "id": 329, "isthing": 0, "name": "rug"},
|
| 401 |
+
{"color": [8, 255, 214], "id": 330, "isthing": 0, "name": "ruler"},
|
| 402 |
+
{"color": [7, 255, 224], "id": 331, "isthing": 0, "name": "runway"},
|
| 403 |
+
{"color": [255, 184, 6], "id": 332, "isthing": 0, "name": "saddle"},
|
| 404 |
+
{"color": [10, 255, 71], "id": 333, "isthing": 0, "name": "sand"},
|
| 405 |
+
{"color": [255, 41, 10], "id": 334, "isthing": 0, "name": "saw"},
|
| 406 |
+
{"color": [7, 255, 255], "id": 335, "isthing": 0, "name": "scale"},
|
| 407 |
+
{"color": [224, 255, 8], "id": 336, "isthing": 0, "name": "scanner"},
|
| 408 |
+
{"color": [102, 8, 255], "id": 337, "isthing": 0, "name": "scissors"},
|
| 409 |
+
{"color": [255, 61, 6], "id": 338, "isthing": 0, "name": "scoop"},
|
| 410 |
+
{"color": [255, 194, 7], "id": 339, "isthing": 0, "name": "screen"},
|
| 411 |
+
{"color": [255, 122, 8], "id": 340, "isthing": 0, "name": "screwdriver"},
|
| 412 |
+
{"color": [0, 255, 20], "id": 341, "isthing": 0, "name": "sculpture"},
|
| 413 |
+
{"color": [255, 8, 41], "id": 342, "isthing": 0, "name": "scythe"},
|
| 414 |
+
{"color": [255, 5, 153], "id": 343, "isthing": 0, "name": "sewer"},
|
| 415 |
+
{"color": [6, 51, 255], "id": 344, "isthing": 0, "name": "sewing machine"},
|
| 416 |
+
{"color": [235, 12, 255], "id": 345, "isthing": 0, "name": "shed"},
|
| 417 |
+
{"color": [160, 150, 20], "id": 346, "isthing": 0, "name": "sheep"},
|
| 418 |
+
{"color": [0, 163, 255], "id": 347, "isthing": 0, "name": "shell"},
|
| 419 |
+
{"color": [140, 140, 140], "id": 348, "isthing": 0, "name": "shelves"},
|
| 420 |
+
{"color": [250, 10, 15], "id": 349, "isthing": 0, "name": "shoe"},
|
| 421 |
+
{"color": [20, 255, 0], "id": 350, "isthing": 0, "name": "shopping cart"},
|
| 422 |
+
{"color": [31, 255, 0], "id": 351, "isthing": 0, "name": "shovel"},
|
| 423 |
+
{"color": [255, 31, 0], "id": 352, "isthing": 0, "name": "sidecar"},
|
| 424 |
+
{"color": [255, 224, 0], "id": 353, "isthing": 0, "name": "sidewalk"},
|
| 425 |
+
{"color": [153, 255, 0], "id": 354, "isthing": 0, "name": "sign"},
|
| 426 |
+
{"color": [0, 0, 255], "id": 355, "isthing": 0, "name": "signal light"},
|
| 427 |
+
{"color": [255, 71, 0], "id": 356, "isthing": 0, "name": "sink"},
|
| 428 |
+
{"color": [0, 235, 255], "id": 357, "isthing": 0, "name": "skateboard"},
|
| 429 |
+
{"color": [0, 173, 255], "id": 358, "isthing": 0, "name": "ski"},
|
| 430 |
+
{"color": [31, 0, 255], "id": 359, "isthing": 0, "name": "sky"},
|
| 431 |
+
{"color": [120, 120, 120], "id": 360, "isthing": 0, "name": "sled"},
|
| 432 |
+
{"color": [180, 120, 120], "id": 361, "isthing": 0, "name": "slippers"},
|
| 433 |
+
{"color": [6, 230, 230], "id": 362, "isthing": 0, "name": "smoke"},
|
| 434 |
+
{"color": [80, 50, 50], "id": 363, "isthing": 0, "name": "snail"},
|
| 435 |
+
{"color": [4, 200, 3], "id": 364, "isthing": 0, "name": "snake"},
|
| 436 |
+
{"color": [120, 120, 80], "id": 365, "isthing": 0, "name": "snow"},
|
| 437 |
+
{"color": [140, 140, 140], "id": 366, "isthing": 0, "name": "snowmobiles"},
|
| 438 |
+
{"color": [204, 5, 255], "id": 367, "isthing": 0, "name": "sofa"},
|
| 439 |
+
{"color": [230, 230, 230], "id": 368, "isthing": 0, "name": "spanner"},
|
| 440 |
+
{"color": [4, 250, 7], "id": 369, "isthing": 0, "name": "spatula"},
|
| 441 |
+
{"color": [224, 5, 255], "id": 370, "isthing": 0, "name": "speaker"},
|
| 442 |
+
{"color": [235, 255, 7], "id": 371, "isthing": 0, "name": "speed bump"},
|
| 443 |
+
{"color": [150, 5, 61], "id": 372, "isthing": 0, "name": "spice container"},
|
| 444 |
+
{"color": [120, 120, 70], "id": 373, "isthing": 0, "name": "spoon"},
|
| 445 |
+
{"color": [8, 255, 51], "id": 374, "isthing": 0, "name": "sprayer"},
|
| 446 |
+
{"color": [255, 6, 82], "id": 375, "isthing": 0, "name": "squirrel"},
|
| 447 |
+
{"color": [143, 255, 140], "id": 376, "isthing": 0, "name": "stage"},
|
| 448 |
+
{"color": [204, 255, 4], "id": 377, "isthing": 0, "name": "stair"},
|
| 449 |
+
{"color": [255, 51, 7], "id": 378, "isthing": 0, "name": "stapler"},
|
| 450 |
+
{"color": [204, 70, 3], "id": 379, "isthing": 0, "name": "stick"},
|
| 451 |
+
{"color": [0, 102, 200], "id": 380, "isthing": 0, "name": "sticky note"},
|
| 452 |
+
{"color": [61, 230, 250], "id": 381, "isthing": 0, "name": "stone"},
|
| 453 |
+
{"color": [255, 6, 51], "id": 382, "isthing": 0, "name": "stool"},
|
| 454 |
+
{"color": [11, 102, 255], "id": 383, "isthing": 0, "name": "stove"},
|
| 455 |
+
{"color": [255, 7, 71], "id": 384, "isthing": 0, "name": "straw"},
|
| 456 |
+
{"color": [255, 9, 224], "id": 385, "isthing": 0, "name": "stretcher"},
|
| 457 |
+
{"color": [9, 7, 230], "id": 386, "isthing": 0, "name": "sun"},
|
| 458 |
+
{"color": [220, 220, 220], "id": 387, "isthing": 0, "name": "sunglass"},
|
| 459 |
+
{"color": [255, 9, 92], "id": 388, "isthing": 0, "name": "sunshade"},
|
| 460 |
+
{"color": [112, 9, 255], "id": 389, "isthing": 0, "name": "surveillance camera"},
|
| 461 |
+
{"color": [8, 255, 214], "id": 390, "isthing": 0, "name": "swan"},
|
| 462 |
+
{"color": [7, 255, 224], "id": 391, "isthing": 0, "name": "sweeper"},
|
| 463 |
+
{"color": [255, 184, 6], "id": 392, "isthing": 0, "name": "swim ring"},
|
| 464 |
+
{"color": [10, 255, 71], "id": 393, "isthing": 0, "name": "swimming pool"},
|
| 465 |
+
{"color": [255, 41, 10], "id": 394, "isthing": 0, "name": "swing"},
|
| 466 |
+
{"color": [7, 255, 255], "id": 395, "isthing": 0, "name": "switch"},
|
| 467 |
+
{"color": [224, 255, 8], "id": 396, "isthing": 0, "name": "table"},
|
| 468 |
+
{"color": [102, 8, 255], "id": 397, "isthing": 0, "name": "tableware"},
|
| 469 |
+
{"color": [255, 61, 6], "id": 398, "isthing": 0, "name": "tank"},
|
| 470 |
+
{"color": [255, 194, 7], "id": 399, "isthing": 0, "name": "tap"},
|
| 471 |
+
{"color": [255, 122, 8], "id": 400, "isthing": 0, "name": "tape"},
|
| 472 |
+
{"color": [0, 255, 20], "id": 401, "isthing": 0, "name": "tarp"},
|
| 473 |
+
{"color": [255, 8, 41], "id": 402, "isthing": 0, "name": "telephone"},
|
| 474 |
+
{"color": [255, 5, 153], "id": 403, "isthing": 0, "name": "telephone booth"},
|
| 475 |
+
{"color": [6, 51, 255], "id": 404, "isthing": 0, "name": "tent"},
|
| 476 |
+
{"color": [235, 12, 255], "id": 405, "isthing": 0, "name": "tire"},
|
| 477 |
+
{"color": [160, 150, 20], "id": 406, "isthing": 0, "name": "toaster"},
|
| 478 |
+
{"color": [0, 163, 255], "id": 407, "isthing": 0, "name": "toilet"},
|
| 479 |
+
{"color": [140, 140, 140], "id": 408, "isthing": 0, "name": "tong"},
|
| 480 |
+
{"color": [250, 10, 15], "id": 409, "isthing": 0, "name": "tool"},
|
| 481 |
+
{"color": [20, 255, 0], "id": 410, "isthing": 0, "name": "toothbrush"},
|
| 482 |
+
{"color": [31, 255, 0], "id": 411, "isthing": 0, "name": "towel"},
|
| 483 |
+
{"color": [255, 31, 0], "id": 412, "isthing": 0, "name": "toy"},
|
| 484 |
+
{"color": [255, 224, 0], "id": 413, "isthing": 0, "name": "toy car"},
|
| 485 |
+
{"color": [153, 255, 0], "id": 414, "isthing": 0, "name": "track"},
|
| 486 |
+
{"color": [0, 0, 255], "id": 415, "isthing": 0, "name": "train"},
|
| 487 |
+
{"color": [255, 71, 0], "id": 416, "isthing": 0, "name": "trampoline"},
|
| 488 |
+
{"color": [0, 235, 255], "id": 417, "isthing": 0, "name": "trash bin"},
|
| 489 |
+
{"color": [0, 173, 255], "id": 418, "isthing": 0, "name": "tray"},
|
| 490 |
+
{"color": [31, 0, 255], "id": 419, "isthing": 0, "name": "tree"},
|
| 491 |
+
{"color": [120, 120, 120], "id": 420, "isthing": 0, "name": "tricycle"},
|
| 492 |
+
{"color": [180, 120, 120], "id": 421, "isthing": 0, "name": "tripod"},
|
| 493 |
+
{"color": [6, 230, 230], "id": 422, "isthing": 0, "name": "trophy"},
|
| 494 |
+
{"color": [80, 50, 50], "id": 423, "isthing": 0, "name": "truck"},
|
| 495 |
+
{"color": [4, 200, 3], "id": 424, "isthing": 0, "name": "tube"},
|
| 496 |
+
{"color": [120, 120, 80], "id": 425, "isthing": 0, "name": "turtle"},
|
| 497 |
+
{"color": [140, 140, 140], "id": 426, "isthing": 0, "name": "tvmonitor"},
|
| 498 |
+
{"color": [204, 5, 255], "id": 427, "isthing": 0, "name": "tweezers"},
|
| 499 |
+
{"color": [230, 230, 230], "id": 428, "isthing": 0, "name": "typewriter"},
|
| 500 |
+
{"color": [4, 250, 7], "id": 429, "isthing": 0, "name": "umbrella"},
|
| 501 |
+
{"color": [224, 5, 255], "id": 430, "isthing": 0, "name": "unknown"},
|
| 502 |
+
{"color": [235, 255, 7], "id": 431, "isthing": 0, "name": "vacuum cleaner"},
|
| 503 |
+
{"color": [150, 5, 61], "id": 432, "isthing": 0, "name": "vending machine"},
|
| 504 |
+
{"color": [120, 120, 70], "id": 433, "isthing": 0, "name": "video camera"},
|
| 505 |
+
{"color": [8, 255, 51], "id": 434, "isthing": 0, "name": "video game console"},
|
| 506 |
+
{"color": [255, 6, 82], "id": 435, "isthing": 0, "name": "video player"},
|
| 507 |
+
{"color": [143, 255, 140], "id": 436, "isthing": 0, "name": "video tape"},
|
| 508 |
+
{"color": [204, 255, 4], "id": 437, "isthing": 0, "name": "violin"},
|
| 509 |
+
{"color": [255, 51, 7], "id": 438, "isthing": 0, "name": "wakeboard"},
|
| 510 |
+
{"color": [204, 70, 3], "id": 439, "isthing": 0, "name": "wall"},
|
| 511 |
+
{"color": [0, 102, 200], "id": 440, "isthing": 0, "name": "wallet"},
|
| 512 |
+
{"color": [61, 230, 250], "id": 441, "isthing": 0, "name": "wardrobe"},
|
| 513 |
+
{"color": [255, 6, 51], "id": 442, "isthing": 0, "name": "washing machine"},
|
| 514 |
+
{"color": [11, 102, 255], "id": 443, "isthing": 0, "name": "watch"},
|
| 515 |
+
{"color": [255, 7, 71], "id": 444, "isthing": 0, "name": "water"},
|
| 516 |
+
{"color": [255, 9, 224], "id": 445, "isthing": 0, "name": "water dispenser"},
|
| 517 |
+
{"color": [9, 7, 230], "id": 446, "isthing": 0, "name": "water pipe"},
|
| 518 |
+
{"color": [220, 220, 220], "id": 447, "isthing": 0, "name": "water skate board"},
|
| 519 |
+
{"color": [255, 9, 92], "id": 448, "isthing": 0, "name": "watermelon"},
|
| 520 |
+
{"color": [112, 9, 255], "id": 449, "isthing": 0, "name": "whale"},
|
| 521 |
+
{"color": [8, 255, 214], "id": 450, "isthing": 0, "name": "wharf"},
|
| 522 |
+
{"color": [7, 255, 224], "id": 451, "isthing": 0, "name": "wheel"},
|
| 523 |
+
{"color": [255, 184, 6], "id": 452, "isthing": 0, "name": "wheelchair"},
|
| 524 |
+
{"color": [10, 255, 71], "id": 453, "isthing": 0, "name": "window"},
|
| 525 |
+
{"color": [255, 41, 10], "id": 454, "isthing": 0, "name": "window blinds"},
|
| 526 |
+
{"color": [7, 255, 255], "id": 455, "isthing": 0, "name": "wineglass"},
|
| 527 |
+
{"color": [224, 255, 8], "id": 456, "isthing": 0, "name": "wire"},
|
| 528 |
+
{"color": [102, 8, 255], "id": 457, "isthing": 0, "name": "wood"},
|
| 529 |
+
{"color": [255, 61, 6], "id": 458, "isthing": 0, "name": "wool"},
|
| 530 |
+
]
|
| 531 |
+
|
| 532 |
+
PASCAL_VOC_21_CATEGORIES = [
|
| 533 |
+
{"color": [0, 0, 0], "id": 0, "isthing": 1, "name": "background"},
|
| 534 |
+
{"color": [128, 0, 0], "id": 1, "isthing": 1, "name": "aeroplane"},
|
| 535 |
+
{"color": [0, 128, 0], "id": 2, "isthing": 1, "name": "bicycle"},
|
| 536 |
+
{"color": [128, 128, 0], "id": 3, "isthing": 1, "name": "bird"},
|
| 537 |
+
{"color": [0, 0, 128], "id": 4, "isthing": 1, "name": "boat"},
|
| 538 |
+
{"color": [128, 0, 128], "id": 5, "isthing": 1, "name": "bottle"},
|
| 539 |
+
{"color": [0, 128, 128], "id": 6, "isthing": 1, "name": "bus"},
|
| 540 |
+
{"color": [128, 128, 128], "id": 7, "isthing": 1, "name": "car"},
|
| 541 |
+
{"color": [64, 0, 0], "id": 8, "isthing": 1, "name": "cat"},
|
| 542 |
+
{"color": [192, 0, 0], "id": 9, "isthing": 1, "name": "chair"},
|
| 543 |
+
{"color": [64, 128, 0], "id": 10, "isthing": 1, "name": "cow"},
|
| 544 |
+
{"color": [192, 128, 0], "id": 11, "isthing": 1, "name": "diningtable"},
|
| 545 |
+
{"color": [64, 0, 128], "id": 12, "isthing": 1, "name": "dog"},
|
| 546 |
+
{"color": [192, 0, 128], "id": 13, "isthing": 1, "name": "horse"},
|
| 547 |
+
{"color": [64, 128, 128], "id": 14, "isthing": 1, "name": "motorbike"},
|
| 548 |
+
{"color": [192, 128, 128], "id": 15, "isthing": 1, "name": "person"},
|
| 549 |
+
{"color": [0, 64, 0], "id": 16, "isthing": 1, "name": "pottedplant"},
|
| 550 |
+
{"color": [128, 64, 0], "id": 17, "isthing": 1, "name": "sheep"},
|
| 551 |
+
{"color": [0, 192, 0], "id": 18, "isthing": 1, "name": "sofa"},
|
| 552 |
+
{"color": [128, 192, 0], "id": 19, "isthing": 1, "name": "train"},
|
| 553 |
+
{"color": [0, 64, 128], "id": 20, "isthing": 1, "name": "tvmonitor"},
|
| 554 |
+
]
|
| 555 |
+
|
| 556 |
+
PASCAL_PARTS_CATEGORIES = [
|
| 557 |
+
{"id": 1, "name": "aeroplane body", "color": [231, 4, 237]},
|
| 558 |
+
{"id": 2, "name": "aeroplane stern", "color": [116, 80, 69]},
|
| 559 |
+
{"id": 3, "name": "aeroplane wing", "color": [214, 86, 123]},
|
| 560 |
+
{"id": 4, "name": "aeroplane tail", "color": [22, 174, 172]},
|
| 561 |
+
{"id": 5, "name": "aeroplane engine", "color": [197, 128, 182]},
|
| 562 |
+
{"id": 6, "name": "aeroplane wheel", "color": [82, 197, 247]},
|
| 563 |
+
{"id": 7, "name": "bicycle body", "color": [125, 34, 155]},
|
| 564 |
+
{"id": 8, "name": "bicycle wheel", "color": [240, 6, 206]},
|
| 565 |
+
{"id": 9, "name": "bicycle saddle", "color": [0, 67, 113]},
|
| 566 |
+
{"id": 10, "name": "bicycle handlebar", "color": [112, 158, 137]},
|
| 567 |
+
{"id": 11, "name": "bicycle headlight", "color": [255, 182, 87]},
|
| 568 |
+
{"id": 12, "name": "bird torso", "color": [189, 249, 133]},
|
| 569 |
+
{"id": 13, "name": "bird head", "color": [104, 202, 100]},
|
| 570 |
+
{"id": 14, "name": "bird neck", "color": [158, 181, 70]},
|
| 571 |
+
{"id": 15, "name": "bird wing", "color": [61, 245, 238]},
|
| 572 |
+
{"id": 16, "name": "bird leg", "color": [55, 126, 0]},
|
| 573 |
+
{"id": 17, "name": "bird foot", "color": [225, 182, 182]},
|
| 574 |
+
{"id": 18, "name": "bird tail", "color": [68, 62, 33]},
|
| 575 |
+
{"id": 19, "name": "boat ", "color": [200, 219, 162]},
|
| 576 |
+
{"id": 20, "name": "bottle body", "color": [172, 155, 96]},
|
| 577 |
+
{"id": 21, "name": "bottle cap", "color": [185, 14, 216]},
|
| 578 |
+
{"id": 22, "name": "bus body", "color": [3, 58, 66]},
|
| 579 |
+
{"id": 23, "name": "bus frontside", "color": [26, 173, 31]},
|
| 580 |
+
{"id": 24, "name": "bus leftside", "color": [205, 197, 47]},
|
| 581 |
+
{"id": 25, "name": "bus rightside", "color": [6, 223, 194]},
|
| 582 |
+
{"id": 26, "name": "bus backside", "color": [10, 232, 224]},
|
| 583 |
+
{"id": 27, "name": "bus roofside", "color": [189, 124, 163]},
|
| 584 |
+
{"id": 28, "name": "bus mirror", "color": [253, 98, 118]},
|
| 585 |
+
{"id": 29, "name": "bus fliplate", "color": [134, 124, 251]},
|
| 586 |
+
{"id": 30, "name": "bus bliplate", "color": [86, 248, 252]},
|
| 587 |
+
{"id": 31, "name": "bus door", "color": [104, 232, 186]},
|
| 588 |
+
{"id": 32, "name": "bus wheel", "color": [73, 10, 81]},
|
| 589 |
+
{"id": 33, "name": "bus headlight", "color": [83, 15, 206]},
|
| 590 |
+
{"id": 34, "name": "bus window", "color": [182, 248, 35]},
|
| 591 |
+
{"id": 35, "name": "car body", "color": [111, 175, 136]},
|
| 592 |
+
{"id": 36, "name": "car mirror", "color": [244, 27, 39]},
|
| 593 |
+
{"id": 37, "name": "car tmirror", "color": [60, 75, 197]},
|
| 594 |
+
{"id": 38, "name": "car fliplate", "color": [32, 124, 177]},
|
| 595 |
+
{"id": 39, "name": "car bliplate", "color": [132, 107, 137]},
|
| 596 |
+
{"id": 40, "name": "car door", "color": [29, 145, 220]},
|
| 597 |
+
{"id": 41, "name": "car wheel", "color": [211, 58, 216]},
|
| 598 |
+
{"id": 42, "name": "car headlight", "color": [253, 195, 114]},
|
| 599 |
+
{"id": 43, "name": "car window", "color": [51, 163, 166]},
|
| 600 |
+
{"id": 44, "name": "cat torso", "color": [68, 44, 17]},
|
| 601 |
+
{"id": 45, "name": "cat head", "color": [148, 109, 203]},
|
| 602 |
+
{"id": 46, "name": "cat eye", "color": [221, 235, 212]},
|
| 603 |
+
{"id": 47, "name": "cat ear", "color": [25, 226, 114]},
|
| 604 |
+
{"id": 48, "name": "cat nose", "color": [99, 126, 184]},
|
| 605 |
+
{"id": 49, "name": "cat neck", "color": [54, 164, 161]},
|
| 606 |
+
{"id": 50, "name": "cat leg", "color": [114, 251, 219]},
|
| 607 |
+
{"id": 51, "name": "cat pawn", "color": [145, 28, 176]},
|
| 608 |
+
{"id": 52, "name": "cat tail", "color": [22, 29, 245]},
|
| 609 |
+
{"id": 53, "name": "chair ", "color": [174, 108, 109]},
|
| 610 |
+
{"id": 54, "name": "cow torso", "color": [153, 207, 125]},
|
| 611 |
+
{"id": 55, "name": "cow head", "color": [243, 197, 251]},
|
| 612 |
+
{"id": 56, "name": "cow eye", "color": [99, 87, 120]},
|
| 613 |
+
{"id": 57, "name": "cow ear", "color": [194, 7, 114]},
|
| 614 |
+
{"id": 58, "name": "cow muzzle", "color": [242, 122, 177]},
|
| 615 |
+
{"id": 59, "name": "cow horn", "color": [202, 242, 232]},
|
| 616 |
+
{"id": 60, "name": "cow neck", "color": [250, 136, 178]},
|
| 617 |
+
{"id": 61, "name": "cow leg", "color": [171, 46, 206]},
|
| 618 |
+
{"id": 62, "name": "cow tail", "color": [186, 133, 2]},
|
| 619 |
+
{"id": 63, "name": "table ", "color": [201, 1, 108]},
|
| 620 |
+
{"id": 64, "name": "dog torso", "color": [245, 11, 186]},
|
| 621 |
+
{"id": 65, "name": "dog head", "color": [33, 191, 131]},
|
| 622 |
+
{"id": 66, "name": "dog eye", "color": [225, 95, 66]},
|
| 623 |
+
{"id": 67, "name": "dog ear", "color": [124, 25, 24]},
|
| 624 |
+
{"id": 68, "name": "dog nose", "color": [214, 234, 112]},
|
| 625 |
+
{"id": 69, "name": "dog neck", "color": [129, 83, 21]},
|
| 626 |
+
{"id": 70, "name": "dog leg", "color": [185, 76, 143]},
|
| 627 |
+
{"id": 71, "name": "dog pawn", "color": [180, 1, 74]},
|
| 628 |
+
{"id": 72, "name": "dog tail", "color": [121, 134, 63]},
|
| 629 |
+
{"id": 73, "name": "dog muzzle", "color": [90, 58, 214]},
|
| 630 |
+
{"id": 74, "name": "horse body", "color": [223, 7, 152]},
|
| 631 |
+
{"id": 75, "name": "horse head", "color": [154, 96, 130]},
|
| 632 |
+
{"id": 76, "name": "horse eye", "color": [221, 98, 183]},
|
| 633 |
+
{"id": 77, "name": "horse ear", "color": [230, 145, 183]},
|
| 634 |
+
{"id": 78, "name": "horse muzzle", "color": [213, 203, 88]},
|
| 635 |
+
{"id": 79, "name": "horse torso", "color": [183, 92, 254]},
|
| 636 |
+
{"id": 80, "name": "horse neck", "color": [206, 114, 11]},
|
| 637 |
+
{"id": 81, "name": "horse leg", "color": [214, 238, 15]},
|
| 638 |
+
{"id": 82, "name": "horse tail", "color": [57, 239, 109]},
|
| 639 |
+
{"id": 83, "name": "motorbike body", "color": [197, 138, 146]},
|
| 640 |
+
{"id": 84, "name": "motorbike wheel", "color": [124, 107, 252]},
|
| 641 |
+
{"id": 85, "name": "motorbike handlebar", "color": [163, 225, 169]},
|
| 642 |
+
{"id": 86, "name": "motorbike saddle", "color": [254, 180, 116]},
|
| 643 |
+
{"id": 87, "name": "motorbike headlight", "color": [119, 52, 22]},
|
| 644 |
+
{"id": 88, "name": "person body", "color": [198, 68, 18]},
|
| 645 |
+
{"id": 89, "name": "person head", "color": [40, 30, 77]},
|
| 646 |
+
{"id": 90, "name": "person eye", "color": [237, 64, 148]},
|
| 647 |
+
{"id": 91, "name": "person ear", "color": [49, 186, 234]},
|
| 648 |
+
{"id": 92, "name": "person ebrow", "color": [242, 204, 127]},
|
| 649 |
+
{"id": 93, "name": "person nose", "color": [101, 145, 176]},
|
| 650 |
+
{"id": 94, "name": "person mouth", "color": [31, 78, 216]},
|
| 651 |
+
{"id": 95, "name": "person hair", "color": [95, 148, 151]},
|
| 652 |
+
{"id": 96, "name": "person torso", "color": [126, 117, 235]},
|
| 653 |
+
{"id": 97, "name": "person neck", "color": [13, 146, 62]},
|
| 654 |
+
{"id": 98, "name": "person lower arm", "color": [9, 41, 5]},
|
| 655 |
+
{"id": 99, "name": "person upper arm", "color": [110, 109, 109]},
|
| 656 |
+
{"id": 100, "name": "person hand", "color": [58, 227, 163]},
|
| 657 |
+
{"id": 101, "name": "person lower leg", "color": [132, 63, 32]},
|
| 658 |
+
{"id": 102, "name": "person upper leg", "color": [212, 118, 174]},
|
| 659 |
+
{"id": 103, "name": "person foot", "color": [45, 66, 254]},
|
| 660 |
+
{"id": 104, "name": "pottedplant plant", "color": [236, 149, 209]},
|
| 661 |
+
{"id": 105, "name": "pottedplant pot", "color": [80, 197, 134]},
|
| 662 |
+
{"id": 106, "name": "sheep torso", "color": [241, 111, 194]},
|
| 663 |
+
{"id": 107, "name": "sheep head", "color": [31, 13, 13]},
|
| 664 |
+
{"id": 108, "name": "sheep eye", "color": [34, 207, 63]},
|
| 665 |
+
{"id": 109, "name": "sheep ear", "color": [249, 117, 121]},
|
| 666 |
+
{"id": 110, "name": "sheep muzzle", "color": [172, 128, 70]},
|
| 667 |
+
{"id": 111, "name": "sheep horn", "color": [97, 144, 104]},
|
| 668 |
+
{"id": 112, "name": "sheep neck", "color": [121, 163, 14]},
|
| 669 |
+
{"id": 113, "name": "sheep leg", "color": [38, 79, 231]},
|
| 670 |
+
{"id": 114, "name": "sheep tail", "color": [218, 195, 52]},
|
| 671 |
+
{"id": 115, "name": "sofa ", "color": [102, 8, 225]},
|
| 672 |
+
{"id": 116, "name": "train body", "color": [150, 44, 180]},
|
| 673 |
+
{"id": 117, "name": "train head", "color": [99, 250, 180]},
|
| 674 |
+
{"id": 118, "name": "train headlight", "color": [24, 148, 249]},
|
| 675 |
+
{"id": 119, "name": "train coach", "color": [143, 232, 181]},
|
| 676 |
+
{"id": 120, "name": "tvmonitor frame", "color": [68, 191, 134]},
|
| 677 |
+
{"id": 121, "name": "tvmonitor screen", "color": [186, 6, 38]},
|
| 678 |
+
{"id": 122, "name": "bag ", "color": [215, 253, 9]},
|
| 679 |
+
{"id": 123, "name": "basket ", "color": [150, 44, 154]},
|
| 680 |
+
{"id": 124, "name": "bed ", "color": [66, 132, 108]},
|
| 681 |
+
{"id": 125, "name": "bedclothes ", "color": [193, 84, 92]},
|
| 682 |
+
{"id": 126, "name": "bench ", "color": [84, 154, 254]},
|
| 683 |
+
{"id": 127, "name": "bird cage ", "color": [2, 93, 169]},
|
| 684 |
+
{"id": 128, "name": "board ", "color": [41, 254, 95]},
|
| 685 |
+
{"id": 129, "name": "book ", "color": [157, 228, 148]},
|
| 686 |
+
{"id": 130, "name": "bowl ", "color": [201, 198, 2]},
|
| 687 |
+
{"id": 131, "name": "box ", "color": [237, 151, 223]},
|
| 688 |
+
{"id": 132, "name": "bridge ", "color": [74, 200, 197]},
|
| 689 |
+
{"id": 133, "name": "brush ", "color": [157, 2, 192]},
|
| 690 |
+
{"id": 134, "name": "bucket ", "color": [62, 8, 145]},
|
| 691 |
+
{"id": 135, "name": "building ", "color": [244, 158, 23]},
|
| 692 |
+
{"id": 136, "name": "cabinet ", "color": [143, 34, 160]},
|
| 693 |
+
{"id": 137, "name": "cage ", "color": [74, 182, 153]},
|
| 694 |
+
{"id": 138, "name": "case ", "color": [44, 161, 32]},
|
| 695 |
+
{"id": 139, "name": "ceiling ", "color": [22, 207, 172]},
|
| 696 |
+
{"id": 140, "name": "cloth ", "color": [62, 233, 51]},
|
| 697 |
+
{"id": 141, "name": "computer ", "color": [203, 221, 8]},
|
| 698 |
+
{"id": 142, "name": "counter ", "color": [155, 154, 208]},
|
| 699 |
+
{"id": 143, "name": "cup ", "color": [136, 170, 161]},
|
| 700 |
+
{"id": 144, "name": "curtain ", "color": [69, 238, 67]},
|
| 701 |
+
{"id": 145, "name": "cushion ", "color": [250, 140, 63]},
|
| 702 |
+
{"id": 146, "name": "door ", "color": [228, 29, 142]},
|
| 703 |
+
{"id": 147, "name": "fence ", "color": [149, 149, 255]},
|
| 704 |
+
{"id": 148, "name": "fire place ", "color": [25, 17, 14]},
|
| 705 |
+
{"id": 149, "name": "floor ", "color": [141, 121, 107]},
|
| 706 |
+
{"id": 150, "name": "flower ", "color": [196, 171, 99]},
|
| 707 |
+
{"id": 151, "name": "food ", "color": [246, 30, 195]},
|
| 708 |
+
{"id": 152, "name": "fridge ", "color": [95, 2, 42]},
|
| 709 |
+
{"id": 153, "name": "grandstand ", "color": [174, 116, 162]},
|
| 710 |
+
{"id": 154, "name": "grass ", "color": [251, 58, 246]},
|
| 711 |
+
{"id": 155, "name": "ground ", "color": [138, 68, 168]},
|
| 712 |
+
{"id": 156, "name": "horse-drawn carriage ", "color": [236, 220, 194]},
|
| 713 |
+
{"id": 157, "name": "keyboard ", "color": [228, 180, 129]},
|
| 714 |
+
{"id": 158, "name": "laptop ", "color": [41, 39, 187]},
|
| 715 |
+
{"id": 159, "name": "light ", "color": [18, 155, 71]},
|
| 716 |
+
{"id": 160, "name": "mat ", "color": [81, 149, 168]},
|
| 717 |
+
{"id": 161, "name": "metal ", "color": [222, 250, 122]},
|
| 718 |
+
{"id": 162, "name": "mirror ", "color": [27, 14, 162]},
|
| 719 |
+
{"id": 163, "name": "mountain ", "color": [96, 67, 42]},
|
| 720 |
+
{"id": 164, "name": "mouse ", "color": [248, 27, 142]},
|
| 721 |
+
{"id": 165, "name": "pack ", "color": [48, 208, 79]},
|
| 722 |
+
{"id": 166, "name": "paper ", "color": [85, 44, 114]},
|
| 723 |
+
{"id": 167, "name": "picture ", "color": [8, 66, 36]},
|
| 724 |
+
{"id": 168, "name": "pillow ", "color": [199, 38, 36]},
|
| 725 |
+
{"id": 169, "name": "plant ", "color": [45, 67, 214]},
|
| 726 |
+
{"id": 170, "name": "plate ", "color": [176, 85, 199]},
|
| 727 |
+
{"id": 171, "name": "platform ", "color": [118, 46, 134]},
|
| 728 |
+
{"id": 172, "name": "pole ", "color": [66, 53, 97]},
|
| 729 |
+
{"id": 173, "name": "poster ", "color": [134, 95, 198]},
|
| 730 |
+
{"id": 174, "name": "pot ", "color": [56, 185, 27]},
|
| 731 |
+
{"id": 175, "name": "road ", "color": [12, 12, 242]},
|
| 732 |
+
{"id": 176, "name": "rock ", "color": [141, 182, 239]},
|
| 733 |
+
{"id": 177, "name": "rope ", "color": [242, 15, 134]},
|
| 734 |
+
{"id": 178, "name": "rug ", "color": [119, 78, 116]},
|
| 735 |
+
{"id": 179, "name": "sand ", "color": [159, 25, 177]},
|
| 736 |
+
{"id": 180, "name": "sculpture ", "color": [155, 71, 2]},
|
| 737 |
+
{"id": 181, "name": "shelves ", "color": [13, 156, 172]},
|
| 738 |
+
{"id": 182, "name": "sidewalk ", "color": [153, 56, 74]},
|
| 739 |
+
{"id": 183, "name": "sign ", "color": [132, 5, 169]},
|
| 740 |
+
{"id": 184, "name": "sink ", "color": [202, 115, 244]},
|
| 741 |
+
{"id": 185, "name": "sky ", "color": [189, 81, 126]},
|
| 742 |
+
{"id": 186, "name": "smoke ", "color": [50, 105, 141]},
|
| 743 |
+
{"id": 187, "name": "snow ", "color": [163, 75, 126]},
|
| 744 |
+
{"id": 188, "name": "speaker ", "color": [25, 28, 9]},
|
| 745 |
+
{"id": 189, "name": "stage ", "color": [57, 175, 211]},
|
| 746 |
+
{"id": 190, "name": "stair ", "color": [36, 182, 123]},
|
| 747 |
+
{"id": 191, "name": "tent ", "color": [210, 184, 159]},
|
| 748 |
+
{"id": 192, "name": "toy ", "color": [139, 14, 196]},
|
| 749 |
+
{"id": 193, "name": "track ", "color": [204, 225, 55]},
|
| 750 |
+
{"id": 194, "name": "tree ", "color": [145, 64, 92]},
|
| 751 |
+
{"id": 195, "name": "truck ", "color": [43, 65, 241]},
|
| 752 |
+
{"id": 196, "name": "wall ", "color": [220, 189, 61]},
|
| 753 |
+
{"id": 197, "name": "water ", "color": [250, 95, 220]},
|
| 754 |
+
{"id": 198, "name": "window ", "color": [176, 117, 245]},
|
| 755 |
+
{"id": 199, "name": "wineglass ", "color": [102, 162, 66]},
|
| 756 |
+
{"id": 200, "name": "wood ", "color": [100, 60, 45]},
|
| 757 |
+
]
|
| 758 |
+
|
| 759 |
+
PASCAL_PARTS_PARTS_ONLY = [
|
| 760 |
+
{"id": 1, "name": "aeroplane body", "color": [30, 178, 112]},
|
| 761 |
+
{"id": 2, "name": "aeroplane stern", "color": [0, 80, 42]},
|
| 762 |
+
{"id": 3, "name": "aeroplane wing", "color": [160, 237, 245]},
|
| 763 |
+
{"id": 4, "name": "aeroplane engine", "color": [144, 222, 51]},
|
| 764 |
+
{"id": 5, "name": "aeroplane wheel", "color": [155, 121, 20]},
|
| 765 |
+
{"id": 6, "name": "bicycle body", "color": [24, 50, 96]},
|
| 766 |
+
{"id": 7, "name": "bicycle wheel", "color": [247, 201, 171]},
|
| 767 |
+
{"id": 8, "name": "bird torso", "color": [63, 162, 50]},
|
| 768 |
+
{"id": 9, "name": "bird head", "color": [143, 18, 27]},
|
| 769 |
+
{"id": 10, "name": "bird wing", "color": [204, 34, 128]},
|
| 770 |
+
{"id": 11, "name": "bird leg", "color": [31, 37, 39]},
|
| 771 |
+
{"id": 12, "name": "boat ", "color": [175, 16, 226]},
|
| 772 |
+
{"id": 13, "name": "bottle cap", "color": [31, 13, 221]},
|
| 773 |
+
{"id": 14, "name": "bottle body", "color": [120, 248, 33]},
|
| 774 |
+
{"id": 15, "name": "bus body", "color": [243, 104, 244]},
|
| 775 |
+
{"id": 16, "name": "bus wheel", "color": [247, 196, 104]},
|
| 776 |
+
{"id": 17, "name": "bus window", "color": [63, 138, 111]},
|
| 777 |
+
{"id": 18, "name": "car body", "color": [200, 176, 116]},
|
| 778 |
+
{"id": 19, "name": "car license plate", "color": [79, 146, 205]},
|
| 779 |
+
{"id": 20, "name": "car wheel", "color": [231, 126, 229]},
|
| 780 |
+
{"id": 21, "name": "car light", "color": [120, 219, 85]},
|
| 781 |
+
{"id": 22, "name": "car window", "color": [240, 73, 236]},
|
| 782 |
+
{"id": 23, "name": "cat torso", "color": [24, 254, 246]},
|
| 783 |
+
{"id": 24, "name": "cat head", "color": [38, 29, 151]},
|
| 784 |
+
{"id": 25, "name": "cat leg", "color": [229, 8, 161]},
|
| 785 |
+
{"id": 26, "name": "cat tail", "color": [212, 191, 142]},
|
| 786 |
+
{"id": 27, "name": "chair ", "color": [235, 90, 210]},
|
| 787 |
+
{"id": 28, "name": "cow torso", "color": [72, 26, 132]},
|
| 788 |
+
{"id": 29, "name": "cow head", "color": [28, 249, 68]},
|
| 789 |
+
{"id": 30, "name": "cow leg", "color": [69, 62, 39]},
|
| 790 |
+
{"id": 31, "name": "cow tail", "color": [238, 140, 59]},
|
| 791 |
+
{"id": 32, "name": "table ", "color": [73, 170, 102]},
|
| 792 |
+
{"id": 33, "name": "dog torso", "color": [51, 140, 200]},
|
| 793 |
+
{"id": 34, "name": "dog head", "color": [141, 130, 240]},
|
| 794 |
+
{"id": 35, "name": "dog leg", "color": [223, 199, 36]},
|
| 795 |
+
{"id": 36, "name": "dog tail", "color": [40, 192, 182]},
|
| 796 |
+
{"id": 37, "name": "horse torso", "color": [212, 206, 245]},
|
| 797 |
+
{"id": 38, "name": "horse head", "color": [59, 63, 103]},
|
| 798 |
+
{"id": 39, "name": "horse leg", "color": [50, 72, 178]},
|
| 799 |
+
{"id": 40, "name": "horse tail", "color": [49, 64, 103]},
|
| 800 |
+
{"id": 41, "name": "motorbike body", "color": [226, 39, 217]},
|
| 801 |
+
{"id": 42, "name": "motorbike wheel", "color": [11, 110, 195]},
|
| 802 |
+
{"id": 43, "name": "person torso", "color": [155, 219, 139]},
|
| 803 |
+
{"id": 44, "name": "person head", "color": [168, 137, 15]},
|
| 804 |
+
{"id": 45, "name": "person lower arm", "color": [187, 194, 167]},
|
| 805 |
+
{"id": 46, "name": "person upper arm", "color": [60, 80, 21]},
|
| 806 |
+
{"id": 47, "name": "person lower leg", "color": [180, 219, 17]},
|
| 807 |
+
{"id": 48, "name": "person upper leg", "color": [240, 249, 227]},
|
| 808 |
+
{"id": 49, "name": "pottedplant plant", "color": [191, 176, 151]},
|
| 809 |
+
{"id": 50, "name": "pottedplant pot", "color": [13, 133, 225]},
|
| 810 |
+
{"id": 51, "name": "sheep torso", "color": [178, 101, 246]},
|
| 811 |
+
{"id": 52, "name": "sheep head", "color": [52, 108, 42]},
|
| 812 |
+
{"id": 53, "name": "sheep leg", "color": [92, 169, 47]},
|
| 813 |
+
{"id": 54, "name": "sofa ", "color": [45, 45, 192]},
|
| 814 |
+
{"id": 55, "name": "train body", "color": [168, 7, 178]},
|
| 815 |
+
{"id": 56, "name": "tvmonitor frame", "color": [59, 89, 2]},
|
| 816 |
+
{"id": 57, "name": "tvmonitor screen", "color": [51, 85, 167]},
|
| 817 |
+
]
|
| 818 |
+
|
| 819 |
+
|
| 820 |
+
def _get_ctx59_meta():
|
| 821 |
+
# Id 0 is reserved for ignore_label, we change ignore_label for 0
|
| 822 |
+
# to 255 in our pre-processing, so all ids are shifted by 1.
|
| 823 |
+
stuff_ids = [k["id"] for k in PASCAL_CTX_59_CATEGORIES]
|
| 824 |
+
assert len(stuff_ids) == 59, len(stuff_ids)
|
| 825 |
+
|
| 826 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 827 |
+
# (in [0, 91], used in models) to ids in the dataset (used for processing results)
|
| 828 |
+
stuff_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(stuff_ids)}
|
| 829 |
+
stuff_classes = [k["name"] for k in PASCAL_CTX_59_CATEGORIES]
|
| 830 |
+
|
| 831 |
+
ret = {
|
| 832 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 833 |
+
"stuff_classes": stuff_classes,
|
| 834 |
+
}
|
| 835 |
+
return ret
|
| 836 |
+
|
| 837 |
+
|
| 838 |
+
def register_all_ctx59(root):
|
| 839 |
+
root = os.path.join(root, "pascal_ctx_d2")
|
| 840 |
+
meta = _get_ctx59_meta()
|
| 841 |
+
for name, dirname in [("train", "training"), ("val", "validation")]:
|
| 842 |
+
image_dir = os.path.join(root, "images", dirname)
|
| 843 |
+
gt_dir = os.path.join(root, "annotations_ctx59", dirname)
|
| 844 |
+
name = f"ctx59_sem_seg_{name}"
|
| 845 |
+
DatasetCatalog.register(
|
| 846 |
+
name,
|
| 847 |
+
lambda x=image_dir, y=gt_dir: load_sem_seg(
|
| 848 |
+
y, x, gt_ext="png", image_ext="jpg", dataset_name="pascal_context_59"
|
| 849 |
+
),
|
| 850 |
+
)
|
| 851 |
+
MetadataCatalog.get(name).set(
|
| 852 |
+
stuff_classes=meta["stuff_classes"][:],
|
| 853 |
+
thing_dataset_id_to_contiguous_id={}, # to make Mask2Former happy
|
| 854 |
+
stuff_dataset_id_to_contiguous_id=meta["stuff_dataset_id_to_contiguous_id"],
|
| 855 |
+
image_root=image_dir,
|
| 856 |
+
sem_seg_root=gt_dir,
|
| 857 |
+
evaluator_type="sem_seg",
|
| 858 |
+
ignore_label=255,
|
| 859 |
+
)
|
| 860 |
+
|
| 861 |
+
|
| 862 |
+
def _get_pascal21_meta():
|
| 863 |
+
# Id 0 is reserved for ignore_label, we change ignore_label for 0
|
| 864 |
+
# to 255 in our pre-processing, so all ids are shifted by 1.
|
| 865 |
+
stuff_ids = [k["id"] for k in PASCAL_VOC_21_CATEGORIES]
|
| 866 |
+
assert len(stuff_ids) == 21, len(stuff_ids)
|
| 867 |
+
|
| 868 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 869 |
+
# (in [0, 91], used in models) to ids in the dataset (used for processing results)
|
| 870 |
+
stuff_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(stuff_ids)}
|
| 871 |
+
stuff_classes = [k["name"] for k in PASCAL_VOC_21_CATEGORIES]
|
| 872 |
+
|
| 873 |
+
ret = {
|
| 874 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 875 |
+
"stuff_classes": stuff_classes,
|
| 876 |
+
}
|
| 877 |
+
return ret
|
| 878 |
+
|
| 879 |
+
|
| 880 |
+
def register_all_pascal21(root):
|
| 881 |
+
root = os.path.join(root, "pascal_voc_d2")
|
| 882 |
+
meta = _get_pascal21_meta()
|
| 883 |
+
for name, dirname in [("train", "training"), ("val", "validation")]:
|
| 884 |
+
image_dir = os.path.join(root, "images", dirname)
|
| 885 |
+
gt_dir = os.path.join(root, "annotations_pascal21", dirname)
|
| 886 |
+
name = f"pascal21_sem_seg_{name}"
|
| 887 |
+
DatasetCatalog.register(
|
| 888 |
+
name,
|
| 889 |
+
lambda x=image_dir, y=gt_dir: load_sem_seg(
|
| 890 |
+
y, x, gt_ext="png", image_ext="jpg", dataset_name="pascal_voc_21"
|
| 891 |
+
),
|
| 892 |
+
)
|
| 893 |
+
MetadataCatalog.get(name).set(
|
| 894 |
+
stuff_classes=meta["stuff_classes"][:],
|
| 895 |
+
thing_dataset_id_to_contiguous_id={}, # to make Mask2Former happy
|
| 896 |
+
stuff_dataset_id_to_contiguous_id=meta["stuff_dataset_id_to_contiguous_id"],
|
| 897 |
+
image_root=image_dir,
|
| 898 |
+
sem_seg_root=gt_dir,
|
| 899 |
+
evaluator_type="sem_seg",
|
| 900 |
+
ignore_label=255,
|
| 901 |
+
)
|
| 902 |
+
|
| 903 |
+
|
| 904 |
+
def _get_ctx459_meta():
|
| 905 |
+
# Id 0 is reserved for ignore_label, we change ignore_label for 0
|
| 906 |
+
# to 255 in our pre-processing, so all ids are shifted by 1.
|
| 907 |
+
stuff_ids = [k["id"] for k in PASCAL_CTX_459_CATEGORIES]
|
| 908 |
+
assert len(stuff_ids) == 459, len(stuff_ids)
|
| 909 |
+
|
| 910 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 911 |
+
# (in [0, 91], used in models) to ids in the dataset (used for processing results)
|
| 912 |
+
stuff_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(stuff_ids)}
|
| 913 |
+
stuff_classes = [k["name"] for k in PASCAL_CTX_459_CATEGORIES]
|
| 914 |
+
|
| 915 |
+
ret = {
|
| 916 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 917 |
+
"stuff_classes": stuff_classes,
|
| 918 |
+
}
|
| 919 |
+
return ret
|
| 920 |
+
|
| 921 |
+
|
| 922 |
+
def register_all_ctx459(root):
|
| 923 |
+
root = os.path.join(root, "pascal_ctx_d2")
|
| 924 |
+
meta = _get_ctx459_meta()
|
| 925 |
+
for name, dirname in [("train", "training"), ("val", "validation")]:
|
| 926 |
+
image_dir = os.path.join(root, "images", dirname)
|
| 927 |
+
gt_dir = os.path.join(root, "annotations_ctx459", dirname)
|
| 928 |
+
name = f"ctx459_sem_seg_{name}"
|
| 929 |
+
DatasetCatalog.register(
|
| 930 |
+
name,
|
| 931 |
+
lambda x=image_dir, y=gt_dir: load_sem_seg(
|
| 932 |
+
y, x, gt_ext="tif", image_ext="jpg", dataset_name="pascal_context_459"
|
| 933 |
+
),
|
| 934 |
+
)
|
| 935 |
+
MetadataCatalog.get(name).set(
|
| 936 |
+
stuff_classes=meta["stuff_classes"][:],
|
| 937 |
+
thing_dataset_id_to_contiguous_id={}, # to make Mask2Former happy
|
| 938 |
+
stuff_dataset_id_to_contiguous_id=meta["stuff_dataset_id_to_contiguous_id"],
|
| 939 |
+
image_root=image_dir,
|
| 940 |
+
sem_seg_root=gt_dir,
|
| 941 |
+
evaluator_type="sem_seg",
|
| 942 |
+
ignore_label=65535, # NOTE: gt is saved in 16-bit TIFF images
|
| 943 |
+
)
|
| 944 |
+
|
| 945 |
+
|
| 946 |
+
def _get_parts_meta():
|
| 947 |
+
# Id 0 is reserved for ignore_label, we change ignore_label for 0
|
| 948 |
+
# to 255 in our pre-processing, so all ids are shifted by 1.
|
| 949 |
+
stuff_ids = [k["id"] for k in PASCAL_PARTS_CATEGORIES]
|
| 950 |
+
# assert len(stuff_ids) == 459, len(stuff_ids)
|
| 951 |
+
|
| 952 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 953 |
+
# (in [0, 91], used in models) to ids in the dataset (used for processing results)
|
| 954 |
+
stuff_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(stuff_ids)}
|
| 955 |
+
stuff_classes = [k["name"] for k in PASCAL_PARTS_CATEGORIES]
|
| 956 |
+
|
| 957 |
+
ret = {
|
| 958 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 959 |
+
"stuff_classes": stuff_classes,
|
| 960 |
+
}
|
| 961 |
+
return ret
|
| 962 |
+
|
| 963 |
+
|
| 964 |
+
def _get_parts_only_meta():
|
| 965 |
+
# Id 0 is reserved for ignore_label, we change ignore_label for 0
|
| 966 |
+
# to 255 in our pre-processing, so all ids are shifted by 1.
|
| 967 |
+
stuff_ids = [k["id"] for k in PASCAL_PARTS_PARTS_ONLY]
|
| 968 |
+
# assert len(stuff_ids) == 459, len(stuff_ids)
|
| 969 |
+
|
| 970 |
+
# For semantic segmentation, this mapping maps from contiguous stuff id
|
| 971 |
+
# (in [0, 91], used in models) to ids in the dataset (used for processing results)
|
| 972 |
+
stuff_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(stuff_ids)}
|
| 973 |
+
stuff_classes = [k["name"] for k in PASCAL_PARTS_PARTS_ONLY]
|
| 974 |
+
|
| 975 |
+
ret = {
|
| 976 |
+
"stuff_dataset_id_to_contiguous_id": stuff_dataset_id_to_contiguous_id,
|
| 977 |
+
"stuff_classes": stuff_classes,
|
| 978 |
+
}
|
| 979 |
+
return ret
|
| 980 |
+
|
| 981 |
+
|
| 982 |
+
def register_all_pascal_parts_only(root):
|
| 983 |
+
data_root = root
|
| 984 |
+
root = os.path.join(root, "pascal_parts")
|
| 985 |
+
meta = _get_parts_only_meta()
|
| 986 |
+
for name, dirname in [
|
| 987 |
+
("train", "training_merged"),
|
| 988 |
+
("val", "validation_merged"),
|
| 989 |
+
("test", "test_merged"),
|
| 990 |
+
]:
|
| 991 |
+
image_dir = os.path.join(data_root, "VOCdevkit/VOC2010/JPEGImages")
|
| 992 |
+
gt_dir = os.path.join(root, "labels", dirname)
|
| 993 |
+
name = f"pascal_parts_merged_{name}"
|
| 994 |
+
DatasetCatalog.register(
|
| 995 |
+
name,
|
| 996 |
+
lambda x=image_dir, y=gt_dir: load_sem_seg(
|
| 997 |
+
y, x, gt_ext="tif", image_ext="jpg", dataset_name="pascal_parts_merged"
|
| 998 |
+
),
|
| 999 |
+
)
|
| 1000 |
+
MetadataCatalog.get(name).set(
|
| 1001 |
+
stuff_classes=meta["stuff_classes"][:],
|
| 1002 |
+
thing_dataset_id_to_contiguous_id={}, # to make Mask2Former happy
|
| 1003 |
+
stuff_dataset_id_to_contiguous_id=meta["stuff_dataset_id_to_contiguous_id"],
|
| 1004 |
+
image_root=image_dir,
|
| 1005 |
+
sem_seg_root=gt_dir,
|
| 1006 |
+
evaluator_type="sem_seg",
|
| 1007 |
+
ignore_label=0, # NOTE: gt is saved in 16-bit TIFF images
|
| 1008 |
+
)
|
| 1009 |
+
|
| 1010 |
+
|
| 1011 |
+
PASCAL_LABEL_PART_GROUP = {
|
| 1012 |
+
1: 1,
|
| 1013 |
+
2: 2,
|
| 1014 |
+
3: 3,
|
| 1015 |
+
4: 2,
|
| 1016 |
+
5: 4,
|
| 1017 |
+
6: 5,
|
| 1018 |
+
7: 6,
|
| 1019 |
+
8: 7,
|
| 1020 |
+
9: 6,
|
| 1021 |
+
10: 6,
|
| 1022 |
+
11: 6,
|
| 1023 |
+
12: 8,
|
| 1024 |
+
13: 9,
|
| 1025 |
+
14: 9,
|
| 1026 |
+
15: 10,
|
| 1027 |
+
16: 11,
|
| 1028 |
+
17: 11,
|
| 1029 |
+
18: 8,
|
| 1030 |
+
19: 12,
|
| 1031 |
+
20: 14,
|
| 1032 |
+
21: 13,
|
| 1033 |
+
22: 15,
|
| 1034 |
+
23: 15,
|
| 1035 |
+
24: 15,
|
| 1036 |
+
25: 15,
|
| 1037 |
+
26: 15,
|
| 1038 |
+
27: 15,
|
| 1039 |
+
28: 15,
|
| 1040 |
+
29: 15,
|
| 1041 |
+
30: 15,
|
| 1042 |
+
31: 15,
|
| 1043 |
+
32: 16,
|
| 1044 |
+
33: 15,
|
| 1045 |
+
34: 17,
|
| 1046 |
+
35: 18,
|
| 1047 |
+
36: 18,
|
| 1048 |
+
37: 18,
|
| 1049 |
+
38: 19,
|
| 1050 |
+
39: 19,
|
| 1051 |
+
40: 18,
|
| 1052 |
+
41: 20,
|
| 1053 |
+
42: 21,
|
| 1054 |
+
43: 22,
|
| 1055 |
+
44: 23,
|
| 1056 |
+
45: 24,
|
| 1057 |
+
46: 24,
|
| 1058 |
+
47: 24,
|
| 1059 |
+
48: 24,
|
| 1060 |
+
49: 23,
|
| 1061 |
+
50: 25,
|
| 1062 |
+
51: 25,
|
| 1063 |
+
52: 26,
|
| 1064 |
+
53: 27,
|
| 1065 |
+
54: 28,
|
| 1066 |
+
55: 29,
|
| 1067 |
+
56: 29,
|
| 1068 |
+
57: 29,
|
| 1069 |
+
58: 29,
|
| 1070 |
+
59: 29,
|
| 1071 |
+
60: 28,
|
| 1072 |
+
61: 30,
|
| 1073 |
+
62: 31,
|
| 1074 |
+
63: 32,
|
| 1075 |
+
64: 33,
|
| 1076 |
+
65: 34,
|
| 1077 |
+
66: 34,
|
| 1078 |
+
67: 34,
|
| 1079 |
+
68: 34,
|
| 1080 |
+
69: 33,
|
| 1081 |
+
70: 35,
|
| 1082 |
+
71: 35,
|
| 1083 |
+
72: 36,
|
| 1084 |
+
73: 34,
|
| 1085 |
+
74: 37,
|
| 1086 |
+
75: 38,
|
| 1087 |
+
76: 38,
|
| 1088 |
+
77: 38,
|
| 1089 |
+
78: 38,
|
| 1090 |
+
79: 37,
|
| 1091 |
+
80: 37,
|
| 1092 |
+
81: 39,
|
| 1093 |
+
82: 40,
|
| 1094 |
+
83: 41,
|
| 1095 |
+
84: 42,
|
| 1096 |
+
85: 41,
|
| 1097 |
+
86: 41,
|
| 1098 |
+
87: 41,
|
| 1099 |
+
88: 43,
|
| 1100 |
+
89: 44,
|
| 1101 |
+
90: 44,
|
| 1102 |
+
91: 44,
|
| 1103 |
+
92: 44,
|
| 1104 |
+
93: 44,
|
| 1105 |
+
94: 44,
|
| 1106 |
+
95: 44,
|
| 1107 |
+
96: 43,
|
| 1108 |
+
97: 43,
|
| 1109 |
+
98: 45,
|
| 1110 |
+
99: 46,
|
| 1111 |
+
100: 45,
|
| 1112 |
+
101: 47,
|
| 1113 |
+
102: 48,
|
| 1114 |
+
103: 47,
|
| 1115 |
+
104: 49,
|
| 1116 |
+
105: 50,
|
| 1117 |
+
106: 51,
|
| 1118 |
+
107: 52,
|
| 1119 |
+
108: 52,
|
| 1120 |
+
109: 52,
|
| 1121 |
+
110: 52,
|
| 1122 |
+
111: 52,
|
| 1123 |
+
112: 51,
|
| 1124 |
+
113: 53,
|
| 1125 |
+
114: 51,
|
| 1126 |
+
115: 54,
|
| 1127 |
+
116: 55,
|
| 1128 |
+
117: 55,
|
| 1129 |
+
118: 55,
|
| 1130 |
+
119: 55,
|
| 1131 |
+
120: 56,
|
| 1132 |
+
121: 57,
|
| 1133 |
+
}
|
| 1134 |
+
|
| 1135 |
+
|
| 1136 |
+
def register_all_pascal_parts(root):
|
| 1137 |
+
data_root = root
|
| 1138 |
+
register_all_pascal_parts_only(data_root)
|
| 1139 |
+
root = os.path.join(root, "pascal_parts")
|
| 1140 |
+
meta = _get_parts_meta()
|
| 1141 |
+
for name, dirname in [("train", "training"), ("val", "validation"), ("test", "test_pano")]:
|
| 1142 |
+
image_dir = os.path.join(data_root, "VOCdevkit/VOC2010/JPEGImages")
|
| 1143 |
+
gt_dir = os.path.join(root, "labels", dirname)
|
| 1144 |
+
name = f"pascal_parts_{name}"
|
| 1145 |
+
DatasetCatalog.register(
|
| 1146 |
+
name, lambda x=image_dir, y=gt_dir: load_sem_seg(y, x, gt_ext="tif", image_ext="jpg")
|
| 1147 |
+
)
|
| 1148 |
+
MetadataCatalog.get(name).set(
|
| 1149 |
+
stuff_classes=meta["stuff_classes"][:],
|
| 1150 |
+
thing_dataset_id_to_contiguous_id={}, # to make Mask2Former happy
|
| 1151 |
+
stuff_dataset_id_to_contiguous_id=meta["stuff_dataset_id_to_contiguous_id"],
|
| 1152 |
+
image_root=image_dir,
|
| 1153 |
+
sem_seg_root=gt_dir,
|
| 1154 |
+
evaluator_type="sem_seg",
|
| 1155 |
+
label_group=PASCAL_LABEL_PART_GROUP,
|
| 1156 |
+
# ignore_label=0, # NOTE: gt is saved in 16-bit TIFF images
|
| 1157 |
+
ignore_label=255, # NOTE: gt is saved in 16-bit TIFF images
|
| 1158 |
+
)
|
| 1159 |
+
|
| 1160 |
+
|
| 1161 |
+
_PREDEFINED_SPLITS_PASCALVOCPART = {}
|
| 1162 |
+
_PREDEFINED_SPLITS_PASCALVOCPART["pascalvocpart"] = {
|
| 1163 |
+
"pascalvocpart": (
|
| 1164 |
+
"VOCdevkit/VOC2010/JPEGImages",
|
| 1165 |
+
"pascal_parts/pascalvocpart_training_instance.json",
|
| 1166 |
+
),
|
| 1167 |
+
"pascalvocpart_train": (
|
| 1168 |
+
"VOCdevkit/VOC2010/JPEGImages",
|
| 1169 |
+
"pascal_parts/pascalvocpart_training_instance.json",
|
| 1170 |
+
),
|
| 1171 |
+
"pascalvocpart_val": (
|
| 1172 |
+
"VOCdevkit/VOC2010/JPEGImages",
|
| 1173 |
+
"pascal_parts/pascalvocpart_validation_instance.json",
|
| 1174 |
+
),
|
| 1175 |
+
}
|
| 1176 |
+
|
| 1177 |
+
|
| 1178 |
+
def _get_builtin_metadata(dataset_name):
|
| 1179 |
+
return _get_pascalvocpart_metadata([])
|
| 1180 |
+
|
| 1181 |
+
raise KeyError("No built-in metadata for dataset {}".format(dataset_name))
|
| 1182 |
+
|
| 1183 |
+
|
| 1184 |
+
def _get_pascalvocpart_metadata(categories):
|
| 1185 |
+
if len(categories) == 0:
|
| 1186 |
+
return {}
|
| 1187 |
+
id_to_name = {x["id"]: x["name"] for x in categories}
|
| 1188 |
+
thing_dataset_id_to_contiguous_id = {i: i for i in range(len(categories))}
|
| 1189 |
+
thing_classes = [id_to_name[k] for k in sorted(id_to_name)]
|
| 1190 |
+
return {
|
| 1191 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 1192 |
+
"thing_classes": thing_classes,
|
| 1193 |
+
}
|
| 1194 |
+
|
| 1195 |
+
|
| 1196 |
+
def register_all_pascalvocpart(root):
|
| 1197 |
+
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_PASCALVOCPART.items():
|
| 1198 |
+
for key, (image_root, json_file) in splits_per_dataset.items():
|
| 1199 |
+
custom_register_coco_instances(
|
| 1200 |
+
key,
|
| 1201 |
+
_get_builtin_metadata(dataset_name),
|
| 1202 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 1203 |
+
os.path.join(root, image_root),
|
| 1204 |
+
)
|
| 1205 |
+
|
| 1206 |
+
|
| 1207 |
+
# register_all_ctx59(os.getenv("DETECTRON2_DATASETS", "datasets"))
|
| 1208 |
+
# register_all_pascal21(os.getenv("DETECTRON2_DATASETS", "datasets"))
|
| 1209 |
+
# register_all_ctx459(os.getenv("DETECTRON2_DATASETS", "datasets"))
|
| 1210 |
+
|
| 1211 |
+
# True for open source;
|
| 1212 |
+
# Internally at fb, we register them elsewhere
|
| 1213 |
+
if __name__.endswith(".pascal_voc_external"):
|
| 1214 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 1215 |
+
_root = os.path.expanduser(os.getenv("DETECTRON2_DATASETS", "datasets"))
|
| 1216 |
+
# register_all_pascal_parts(_root)
|
| 1217 |
+
register_all_pascalvocpart(_root)
|
approach/ovod/APE/ape/data/datasets/phrasecut.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
from .coco import custom_register_coco_instances
|
| 5 |
+
|
| 6 |
+
logger = logging.getLogger(__name__)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _get_builtin_metadata(dataset_name):
|
| 10 |
+
return _get_phrasecut_metadata([])
|
| 11 |
+
|
| 12 |
+
raise KeyError("No built-in metadata for dataset {}".format(dataset_name))
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _get_phrasecut_metadata(categories):
|
| 16 |
+
if len(categories) == 0:
|
| 17 |
+
return {}
|
| 18 |
+
id_to_name = {x["id"]: x["name"] for x in categories}
|
| 19 |
+
thing_dataset_id_to_contiguous_id = {i + 1: i for i in range(len(categories))}
|
| 20 |
+
thing_classes = [id_to_name[k] for k in sorted(id_to_name)]
|
| 21 |
+
return {
|
| 22 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 23 |
+
"thing_classes": thing_classes,
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
_PREDEFINED_SPLITS_PHRASECUT = {}
|
| 28 |
+
_PREDEFINED_SPLITS_PHRASECUT["phrasecut"] = {
|
| 29 |
+
"phrasecut": (
|
| 30 |
+
"phrasecut/images",
|
| 31 |
+
"phrasecut/phrasecut.json",
|
| 32 |
+
),
|
| 33 |
+
"phrasecut_train": (
|
| 34 |
+
"phrasecut/images",
|
| 35 |
+
"phrasecut/phrasecut_train.json",
|
| 36 |
+
),
|
| 37 |
+
"phrasecut_val": (
|
| 38 |
+
"phrasecut/images",
|
| 39 |
+
"phrasecut/phrasecut_val.json",
|
| 40 |
+
),
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def register_all_phrasecut(root):
|
| 45 |
+
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_PHRASECUT.items():
|
| 46 |
+
for key, (image_root, json_file) in splits_per_dataset.items():
|
| 47 |
+
custom_register_coco_instances(
|
| 48 |
+
key,
|
| 49 |
+
_get_builtin_metadata(dataset_name),
|
| 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 |
+
|
| 55 |
+
# True for open source;
|
| 56 |
+
# Internally at fb, we register them elsewhere
|
| 57 |
+
if __name__.endswith(".phrasecut"):
|
| 58 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 59 |
+
_root = os.path.expanduser(os.getenv("DETECTRON2_DATASETS", "datasets"))
|
| 60 |
+
register_all_phrasecut(_root)
|
approach/ovod/APE/ape/data/datasets/refcoco.py
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import io
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
import pycocotools.mask as mask_util
|
| 8 |
+
from PIL import Image
|
| 9 |
+
|
| 10 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 11 |
+
from detectron2.structures import Boxes, BoxMode, PolygonMasks, RotatedBoxes
|
| 12 |
+
from detectron2.utils.file_io import PathManager
|
| 13 |
+
from fvcore.common.timer import Timer
|
| 14 |
+
from iopath.common.file_io import file_lock
|
| 15 |
+
|
| 16 |
+
"""
|
| 17 |
+
This file contains functions to parse COCO-format annotations into dicts in "Detectron2 format".
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
__all__ = ["load_refcoco_json", "convert_to_coco_json", "register_refcoco"]
|
| 24 |
+
|
| 25 |
+
REFCOCO_CATEGORIES = [
|
| 26 |
+
{"color": [220, 20, 60], "isthing": 1, "id": 1, "name": "object"}
|
| 27 |
+
] # only one class for visual grounding
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def _get_refcoco_meta():
|
| 31 |
+
thing_ids = [k["id"] for k in REFCOCO_CATEGORIES if k["isthing"] == 1]
|
| 32 |
+
thing_colors = [k["color"] for k in REFCOCO_CATEGORIES if k["isthing"] == 1]
|
| 33 |
+
assert len(thing_ids) == 1, len(thing_ids)
|
| 34 |
+
|
| 35 |
+
thing_dataset_id_to_contiguous_id = {k: i for i, k in enumerate(thing_ids)}
|
| 36 |
+
thing_classes = [k["name"] for k in REFCOCO_CATEGORIES if k["isthing"] == 1]
|
| 37 |
+
ret = {
|
| 38 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 39 |
+
"thing_classes": thing_classes,
|
| 40 |
+
"thing_colors": thing_colors,
|
| 41 |
+
}
|
| 42 |
+
return ret
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def load_refcoco_json(json_file, image_root, dataset_name=None, extra_annotation_keys=None):
|
| 46 |
+
"""
|
| 47 |
+
Load a json file with COCO's instances annotation format.
|
| 48 |
+
Currently supports instance detection, instance segmentation,
|
| 49 |
+
and person keypoints annotations.
|
| 50 |
+
|
| 51 |
+
Args:
|
| 52 |
+
json_file (str): full path to the json file in COCO instances annotation format.
|
| 53 |
+
image_root (str or path-like): the directory where the images in this json file exists.
|
| 54 |
+
dataset_name (str or None): the name of the dataset (e.g., coco_2017_train).
|
| 55 |
+
When provided, this function will also do the following:
|
| 56 |
+
|
| 57 |
+
* Put "thing_classes" into the metadata associated with this dataset.
|
| 58 |
+
* Map the category ids into a contiguous range (needed by standard dataset format),
|
| 59 |
+
and add "thing_dataset_id_to_contiguous_id" to the metadata associated
|
| 60 |
+
with this dataset.
|
| 61 |
+
|
| 62 |
+
This option should usually be provided, unless users need to load
|
| 63 |
+
the original json content and apply more processing manually.
|
| 64 |
+
extra_annotation_keys (list[str]): list of per-annotation keys that should also be
|
| 65 |
+
loaded into the dataset dict (besides "iscrowd", "bbox", "keypoints",
|
| 66 |
+
"category_id", "segmentation"). The values for these keys will be returned as-is.
|
| 67 |
+
For example, the densepose annotations are loaded in this way.
|
| 68 |
+
|
| 69 |
+
Returns:
|
| 70 |
+
list[dict]: a list of dicts in Detectron2 standard dataset dicts format (See
|
| 71 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ ) when `dataset_name` is not None.
|
| 72 |
+
If `dataset_name` is None, the returned `category_ids` may be
|
| 73 |
+
incontiguous and may not conform to the Detectron2 standard format.
|
| 74 |
+
|
| 75 |
+
Notes:
|
| 76 |
+
1. This function does not read the image files.
|
| 77 |
+
The results do not have the "image" field.
|
| 78 |
+
"""
|
| 79 |
+
from pycocotools.coco import COCO
|
| 80 |
+
|
| 81 |
+
timer = Timer()
|
| 82 |
+
json_file = PathManager.get_local_path(json_file)
|
| 83 |
+
with contextlib.redirect_stdout(io.StringIO()):
|
| 84 |
+
coco_api = COCO(json_file)
|
| 85 |
+
if timer.seconds() > 1:
|
| 86 |
+
logger.info("Loading {} takes {:.2f} seconds.".format(json_file, timer.seconds()))
|
| 87 |
+
|
| 88 |
+
id_map = None
|
| 89 |
+
if dataset_name is not None:
|
| 90 |
+
meta = MetadataCatalog.get(dataset_name)
|
| 91 |
+
cat_ids = sorted(coco_api.getCatIds())
|
| 92 |
+
cats = coco_api.loadCats(cat_ids)
|
| 93 |
+
# The categories in a custom json file may not be sorted.
|
| 94 |
+
thing_classes = [c["name"] for c in sorted(cats, key=lambda x: x["id"])]
|
| 95 |
+
meta.thing_classes = thing_classes
|
| 96 |
+
|
| 97 |
+
# In COCO, certain category ids are artificially removed,
|
| 98 |
+
# and by convention they are always ignored.
|
| 99 |
+
# We deal with COCO's id issue and translate
|
| 100 |
+
# the category ids to contiguous ids in [0, 80).
|
| 101 |
+
|
| 102 |
+
# It works by looking at the "categories" field in the json, therefore
|
| 103 |
+
# if users' own json also have incontiguous ids, we'll
|
| 104 |
+
# apply this mapping as well but print a warning.
|
| 105 |
+
if not (min(cat_ids) == 1 and max(cat_ids) == len(cat_ids)):
|
| 106 |
+
if "coco" not in dataset_name:
|
| 107 |
+
logger.warning(
|
| 108 |
+
"""
|
| 109 |
+
Category ids in annotations are not in [1, #categories]! We'll apply a mapping for you.
|
| 110 |
+
"""
|
| 111 |
+
)
|
| 112 |
+
id_map = {v: i for i, v in enumerate(cat_ids)}
|
| 113 |
+
meta.thing_dataset_id_to_contiguous_id = id_map
|
| 114 |
+
|
| 115 |
+
cat_ids = cat_ids + list(range(max(cat_ids) + 1, 100000))
|
| 116 |
+
id_map = {v: i for i, v in enumerate(cat_ids)}
|
| 117 |
+
|
| 118 |
+
# sort indices for reproducible results
|
| 119 |
+
img_ids = sorted(coco_api.imgs.keys())
|
| 120 |
+
# imgs is a list of dicts, each looks something like:
|
| 121 |
+
# {'license': 4,
|
| 122 |
+
# 'url': 'http://farm6.staticflickr.com/5454/9413846304_881d5e5c3b_z.jpg',
|
| 123 |
+
# 'file_name': 'COCO_val2014_000000001268.jpg',
|
| 124 |
+
# 'height': 427,
|
| 125 |
+
# 'width': 640,
|
| 126 |
+
# 'date_captured': '2013-11-17 05:57:24',
|
| 127 |
+
# 'id': 1268}
|
| 128 |
+
imgs = coco_api.loadImgs(img_ids)
|
| 129 |
+
# anns is a list[list[dict]], where each dict is an annotation
|
| 130 |
+
# record for an object. The inner list enumerates the objects in an image
|
| 131 |
+
# and the outer list enumerates over images. Example of anns[0]:
|
| 132 |
+
# [{'segmentation': [[192.81,
|
| 133 |
+
# 247.09,
|
| 134 |
+
# ...
|
| 135 |
+
# 219.03,
|
| 136 |
+
# 249.06]],
|
| 137 |
+
# 'area': 1035.749,
|
| 138 |
+
# 'iscrowd': 0,
|
| 139 |
+
# 'image_id': 1268,
|
| 140 |
+
# 'bbox': [192.81, 224.8, 74.73, 33.43],
|
| 141 |
+
# 'category_id': 16,
|
| 142 |
+
# 'id': 42986},
|
| 143 |
+
# ...]
|
| 144 |
+
anns = [coco_api.imgToAnns[img_id] for img_id in img_ids]
|
| 145 |
+
total_num_valid_anns = sum([len(x) for x in anns])
|
| 146 |
+
total_num_anns = len(coco_api.anns)
|
| 147 |
+
if total_num_valid_anns < total_num_anns:
|
| 148 |
+
logger.warning(
|
| 149 |
+
f"{json_file} contains {total_num_anns} annotations, but only "
|
| 150 |
+
f"{total_num_valid_anns} of them match to images in the file."
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
if "minival" not in json_file:
|
| 154 |
+
# The popular valminusminival & minival annotations for COCO2014 contain this bug.
|
| 155 |
+
# However the ratio of buggy annotations there is tiny and does not affect accuracy.
|
| 156 |
+
# Therefore we explicitly white-list them.
|
| 157 |
+
ann_ids = [ann["id"] for anns_per_image in anns for ann in anns_per_image]
|
| 158 |
+
assert len(set(ann_ids)) == len(ann_ids), "Annotation ids in '{}' are not unique!".format(
|
| 159 |
+
json_file
|
| 160 |
+
)
|
| 161 |
+
|
| 162 |
+
imgs_anns = list(zip(imgs, anns))
|
| 163 |
+
logger.info("Loaded {} images in COCO format from {}".format(len(imgs_anns), json_file))
|
| 164 |
+
|
| 165 |
+
dataset_dicts = []
|
| 166 |
+
|
| 167 |
+
ann_keys = ["iscrowd", "bbox", "keypoints", "category_id"] + (extra_annotation_keys or [])
|
| 168 |
+
|
| 169 |
+
num_instances_without_valid_segmentation = 0
|
| 170 |
+
|
| 171 |
+
for (img_dict, anno_dict_list) in imgs_anns:
|
| 172 |
+
record = {}
|
| 173 |
+
record["file_name"] = os.path.join(image_root, img_dict["file_name"])
|
| 174 |
+
record["height"] = img_dict["height"]
|
| 175 |
+
record["width"] = img_dict["width"]
|
| 176 |
+
if "expressions" in img_dict:
|
| 177 |
+
record["expressions"] = img_dict["expressions"]
|
| 178 |
+
image_id = record["image_id"] = img_dict["id"]
|
| 179 |
+
|
| 180 |
+
objs = []
|
| 181 |
+
for anno in anno_dict_list:
|
| 182 |
+
# Check that the image_id in this annotation is the same as
|
| 183 |
+
# the image_id we're looking at.
|
| 184 |
+
# This fails only when the data parsing logic or the annotation file is buggy.
|
| 185 |
+
|
| 186 |
+
# The original COCO valminusminival2014 & minival2014 annotation files
|
| 187 |
+
# actually contains bugs that, together with certain ways of using COCO API,
|
| 188 |
+
# can trigger this assertion.
|
| 189 |
+
assert anno["image_id"] == image_id
|
| 190 |
+
|
| 191 |
+
assert anno.get("ignore", 0) == 0, '"ignore" in COCO json file is not supported.'
|
| 192 |
+
|
| 193 |
+
obj = {key: anno[key] for key in ann_keys if key in anno}
|
| 194 |
+
if "bbox" in obj and len(obj["bbox"]) == 0:
|
| 195 |
+
raise ValueError(
|
| 196 |
+
f"One annotation of image {image_id} contains empty 'bbox' value! "
|
| 197 |
+
"This json does not have valid COCO format."
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
segm = anno.get("segmentation", None)
|
| 201 |
+
if segm: # either list[list[float]] or dict(RLE)
|
| 202 |
+
if isinstance(segm, dict):
|
| 203 |
+
if isinstance(segm["counts"], list):
|
| 204 |
+
# convert to compressed RLE
|
| 205 |
+
segm = mask_util.frPyObjects(segm, *segm["size"])
|
| 206 |
+
else:
|
| 207 |
+
# filter out invalid polygons (< 3 points)
|
| 208 |
+
segm = [poly for poly in segm if len(poly) % 2 == 0 and len(poly) >= 6]
|
| 209 |
+
if len(segm) == 0:
|
| 210 |
+
num_instances_without_valid_segmentation += 1
|
| 211 |
+
continue # ignore this instance
|
| 212 |
+
obj["segmentation"] = segm
|
| 213 |
+
|
| 214 |
+
keypts = anno.get("keypoints", None)
|
| 215 |
+
if keypts: # list[int]
|
| 216 |
+
for idx, v in enumerate(keypts):
|
| 217 |
+
if idx % 3 != 2:
|
| 218 |
+
# COCO's segmentation coordinates are floating points in [0, H or W],
|
| 219 |
+
# but keypoint coordinates are integers in [0, H-1 or W-1]
|
| 220 |
+
# Therefore we assume the coordinates are "pixel indices" and
|
| 221 |
+
# add 0.5 to convert to floating point coordinates.
|
| 222 |
+
keypts[idx] = v + 0.5
|
| 223 |
+
obj["keypoints"] = keypts
|
| 224 |
+
|
| 225 |
+
phrase = anno.get("phrase", None)
|
| 226 |
+
if phrase:
|
| 227 |
+
obj["phrase"] = phrase
|
| 228 |
+
obj["bbox_mode"] = BoxMode.XYWH_ABS
|
| 229 |
+
if id_map:
|
| 230 |
+
annotation_category_id = obj["category_id"]
|
| 231 |
+
try:
|
| 232 |
+
obj["category_id"] = id_map[annotation_category_id]
|
| 233 |
+
except KeyError as e:
|
| 234 |
+
raise KeyError(
|
| 235 |
+
f"Encountered category_id={annotation_category_id} "
|
| 236 |
+
"but this id does not exist in 'categories' of the json file."
|
| 237 |
+
) from e
|
| 238 |
+
objs.append(obj)
|
| 239 |
+
record["annotations"] = objs
|
| 240 |
+
record["task"] = "grounding"
|
| 241 |
+
dataset_dicts.append(record)
|
| 242 |
+
|
| 243 |
+
if num_instances_without_valid_segmentation > 0:
|
| 244 |
+
logger.warning(
|
| 245 |
+
"Filtered out {} instances without valid segmentation. ".format(
|
| 246 |
+
num_instances_without_valid_segmentation
|
| 247 |
+
)
|
| 248 |
+
+ "There might be issues in your dataset generation process. Please "
|
| 249 |
+
"check https://detectron2.readthedocs.io/en/latest/tutorials/datasets.html carefully"
|
| 250 |
+
)
|
| 251 |
+
return dataset_dicts
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
def register_refcoco(name, metadata, json_file, image_root):
|
| 255 |
+
"""
|
| 256 |
+
Register a dataset in COCO's json annotation format for
|
| 257 |
+
instance detection, instance segmentation and keypoint detection.
|
| 258 |
+
(i.e., Type 1 and 2 in http://cocodataset.org/#format-data.
|
| 259 |
+
`instances*.json` and `person_keypoints*.json` in the dataset).
|
| 260 |
+
|
| 261 |
+
This is an example of how to register a new dataset.
|
| 262 |
+
You can do something similar to this function, to register new datasets.
|
| 263 |
+
|
| 264 |
+
Args:
|
| 265 |
+
name (str): the name that identifies a dataset, e.g. "coco_2014_train".
|
| 266 |
+
metadata (dict): extra metadata associated with this dataset. You can
|
| 267 |
+
leave it as an empty dict.
|
| 268 |
+
json_file (str): path to the json instance annotation file.
|
| 269 |
+
image_root (str or path-like): directory which contains all the images.
|
| 270 |
+
"""
|
| 271 |
+
assert isinstance(name, str), name
|
| 272 |
+
assert isinstance(json_file, (str, os.PathLike)), json_file
|
| 273 |
+
assert isinstance(image_root, (str, os.PathLike)), image_root
|
| 274 |
+
# 1. register a function which returns dicts
|
| 275 |
+
DatasetCatalog.register(name, lambda: load_refcoco_json(json_file, image_root, name))
|
| 276 |
+
|
| 277 |
+
# 2. Optionally, add metadata about this dataset,
|
| 278 |
+
# since they might be useful in evaluation, visualization or logging
|
| 279 |
+
MetadataCatalog.get(name).set(
|
| 280 |
+
json_file=json_file, image_root=image_root, evaluator_type="refcoco", **metadata
|
| 281 |
+
)
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
# ==== Predefined splits for REFCOCO datasets ===========
|
| 285 |
+
_PREDEFINED_SPLITS_REFCOCO = {
|
| 286 |
+
# refcoco
|
| 287 |
+
"refcoco-unc-train": ("coco/train2014", "SeqTR/refcoco-unc/instances_cocofied_train.json"),
|
| 288 |
+
"refcoco-unc-val": ("coco/train2014", "SeqTR/refcoco-unc/instances_cocofied_val.json"),
|
| 289 |
+
"refcoco-unc-testA": ("coco/train2014", "SeqTR/refcoco-unc/instances_cocofied_testA.json"),
|
| 290 |
+
"refcoco-unc-testB": ("coco/train2014", "SeqTR/refcoco-unc/instances_cocofied_testB.json"),
|
| 291 |
+
# refcocog
|
| 292 |
+
"refcocog-umd-train": ("coco/train2014", "SeqTR/refcocog-umd/instances_cocofied_train.json"),
|
| 293 |
+
"refcocog-umd-val": ("coco/train2014", "SeqTR/refcocog-umd/instances_cocofied_val.json"),
|
| 294 |
+
"refcocog-umd-test": ("coco/train2014", "SeqTR/refcocog-umd/instances_cocofied_test.json"),
|
| 295 |
+
"refcocog-google-val": ("coco/train2014", "SeqTR/refcocog-google/instances_cocofied_val.json"),
|
| 296 |
+
# refcoco+
|
| 297 |
+
"refcocoplus-unc-train": (
|
| 298 |
+
"coco/train2014",
|
| 299 |
+
"SeqTR/refcocoplus-unc/instances_cocofied_train.json",
|
| 300 |
+
),
|
| 301 |
+
"refcocoplus-unc-val": ("coco/train2014", "SeqTR/refcocoplus-unc/instances_cocofied_val.json"),
|
| 302 |
+
"refcocoplus-unc-testA": (
|
| 303 |
+
"coco/train2014",
|
| 304 |
+
"SeqTR/refcocoplus-unc/instances_cocofied_testA.json",
|
| 305 |
+
),
|
| 306 |
+
"refcocoplus-unc-testB": (
|
| 307 |
+
"coco/train2014",
|
| 308 |
+
"SeqTR/refcocoplus-unc/instances_cocofied_testB.json",
|
| 309 |
+
),
|
| 310 |
+
# mixed
|
| 311 |
+
"refcoco-mixed": ("coco/train2014", "SeqTR/refcoco-mixed/instances_cocofied_train.json"),
|
| 312 |
+
"refcoco-mixed-filter": (
|
| 313 |
+
"coco/train2014",
|
| 314 |
+
"SeqTR/refcoco-mixed/instances_cocofied_train_filter.json",
|
| 315 |
+
),
|
| 316 |
+
"refcoco-mixed_group-by-image": (
|
| 317 |
+
"coco/train2014",
|
| 318 |
+
"SeqTR/refcoco-mixed_group-by-image/instances_cocofied_train.json",
|
| 319 |
+
),
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def register_all_refcoco(root):
|
| 324 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_REFCOCO.items():
|
| 325 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 326 |
+
register_refcoco(
|
| 327 |
+
key,
|
| 328 |
+
_get_refcoco_meta(),
|
| 329 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 330 |
+
os.path.join(root, image_root),
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
if __name__.endswith(".refcoco"):
|
| 335 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 336 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 337 |
+
register_all_refcoco(_root)
|
approach/ovod/APE/ape/data/datasets/register_bdd100k_panoseg.py
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --------------------------------------------------------
|
| 2 |
+
# X-Decoder -- Generalized Decoding for Pixel, Image, and Language
|
| 3 |
+
# Copyright (c) 2022 Microsoft
|
| 4 |
+
# Licensed under The MIT License [see LICENSE for details]
|
| 5 |
+
# Modified by Xueyan Zou (xueyan@cs.wisc.edu)
|
| 6 |
+
# --------------------------------------------------------
|
| 7 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 8 |
+
import json
|
| 9 |
+
import os
|
| 10 |
+
from collections import namedtuple
|
| 11 |
+
|
| 12 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 13 |
+
from detectron2.utils.file_io import PathManager
|
| 14 |
+
|
| 15 |
+
Label = namedtuple(
|
| 16 |
+
"Label",
|
| 17 |
+
[
|
| 18 |
+
"name", # The identifier of this label, e.g. 'car', 'person', ... .
|
| 19 |
+
# We use them to uniquely name a class
|
| 20 |
+
"id", # An integer ID that is associated with this label.
|
| 21 |
+
# The IDs are used to represent the label in ground truth images An ID
|
| 22 |
+
# of -1 means that this label does not have an ID and thus is ignored
|
| 23 |
+
# when creating ground truth images (e.g. license plate). Do not modify
|
| 24 |
+
# these IDs, since exactly these IDs are expected by the evaluation
|
| 25 |
+
# server.
|
| 26 |
+
"trainId",
|
| 27 |
+
# Feel free to modify these IDs as suitable for your method. Then
|
| 28 |
+
# create ground truth images with train IDs, using the tools provided
|
| 29 |
+
# in the 'preparation' folder. However, make sure to validate or submit
|
| 30 |
+
# results to our evaluation server using the regular IDs above! For
|
| 31 |
+
# trainIds, multiple labels might have the same ID. Then, these labels
|
| 32 |
+
# are mapped to the same class in the ground truth images. For the
|
| 33 |
+
# inverse mapping, we use the label that is defined first in the list
|
| 34 |
+
# below. For example, mapping all void-type classes to the same ID in
|
| 35 |
+
# training, might make sense for some approaches. Max value is 255!
|
| 36 |
+
"category", # The name of the category that this label belongs to
|
| 37 |
+
"categoryId",
|
| 38 |
+
# The ID of this category. Used to create ground truth images
|
| 39 |
+
# on category level.
|
| 40 |
+
"hasInstances",
|
| 41 |
+
# Whether this label distinguishes between single instances or not
|
| 42 |
+
"ignoreInEval",
|
| 43 |
+
# Whether pixels having this class as ground truth label are ignored
|
| 44 |
+
# during evaluations or not
|
| 45 |
+
"color", # The color of this label
|
| 46 |
+
],
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# Our extended list of label types. Our train id is compatible with Cityscapes
|
| 51 |
+
BDD_CATEGORIES = [
|
| 52 |
+
# name id trainId category catId
|
| 53 |
+
# hasInstances ignoreInEval color
|
| 54 |
+
# Label("unlabeled", 0, 255, "void", 0, False, True, (0, 0, 0)),
|
| 55 |
+
Label("dynamic", 1, 255, "void", 0, False, True, (111, 74, 0)),
|
| 56 |
+
Label("ego vehicle", 2, 255, "void", 0, False, True, (0, 0, 0)),
|
| 57 |
+
Label("ground", 3, 255, "void", 0, False, True, (81, 0, 81)),
|
| 58 |
+
Label("static", 4, 255, "void", 0, False, True, (0, 0, 0)),
|
| 59 |
+
Label("parking", 5, 255, "flat", 1, False, True, (250, 170, 160)),
|
| 60 |
+
Label("rail track", 6, 255, "flat", 1, False, True, (230, 150, 140)),
|
| 61 |
+
Label("road", 7, 0, "flat", 1, False, False, (128, 64, 128)),
|
| 62 |
+
Label("sidewalk", 8, 1, "flat", 1, False, False, (244, 35, 232)),
|
| 63 |
+
Label("bridge", 9, 255, "construction", 2, False, True, (150, 100, 100)),
|
| 64 |
+
Label("building", 10, 2, "construction", 2, False, False, (70, 70, 70)),
|
| 65 |
+
Label("fence", 11, 4, "construction", 2, False, False, (190, 153, 153)),
|
| 66 |
+
Label("garage", 12, 255, "construction", 2, False, True, (180, 100, 180)),
|
| 67 |
+
Label("guard rail", 13, 255, "construction", 2, False, True, (180, 165, 180)),
|
| 68 |
+
Label("tunnel", 14, 255, "construction", 2, False, True, (150, 120, 90)),
|
| 69 |
+
Label("wall", 15, 3, "construction", 2, False, False, (102, 102, 156)),
|
| 70 |
+
Label("banner", 16, 255, "object", 3, False, True, (250, 170, 100)),
|
| 71 |
+
Label("billboard", 17, 255, "object", 3, False, True, (220, 220, 250)),
|
| 72 |
+
Label("lane divider", 18, 255, "object", 3, False, True, (255, 165, 0)),
|
| 73 |
+
Label("parking sign", 19, 255, "object", 3, False, False, (220, 20, 60)),
|
| 74 |
+
Label("pole", 20, 5, "object", 3, False, False, (153, 153, 153)),
|
| 75 |
+
Label("polegroup", 21, 255, "object", 3, False, True, (153, 153, 153)),
|
| 76 |
+
Label("street light", 22, 255, "object", 3, False, True, (220, 220, 100)),
|
| 77 |
+
Label("traffic cone", 23, 255, "object", 3, False, True, (255, 70, 0)),
|
| 78 |
+
Label("traffic device", 24, 255, "object", 3, False, True, (220, 220, 220)),
|
| 79 |
+
Label("traffic light", 25, 6, "object", 3, False, False, (250, 170, 30)),
|
| 80 |
+
Label("traffic sign", 26, 7, "object", 3, False, False, (220, 220, 0)),
|
| 81 |
+
Label(
|
| 82 |
+
"traffic sign frame",
|
| 83 |
+
27,
|
| 84 |
+
255,
|
| 85 |
+
"object",
|
| 86 |
+
3,
|
| 87 |
+
False,
|
| 88 |
+
True,
|
| 89 |
+
(250, 170, 250),
|
| 90 |
+
),
|
| 91 |
+
Label("terrain", 28, 9, "nature", 4, False, False, (152, 251, 152)),
|
| 92 |
+
Label("vegetation", 29, 8, "nature", 4, False, False, (107, 142, 35)),
|
| 93 |
+
Label("sky", 30, 10, "sky", 5, False, False, (70, 130, 180)),
|
| 94 |
+
Label("person", 31, 11, "human", 6, True, False, (220, 20, 60)),
|
| 95 |
+
Label("rider", 32, 12, "human", 6, True, False, (255, 0, 0)),
|
| 96 |
+
Label("bicycle", 33, 18, "vehicle", 7, True, False, (119, 11, 32)),
|
| 97 |
+
Label("bus", 34, 15, "vehicle", 7, True, False, (0, 60, 100)),
|
| 98 |
+
Label("car", 35, 13, "vehicle", 7, True, False, (0, 0, 142)),
|
| 99 |
+
Label("caravan", 36, 255, "vehicle", 7, True, True, (0, 0, 90)),
|
| 100 |
+
Label("motorcycle", 37, 17, "vehicle", 7, True, False, (0, 0, 230)),
|
| 101 |
+
Label("trailer", 38, 255, "vehicle", 7, True, True, (0, 0, 110)),
|
| 102 |
+
Label("train", 39, 16, "vehicle", 7, True, False, (0, 80, 100)),
|
| 103 |
+
Label("truck", 40, 14, "vehicle", 7, True, False, (0, 0, 70)),
|
| 104 |
+
]
|
| 105 |
+
|
| 106 |
+
BDD_COLORS = [k.color for k in BDD_CATEGORIES]
|
| 107 |
+
|
| 108 |
+
MetadataCatalog.get("bdd100k_pano_val").set(
|
| 109 |
+
stuff_colors=BDD_COLORS[:],
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def load_bdd_panoptic_json(json_file, image_dir, gt_dir, meta):
|
| 114 |
+
"""
|
| 115 |
+
Args:
|
| 116 |
+
image_dir (str): path to the raw dataset. e.g., "~/coco/train2017".
|
| 117 |
+
gt_dir (str): path to the raw annotations. e.g., "~/coco/panoptic_train2017".
|
| 118 |
+
json_file (str): path to the json file. e.g., "~/coco/annotations/panoptic_train2017.json".
|
| 119 |
+
Returns:
|
| 120 |
+
list[dict]: a list of dicts in Detectron2 standard format. (See
|
| 121 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ )
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
def _convert_category_id(segment_info, meta):
|
| 125 |
+
if segment_info["category_id"] in meta["thing_dataset_id_to_contiguous_id"]:
|
| 126 |
+
segment_info["category_id"] = meta["thing_dataset_id_to_contiguous_id"][
|
| 127 |
+
segment_info["category_id"]
|
| 128 |
+
]
|
| 129 |
+
segment_info["isthing"] = True
|
| 130 |
+
else:
|
| 131 |
+
segment_info["category_id"] = meta["stuff_dataset_id_to_contiguous_id"][
|
| 132 |
+
segment_info["category_id"]
|
| 133 |
+
]
|
| 134 |
+
segment_info["isthing"] = False
|
| 135 |
+
return segment_info
|
| 136 |
+
|
| 137 |
+
with PathManager.open(json_file) as f:
|
| 138 |
+
json_info = json.load(f)
|
| 139 |
+
|
| 140 |
+
ret = []
|
| 141 |
+
for ann in json_info["annotations"]:
|
| 142 |
+
image_id = ann["image_id"]
|
| 143 |
+
# TODO: currently we assume image and label has the same filename but
|
| 144 |
+
# different extension, and images have extension ".jpg" for COCO. Need
|
| 145 |
+
# to make image extension a user-provided argument if we extend this
|
| 146 |
+
# function to support other COCO-like datasets.
|
| 147 |
+
file_name = ann["file_name"].replace("png", "jpg")
|
| 148 |
+
|
| 149 |
+
image_file = os.path.join(image_dir, file_name)
|
| 150 |
+
label_file = os.path.join(gt_dir, ann["file_name"])
|
| 151 |
+
|
| 152 |
+
segments_info = [_convert_category_id(x, meta) for x in ann["segments_info"]]
|
| 153 |
+
ret.append(
|
| 154 |
+
{
|
| 155 |
+
"file_name": image_file,
|
| 156 |
+
"image_id": image_id,
|
| 157 |
+
"pan_seg_file_name": label_file,
|
| 158 |
+
"segments_info": segments_info,
|
| 159 |
+
}
|
| 160 |
+
)
|
| 161 |
+
assert len(ret), f"No images found in {image_dir}!"
|
| 162 |
+
assert PathManager.isfile(ret[0]["file_name"]), ret[0]["file_name"]
|
| 163 |
+
assert PathManager.isfile(ret[0]["pan_seg_file_name"]), ret[0]["pan_seg_file_name"]
|
| 164 |
+
return ret
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
def register_bdd_panoptic(
|
| 168 |
+
name,
|
| 169 |
+
metadata,
|
| 170 |
+
image_root,
|
| 171 |
+
panoptic_root,
|
| 172 |
+
panoptic_json,
|
| 173 |
+
):
|
| 174 |
+
"""
|
| 175 |
+
Register a "standard" version of ADE20k panoptic segmentation dataset named `name`.
|
| 176 |
+
The dictionaries in this registered dataset follows detectron2's standard format.
|
| 177 |
+
Hence it's called "standard".
|
| 178 |
+
Args:
|
| 179 |
+
name (str): the name that identifies a dataset,
|
| 180 |
+
e.g. "ade20k_panoptic_train"
|
| 181 |
+
metadata (dict): extra metadata associated with this dataset.
|
| 182 |
+
image_root (str): directory which contains all the images
|
| 183 |
+
panoptic_root (str): directory which contains panoptic annotation images in COCO format
|
| 184 |
+
panoptic_json (str): path to the json panoptic annotation file in COCO format
|
| 185 |
+
sem_seg_root (none): not used, to be consistent with
|
| 186 |
+
`register_coco_panoptic_separated`.
|
| 187 |
+
instances_json (str): path to the json instance annotation file
|
| 188 |
+
"""
|
| 189 |
+
panoptic_name = name
|
| 190 |
+
DatasetCatalog.register(
|
| 191 |
+
panoptic_name,
|
| 192 |
+
lambda: load_bdd_panoptic_json(panoptic_json, image_root, panoptic_root, metadata),
|
| 193 |
+
)
|
| 194 |
+
MetadataCatalog.get(panoptic_name).set(
|
| 195 |
+
panoptic_root=panoptic_root,
|
| 196 |
+
image_root=image_root,
|
| 197 |
+
panoptic_json=panoptic_json,
|
| 198 |
+
evaluator_type="bdd_panoptic_pano",
|
| 199 |
+
ignore_label=0,
|
| 200 |
+
label_divisor=1000,
|
| 201 |
+
**metadata,
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
_PREDEFINED_SPLITS_SCANNET_PANOPTIC = {
|
| 206 |
+
"bdd10k_40_panoptic_val": (
|
| 207 |
+
"bdd100k/images/10k/val",
|
| 208 |
+
"bdd100k/labels/pan_seg/coco_pano/val",
|
| 209 |
+
"bdd100k/labels/pan_seg/meta/coco_val.json",
|
| 210 |
+
),
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def get_metadata():
|
| 215 |
+
meta = {}
|
| 216 |
+
# The following metadata maps contiguous id from [0, #thing categories +
|
| 217 |
+
# #stuff categories) to their names and colors. We have to replica of the
|
| 218 |
+
# same name and color under "thing_*" and "stuff_*" because the current
|
| 219 |
+
# visualization function in D2 handles thing and class classes differently
|
| 220 |
+
# due to some heuristic used in Panoptic FPN. We keep the same naming to
|
| 221 |
+
# enable reusing existing visualization functions.
|
| 222 |
+
thing_classes = [k.name for k in BDD_CATEGORIES if k.hasInstances == True]
|
| 223 |
+
thing_colors = [k.color for k in BDD_CATEGORIES if k.hasInstances == True]
|
| 224 |
+
stuff_classes = [k.name for k in BDD_CATEGORIES]
|
| 225 |
+
stuff_colors = [k.color for k in BDD_CATEGORIES]
|
| 226 |
+
|
| 227 |
+
meta["thing_classes"] = thing_classes
|
| 228 |
+
meta["thing_colors"] = thing_colors
|
| 229 |
+
meta["stuff_classes"] = stuff_classes
|
| 230 |
+
meta["stuff_colors"] = stuff_colors
|
| 231 |
+
|
| 232 |
+
# Convert category id for training:
|
| 233 |
+
# category id: like semantic segmentation, it is the class id for each
|
| 234 |
+
# pixel. Since there are some classes not used in evaluation, the category
|
| 235 |
+
# id is not always contiguous and thus we have two set of category ids:
|
| 236 |
+
# - original category id: category id in the original dataset, mainly
|
| 237 |
+
# used for evaluation.
|
| 238 |
+
# - contiguous category id: [0, #classes), in order to train the linear
|
| 239 |
+
# softmax classifier.
|
| 240 |
+
thing_dataset_id_to_contiguous_id = {}
|
| 241 |
+
stuff_dataset_id_to_contiguous_id = {}
|
| 242 |
+
|
| 243 |
+
for i, cat in enumerate(BDD_CATEGORIES):
|
| 244 |
+
if cat.hasInstances:
|
| 245 |
+
thing_dataset_id_to_contiguous_id[cat.id] = i
|
| 246 |
+
# else:
|
| 247 |
+
# stuff_dataset_id_to_contiguous_id[cat["id"]] = i
|
| 248 |
+
|
| 249 |
+
# in order to use sem_seg evaluator
|
| 250 |
+
stuff_dataset_id_to_contiguous_id[cat.id] = i
|
| 251 |
+
|
| 252 |
+
meta["thing_dataset_id_to_contiguous_id"] = thing_dataset_id_to_contiguous_id
|
| 253 |
+
meta["stuff_dataset_id_to_contiguous_id"] = stuff_dataset_id_to_contiguous_id
|
| 254 |
+
return meta
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def register_all_bdd_panoptic(root):
|
| 258 |
+
metadata = get_metadata()
|
| 259 |
+
for (
|
| 260 |
+
prefix,
|
| 261 |
+
(image_root, panoptic_root, panoptic_json),
|
| 262 |
+
) in _PREDEFINED_SPLITS_SCANNET_PANOPTIC.items():
|
| 263 |
+
# The "standard" version of COCO panoptic segmentation dataset,
|
| 264 |
+
# e.g. used by Panoptic-DeepLab
|
| 265 |
+
register_bdd_panoptic(
|
| 266 |
+
prefix,
|
| 267 |
+
metadata,
|
| 268 |
+
os.path.join(root, image_root),
|
| 269 |
+
os.path.join(root, panoptic_root),
|
| 270 |
+
os.path.join(root, panoptic_json),
|
| 271 |
+
)
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
if __name__.endswith(".register_bdd100k_panoseg"):
|
| 275 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 276 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 277 |
+
register_all_bdd_panoptic(_root)
|
approach/ovod/APE/ape/data/datasets/register_bdd100k_semseg.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --------------------------------------------------------
|
| 2 |
+
# X-Decoder -- Generalized Decoding for Pixel, Image, and Language
|
| 3 |
+
# Copyright (c) 2022 Microsoft
|
| 4 |
+
# Licensed under The MIT License [see LICENSE for details]
|
| 5 |
+
# Modified by Xueyan Zou (xueyan@cs.wisc.edu)
|
| 6 |
+
# --------------------------------------------------------
|
| 7 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 8 |
+
import glob
|
| 9 |
+
import os
|
| 10 |
+
from typing import List, Tuple, Union
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
|
| 14 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 15 |
+
from detectron2.utils.file_io import PathManager
|
| 16 |
+
|
| 17 |
+
BDD_SEM = [
|
| 18 |
+
"road",
|
| 19 |
+
"sidewalk",
|
| 20 |
+
"building",
|
| 21 |
+
"wall",
|
| 22 |
+
"fence",
|
| 23 |
+
"pole",
|
| 24 |
+
"traffic light",
|
| 25 |
+
"traffic sign",
|
| 26 |
+
"vegetation",
|
| 27 |
+
"terrain",
|
| 28 |
+
"sky",
|
| 29 |
+
"person",
|
| 30 |
+
"rider",
|
| 31 |
+
"car",
|
| 32 |
+
"truck",
|
| 33 |
+
"bus",
|
| 34 |
+
"train",
|
| 35 |
+
"motorcycle",
|
| 36 |
+
"bicycle",
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
__all__ = ["load_scannet_instances", "register_scannet_context"]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def load_bdd_instances(
|
| 43 |
+
name: str, dirname: str, split: str, class_names: Union[List[str], Tuple[str, ...]]
|
| 44 |
+
):
|
| 45 |
+
"""
|
| 46 |
+
Load BDD annotations to Detectron2 format.
|
| 47 |
+
|
| 48 |
+
Args:
|
| 49 |
+
dirname: Contain "Annotations", "ImageSets", "JPEGImages"
|
| 50 |
+
split (str): one of "train", "test", "val", "trainval"
|
| 51 |
+
class_names: list or tuple of class names
|
| 52 |
+
"""
|
| 53 |
+
img_folder = os.path.join(dirname, "images", "10k", split)
|
| 54 |
+
img_pths = sorted(glob.glob(os.path.join(img_folder, "*.jpg")))
|
| 55 |
+
|
| 56 |
+
sem_folder = os.path.join(dirname, "labels", "sem_seg", "masks", split)
|
| 57 |
+
sem_pths = sorted(glob.glob(os.path.join(sem_folder, "*.png")))
|
| 58 |
+
|
| 59 |
+
assert len(img_pths) == len(sem_pths)
|
| 60 |
+
|
| 61 |
+
dicts = []
|
| 62 |
+
for img_pth, sem_pth in zip(img_pths, sem_pths):
|
| 63 |
+
r = {
|
| 64 |
+
"file_name": img_pth,
|
| 65 |
+
"sem_seg_file_name": sem_pth,
|
| 66 |
+
"image_id": img_pth.split("/")[-1].split(".")[0],
|
| 67 |
+
}
|
| 68 |
+
dicts.append(r)
|
| 69 |
+
return dicts
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def register_bdd_context(name, dirname, split, class_names=BDD_SEM):
|
| 73 |
+
DatasetCatalog.register(name, lambda: load_bdd_instances(name, dirname, split, class_names))
|
| 74 |
+
MetadataCatalog.get(name).set(
|
| 75 |
+
stuff_classes=class_names,
|
| 76 |
+
dirname=dirname,
|
| 77 |
+
split=split,
|
| 78 |
+
ignore_label=[255],
|
| 79 |
+
thing_dataset_id_to_contiguous_id={},
|
| 80 |
+
class_offset=0,
|
| 81 |
+
keep_sem_bgd=False,
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def register_all_bdd_semseg(root):
|
| 86 |
+
SPLITS = [
|
| 87 |
+
("bdd10k_val_sem_seg", "bdd100k", "val"),
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
+
for name, dirname, split in SPLITS:
|
| 91 |
+
register_bdd_context(name, os.path.join(root, dirname), split)
|
| 92 |
+
MetadataCatalog.get(name).evaluator_type = "sem_seg"
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
if __name__.endswith(".register_bdd100k_semseg"):
|
| 96 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 97 |
+
_root = os.getenv("DATASET", "datasets")
|
| 98 |
+
register_all_bdd_semseg(_root)
|
approach/ovod/APE/ape/data/datasets/register_pascal_context.py
ADDED
|
@@ -0,0 +1,587 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
PASCALCONTEX59_NAMES = (
|
| 8 |
+
"aeroplane",
|
| 9 |
+
"bicycle",
|
| 10 |
+
"bird",
|
| 11 |
+
"boat",
|
| 12 |
+
"bottle",
|
| 13 |
+
"bus",
|
| 14 |
+
"car",
|
| 15 |
+
"cat",
|
| 16 |
+
"chair",
|
| 17 |
+
"cow",
|
| 18 |
+
"table",
|
| 19 |
+
"dog",
|
| 20 |
+
"horse",
|
| 21 |
+
"motorbike",
|
| 22 |
+
"person",
|
| 23 |
+
"pottedplant",
|
| 24 |
+
"sheep",
|
| 25 |
+
"sofa",
|
| 26 |
+
"train",
|
| 27 |
+
"tvmonitor",
|
| 28 |
+
"bag",
|
| 29 |
+
"bed",
|
| 30 |
+
"bench",
|
| 31 |
+
"book",
|
| 32 |
+
"building",
|
| 33 |
+
"cabinet",
|
| 34 |
+
"ceiling",
|
| 35 |
+
"cloth",
|
| 36 |
+
"computer",
|
| 37 |
+
"cup",
|
| 38 |
+
"door",
|
| 39 |
+
"fence",
|
| 40 |
+
"floor",
|
| 41 |
+
"flower",
|
| 42 |
+
"food",
|
| 43 |
+
"grass",
|
| 44 |
+
"ground",
|
| 45 |
+
"keyboard",
|
| 46 |
+
"light",
|
| 47 |
+
"mountain",
|
| 48 |
+
"mouse",
|
| 49 |
+
"curtain",
|
| 50 |
+
"platform",
|
| 51 |
+
"sign",
|
| 52 |
+
"plate",
|
| 53 |
+
"road",
|
| 54 |
+
"rock",
|
| 55 |
+
"shelves",
|
| 56 |
+
"sidewalk",
|
| 57 |
+
"sky",
|
| 58 |
+
"snow",
|
| 59 |
+
"bedclothes",
|
| 60 |
+
"track",
|
| 61 |
+
"tree",
|
| 62 |
+
"truck",
|
| 63 |
+
"wall",
|
| 64 |
+
"water",
|
| 65 |
+
"window",
|
| 66 |
+
"wood",
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
PASCALCONTEX459_NAMES = (
|
| 70 |
+
"accordion",
|
| 71 |
+
"aeroplane",
|
| 72 |
+
"air conditioner",
|
| 73 |
+
"antenna",
|
| 74 |
+
"artillery",
|
| 75 |
+
"ashtray",
|
| 76 |
+
"atrium",
|
| 77 |
+
"baby carriage",
|
| 78 |
+
"bag",
|
| 79 |
+
"ball",
|
| 80 |
+
"balloon",
|
| 81 |
+
"bamboo weaving",
|
| 82 |
+
"barrel",
|
| 83 |
+
"baseball bat",
|
| 84 |
+
"basket",
|
| 85 |
+
"basketball backboard",
|
| 86 |
+
"bathtub",
|
| 87 |
+
"bed",
|
| 88 |
+
"bedclothes",
|
| 89 |
+
"beer",
|
| 90 |
+
"bell",
|
| 91 |
+
"bench",
|
| 92 |
+
"bicycle",
|
| 93 |
+
"binoculars",
|
| 94 |
+
"bird",
|
| 95 |
+
"bird cage",
|
| 96 |
+
"bird feeder",
|
| 97 |
+
"bird nest",
|
| 98 |
+
"blackboard",
|
| 99 |
+
"board",
|
| 100 |
+
"boat",
|
| 101 |
+
"bone",
|
| 102 |
+
"book",
|
| 103 |
+
"bottle",
|
| 104 |
+
"bottle opener",
|
| 105 |
+
"bowl",
|
| 106 |
+
"box",
|
| 107 |
+
"bracelet",
|
| 108 |
+
"brick",
|
| 109 |
+
"bridge",
|
| 110 |
+
"broom",
|
| 111 |
+
"brush",
|
| 112 |
+
"bucket",
|
| 113 |
+
"building",
|
| 114 |
+
"bus",
|
| 115 |
+
"cabinet",
|
| 116 |
+
"cabinet door",
|
| 117 |
+
"cage",
|
| 118 |
+
"cake",
|
| 119 |
+
"calculator",
|
| 120 |
+
"calendar",
|
| 121 |
+
"camel",
|
| 122 |
+
"camera",
|
| 123 |
+
"camera lens",
|
| 124 |
+
"can",
|
| 125 |
+
"candle",
|
| 126 |
+
"candle holder",
|
| 127 |
+
"cap",
|
| 128 |
+
"car",
|
| 129 |
+
"card",
|
| 130 |
+
"cart",
|
| 131 |
+
"case",
|
| 132 |
+
"casette recorder",
|
| 133 |
+
"cash register",
|
| 134 |
+
"cat",
|
| 135 |
+
"cd",
|
| 136 |
+
"cd player",
|
| 137 |
+
"ceiling",
|
| 138 |
+
"cell phone",
|
| 139 |
+
"cello",
|
| 140 |
+
"chain",
|
| 141 |
+
"chair",
|
| 142 |
+
"chessboard",
|
| 143 |
+
"chicken",
|
| 144 |
+
"chopstick",
|
| 145 |
+
"clip",
|
| 146 |
+
"clippers",
|
| 147 |
+
"clock",
|
| 148 |
+
"closet",
|
| 149 |
+
"cloth",
|
| 150 |
+
"clothes tree",
|
| 151 |
+
"coffee",
|
| 152 |
+
"coffee machine",
|
| 153 |
+
"comb",
|
| 154 |
+
"computer",
|
| 155 |
+
"concrete",
|
| 156 |
+
"cone",
|
| 157 |
+
"container",
|
| 158 |
+
"control booth",
|
| 159 |
+
"controller",
|
| 160 |
+
"cooker",
|
| 161 |
+
"copying machine",
|
| 162 |
+
"coral",
|
| 163 |
+
"cork",
|
| 164 |
+
"corkscrew",
|
| 165 |
+
"counter",
|
| 166 |
+
"court",
|
| 167 |
+
"cow",
|
| 168 |
+
"crabstick",
|
| 169 |
+
"crane",
|
| 170 |
+
"crate",
|
| 171 |
+
"cross",
|
| 172 |
+
"crutch",
|
| 173 |
+
"cup",
|
| 174 |
+
"curtain",
|
| 175 |
+
"cushion",
|
| 176 |
+
"cutting board",
|
| 177 |
+
"dais",
|
| 178 |
+
"disc",
|
| 179 |
+
"disc case",
|
| 180 |
+
"dishwasher",
|
| 181 |
+
"dock",
|
| 182 |
+
"dog",
|
| 183 |
+
"dolphin",
|
| 184 |
+
"door",
|
| 185 |
+
"drainer",
|
| 186 |
+
"dray",
|
| 187 |
+
"drink dispenser",
|
| 188 |
+
"drinking machine",
|
| 189 |
+
"drop",
|
| 190 |
+
"drug",
|
| 191 |
+
"drum",
|
| 192 |
+
"drum kit",
|
| 193 |
+
"duck",
|
| 194 |
+
"dumbbell",
|
| 195 |
+
"earphone",
|
| 196 |
+
"earrings",
|
| 197 |
+
"egg",
|
| 198 |
+
"electric fan",
|
| 199 |
+
"electric iron",
|
| 200 |
+
"electric pot",
|
| 201 |
+
"electric saw",
|
| 202 |
+
"electronic keyboard",
|
| 203 |
+
"engine",
|
| 204 |
+
"envelope",
|
| 205 |
+
"equipment",
|
| 206 |
+
"escalator",
|
| 207 |
+
"exhibition booth",
|
| 208 |
+
"extinguisher",
|
| 209 |
+
"eyeglass",
|
| 210 |
+
"fan",
|
| 211 |
+
"faucet",
|
| 212 |
+
"fax machine",
|
| 213 |
+
"fence",
|
| 214 |
+
"ferris wheel",
|
| 215 |
+
"fire extinguisher",
|
| 216 |
+
"fire hydrant",
|
| 217 |
+
"fire place",
|
| 218 |
+
"fish",
|
| 219 |
+
"fish tank",
|
| 220 |
+
"fishbowl",
|
| 221 |
+
"fishing net",
|
| 222 |
+
"fishing pole",
|
| 223 |
+
"flag",
|
| 224 |
+
"flagstaff",
|
| 225 |
+
"flame",
|
| 226 |
+
"flashlight",
|
| 227 |
+
"floor",
|
| 228 |
+
"flower",
|
| 229 |
+
"fly",
|
| 230 |
+
"foam",
|
| 231 |
+
"food",
|
| 232 |
+
"footbridge",
|
| 233 |
+
"forceps",
|
| 234 |
+
"fork",
|
| 235 |
+
"forklift",
|
| 236 |
+
"fountain",
|
| 237 |
+
"fox",
|
| 238 |
+
"frame",
|
| 239 |
+
"fridge",
|
| 240 |
+
"frog",
|
| 241 |
+
"fruit",
|
| 242 |
+
"funnel",
|
| 243 |
+
"furnace",
|
| 244 |
+
"game controller",
|
| 245 |
+
"game machine",
|
| 246 |
+
"gas cylinder",
|
| 247 |
+
"gas hood",
|
| 248 |
+
"gas stove",
|
| 249 |
+
"gift box",
|
| 250 |
+
"glass",
|
| 251 |
+
"glass marble",
|
| 252 |
+
"globe",
|
| 253 |
+
"glove",
|
| 254 |
+
"goal",
|
| 255 |
+
"grandstand",
|
| 256 |
+
"grass",
|
| 257 |
+
"gravestone",
|
| 258 |
+
"ground",
|
| 259 |
+
"guardrail",
|
| 260 |
+
"guitar",
|
| 261 |
+
"gun",
|
| 262 |
+
"hammer",
|
| 263 |
+
"hand cart",
|
| 264 |
+
"handle",
|
| 265 |
+
"handrail",
|
| 266 |
+
"hanger",
|
| 267 |
+
"hard disk drive",
|
| 268 |
+
"hat",
|
| 269 |
+
"hay",
|
| 270 |
+
"headphone",
|
| 271 |
+
"heater",
|
| 272 |
+
"helicopter",
|
| 273 |
+
"helmet",
|
| 274 |
+
"holder",
|
| 275 |
+
"hook",
|
| 276 |
+
"horse",
|
| 277 |
+
"horse-drawn carriage",
|
| 278 |
+
"hot-air balloon",
|
| 279 |
+
"hydrovalve",
|
| 280 |
+
"ice",
|
| 281 |
+
"inflator pump",
|
| 282 |
+
"ipod",
|
| 283 |
+
"iron",
|
| 284 |
+
"ironing board",
|
| 285 |
+
"jar",
|
| 286 |
+
"kart",
|
| 287 |
+
"kettle",
|
| 288 |
+
"key",
|
| 289 |
+
"keyboard",
|
| 290 |
+
"kitchen range",
|
| 291 |
+
"kite",
|
| 292 |
+
"knife",
|
| 293 |
+
"knife block",
|
| 294 |
+
"ladder",
|
| 295 |
+
"ladder truck",
|
| 296 |
+
"ladle",
|
| 297 |
+
"laptop",
|
| 298 |
+
"leaves",
|
| 299 |
+
"lid",
|
| 300 |
+
"life buoy",
|
| 301 |
+
"light",
|
| 302 |
+
"light bulb",
|
| 303 |
+
"lighter",
|
| 304 |
+
"line",
|
| 305 |
+
"lion",
|
| 306 |
+
"lobster",
|
| 307 |
+
"lock",
|
| 308 |
+
"machine",
|
| 309 |
+
"mailbox",
|
| 310 |
+
"mannequin",
|
| 311 |
+
"map",
|
| 312 |
+
"mask",
|
| 313 |
+
"mat",
|
| 314 |
+
"match book",
|
| 315 |
+
"mattress",
|
| 316 |
+
"menu",
|
| 317 |
+
"metal",
|
| 318 |
+
"meter box",
|
| 319 |
+
"microphone",
|
| 320 |
+
"microwave",
|
| 321 |
+
"mirror",
|
| 322 |
+
"missile",
|
| 323 |
+
"model",
|
| 324 |
+
"money",
|
| 325 |
+
"monkey",
|
| 326 |
+
"mop",
|
| 327 |
+
"motorbike",
|
| 328 |
+
"mountain",
|
| 329 |
+
"mouse",
|
| 330 |
+
"mouse pad",
|
| 331 |
+
"musical instrument",
|
| 332 |
+
"napkin",
|
| 333 |
+
"net",
|
| 334 |
+
"newspaper",
|
| 335 |
+
"oar",
|
| 336 |
+
"ornament",
|
| 337 |
+
"outlet",
|
| 338 |
+
"oven",
|
| 339 |
+
"oxygen bottle",
|
| 340 |
+
"pack",
|
| 341 |
+
"pan",
|
| 342 |
+
"paper",
|
| 343 |
+
"paper box",
|
| 344 |
+
"paper cutter",
|
| 345 |
+
"parachute",
|
| 346 |
+
"parasol",
|
| 347 |
+
"parterre",
|
| 348 |
+
"patio",
|
| 349 |
+
"pelage",
|
| 350 |
+
"pen",
|
| 351 |
+
"pen container",
|
| 352 |
+
"pencil",
|
| 353 |
+
"person",
|
| 354 |
+
"photo",
|
| 355 |
+
"piano",
|
| 356 |
+
"picture",
|
| 357 |
+
"pig",
|
| 358 |
+
"pillar",
|
| 359 |
+
"pillow",
|
| 360 |
+
"pipe",
|
| 361 |
+
"pitcher",
|
| 362 |
+
"plant",
|
| 363 |
+
"plastic",
|
| 364 |
+
"plate",
|
| 365 |
+
"platform",
|
| 366 |
+
"player",
|
| 367 |
+
"playground",
|
| 368 |
+
"pliers",
|
| 369 |
+
"plume",
|
| 370 |
+
"poker",
|
| 371 |
+
"poker chip",
|
| 372 |
+
"pole",
|
| 373 |
+
"pool table",
|
| 374 |
+
"postcard",
|
| 375 |
+
"poster",
|
| 376 |
+
"pot",
|
| 377 |
+
"pottedplant",
|
| 378 |
+
"printer",
|
| 379 |
+
"projector",
|
| 380 |
+
"pumpkin",
|
| 381 |
+
"rabbit",
|
| 382 |
+
"racket",
|
| 383 |
+
"radiator",
|
| 384 |
+
"radio",
|
| 385 |
+
"rail",
|
| 386 |
+
"rake",
|
| 387 |
+
"ramp",
|
| 388 |
+
"range hood",
|
| 389 |
+
"receiver",
|
| 390 |
+
"recorder",
|
| 391 |
+
"recreational machines",
|
| 392 |
+
"remote control",
|
| 393 |
+
"road",
|
| 394 |
+
"robot",
|
| 395 |
+
"rock",
|
| 396 |
+
"rocket",
|
| 397 |
+
"rocking horse",
|
| 398 |
+
"rope",
|
| 399 |
+
"rug",
|
| 400 |
+
"ruler",
|
| 401 |
+
"runway",
|
| 402 |
+
"saddle",
|
| 403 |
+
"sand",
|
| 404 |
+
"saw",
|
| 405 |
+
"scale",
|
| 406 |
+
"scanner",
|
| 407 |
+
"scissors",
|
| 408 |
+
"scoop",
|
| 409 |
+
"screen",
|
| 410 |
+
"screwdriver",
|
| 411 |
+
"sculpture",
|
| 412 |
+
"scythe",
|
| 413 |
+
"sewer",
|
| 414 |
+
"sewing machine",
|
| 415 |
+
"shed",
|
| 416 |
+
"sheep",
|
| 417 |
+
"shell",
|
| 418 |
+
"shelves",
|
| 419 |
+
"shoe",
|
| 420 |
+
"shopping cart",
|
| 421 |
+
"shovel",
|
| 422 |
+
"sidecar",
|
| 423 |
+
"sidewalk",
|
| 424 |
+
"sign",
|
| 425 |
+
"signal light",
|
| 426 |
+
"sink",
|
| 427 |
+
"skateboard",
|
| 428 |
+
"ski",
|
| 429 |
+
"sky",
|
| 430 |
+
"sled",
|
| 431 |
+
"slippers",
|
| 432 |
+
"smoke",
|
| 433 |
+
"snail",
|
| 434 |
+
"snake",
|
| 435 |
+
"snow",
|
| 436 |
+
"snowmobiles",
|
| 437 |
+
"sofa",
|
| 438 |
+
"spanner",
|
| 439 |
+
"spatula",
|
| 440 |
+
"speaker",
|
| 441 |
+
"speed bump",
|
| 442 |
+
"spice container",
|
| 443 |
+
"spoon",
|
| 444 |
+
"sprayer",
|
| 445 |
+
"squirrel",
|
| 446 |
+
"stage",
|
| 447 |
+
"stair",
|
| 448 |
+
"stapler",
|
| 449 |
+
"stick",
|
| 450 |
+
"sticky note",
|
| 451 |
+
"stone",
|
| 452 |
+
"stool",
|
| 453 |
+
"stove",
|
| 454 |
+
"straw",
|
| 455 |
+
"stretcher",
|
| 456 |
+
"sun",
|
| 457 |
+
"sunglass",
|
| 458 |
+
"sunshade",
|
| 459 |
+
"surveillance camera",
|
| 460 |
+
"swan",
|
| 461 |
+
"sweeper",
|
| 462 |
+
"swim ring",
|
| 463 |
+
"swimming pool",
|
| 464 |
+
"swing",
|
| 465 |
+
"switch",
|
| 466 |
+
"table",
|
| 467 |
+
"tableware",
|
| 468 |
+
"tank",
|
| 469 |
+
"tap",
|
| 470 |
+
"tape",
|
| 471 |
+
"tarp",
|
| 472 |
+
"telephone",
|
| 473 |
+
"telephone booth",
|
| 474 |
+
"tent",
|
| 475 |
+
"tire",
|
| 476 |
+
"toaster",
|
| 477 |
+
"toilet",
|
| 478 |
+
"tong",
|
| 479 |
+
"tool",
|
| 480 |
+
"toothbrush",
|
| 481 |
+
"towel",
|
| 482 |
+
"toy",
|
| 483 |
+
"toy car",
|
| 484 |
+
"track",
|
| 485 |
+
"train",
|
| 486 |
+
"trampoline",
|
| 487 |
+
"trash bin",
|
| 488 |
+
"tray",
|
| 489 |
+
"tree",
|
| 490 |
+
"tricycle",
|
| 491 |
+
"tripod",
|
| 492 |
+
"trophy",
|
| 493 |
+
"truck",
|
| 494 |
+
"tube",
|
| 495 |
+
"turtle",
|
| 496 |
+
"tvmonitor",
|
| 497 |
+
"tweezers",
|
| 498 |
+
"typewriter",
|
| 499 |
+
"umbrella",
|
| 500 |
+
"unknown",
|
| 501 |
+
"vacuum cleaner",
|
| 502 |
+
"vending machine",
|
| 503 |
+
"video camera",
|
| 504 |
+
"video game console",
|
| 505 |
+
"video player",
|
| 506 |
+
"video tape",
|
| 507 |
+
"violin",
|
| 508 |
+
"wakeboard",
|
| 509 |
+
"wall",
|
| 510 |
+
"wallet",
|
| 511 |
+
"wardrobe",
|
| 512 |
+
"washing machine",
|
| 513 |
+
"watch",
|
| 514 |
+
"water",
|
| 515 |
+
"water dispenser",
|
| 516 |
+
"water pipe",
|
| 517 |
+
"water skate board",
|
| 518 |
+
"watermelon",
|
| 519 |
+
"whale",
|
| 520 |
+
"wharf",
|
| 521 |
+
"wheel",
|
| 522 |
+
"wheelchair",
|
| 523 |
+
"window",
|
| 524 |
+
"window blinds",
|
| 525 |
+
"wineglass",
|
| 526 |
+
"wire",
|
| 527 |
+
"wood",
|
| 528 |
+
"wool",
|
| 529 |
+
)
|
| 530 |
+
|
| 531 |
+
|
| 532 |
+
def _get_voc_meta(cat_list):
|
| 533 |
+
ret = {
|
| 534 |
+
"stuff_classes": cat_list,
|
| 535 |
+
}
|
| 536 |
+
return ret
|
| 537 |
+
|
| 538 |
+
|
| 539 |
+
def register_pascal_context_59(root):
|
| 540 |
+
root = os.path.join(root, "VOCdevkit/VOC2010")
|
| 541 |
+
meta = _get_voc_meta(PASCALCONTEX59_NAMES)
|
| 542 |
+
for name, image_dirname, sem_seg_dirname in [
|
| 543 |
+
("val", "JPEGImages", "annotations_detectron2/pc59_val"),
|
| 544 |
+
]:
|
| 545 |
+
image_dir = os.path.join(root, image_dirname)
|
| 546 |
+
gt_dir = os.path.join(root, sem_seg_dirname)
|
| 547 |
+
all_name = f"pascal_context_59_sem_seg_{name}"
|
| 548 |
+
DatasetCatalog.register(
|
| 549 |
+
all_name,
|
| 550 |
+
lambda x=image_dir, y=gt_dir: load_sem_seg(y, x, gt_ext="png", image_ext="jpg"),
|
| 551 |
+
)
|
| 552 |
+
MetadataCatalog.get(all_name).set(
|
| 553 |
+
image_root=image_dir,
|
| 554 |
+
sem_seg_root=gt_dir,
|
| 555 |
+
evaluator_type="sem_seg",
|
| 556 |
+
ignore_label=255,
|
| 557 |
+
**meta,
|
| 558 |
+
)
|
| 559 |
+
|
| 560 |
+
|
| 561 |
+
def register_pascal_context_459(root):
|
| 562 |
+
root = os.path.join(root, "VOCdevkit/VOC2010")
|
| 563 |
+
meta = _get_voc_meta(PASCALCONTEX459_NAMES)
|
| 564 |
+
for name, image_dirname, sem_seg_dirname in [
|
| 565 |
+
("val", "JPEGImages", "annotations_detectron2/pc459_val"),
|
| 566 |
+
]:
|
| 567 |
+
image_dir = os.path.join(root, image_dirname)
|
| 568 |
+
gt_dir = os.path.join(root, sem_seg_dirname)
|
| 569 |
+
all_name = f"pascal_context_459_sem_seg_{name}"
|
| 570 |
+
DatasetCatalog.register(
|
| 571 |
+
all_name,
|
| 572 |
+
lambda x=image_dir, y=gt_dir: load_sem_seg(y, x, gt_ext="tif", image_ext="jpg"),
|
| 573 |
+
)
|
| 574 |
+
MetadataCatalog.get(all_name).set(
|
| 575 |
+
image_root=image_dir,
|
| 576 |
+
sem_seg_root=gt_dir,
|
| 577 |
+
evaluator_type="sem_seg",
|
| 578 |
+
ignore_label=65535, # NOTE: gt is saved in 16-bit TIFF images
|
| 579 |
+
**meta,
|
| 580 |
+
)
|
| 581 |
+
|
| 582 |
+
|
| 583 |
+
if __name__.endswith(".register_pascal_context"):
|
| 584 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 585 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 586 |
+
register_pascal_context_59(_root)
|
| 587 |
+
register_pascal_context_459(_root)
|
approach/ovod/APE/ape/data/datasets/register_voc_seg.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
PASCALVOC20_NAMES = (
|
| 8 |
+
"aeroplane",
|
| 9 |
+
"bicycle",
|
| 10 |
+
"bird",
|
| 11 |
+
"boat",
|
| 12 |
+
"bottle",
|
| 13 |
+
"bus",
|
| 14 |
+
"car",
|
| 15 |
+
"cat",
|
| 16 |
+
"chair",
|
| 17 |
+
"cow",
|
| 18 |
+
"diningtable",
|
| 19 |
+
"dog",
|
| 20 |
+
"horse",
|
| 21 |
+
"motorbike",
|
| 22 |
+
"person",
|
| 23 |
+
"pottedplant",
|
| 24 |
+
"sheep",
|
| 25 |
+
"sofa",
|
| 26 |
+
"train",
|
| 27 |
+
"tvmonitor",
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _get_voc_meta(cat_list):
|
| 32 |
+
ret = {
|
| 33 |
+
"stuff_classes": cat_list,
|
| 34 |
+
}
|
| 35 |
+
return ret
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def register_pascalvoc(root):
|
| 39 |
+
root = os.path.join(root, "VOCdevkit/VOC2012")
|
| 40 |
+
meta = _get_voc_meta(PASCALVOC20_NAMES)
|
| 41 |
+
|
| 42 |
+
for name, image_dirname, sem_seg_dirname in [
|
| 43 |
+
("val", "JPEGImages", "annotations_detectron2/val"),
|
| 44 |
+
]:
|
| 45 |
+
image_dir = os.path.join(root, image_dirname)
|
| 46 |
+
gt_dir = os.path.join(root, sem_seg_dirname)
|
| 47 |
+
all_name = f"pascalvoc20_sem_seg_{name}"
|
| 48 |
+
DatasetCatalog.register(
|
| 49 |
+
all_name,
|
| 50 |
+
lambda x=image_dir, y=gt_dir: load_sem_seg(y, x, gt_ext="png", image_ext="jpg"),
|
| 51 |
+
)
|
| 52 |
+
MetadataCatalog.get(all_name).set(
|
| 53 |
+
image_root=image_dir,
|
| 54 |
+
sem_seg_root=gt_dir,
|
| 55 |
+
evaluator_type="sem_seg",
|
| 56 |
+
ignore_label=255,
|
| 57 |
+
**meta,
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
if __name__.endswith(".register_voc_seg"):
|
| 62 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 63 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 64 |
+
register_pascalvoc(_root)
|
approach/ovod/APE/ape/data/datasets/sa1b.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from detectron2.data.datasets.register_coco import register_coco_instances
|
| 4 |
+
|
| 5 |
+
SA1B_CATEGORIES = [
|
| 6 |
+
{"id": 1, "name": "object"},
|
| 7 |
+
]
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _get_builtin_metadata(key):
|
| 11 |
+
id_to_name = {x["id"]: x["name"] for x in SA1B_CATEGORIES}
|
| 12 |
+
thing_dataset_id_to_contiguous_id = {i + 1: i for i in range(len(SA1B_CATEGORIES))}
|
| 13 |
+
thing_classes = [id_to_name[k] for k in sorted(id_to_name)]
|
| 14 |
+
return {
|
| 15 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 16 |
+
"thing_classes": thing_classes,
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
_PREDEFINED_SPLITS_SA1B = {
|
| 21 |
+
"sa1b": ("SA-1B/images", "SA-1B/sam1b_instance.json"),
|
| 22 |
+
"sa1b_1m": ("SA-1B/images", "SA-1B/sam1b_instance_1000000.json"),
|
| 23 |
+
"sa1b_2m": ("SA-1B/images", "SA-1B/sam1b_instance_2000000.json"),
|
| 24 |
+
"sa1b_4m": ("SA-1B/images", "SA-1B/sam1b_instance_4000000.json"),
|
| 25 |
+
"sa1b_6m": ("SA-1B/images", "SA-1B/sam1b_instance_6000000.json"),
|
| 26 |
+
"sa1b_8m": ("SA-1B/images", "SA-1B/sam1b_instance_8000000.json"),
|
| 27 |
+
"sa1b_10m": ("SA-1B/images", "SA-1B/sam1b_instance_10000000.json"),
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def register_all_sa1b(root):
|
| 32 |
+
for key, (image_root, json_file) in _PREDEFINED_SPLITS_SA1B.items():
|
| 33 |
+
register_coco_instances(
|
| 34 |
+
key,
|
| 35 |
+
_get_builtin_metadata(key),
|
| 36 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 37 |
+
os.path.join(root, image_root),
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__.endswith(".sa1b"):
|
| 42 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 43 |
+
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
|
| 44 |
+
register_all_sa1b(_root)
|
approach/ovod/APE/ape/data/datasets/seginw_categories.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
SEGINW_CATEGORIES = {
|
| 2 |
+
"seginw_Helmet-Head": ["Helmet"],
|
| 3 |
+
"seginw_Line-Contour": ["line-structure"],
|
| 4 |
+
"seginw_Elephants": ["elephant"],
|
| 5 |
+
"seginw_Hand-Metal": ["hand", "metal"],
|
| 6 |
+
"seginw_Watermelon": ["watermelon"],
|
| 7 |
+
"seginw_House-Parts": [
|
| 8 |
+
"aluminium door",
|
| 9 |
+
"aluminium window",
|
| 10 |
+
"cellar window",
|
| 11 |
+
"mint cond roof",
|
| 12 |
+
"plaster",
|
| 13 |
+
"plastic door",
|
| 14 |
+
"plastic window",
|
| 15 |
+
"plate fascade",
|
| 16 |
+
"wooden door",
|
| 17 |
+
"wooden fascade",
|
| 18 |
+
"wooden window",
|
| 19 |
+
"worn cond roof",
|
| 20 |
+
],
|
| 21 |
+
"seginw_HouseHold-Items": ["bottle", "mouse", "perfume", "phone"],
|
| 22 |
+
"seginw_Strawberry": ["R_strawberry", "people"],
|
| 23 |
+
"seginw_WareHouse-Box": ["box", "dmg box", "label"],
|
| 24 |
+
"seginw_Fruits": ["apple", "lemon", "orange", "pear", "strawberry"],
|
| 25 |
+
"seginw_Nutterfly-Squireel": ["butterfly", "squirrel"],
|
| 26 |
+
"seginw_Hand": ["Hand-Segmentation", "hand"],
|
| 27 |
+
"seginw_Garbage": ["bin", "garbage", "pavement", "road"],
|
| 28 |
+
"seginw_Chicken": ["chicken"],
|
| 29 |
+
"seginw_Rail": ["rail"],
|
| 30 |
+
"seginw_Airplane-Parts": ["Airplane", "Body", "Cockpit", "Engine", "Wing"],
|
| 31 |
+
"seginw_Face-Mask": ["Mask"],
|
| 32 |
+
"seginw_Brain-Tumor": ["tumor"],
|
| 33 |
+
"seginw_Poles": ["poles"],
|
| 34 |
+
"seginw_Car-Parts": [
|
| 35 |
+
"back_bumper",
|
| 36 |
+
"back_door",
|
| 37 |
+
"back_glass",
|
| 38 |
+
"back_light",
|
| 39 |
+
"front_bumper",
|
| 40 |
+
"front_door",
|
| 41 |
+
"front_glass",
|
| 42 |
+
"front_light",
|
| 43 |
+
"hood",
|
| 44 |
+
],
|
| 45 |
+
"seginw_Electric-Shaver": ["caorau"],
|
| 46 |
+
"seginw_Bottles": ["bottle", "can", "label"],
|
| 47 |
+
"seginw_Toolkits": [
|
| 48 |
+
"Allen-key",
|
| 49 |
+
"block",
|
| 50 |
+
"gasket",
|
| 51 |
+
"plier",
|
| 52 |
+
"prism",
|
| 53 |
+
"screw",
|
| 54 |
+
"screwdriver",
|
| 55 |
+
"wrench",
|
| 56 |
+
],
|
| 57 |
+
"seginw_Trash": [
|
| 58 |
+
"Aluminium foil",
|
| 59 |
+
"Cigarette",
|
| 60 |
+
"Clear plastic bottle",
|
| 61 |
+
"Corrugated carton",
|
| 62 |
+
"Disposable plastic cup",
|
| 63 |
+
"Drink Can",
|
| 64 |
+
"Egg Carton",
|
| 65 |
+
"Foam cup",
|
| 66 |
+
"Food Can",
|
| 67 |
+
"Garbage bag",
|
| 68 |
+
"Glass bottle",
|
| 69 |
+
"Glass cup",
|
| 70 |
+
"Metal bottle cap",
|
| 71 |
+
"Other carton",
|
| 72 |
+
"Other plastic bottle",
|
| 73 |
+
"Paper cup",
|
| 74 |
+
"Plastic bag - wrapper",
|
| 75 |
+
"Plastic bottle cap",
|
| 76 |
+
"Plastic lid",
|
| 77 |
+
"Plastic straw",
|
| 78 |
+
"Pop tab",
|
| 79 |
+
"Styrofoam piece",
|
| 80 |
+
],
|
| 81 |
+
"seginw_Salmon-Fillet": ["Salmon_fillet"],
|
| 82 |
+
"seginw_Puppies": ["puppy"],
|
| 83 |
+
"seginw_Tablets": ["tablets"],
|
| 84 |
+
"seginw_Cable": ["cable"],
|
| 85 |
+
"seginw_Fire": ["fire"],
|
| 86 |
+
"seginw_Phones": ["phone"],
|
| 87 |
+
"seginw_Cows": ["cow"],
|
| 88 |
+
"seginw_Ginger-Garlic": ["garlic", "ginger"],
|
| 89 |
+
}
|
approach/ovod/APE/ape/data/datasets/seginw_instance.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import collections
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
from detectron2.data import DatasetCatalog, MetadataCatalog
|
| 7 |
+
from detectron2.data.datasets import load_sem_seg
|
| 8 |
+
from detectron2.data.datasets.builtin_meta import COCO_CATEGORIES
|
| 9 |
+
from detectron2.utils.file_io import PathManager
|
| 10 |
+
|
| 11 |
+
from .seginw_categories import SEGINW_CATEGORIES
|
| 12 |
+
|
| 13 |
+
_CATEGORIES = [
|
| 14 |
+
"Elephants",
|
| 15 |
+
"Hand-Metal",
|
| 16 |
+
"Watermelon",
|
| 17 |
+
"House-Parts",
|
| 18 |
+
"HouseHold-Items",
|
| 19 |
+
"Strawberry",
|
| 20 |
+
"Fruits",
|
| 21 |
+
"Nutterfly-Squireel",
|
| 22 |
+
"Hand",
|
| 23 |
+
"Garbage",
|
| 24 |
+
"Chicken",
|
| 25 |
+
"Rail",
|
| 26 |
+
"Airplane-Parts",
|
| 27 |
+
"Brain-Tumor",
|
| 28 |
+
"Poles",
|
| 29 |
+
"Electric-Shaver",
|
| 30 |
+
"Bottles",
|
| 31 |
+
"Toolkits",
|
| 32 |
+
"Trash",
|
| 33 |
+
"Salmon-Fillet",
|
| 34 |
+
"Puppies",
|
| 35 |
+
"Tablets",
|
| 36 |
+
"Phones",
|
| 37 |
+
"Cows",
|
| 38 |
+
"Ginger-Garlic",
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
_PREDEFINED_SPLITS_SEGINW = {
|
| 42 |
+
"seginw_{}_val".format(cat): (
|
| 43 |
+
"valid",
|
| 44 |
+
"seginw/{}".format(cat), # image_root
|
| 45 |
+
"_annotations_min1cat.coco.json", # annot_root
|
| 46 |
+
)
|
| 47 |
+
for cat in _CATEGORIES
|
| 48 |
+
}
|
| 49 |
+
_PREDEFINED_SPLITS_SEGINW.update(
|
| 50 |
+
{
|
| 51 |
+
"seginw_{}_train".format(cat): (
|
| 52 |
+
"train",
|
| 53 |
+
"seginw/{}".format(cat), # image_root
|
| 54 |
+
"_annotations_min1cat.coco.json", # annot_root
|
| 55 |
+
)
|
| 56 |
+
for cat in _CATEGORIES
|
| 57 |
+
}
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def get_metadata(name):
|
| 62 |
+
# meta = {"thing_dataset_id_to_contiguous_id": {}}
|
| 63 |
+
meta = {}
|
| 64 |
+
meta["thing_classes"] = SEGINW_CATEGORIES[name.replace("_train", "").replace("_val", "")]
|
| 65 |
+
meta["thing_dataset_id_to_contiguous_id"] = {i: i for i in range(len(meta["thing_classes"]))}
|
| 66 |
+
return meta
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def load_seginw_json(name, image_root, annot_json, metadata):
|
| 70 |
+
"""
|
| 71 |
+
Args:
|
| 72 |
+
image_dir (str): path to the raw dataset. e.g., "~/coco/train2017".
|
| 73 |
+
gt_dir (str): path to the raw annotations. e.g., "~/coco/panoptic_train2017".
|
| 74 |
+
json_file (str): path to the json file. e.g., "~/coco/annotations/panoptic_train2017.json".
|
| 75 |
+
Returns:
|
| 76 |
+
list[dict]: a list of dicts in Detectron2 standard format. (See
|
| 77 |
+
`Using Custom Datasets </tutorials/datasets.html>`_ )
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
with PathManager.open(annot_json) as f:
|
| 81 |
+
json_info = json.load(f)
|
| 82 |
+
|
| 83 |
+
# build dictionary for grounding
|
| 84 |
+
grd_dict = collections.defaultdict(list)
|
| 85 |
+
for grd_ann in json_info["annotations"]:
|
| 86 |
+
image_id = int(grd_ann["image_id"])
|
| 87 |
+
grd_dict[image_id].append(grd_ann)
|
| 88 |
+
|
| 89 |
+
ret = []
|
| 90 |
+
for image in json_info["images"]:
|
| 91 |
+
image_id = int(image["id"])
|
| 92 |
+
image_file = os.path.join(image_root, image["file_name"])
|
| 93 |
+
grounding_anno = grd_dict[image_id]
|
| 94 |
+
|
| 95 |
+
if "train" in name and len(grounding_anno) == 0:
|
| 96 |
+
continue
|
| 97 |
+
|
| 98 |
+
ret.append(
|
| 99 |
+
{
|
| 100 |
+
"file_name": image_file,
|
| 101 |
+
"image_id": image_id,
|
| 102 |
+
"inst_info": grounding_anno,
|
| 103 |
+
}
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
assert len(ret), f"No images found in {image_root}!"
|
| 107 |
+
assert PathManager.isfile(ret[0]["file_name"]), ret[0]["file_name"]
|
| 108 |
+
return ret
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def register_seginw(name, metadata, image_root, annot_json):
|
| 112 |
+
DatasetCatalog.register(
|
| 113 |
+
name,
|
| 114 |
+
lambda: load_seginw_json(name, image_root, annot_json, metadata),
|
| 115 |
+
)
|
| 116 |
+
MetadataCatalog.get(name).set(
|
| 117 |
+
image_root=image_root,
|
| 118 |
+
json_file=annot_json,
|
| 119 |
+
evaluator_type="seginw",
|
| 120 |
+
ignore_label=255,
|
| 121 |
+
label_divisor=1000,
|
| 122 |
+
**metadata,
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def register_all_seginw(root):
|
| 127 |
+
for (
|
| 128 |
+
prefix,
|
| 129 |
+
(split, folder_name, annot_name),
|
| 130 |
+
) in _PREDEFINED_SPLITS_SEGINW.items():
|
| 131 |
+
register_seginw(
|
| 132 |
+
prefix,
|
| 133 |
+
get_metadata(prefix),
|
| 134 |
+
os.path.join(root, folder_name, split),
|
| 135 |
+
os.path.join(root, folder_name, split, annot_name),
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
if __name__.endswith(".seginw_instance"):
|
| 140 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 141 |
+
_root = os.getenv("DATASET", "datasets")
|
| 142 |
+
register_all_seginw(_root)
|
approach/ovod/APE/ape/data/datasets/visualgenome.py
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
from .coco import custom_register_coco_instances
|
| 5 |
+
from .visualgenome_categories import (
|
| 6 |
+
VISUALGENOME_150_CATEGORIES,
|
| 7 |
+
VISUALGENOME_1356_CATEGORIES,
|
| 8 |
+
VISUALGENOME_1356MINUS150_CATEGORIES,
|
| 9 |
+
VISUALGENOME_77962_CATEGORIES,
|
| 10 |
+
VISUALGENOME_77962MINUS150_CATEGORIES,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
logger = logging.getLogger(__name__)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def _get_builtin_metadata(dataset_name):
|
| 17 |
+
if dataset_name == "visualgenome_150_box":
|
| 18 |
+
return _get_visualgenome_metadata(VISUALGENOME_150_CATEGORIES)
|
| 19 |
+
|
| 20 |
+
if dataset_name == "visualgenome_region":
|
| 21 |
+
return _get_visualgenome_metadata([])
|
| 22 |
+
|
| 23 |
+
if dataset_name == "visualgenome_150_box_and_region":
|
| 24 |
+
return _get_visualgenome_metadata(VISUALGENOME_150_CATEGORIES)
|
| 25 |
+
|
| 26 |
+
if dataset_name == "visualgenome_77962_box_and_region":
|
| 27 |
+
return _get_visualgenome_metadata(VISUALGENOME_77962_CATEGORIES)
|
| 28 |
+
|
| 29 |
+
if dataset_name == "visualgenome_77962_box":
|
| 30 |
+
return _get_visualgenome_metadata(VISUALGENOME_77962_CATEGORIES)
|
| 31 |
+
|
| 32 |
+
if dataset_name == "visualgenome_77962minus150_box":
|
| 33 |
+
return _get_visualgenome_metadata(VISUALGENOME_77962MINUS150_CATEGORIES)
|
| 34 |
+
|
| 35 |
+
if dataset_name == "visualgenome_77962minus2319_box":
|
| 36 |
+
return _get_visualgenome_metadata(VISUALGENOME_77962MINUS150_CATEGORIES)
|
| 37 |
+
|
| 38 |
+
if dataset_name == "visualgenome_1356_box":
|
| 39 |
+
return _get_visualgenome_metadata(VISUALGENOME_1356_CATEGORIES)
|
| 40 |
+
|
| 41 |
+
if dataset_name == "visualgenome_1356minus150_box":
|
| 42 |
+
return _get_visualgenome_metadata(VISUALGENOME_1356MINUS150_CATEGORIES)
|
| 43 |
+
|
| 44 |
+
if dataset_name == "visualgenome_1356minus2319_box":
|
| 45 |
+
return _get_visualgenome_metadata(VISUALGENOME_1356MINUS150_CATEGORIES)
|
| 46 |
+
|
| 47 |
+
raise KeyError("No built-in metadata for dataset {}".format(dataset_name))
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def _get_visualgenome_metadata(categories):
|
| 51 |
+
if len(categories) == 0:
|
| 52 |
+
return {}
|
| 53 |
+
id_to_name = {x["id"]: x["name"] for x in categories}
|
| 54 |
+
thing_dataset_id_to_contiguous_id = {i + 1: i for i in range(len(categories))}
|
| 55 |
+
thing_classes = [id_to_name[k] for k in sorted(id_to_name)]
|
| 56 |
+
return {
|
| 57 |
+
"thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id,
|
| 58 |
+
"thing_classes": thing_classes,
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
_PREDEFINED_SPLITS_VISUALGENOME = {}
|
| 63 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_150_box"] = {
|
| 64 |
+
"visualgenome_150_box_train": (
|
| 65 |
+
"visualgenome",
|
| 66 |
+
"visualgenome/annotations/visualgenome_150_box_train.json",
|
| 67 |
+
),
|
| 68 |
+
"visualgenome_150_box_val": (
|
| 69 |
+
"visualgenome",
|
| 70 |
+
"visualgenome/annotations/visualgenome_150_box_val.json",
|
| 71 |
+
),
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_150_box_and_region"] = {
|
| 75 |
+
"visualgenome_150_box_and_region_train": (
|
| 76 |
+
"visualgenome",
|
| 77 |
+
"visualgenome/annotations/visualgenome_150_box_and_region_train.json",
|
| 78 |
+
),
|
| 79 |
+
"visualgenome_150_box_and_region_val": (
|
| 80 |
+
"visualgenome",
|
| 81 |
+
"visualgenome/annotations/visualgenome_150_box_and_region_val.json",
|
| 82 |
+
),
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_77962_box"] = {
|
| 86 |
+
"visualgenome_77962_box": (
|
| 87 |
+
"visualgenome",
|
| 88 |
+
"visualgenome/annotations/visualgenome_77962_box.json",
|
| 89 |
+
),
|
| 90 |
+
"visualgenome_77962_box_train": (
|
| 91 |
+
"visualgenome",
|
| 92 |
+
"visualgenome/annotations/visualgenome_77962_box_train.json",
|
| 93 |
+
),
|
| 94 |
+
"visualgenome_77962_box_val": (
|
| 95 |
+
"visualgenome",
|
| 96 |
+
"visualgenome/annotations/visualgenome_77962_box_val.json",
|
| 97 |
+
),
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_77962_box_and_region"] = {
|
| 101 |
+
"visualgenome_77962_box_and_region": (
|
| 102 |
+
"visualgenome",
|
| 103 |
+
"visualgenome/annotations/visualgenome_77962_box_and_region.json",
|
| 104 |
+
),
|
| 105 |
+
"visualgenome_77962_box_and_region_train": (
|
| 106 |
+
"visualgenome",
|
| 107 |
+
"visualgenome/annotations/visualgenome_77962_box_and_region_train.json",
|
| 108 |
+
),
|
| 109 |
+
"visualgenome_77962_box_and_region_val": (
|
| 110 |
+
"visualgenome",
|
| 111 |
+
"visualgenome/annotations/visualgenome_77962_box_and_region_val.json",
|
| 112 |
+
),
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_region"] = {
|
| 116 |
+
"visualgenome_region": (
|
| 117 |
+
"visualgenome",
|
| 118 |
+
"visualgenome/annotations/visualgenome_region.json",
|
| 119 |
+
),
|
| 120 |
+
"visualgenome_region_train": (
|
| 121 |
+
"visualgenome",
|
| 122 |
+
"visualgenome/annotations/visualgenome_region_train.json",
|
| 123 |
+
),
|
| 124 |
+
"visualgenome_region_val": (
|
| 125 |
+
"visualgenome",
|
| 126 |
+
"visualgenome/annotations/visualgenome_region_val.json",
|
| 127 |
+
),
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_77962minus150_box"] = {
|
| 131 |
+
"visualgenome_77962minus150_box": (
|
| 132 |
+
"visualgenome",
|
| 133 |
+
"visualgenome/annotations/visualgenome_77962minus150_box.json",
|
| 134 |
+
),
|
| 135 |
+
"visualgenome_77962minus150_box_train": (
|
| 136 |
+
"visualgenome",
|
| 137 |
+
"visualgenome/annotations/visualgenome_77962minus150_box_train.json",
|
| 138 |
+
),
|
| 139 |
+
"visualgenome_77962minus150_box_val": (
|
| 140 |
+
"visualgenome",
|
| 141 |
+
"visualgenome/annotations/visualgenome_77962minus150_box_val.json",
|
| 142 |
+
),
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_77962minus2319_box"] = {
|
| 146 |
+
"visualgenome_77962minus2319_box": (
|
| 147 |
+
"visualgenome",
|
| 148 |
+
"visualgenome/annotations/visualgenome_77962minus2319_box.json",
|
| 149 |
+
),
|
| 150 |
+
"visualgenome_77962minus2319_box_train": (
|
| 151 |
+
"visualgenome",
|
| 152 |
+
"visualgenome/annotations/visualgenome_77962minus2319_box_train.json",
|
| 153 |
+
),
|
| 154 |
+
"visualgenome_77962minus2319_box_val": (
|
| 155 |
+
"visualgenome",
|
| 156 |
+
"visualgenome/annotations/visualgenome_77962minus2319_box_val.json",
|
| 157 |
+
),
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_1356_box"] = {
|
| 161 |
+
"visualgenome_1356_box": (
|
| 162 |
+
"visualgenome",
|
| 163 |
+
"visualgenome/annotations/visualgenome_1356_box.json",
|
| 164 |
+
),
|
| 165 |
+
"visualgenome_1356_box_train": (
|
| 166 |
+
"visualgenome",
|
| 167 |
+
"visualgenome/annotations/visualgenome_1356_box_train.json",
|
| 168 |
+
),
|
| 169 |
+
"visualgenome_1356_box_val": (
|
| 170 |
+
"visualgenome",
|
| 171 |
+
"visualgenome/annotations/visualgenome_1356_box_val.json",
|
| 172 |
+
),
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_1356minus150_box"] = {
|
| 176 |
+
"visualgenome_1356minus150_box": (
|
| 177 |
+
"visualgenome",
|
| 178 |
+
"visualgenome/annotations/visualgenome_1356minus150_box.json",
|
| 179 |
+
),
|
| 180 |
+
"visualgenome_1356minus150_box_train": (
|
| 181 |
+
"visualgenome",
|
| 182 |
+
"visualgenome/annotations/visualgenome_1356minus150_box_train.json",
|
| 183 |
+
),
|
| 184 |
+
"visualgenome_1356minus150_box_val": (
|
| 185 |
+
"visualgenome",
|
| 186 |
+
"visualgenome/annotations/visualgenome_1356minus150_box_val.json",
|
| 187 |
+
),
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
_PREDEFINED_SPLITS_VISUALGENOME["visualgenome_1356minus2319_box"] = {
|
| 191 |
+
"visualgenome_1356minus2319_box": (
|
| 192 |
+
"visualgenome",
|
| 193 |
+
"visualgenome/annotations/visualgenome_1356minus2319_box.json",
|
| 194 |
+
),
|
| 195 |
+
"visualgenome_1356minus2319_box_train": (
|
| 196 |
+
"visualgenome",
|
| 197 |
+
"visualgenome/annotations/visualgenome_1356minus2319_box_train.json",
|
| 198 |
+
),
|
| 199 |
+
"visualgenome_1356minus2319_box_val": (
|
| 200 |
+
"visualgenome",
|
| 201 |
+
"visualgenome/annotations/visualgenome_1356minus2319_box_val.json",
|
| 202 |
+
),
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def register_all_visualgenome(root):
|
| 207 |
+
for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_VISUALGENOME.items():
|
| 208 |
+
for key, (image_root, json_file) in splits_per_dataset.items():
|
| 209 |
+
custom_register_coco_instances(
|
| 210 |
+
key,
|
| 211 |
+
_get_builtin_metadata(dataset_name),
|
| 212 |
+
os.path.join(root, json_file) if "://" not in json_file else json_file,
|
| 213 |
+
os.path.join(root, image_root),
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
if __name__.endswith(".visualgenome"):
|
| 218 |
+
# Assume pre-defined datasets live in `./datasets`.
|
| 219 |
+
_root = os.path.expanduser(os.getenv("DETECTRON2_DATASETS", "datasets"))
|
| 220 |
+
register_all_visualgenome(_root)
|
approach/ovod/APE/ape/data/datasets/visualgenome_categories.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
approach/ovod/APE/ape/data/samplers/__init__.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .distributed_sampler_multi_dataset import MultiDatasetTrainingSampler
|
| 2 |
+
|
| 3 |
+
__all__ = [
|
| 4 |
+
"MultiDatasetTrainingSampler",
|
| 5 |
+
]
|
approach/ovod/APE/ape/data/samplers/distributed_sampler_multi_dataset.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
import itertools
|
| 3 |
+
import logging
|
| 4 |
+
import math
|
| 5 |
+
from collections import defaultdict
|
| 6 |
+
from typing import Optional
|
| 7 |
+
|
| 8 |
+
import torch
|
| 9 |
+
from torch.utils.data.sampler import Sampler
|
| 10 |
+
|
| 11 |
+
from detectron2.data.samplers import RepeatFactorTrainingSampler
|
| 12 |
+
from detectron2.utils import comm
|
| 13 |
+
|
| 14 |
+
logger = logging.getLogger(__name__)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class MultiDatasetTrainingSampler(Sampler):
|
| 18 |
+
def __init__(self, repeat_factors, *, shuffle=True, seed=None):
|
| 19 |
+
self._shuffle = shuffle
|
| 20 |
+
if seed is None:
|
| 21 |
+
seed = comm.shared_random_seed()
|
| 22 |
+
self._seed = int(seed)
|
| 23 |
+
|
| 24 |
+
self._rank = comm.get_rank()
|
| 25 |
+
self._world_size = comm.get_world_size()
|
| 26 |
+
|
| 27 |
+
# Split into whole number (_int_part) and fractional (_frac_part) parts.
|
| 28 |
+
self._int_part = torch.trunc(repeat_factors)
|
| 29 |
+
self._frac_part = repeat_factors - self._int_part
|
| 30 |
+
|
| 31 |
+
@staticmethod
|
| 32 |
+
def get_repeat_factors(
|
| 33 |
+
dataset_dicts, num_datasets, dataset_ratio, use_rfs, use_cas, repeat_thresh, cas_lambda
|
| 34 |
+
):
|
| 35 |
+
sizes = [0 for _ in range(num_datasets)]
|
| 36 |
+
for d in dataset_dicts:
|
| 37 |
+
sizes[d["dataset_id"]] += 1
|
| 38 |
+
|
| 39 |
+
assert len(dataset_ratio) == len(
|
| 40 |
+
sizes
|
| 41 |
+
), "length of dataset ratio {} should be equal to number if dataset {}".format(
|
| 42 |
+
len(dataset_ratio), len(sizes)
|
| 43 |
+
)
|
| 44 |
+
dataset_weight = [
|
| 45 |
+
torch.ones(s, dtype=torch.float32) * max(sizes) / s * r
|
| 46 |
+
for i, (r, s) in enumerate(zip(dataset_ratio, sizes))
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
logger = logging.getLogger(__name__)
|
| 50 |
+
logger.info(
|
| 51 |
+
"Training sampler dataset weight: {}".format(
|
| 52 |
+
str([max(sizes) / s * r for i, (r, s) in enumerate(zip(dataset_ratio, sizes))])
|
| 53 |
+
)
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
st = 0
|
| 57 |
+
repeat_factors = []
|
| 58 |
+
for i, s in enumerate(sizes):
|
| 59 |
+
assert use_rfs[i] * use_cas[i] == 0
|
| 60 |
+
if use_rfs[i]:
|
| 61 |
+
repeat_factor = RepeatFactorTrainingSampler.repeat_factors_from_category_frequency(
|
| 62 |
+
dataset_dicts[st : st + s], repeat_thresh
|
| 63 |
+
)
|
| 64 |
+
elif use_cas[i]:
|
| 65 |
+
repeat_factor = MultiDatasetTrainingSampler.get_class_balance_factor_per_dataset(
|
| 66 |
+
dataset_dicts[st : st + s], l=cas_lambda
|
| 67 |
+
)
|
| 68 |
+
repeat_factor = repeat_factor * (s / repeat_factor.sum())
|
| 69 |
+
else:
|
| 70 |
+
repeat_factor = torch.ones(s, dtype=torch.float32)
|
| 71 |
+
logger.info(
|
| 72 |
+
"Training sampler class weight: {} {} {}".format(
|
| 73 |
+
repeat_factor.size(), repeat_factor.max(), repeat_factor.min()
|
| 74 |
+
)
|
| 75 |
+
)
|
| 76 |
+
repeat_factors.append(repeat_factor)
|
| 77 |
+
st = st + s
|
| 78 |
+
repeat_factors = torch.cat(repeat_factors)
|
| 79 |
+
dataset_weight = torch.cat(dataset_weight)
|
| 80 |
+
repeat_factors = dataset_weight * repeat_factors
|
| 81 |
+
|
| 82 |
+
return repeat_factors
|
| 83 |
+
|
| 84 |
+
@staticmethod
|
| 85 |
+
def get_class_balance_factor_per_dataset(dataset_dicts, l=1.0):
|
| 86 |
+
rep_factors = []
|
| 87 |
+
category_freq = defaultdict(int)
|
| 88 |
+
for dataset_dict in dataset_dicts: # For each image (without repeats)
|
| 89 |
+
cat_ids = {ann["category_id"] for ann in dataset_dict["annotations"]}
|
| 90 |
+
for cat_id in cat_ids:
|
| 91 |
+
category_freq[cat_id] += 1
|
| 92 |
+
for dataset_dict in dataset_dicts:
|
| 93 |
+
cat_ids = {ann["category_id"] for ann in dataset_dict["annotations"]}
|
| 94 |
+
rep_factor = sum([1.0 / (category_freq[cat_id] ** l) for cat_id in cat_ids])
|
| 95 |
+
rep_factors.append(rep_factor)
|
| 96 |
+
|
| 97 |
+
return torch.tensor(rep_factors, dtype=torch.float32)
|
| 98 |
+
|
| 99 |
+
def _get_epoch_indices(self, generator):
|
| 100 |
+
"""
|
| 101 |
+
Create a list of dataset indices (with repeats) to use for one epoch.
|
| 102 |
+
|
| 103 |
+
Args:
|
| 104 |
+
generator (torch.Generator): pseudo random number generator used for
|
| 105 |
+
stochastic rounding.
|
| 106 |
+
|
| 107 |
+
Returns:
|
| 108 |
+
torch.Tensor: list of dataset indices to use in one epoch. Each index
|
| 109 |
+
is repeated based on its calculated repeat factor.
|
| 110 |
+
"""
|
| 111 |
+
# Since repeat factors are fractional, we use stochastic rounding so
|
| 112 |
+
# that the target repeat factor is achieved in expectation over the
|
| 113 |
+
# course of training
|
| 114 |
+
rands = torch.rand(len(self._frac_part), generator=generator)
|
| 115 |
+
rep_factors = self._int_part + (rands < self._frac_part).float()
|
| 116 |
+
# Construct a list of indices in which we repeat images as specified
|
| 117 |
+
indices = []
|
| 118 |
+
for dataset_index, rep_factor in enumerate(rep_factors):
|
| 119 |
+
indices.extend([dataset_index] * int(rep_factor.item()))
|
| 120 |
+
return torch.tensor(indices, dtype=torch.int64)
|
| 121 |
+
|
| 122 |
+
def __iter__(self):
|
| 123 |
+
start = self._rank
|
| 124 |
+
yield from itertools.islice(self._infinite_indices(), start, None, self._world_size)
|
| 125 |
+
|
| 126 |
+
def _infinite_indices(self):
|
| 127 |
+
g = torch.Generator()
|
| 128 |
+
g.manual_seed(self._seed)
|
| 129 |
+
while True:
|
| 130 |
+
# Sample indices with repeats determined by stochastic rounding; each
|
| 131 |
+
# "epoch" may have a slightly different size due to the rounding.
|
| 132 |
+
indices = self._get_epoch_indices(g)
|
| 133 |
+
if self._shuffle:
|
| 134 |
+
randperm = torch.randperm(len(indices), generator=g)
|
| 135 |
+
yield from indices[randperm].tolist()
|
| 136 |
+
else:
|
| 137 |
+
yield from indices.tolist()
|
approach/ovod/APE/ape/data/transforms/__init__.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
from .augmentation_aa import *
|
| 3 |
+
from .augmentation_lsj import *
|
| 4 |
+
|
| 5 |
+
__all__ = [k for k in globals().keys() if not k.startswith("_")]
|
approach/ovod/APE/ape/data/transforms/augmentation_aa.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from detectron2.data import transforms as T
|
| 2 |
+
from fvcore.transforms.transform import Transform, TransformList
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class AutoAugment(T.Augmentation):
|
| 6 |
+
def __init__(self, cfg):
|
| 7 |
+
super().__init__()
|
| 8 |
+
self.resize = T.AugmentationList(
|
| 9 |
+
[
|
| 10 |
+
T.ResizeShortestEdge(
|
| 11 |
+
[480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800],
|
| 12 |
+
1333,
|
| 13 |
+
sample_style="choice",
|
| 14 |
+
),
|
| 15 |
+
]
|
| 16 |
+
)
|
| 17 |
+
self.resize_crop_resize = T.AugmentationList(
|
| 18 |
+
[
|
| 19 |
+
T.ResizeShortestEdge([400, 500, 600], 1333, sample_style="choice"),
|
| 20 |
+
T.RandomCrop("absolute_range", (384, 600)),
|
| 21 |
+
T.ResizeShortestEdge(
|
| 22 |
+
[480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800],
|
| 23 |
+
1333,
|
| 24 |
+
sample_style="choice",
|
| 25 |
+
),
|
| 26 |
+
]
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
def __call__(self, aug_input) -> Transform:
|
| 30 |
+
|
| 31 |
+
do = self._rand_range(low=0.0, high=1.0)
|
| 32 |
+
if do > 0.5:
|
| 33 |
+
return self.resize(aug_input)
|
| 34 |
+
else:
|
| 35 |
+
return self.resize_crop_resize(aug_input)
|
| 36 |
+
|
| 37 |
+
def __repr__(self):
|
| 38 |
+
msgs = [str(self.resize), str(self.resize_crop_resize)]
|
| 39 |
+
return "AutoAugment[{}]".format(", ".join(msgs))
|
approach/ovod/APE/ape/data/transforms/augmentation_lsj.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from detectron2.data import transforms as T
|
| 2 |
+
from fvcore.transforms.transform import Transform, TransformList
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class LargeScaleJitter(T.Augmentation):
|
| 6 |
+
def __init__(self, cfg):
|
| 7 |
+
super().__init__()
|
| 8 |
+
|
| 9 |
+
image_size = cfg.INPUT.LSJ.IMAGE_SIZE
|
| 10 |
+
min_scale = cfg.INPUT.LSJ.MIN_SCALE
|
| 11 |
+
max_scale = cfg.INPUT.LSJ.MAX_SCALE
|
| 12 |
+
# pad_value = 128.0
|
| 13 |
+
pad_value = 1.0 * sum(cfg.MODEL.PIXEL_MEAN) / len(cfg.MODEL.PIXEL_MEAN)
|
| 14 |
+
seg_pad_value = cfg.INPUT.SEG_PAD_VALUE
|
| 15 |
+
|
| 16 |
+
self.resize_crop = T.AugmentationList(
|
| 17 |
+
[
|
| 18 |
+
T.ResizeScale(
|
| 19 |
+
min_scale=min_scale,
|
| 20 |
+
max_scale=max_scale,
|
| 21 |
+
target_height=image_size,
|
| 22 |
+
target_width=image_size,
|
| 23 |
+
),
|
| 24 |
+
T.FixedSizeCrop(
|
| 25 |
+
crop_size=(image_size, image_size),
|
| 26 |
+
pad_value=pad_value,
|
| 27 |
+
seg_pad_value=seg_pad_value,
|
| 28 |
+
),
|
| 29 |
+
]
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
def __call__(self, aug_input) -> Transform:
|
| 33 |
+
|
| 34 |
+
return self.resize_crop(aug_input)
|
| 35 |
+
|
| 36 |
+
def __repr__(self):
|
| 37 |
+
msgs = str(self.resize_crop)
|
| 38 |
+
return "LargeScaleJitter[{}]".format(msgs)
|
approach/ovod/APE/ape/modeling/backbone/__init__.py
ADDED
|
File without changes
|
approach/ovod/APE/ape/modeling/backbone/utils_eva.py
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
| 2 |
+
import math
|
| 3 |
+
import numpy as np
|
| 4 |
+
from scipy import interpolate
|
| 5 |
+
import torch
|
| 6 |
+
import torch.nn as nn
|
| 7 |
+
import torch.nn.functional as F
|
| 8 |
+
|
| 9 |
+
__all__ = [
|
| 10 |
+
"window_partition",
|
| 11 |
+
"window_unpartition",
|
| 12 |
+
"add_decomposed_rel_pos",
|
| 13 |
+
"get_abs_pos",
|
| 14 |
+
"PatchEmbed",
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def window_partition(x, window_size):
|
| 19 |
+
"""
|
| 20 |
+
Partition into non-overlapping windows with padding if needed.
|
| 21 |
+
Args:
|
| 22 |
+
x (tensor): input tokens with [B, H, W, C].
|
| 23 |
+
window_size (int): window size.
|
| 24 |
+
|
| 25 |
+
Returns:
|
| 26 |
+
windows: windows after partition with [B * num_windows, window_size, window_size, C].
|
| 27 |
+
(Hp, Wp): padded height and width before partition
|
| 28 |
+
"""
|
| 29 |
+
B, H, W, C = x.shape
|
| 30 |
+
|
| 31 |
+
pad_h = (window_size - H % window_size) % window_size
|
| 32 |
+
pad_w = (window_size - W % window_size) % window_size
|
| 33 |
+
if pad_h > 0 or pad_w > 0:
|
| 34 |
+
x = F.pad(x, (0, 0, 0, pad_w, 0, pad_h))
|
| 35 |
+
Hp, Wp = H + pad_h, W + pad_w
|
| 36 |
+
|
| 37 |
+
x = x.view(B, Hp // window_size, window_size, Wp // window_size, window_size, C)
|
| 38 |
+
windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
|
| 39 |
+
return windows, (Hp, Wp)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def window_unpartition(windows, window_size, pad_hw, hw):
|
| 43 |
+
"""
|
| 44 |
+
Window unpartition into original sequences and removing padding.
|
| 45 |
+
Args:
|
| 46 |
+
x (tensor): input tokens with [B * num_windows, window_size, window_size, C].
|
| 47 |
+
window_size (int): window size.
|
| 48 |
+
pad_hw (Tuple): padded height and width (Hp, Wp).
|
| 49 |
+
hw (Tuple): original height and width (H, W) before padding.
|
| 50 |
+
|
| 51 |
+
Returns:
|
| 52 |
+
x: unpartitioned sequences with [B, H, W, C].
|
| 53 |
+
"""
|
| 54 |
+
Hp, Wp = pad_hw
|
| 55 |
+
H, W = hw
|
| 56 |
+
B = windows.shape[0] // (Hp * Wp // window_size // window_size)
|
| 57 |
+
x = windows.view(B, Hp // window_size, Wp // window_size, window_size, window_size, -1)
|
| 58 |
+
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, Hp, Wp, -1)
|
| 59 |
+
|
| 60 |
+
if Hp > H or Wp > W:
|
| 61 |
+
x = x[:, :H, :W, :].contiguous()
|
| 62 |
+
return x
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def get_rel_pos(q_size, k_size, rel_pos, interp_type):
|
| 66 |
+
"""
|
| 67 |
+
Get relative positional embeddings according to the relative positions of
|
| 68 |
+
query and key sizes.
|
| 69 |
+
Args:
|
| 70 |
+
q_size (int): size of query q.
|
| 71 |
+
k_size (int): size of key k.
|
| 72 |
+
rel_pos (Tensor): relative position embeddings (L, C).
|
| 73 |
+
|
| 74 |
+
Returns:
|
| 75 |
+
Extracted positional embeddings according to relative positions.
|
| 76 |
+
"""
|
| 77 |
+
max_rel_dist = int(2 * max(q_size, k_size) - 1)
|
| 78 |
+
# Interpolate rel pos if needed.
|
| 79 |
+
if rel_pos.shape[0] != max_rel_dist:
|
| 80 |
+
if interp_type == "vitdet":
|
| 81 |
+
# the vitdet impl:
|
| 82 |
+
# https://github.com/facebookresearch/detectron2/blob/96c752ce821a3340e27edd51c28a00665dd32a30/detectron2/modeling/backbone/utils.py#L77.
|
| 83 |
+
|
| 84 |
+
rel_pos_resized = F.interpolate(
|
| 85 |
+
rel_pos.reshape(1, rel_pos.shape[0], -1).permute(0, 2, 1),
|
| 86 |
+
size=max_rel_dist,
|
| 87 |
+
mode="linear",
|
| 88 |
+
)
|
| 89 |
+
rel_pos_resized = rel_pos_resized.reshape(-1, max_rel_dist).permute(1, 0)
|
| 90 |
+
elif interp_type == "beit":
|
| 91 |
+
# steal from beit https://github.com/microsoft/unilm/tree/master/beit
|
| 92 |
+
# modified by Yuxin Fang
|
| 93 |
+
|
| 94 |
+
src_size = rel_pos.shape[0]
|
| 95 |
+
dst_size = max_rel_dist
|
| 96 |
+
|
| 97 |
+
q = 1.0903078
|
| 98 |
+
dis = []
|
| 99 |
+
|
| 100 |
+
cur = 1
|
| 101 |
+
for i in range(src_size // 2):
|
| 102 |
+
dis.append(cur)
|
| 103 |
+
cur += q ** (i + 1)
|
| 104 |
+
|
| 105 |
+
r_ids = [-_ for _ in reversed(dis)]
|
| 106 |
+
x = r_ids + [0] + dis
|
| 107 |
+
t = dst_size // 2.0
|
| 108 |
+
dx = np.arange(-t, t + 0.1, 1.0)
|
| 109 |
+
|
| 110 |
+
all_rel_pos_bias = []
|
| 111 |
+
for i in range(rel_pos.shape[1]):
|
| 112 |
+
# a hack from https://github.com/baaivision/EVA/issues/8,
|
| 113 |
+
# could also be used in fine-tuning but the performance haven't been tested.
|
| 114 |
+
z = rel_pos[:, i].view(src_size).cpu().float().detach().numpy()
|
| 115 |
+
f = interpolate.interp1d(x, z, kind='cubic', fill_value="extrapolate")
|
| 116 |
+
all_rel_pos_bias.append(
|
| 117 |
+
torch.Tensor(f(dx)).contiguous().view(-1, 1).to(rel_pos.device))
|
| 118 |
+
rel_pos_resized = torch.cat(all_rel_pos_bias, dim=-1)
|
| 119 |
+
else:
|
| 120 |
+
raise NotImplementedError()
|
| 121 |
+
else:
|
| 122 |
+
rel_pos_resized = rel_pos
|
| 123 |
+
|
| 124 |
+
# Scale the coords with short length if shapes for q and k are different.
|
| 125 |
+
q_coords = torch.arange(q_size)[:, None] * max(k_size / q_size, 1.0)
|
| 126 |
+
k_coords = torch.arange(k_size)[None, :] * max(q_size / k_size, 1.0)
|
| 127 |
+
relative_coords = (q_coords - k_coords) + (k_size - 1) * max(q_size / k_size, 1.0)
|
| 128 |
+
|
| 129 |
+
return rel_pos_resized[relative_coords.long()]
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def add_decomposed_rel_pos(attn, q, rel_pos_h, rel_pos_w, q_size, k_size, interp_type):
|
| 133 |
+
"""
|
| 134 |
+
Calculate decomposed Relative Positional Embeddings from :paper:`mvitv2`.
|
| 135 |
+
https://github.com/facebookresearch/mvit/blob/19786631e330df9f3622e5402b4a419a263a2c80/mvit/models/attention.py # noqa B950
|
| 136 |
+
Args:
|
| 137 |
+
attn (Tensor): attention map.
|
| 138 |
+
q (Tensor): query q in the attention layer with shape (B, q_h * q_w, C).
|
| 139 |
+
rel_pos_h (Tensor): relative position embeddings (Lh, C) for height axis.
|
| 140 |
+
rel_pos_w (Tensor): relative position embeddings (Lw, C) for width axis.
|
| 141 |
+
q_size (Tuple): spatial sequence size of query q with (q_h, q_w).
|
| 142 |
+
k_size (Tuple): spatial sequence size of key k with (k_h, k_w).
|
| 143 |
+
|
| 144 |
+
Returns:
|
| 145 |
+
attn (Tensor): attention map with added relative positional embeddings.
|
| 146 |
+
"""
|
| 147 |
+
q_h, q_w = q_size
|
| 148 |
+
k_h, k_w = k_size
|
| 149 |
+
Rh = get_rel_pos(q_h, k_h, rel_pos_h, interp_type)
|
| 150 |
+
Rw = get_rel_pos(q_w, k_w, rel_pos_w, interp_type)
|
| 151 |
+
|
| 152 |
+
B, _, dim = q.shape
|
| 153 |
+
r_q = q.reshape(B, q_h, q_w, dim)
|
| 154 |
+
rel_h = torch.einsum("bhwc,hkc->bhwk", r_q, Rh)
|
| 155 |
+
rel_w = torch.einsum("bhwc,wkc->bhwk", r_q, Rw)
|
| 156 |
+
|
| 157 |
+
attn = (
|
| 158 |
+
attn.view(B, q_h, q_w, k_h, k_w) + rel_h[:, :, :, :, None] + rel_w[:, :, :, None, :]
|
| 159 |
+
).view(B, q_h * q_w, k_h * k_w)
|
| 160 |
+
|
| 161 |
+
return attn
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def get_abs_pos(abs_pos, has_cls_token, hw):
|
| 165 |
+
"""
|
| 166 |
+
Calculate absolute positional embeddings. If needed, resize embeddings and remove cls_token
|
| 167 |
+
dimension for the original embeddings.
|
| 168 |
+
Args:
|
| 169 |
+
abs_pos (Tensor): absolute positional embeddings with (1, num_position, C).
|
| 170 |
+
has_cls_token (bool): If true, has 1 embedding in abs_pos for cls token.
|
| 171 |
+
hw (Tuple): size of input image tokens.
|
| 172 |
+
|
| 173 |
+
Returns:
|
| 174 |
+
Absolute positional embeddings after processing with shape (1, H, W, C)
|
| 175 |
+
"""
|
| 176 |
+
h, w = hw
|
| 177 |
+
if has_cls_token:
|
| 178 |
+
abs_pos = abs_pos[:, 1:]
|
| 179 |
+
xy_num = abs_pos.shape[1]
|
| 180 |
+
size = int(math.sqrt(xy_num))
|
| 181 |
+
assert size * size == xy_num
|
| 182 |
+
|
| 183 |
+
if size != h or size != w:
|
| 184 |
+
new_abs_pos = F.interpolate(
|
| 185 |
+
abs_pos.reshape(1, size, size, -1).permute(0, 3, 1, 2),
|
| 186 |
+
size=(h, w),
|
| 187 |
+
mode="bicubic",
|
| 188 |
+
align_corners=False,
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
return new_abs_pos.permute(0, 2, 3, 1)
|
| 192 |
+
else:
|
| 193 |
+
return abs_pos.reshape(1, h, w, -1)
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
class PatchEmbed(nn.Module):
|
| 197 |
+
"""
|
| 198 |
+
Image to Patch Embedding.
|
| 199 |
+
"""
|
| 200 |
+
|
| 201 |
+
def __init__(
|
| 202 |
+
self, kernel_size=(16, 16), stride=(16, 16), padding=(0, 0), in_chans=3, embed_dim=768
|
| 203 |
+
):
|
| 204 |
+
"""
|
| 205 |
+
Args:
|
| 206 |
+
kernel_size (Tuple): kernel size of the projection layer.
|
| 207 |
+
stride (Tuple): stride of the projection layer.
|
| 208 |
+
padding (Tuple): padding size of the projection layer.
|
| 209 |
+
in_chans (int): Number of input image channels.
|
| 210 |
+
embed_dim (int): embed_dim (int): Patch embedding dimension.
|
| 211 |
+
"""
|
| 212 |
+
super().__init__()
|
| 213 |
+
|
| 214 |
+
self.proj = nn.Conv2d(
|
| 215 |
+
in_chans, embed_dim, kernel_size=kernel_size, stride=stride, padding=padding
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
def forward(self, x):
|
| 219 |
+
x = self.proj(x)
|
| 220 |
+
# B C H W -> B H W C
|
| 221 |
+
x = x.permute(0, 2, 3, 1)
|
| 222 |
+
return x
|
approach/ovod/APE/ape/modeling/backbone/utils_eva02.py
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
| 2 |
+
import math
|
| 3 |
+
import numpy as np
|
| 4 |
+
from scipy import interpolate
|
| 5 |
+
import torch
|
| 6 |
+
import torch.nn as nn
|
| 7 |
+
import torch.nn.functional as F
|
| 8 |
+
|
| 9 |
+
__all__ = [
|
| 10 |
+
"window_partition",
|
| 11 |
+
"window_unpartition",
|
| 12 |
+
"add_decomposed_rel_pos",
|
| 13 |
+
"get_abs_pos",
|
| 14 |
+
"PatchEmbed",
|
| 15 |
+
"VisionRotaryEmbeddingFast",
|
| 16 |
+
]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def window_partition(x, window_size):
|
| 20 |
+
"""
|
| 21 |
+
Partition into non-overlapping windows with padding if needed.
|
| 22 |
+
Args:
|
| 23 |
+
x (tensor): input tokens with [B, H, W, C].
|
| 24 |
+
window_size (int): window size.
|
| 25 |
+
|
| 26 |
+
Returns:
|
| 27 |
+
windows: windows after partition with [B * num_windows, window_size, window_size, C].
|
| 28 |
+
(Hp, Wp): padded height and width before partition
|
| 29 |
+
"""
|
| 30 |
+
B, H, W, C = x.shape
|
| 31 |
+
|
| 32 |
+
pad_h = (window_size - H % window_size) % window_size
|
| 33 |
+
pad_w = (window_size - W % window_size) % window_size
|
| 34 |
+
if pad_h > 0 or pad_w > 0:
|
| 35 |
+
x = F.pad(x, (0, 0, 0, pad_w, 0, pad_h))
|
| 36 |
+
Hp, Wp = H + pad_h, W + pad_w
|
| 37 |
+
|
| 38 |
+
x = x.view(B, Hp // window_size, window_size, Wp // window_size, window_size, C)
|
| 39 |
+
windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
|
| 40 |
+
return windows, (Hp, Wp)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def window_unpartition(windows, window_size, pad_hw, hw):
|
| 44 |
+
"""
|
| 45 |
+
Window unpartition into original sequences and removing padding.
|
| 46 |
+
Args:
|
| 47 |
+
x (tensor): input tokens with [B * num_windows, window_size, window_size, C].
|
| 48 |
+
window_size (int): window size.
|
| 49 |
+
pad_hw (Tuple): padded height and width (Hp, Wp).
|
| 50 |
+
hw (Tuple): original height and width (H, W) before padding.
|
| 51 |
+
|
| 52 |
+
Returns:
|
| 53 |
+
x: unpartitioned sequences with [B, H, W, C].
|
| 54 |
+
"""
|
| 55 |
+
Hp, Wp = pad_hw
|
| 56 |
+
H, W = hw
|
| 57 |
+
B = windows.shape[0] // (Hp * Wp // window_size // window_size)
|
| 58 |
+
x = windows.view(B, Hp // window_size, Wp // window_size, window_size, window_size, -1)
|
| 59 |
+
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, Hp, Wp, -1)
|
| 60 |
+
|
| 61 |
+
if Hp > H or Wp > W:
|
| 62 |
+
x = x[:, :H, :W, :].contiguous()
|
| 63 |
+
return x
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def get_rel_pos(q_size, k_size, rel_pos):
|
| 67 |
+
"""
|
| 68 |
+
Get relative positional embeddings according to the relative positions of
|
| 69 |
+
query and key sizes.
|
| 70 |
+
Args:
|
| 71 |
+
q_size (int): size of query q.
|
| 72 |
+
k_size (int): size of key k.
|
| 73 |
+
rel_pos (Tensor): relative position embeddings (L, C).
|
| 74 |
+
|
| 75 |
+
Returns:
|
| 76 |
+
Extracted positional embeddings according to relative positions.
|
| 77 |
+
"""
|
| 78 |
+
max_rel_dist = int(2 * max(q_size, k_size) - 1)
|
| 79 |
+
use_log_interpolation = True
|
| 80 |
+
|
| 81 |
+
# Interpolate rel pos if needed.
|
| 82 |
+
if rel_pos.shape[0] != max_rel_dist:
|
| 83 |
+
if not use_log_interpolation:
|
| 84 |
+
# Interpolate rel pos.
|
| 85 |
+
rel_pos_resized = F.interpolate(
|
| 86 |
+
rel_pos.reshape(1, rel_pos.shape[0], -1).permute(0, 2, 1),
|
| 87 |
+
size=max_rel_dist,
|
| 88 |
+
mode="linear",
|
| 89 |
+
)
|
| 90 |
+
rel_pos_resized = rel_pos_resized.reshape(-1, max_rel_dist).permute(1, 0)
|
| 91 |
+
else:
|
| 92 |
+
src_size = rel_pos.shape[0]
|
| 93 |
+
dst_size = max_rel_dist
|
| 94 |
+
|
| 95 |
+
# q = 1.13492
|
| 96 |
+
q = 1.0903078
|
| 97 |
+
dis = []
|
| 98 |
+
|
| 99 |
+
cur = 1
|
| 100 |
+
for i in range(src_size // 2):
|
| 101 |
+
dis.append(cur)
|
| 102 |
+
cur += q ** (i + 1)
|
| 103 |
+
|
| 104 |
+
r_ids = [-_ for _ in reversed(dis)]
|
| 105 |
+
x = r_ids + [0] + dis
|
| 106 |
+
t = dst_size // 2.0
|
| 107 |
+
dx = np.arange(-t, t + 0.1, 1.0)
|
| 108 |
+
all_rel_pos_bias = []
|
| 109 |
+
for i in range(rel_pos.shape[1]):
|
| 110 |
+
z = rel_pos[:, i].view(src_size).cpu().float().numpy()
|
| 111 |
+
f = interpolate.interp1d(x, z, kind='cubic', fill_value="extrapolate")
|
| 112 |
+
all_rel_pos_bias.append(
|
| 113 |
+
torch.Tensor(f(dx)).contiguous().view(-1, 1).to(rel_pos.device))
|
| 114 |
+
rel_pos_resized = torch.cat(all_rel_pos_bias, dim=-1)
|
| 115 |
+
else:
|
| 116 |
+
rel_pos_resized = rel_pos
|
| 117 |
+
|
| 118 |
+
# Scale the coords with short length if shapes for q and k are different.
|
| 119 |
+
q_coords = torch.arange(q_size)[:, None] * max(k_size / q_size, 1.0)
|
| 120 |
+
k_coords = torch.arange(k_size)[None, :] * max(q_size / k_size, 1.0)
|
| 121 |
+
relative_coords = (q_coords - k_coords) + (k_size - 1) * max(q_size / k_size, 1.0)
|
| 122 |
+
|
| 123 |
+
return rel_pos_resized[relative_coords.long()]
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def add_decomposed_rel_pos(attn, q, rel_pos_h, rel_pos_w, q_size, k_size):
|
| 127 |
+
"""
|
| 128 |
+
Calculate decomposed Relative Positional Embeddings from :paper:`mvitv2`.
|
| 129 |
+
https://github.com/facebookresearch/mvit/blob/19786631e330df9f3622e5402b4a419a263a2c80/mvit/models/attention.py # noqa B950
|
| 130 |
+
Args:
|
| 131 |
+
attn (Tensor): attention map.
|
| 132 |
+
q (Tensor): query q in the attention layer with shape (B, q_h * q_w, C).
|
| 133 |
+
rel_pos_h (Tensor): relative position embeddings (Lh, C) for height axis.
|
| 134 |
+
rel_pos_w (Tensor): relative position embeddings (Lw, C) for width axis.
|
| 135 |
+
q_size (Tuple): spatial sequence size of query q with (q_h, q_w).
|
| 136 |
+
k_size (Tuple): spatial sequence size of key k with (k_h, k_w).
|
| 137 |
+
|
| 138 |
+
Returns:
|
| 139 |
+
attn (Tensor): attention map with added relative positional embeddings.
|
| 140 |
+
"""
|
| 141 |
+
q_h, q_w = q_size
|
| 142 |
+
k_h, k_w = k_size
|
| 143 |
+
Rh = get_rel_pos(q_h, k_h, rel_pos_h)
|
| 144 |
+
Rw = get_rel_pos(q_w, k_w, rel_pos_w)
|
| 145 |
+
|
| 146 |
+
B, _, dim = q.shape
|
| 147 |
+
r_q = q.reshape(B, q_h, q_w, dim)
|
| 148 |
+
rel_h = torch.einsum("bhwc,hkc->bhwk", r_q, Rh)
|
| 149 |
+
rel_w = torch.einsum("bhwc,wkc->bhwk", r_q, Rw)
|
| 150 |
+
|
| 151 |
+
attn = (
|
| 152 |
+
attn.view(B, q_h, q_w, k_h, k_w) + rel_h[:, :, :, :, None] + rel_w[:, :, :, None, :]
|
| 153 |
+
).view(B, q_h * q_w, k_h * k_w)
|
| 154 |
+
|
| 155 |
+
return attn
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def get_abs_pos(abs_pos, has_cls_token, hw):
|
| 159 |
+
"""
|
| 160 |
+
Calculate absolute positional embeddings. If needed, resize embeddings and remove cls_token
|
| 161 |
+
dimension for the original embeddings.
|
| 162 |
+
Args:
|
| 163 |
+
abs_pos (Tensor): absolute positional embeddings with (1, num_position, C).
|
| 164 |
+
has_cls_token (bool): If true, has 1 embedding in abs_pos for cls token.
|
| 165 |
+
hw (Tuple): size of input image tokens.
|
| 166 |
+
|
| 167 |
+
Returns:
|
| 168 |
+
Absolute positional embeddings after processing with shape (1, H, W, C)
|
| 169 |
+
"""
|
| 170 |
+
h, w = hw
|
| 171 |
+
if has_cls_token:
|
| 172 |
+
abs_pos = abs_pos[:, 1:]
|
| 173 |
+
xy_num = abs_pos.shape[1]
|
| 174 |
+
size = int(math.sqrt(xy_num))
|
| 175 |
+
assert size * size == xy_num
|
| 176 |
+
|
| 177 |
+
if size != h or size != w:
|
| 178 |
+
new_abs_pos = F.interpolate(
|
| 179 |
+
abs_pos.reshape(1, size, size, -1).permute(0, 3, 1, 2),
|
| 180 |
+
size=(h, w),
|
| 181 |
+
mode="bicubic",
|
| 182 |
+
align_corners=False,
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
return new_abs_pos.permute(0, 2, 3, 1)
|
| 186 |
+
else:
|
| 187 |
+
return abs_pos.reshape(1, h, w, -1)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
class PatchEmbed(nn.Module):
|
| 191 |
+
"""
|
| 192 |
+
Image to Patch Embedding.
|
| 193 |
+
"""
|
| 194 |
+
|
| 195 |
+
def __init__(
|
| 196 |
+
self, kernel_size=(16, 16), stride=(16, 16), padding=(0, 0), in_chans=3, embed_dim=768
|
| 197 |
+
):
|
| 198 |
+
"""
|
| 199 |
+
Args:
|
| 200 |
+
kernel_size (Tuple): kernel size of the projection layer.
|
| 201 |
+
stride (Tuple): stride of the projection layer.
|
| 202 |
+
padding (Tuple): padding size of the projection layer.
|
| 203 |
+
in_chans (int): Number of input image channels.
|
| 204 |
+
embed_dim (int): embed_dim (int): Patch embedding dimension.
|
| 205 |
+
"""
|
| 206 |
+
super().__init__()
|
| 207 |
+
|
| 208 |
+
self.proj = nn.Conv2d(
|
| 209 |
+
in_chans, embed_dim, kernel_size=kernel_size, stride=stride, padding=padding
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
def forward(self, x):
|
| 213 |
+
x = self.proj(x)
|
| 214 |
+
# B C H W -> B H W C
|
| 215 |
+
x = x.permute(0, 2, 3, 1)
|
| 216 |
+
return x
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
from math import pi
|
| 222 |
+
|
| 223 |
+
import torch
|
| 224 |
+
from torch import nn
|
| 225 |
+
|
| 226 |
+
from einops import rearrange, repeat
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
def broadcat(tensors, dim = -1):
|
| 231 |
+
num_tensors = len(tensors)
|
| 232 |
+
shape_lens = set(list(map(lambda t: len(t.shape), tensors)))
|
| 233 |
+
assert len(shape_lens) == 1, 'tensors must all have the same number of dimensions'
|
| 234 |
+
shape_len = list(shape_lens)[0]
|
| 235 |
+
dim = (dim + shape_len) if dim < 0 else dim
|
| 236 |
+
dims = list(zip(*map(lambda t: list(t.shape), tensors)))
|
| 237 |
+
expandable_dims = [(i, val) for i, val in enumerate(dims) if i != dim]
|
| 238 |
+
assert all([*map(lambda t: len(set(t[1])) <= 2, expandable_dims)]), 'invalid dimensions for broadcastable concatentation'
|
| 239 |
+
max_dims = list(map(lambda t: (t[0], max(t[1])), expandable_dims))
|
| 240 |
+
expanded_dims = list(map(lambda t: (t[0], (t[1],) * num_tensors), max_dims))
|
| 241 |
+
expanded_dims.insert(dim, (dim, dims[dim]))
|
| 242 |
+
expandable_shapes = list(zip(*map(lambda t: t[1], expanded_dims)))
|
| 243 |
+
tensors = list(map(lambda t: t[0].expand(*t[1]), zip(tensors, expandable_shapes)))
|
| 244 |
+
return torch.cat(tensors, dim = dim)
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
def rotate_half(x):
|
| 249 |
+
x = rearrange(x, '... (d r) -> ... d r', r = 2)
|
| 250 |
+
x1, x2 = x.unbind(dim = -1)
|
| 251 |
+
x = torch.stack((-x2, x1), dim = -1)
|
| 252 |
+
return rearrange(x, '... d r -> ... (d r)')
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
class VisionRotaryEmbedding(nn.Module):
|
| 257 |
+
def __init__(
|
| 258 |
+
self,
|
| 259 |
+
dim,
|
| 260 |
+
pt_seq_len,
|
| 261 |
+
ft_seq_len=None,
|
| 262 |
+
custom_freqs = None,
|
| 263 |
+
freqs_for = 'lang',
|
| 264 |
+
theta = 10000,
|
| 265 |
+
max_freq = 10,
|
| 266 |
+
num_freqs = 1,
|
| 267 |
+
):
|
| 268 |
+
super().__init__()
|
| 269 |
+
if custom_freqs:
|
| 270 |
+
freqs = custom_freqs
|
| 271 |
+
elif freqs_for == 'lang':
|
| 272 |
+
freqs = 1. / (theta ** (torch.arange(0, dim, 2)[:(dim // 2)].float() / dim))
|
| 273 |
+
elif freqs_for == 'pixel':
|
| 274 |
+
freqs = torch.linspace(1., max_freq / 2, dim // 2) * pi
|
| 275 |
+
elif freqs_for == 'constant':
|
| 276 |
+
freqs = torch.ones(num_freqs).float()
|
| 277 |
+
else:
|
| 278 |
+
raise ValueError(f'unknown modality {freqs_for}')
|
| 279 |
+
|
| 280 |
+
if ft_seq_len is None: ft_seq_len = pt_seq_len
|
| 281 |
+
t = torch.arange(ft_seq_len) / ft_seq_len * pt_seq_len
|
| 282 |
+
|
| 283 |
+
freqs_h = torch.einsum('..., f -> ... f', t, freqs)
|
| 284 |
+
freqs_h = repeat(freqs_h, '... n -> ... (n r)', r = 2)
|
| 285 |
+
|
| 286 |
+
freqs_w = torch.einsum('..., f -> ... f', t, freqs)
|
| 287 |
+
freqs_w = repeat(freqs_w, '... n -> ... (n r)', r = 2)
|
| 288 |
+
|
| 289 |
+
freqs = broadcat((freqs_h[:, None, :], freqs_w[None, :, :]), dim = -1)
|
| 290 |
+
|
| 291 |
+
self.register_buffer("freqs_cos", freqs.cos())
|
| 292 |
+
self.register_buffer("freqs_sin", freqs.sin())
|
| 293 |
+
|
| 294 |
+
print('======== shape of rope freq', self.freqs_cos.shape, '========')
|
| 295 |
+
|
| 296 |
+
def forward(self, t, start_index = 0):
|
| 297 |
+
rot_dim = self.freqs_cos.shape[-1]
|
| 298 |
+
end_index = start_index + rot_dim
|
| 299 |
+
assert rot_dim <= t.shape[-1], f'feature dimension {t.shape[-1]} is not of sufficient size to rotate in all the positions {rot_dim}'
|
| 300 |
+
t_left, t, t_right = t[..., :start_index], t[..., start_index:end_index], t[..., end_index:]
|
| 301 |
+
t = (t * self.freqs_cos) + (rotate_half(t) * self.freqs_sin)
|
| 302 |
+
return torch.cat((t_left, t, t_right), dim = -1)
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
class VisionRotaryEmbeddingFast(nn.Module):
|
| 308 |
+
def __init__(
|
| 309 |
+
self,
|
| 310 |
+
dim,
|
| 311 |
+
pt_seq_len=16,
|
| 312 |
+
ft_seq_len=None,
|
| 313 |
+
custom_freqs = None,
|
| 314 |
+
freqs_for = 'lang',
|
| 315 |
+
theta = 10000,
|
| 316 |
+
max_freq = 10,
|
| 317 |
+
num_freqs = 1,
|
| 318 |
+
):
|
| 319 |
+
super().__init__()
|
| 320 |
+
if custom_freqs:
|
| 321 |
+
freqs = custom_freqs
|
| 322 |
+
elif freqs_for == 'lang':
|
| 323 |
+
freqs = 1. / (theta ** (torch.arange(0, dim, 2)[:(dim // 2)].float() / dim))
|
| 324 |
+
elif freqs_for == 'pixel':
|
| 325 |
+
freqs = torch.linspace(1., max_freq / 2, dim // 2) * pi
|
| 326 |
+
elif freqs_for == 'constant':
|
| 327 |
+
freqs = torch.ones(num_freqs).float()
|
| 328 |
+
else:
|
| 329 |
+
raise ValueError(f'unknown modality {freqs_for}')
|
| 330 |
+
|
| 331 |
+
if ft_seq_len is None: ft_seq_len = pt_seq_len
|
| 332 |
+
t = torch.arange(ft_seq_len) / ft_seq_len * pt_seq_len
|
| 333 |
+
|
| 334 |
+
freqs = torch.einsum('..., f -> ... f', t, freqs)
|
| 335 |
+
freqs = repeat(freqs, '... n -> ... (n r)', r = 2)
|
| 336 |
+
freqs = broadcat((freqs[:, None, :], freqs[None, :, :]), dim = -1)
|
| 337 |
+
|
| 338 |
+
freqs_cos = freqs.cos().view(-1, freqs.shape[-1])
|
| 339 |
+
freqs_sin = freqs.sin().view(-1, freqs.shape[-1])
|
| 340 |
+
|
| 341 |
+
self.register_buffer("freqs_cos", freqs_cos)
|
| 342 |
+
self.register_buffer("freqs_sin", freqs_sin)
|
| 343 |
+
|
| 344 |
+
print('======== shape of rope freq', self.freqs_cos.shape, '========')
|
| 345 |
+
|
| 346 |
+
def forward(self, t): return t * self.freqs_cos + rotate_half(t) * self.freqs_sin
|
| 347 |
+
|
approach/ovod/APE/ape/modeling/backbone/vit.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
|
| 3 |
+
logger = logging.getLogger(__name__)
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
__all__ = ["get_vit_lr_decay_rate"]
|
| 7 |
+
|
| 8 |
+
def get_vit_lr_decay_rate(name, lr_decay_rate=1.0, num_layers=12):
|
| 9 |
+
"""
|
| 10 |
+
Calculate lr decay rate for different ViT blocks.
|
| 11 |
+
Args:
|
| 12 |
+
name (string): parameter name.
|
| 13 |
+
lr_decay_rate (float): base lr decay rate.
|
| 14 |
+
num_layers (int): number of ViT blocks.
|
| 15 |
+
|
| 16 |
+
Returns:
|
| 17 |
+
lr decay rate for the given parameter.
|
| 18 |
+
"""
|
| 19 |
+
if name.startswith("model_vision."):
|
| 20 |
+
name = name[len("model_vision."):]
|
| 21 |
+
|
| 22 |
+
layer_id = num_layers + 1
|
| 23 |
+
if name.startswith("backbone"):
|
| 24 |
+
if ".pos_embed" in name or ".patch_embed" in name:
|
| 25 |
+
layer_id = 0
|
| 26 |
+
elif ".blocks." in name and ".residual." not in name:
|
| 27 |
+
layer_id = int(name[name.find(".blocks.") :].split(".")[2]) + 1
|
| 28 |
+
|
| 29 |
+
logger.info("get_vit_lr_decay_rate: name={} num_layers={} layer_id={} lr_decay_rate={}".format(name, num_layers, layer_id, lr_decay_rate ** (num_layers + 1 - layer_id)))
|
| 30 |
+
return lr_decay_rate ** (num_layers + 1 - layer_id)
|
approach/ovod/APE/ape/modeling/backbone/vit_eva.py
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import math
|
| 3 |
+
import fvcore.nn.weight_init as weight_init
|
| 4 |
+
import torch
|
| 5 |
+
import torch.nn as nn
|
| 6 |
+
import torch.nn.functional as F
|
| 7 |
+
from torch import Tensor, Size
|
| 8 |
+
from typing import Union, List
|
| 9 |
+
from torch.nn.parameter import Parameter
|
| 10 |
+
import numbers
|
| 11 |
+
|
| 12 |
+
from detectron2.layers import CNNBlockBase, Conv2d, get_norm
|
| 13 |
+
from detectron2.modeling.backbone.fpn import _assert_strides_are_log2_contiguous
|
| 14 |
+
|
| 15 |
+
from fairscale.nn.checkpoint import checkpoint_wrapper
|
| 16 |
+
from timm.models.layers import DropPath, Mlp, trunc_normal_
|
| 17 |
+
|
| 18 |
+
from detectron2.modeling.backbone import Backbone
|
| 19 |
+
from .utils_eva import (
|
| 20 |
+
PatchEmbed,
|
| 21 |
+
add_decomposed_rel_pos,
|
| 22 |
+
get_abs_pos,
|
| 23 |
+
window_partition,
|
| 24 |
+
window_unpartition,
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
logger = logging.getLogger(__name__)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
__all__ = ["ViT", "SimpleFeaturePyramid", "get_vit_lr_decay_rate"]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
_shape_t = Union[int, List[int], Size]
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
# steal from beit https://github.com/microsoft/unilm/tree/master/beit
|
| 37 |
+
class LayerNormWithForceFP32(nn.Module):
|
| 38 |
+
__constants__ = ['normalized_shape', 'eps', 'elementwise_affine']
|
| 39 |
+
normalized_shape: _shape_t
|
| 40 |
+
eps: float
|
| 41 |
+
elementwise_affine: bool
|
| 42 |
+
|
| 43 |
+
def __init__(self, normalized_shape: _shape_t, eps: float = 1e-5, elementwise_affine: bool = True) -> None:
|
| 44 |
+
super(LayerNormWithForceFP32, self).__init__()
|
| 45 |
+
if isinstance(normalized_shape, numbers.Integral):
|
| 46 |
+
normalized_shape = (normalized_shape,)
|
| 47 |
+
self.normalized_shape = tuple(normalized_shape)
|
| 48 |
+
self.eps = eps
|
| 49 |
+
self.elementwise_affine = elementwise_affine
|
| 50 |
+
if self.elementwise_affine:
|
| 51 |
+
self.weight = Parameter(torch.Tensor(*normalized_shape))
|
| 52 |
+
self.bias = Parameter(torch.Tensor(*normalized_shape))
|
| 53 |
+
else:
|
| 54 |
+
self.register_parameter('weight', None)
|
| 55 |
+
self.register_parameter('bias', None)
|
| 56 |
+
self.reset_parameters()
|
| 57 |
+
|
| 58 |
+
def reset_parameters(self) -> None:
|
| 59 |
+
if self.elementwise_affine:
|
| 60 |
+
nn.init.ones_(self.weight)
|
| 61 |
+
nn.init.zeros_(self.bias)
|
| 62 |
+
|
| 63 |
+
def forward(self, input: Tensor) -> Tensor:
|
| 64 |
+
return F.layer_norm(
|
| 65 |
+
input.float(), self.normalized_shape, self.weight.float(), self.bias.float(), self.eps).type_as(input)
|
| 66 |
+
|
| 67 |
+
def extra_repr(self) -> Tensor:
|
| 68 |
+
return '{normalized_shape}, eps={eps}, ' \
|
| 69 |
+
'elementwise_affine={elementwise_affine}'.format(**self.__dict__)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class Attention(nn.Module):
|
| 73 |
+
"""Multi-head Attention block with relative position embeddings."""
|
| 74 |
+
|
| 75 |
+
def __init__(
|
| 76 |
+
self,
|
| 77 |
+
dim,
|
| 78 |
+
num_heads=8,
|
| 79 |
+
qkv_bias=True,
|
| 80 |
+
beit_like_qkv_bias=False,
|
| 81 |
+
use_rel_pos=False,
|
| 82 |
+
rel_pos_zero_init=True,
|
| 83 |
+
input_size=None,
|
| 84 |
+
interp_type="vitdet",
|
| 85 |
+
):
|
| 86 |
+
"""
|
| 87 |
+
Args:
|
| 88 |
+
dim (int): Number of input channels.
|
| 89 |
+
num_heads (int): Number of attention heads.
|
| 90 |
+
qkv_bias (bool: If True, add a learnable bias to query, key, value.
|
| 91 |
+
rel_pos (bool): If True, add relative positional embeddings to the attention map.
|
| 92 |
+
rel_pos_zero_init (bool): If True, zero initialize relative positional parameters.
|
| 93 |
+
input_size (int or None): Input resolution for calculating the relative positional
|
| 94 |
+
parameter size.
|
| 95 |
+
"""
|
| 96 |
+
super().__init__()
|
| 97 |
+
self.num_heads = num_heads
|
| 98 |
+
head_dim = dim // num_heads
|
| 99 |
+
self.scale = head_dim**-0.5
|
| 100 |
+
|
| 101 |
+
self.beit_like_qkv_bias = beit_like_qkv_bias
|
| 102 |
+
if beit_like_qkv_bias:
|
| 103 |
+
self.q_bias = nn.Parameter(torch.zeros(dim))
|
| 104 |
+
self.v_bias = nn.Parameter(torch.zeros(dim))
|
| 105 |
+
|
| 106 |
+
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
|
| 107 |
+
self.proj = nn.Linear(dim, dim)
|
| 108 |
+
|
| 109 |
+
self.use_rel_pos = use_rel_pos
|
| 110 |
+
self.interp_type = interp_type
|
| 111 |
+
if self.use_rel_pos:
|
| 112 |
+
# initialize relative positional embeddings
|
| 113 |
+
self.rel_pos_h = nn.Parameter(torch.zeros(2 * input_size[0] - 1, head_dim))
|
| 114 |
+
self.rel_pos_w = nn.Parameter(torch.zeros(2 * input_size[1] - 1, head_dim))
|
| 115 |
+
|
| 116 |
+
if not rel_pos_zero_init:
|
| 117 |
+
trunc_normal_(self.rel_pos_h, std=0.02)
|
| 118 |
+
trunc_normal_(self.rel_pos_w, std=0.02)
|
| 119 |
+
self.qk_float = False
|
| 120 |
+
|
| 121 |
+
def forward(self, x):
|
| 122 |
+
B, H, W, _ = x.shape
|
| 123 |
+
# qkv with shape (3, B, nHead, H * W, C)
|
| 124 |
+
if self.beit_like_qkv_bias:
|
| 125 |
+
qkv_bias = torch.cat((self.q_bias, torch.zeros_like(self.v_bias, requires_grad=False), self.v_bias))
|
| 126 |
+
qkv = torch.nn.functional.linear(input=x, weight=self.qkv.weight, bias=qkv_bias)
|
| 127 |
+
qkv = qkv.reshape(B, H * W, 3, self.num_heads, -1).permute(2, 0, 3, 1, 4)
|
| 128 |
+
else:
|
| 129 |
+
qkv = self.qkv(x).reshape(B, H * W, 3, self.num_heads, -1).permute(2, 0, 3, 1, 4)
|
| 130 |
+
# q, k, v with shape (B * nHead, H * W, C)
|
| 131 |
+
q, k, v = qkv.reshape(3, B * self.num_heads, H * W, -1).unbind(0)
|
| 132 |
+
|
| 133 |
+
if self.qk_float:
|
| 134 |
+
attn = (q.float() * self.scale) @ k.float().transpose(-2, -1)
|
| 135 |
+
if self.use_rel_pos:
|
| 136 |
+
attn = add_decomposed_rel_pos(attn, q, self.rel_pos_h, self.rel_pos_w, (H, W), (H, W), self.interp_type)
|
| 137 |
+
attn = attn.softmax(dim=-1).type_as(x)
|
| 138 |
+
else:
|
| 139 |
+
attn = (q * self.scale) @ k.transpose(-2, -1)
|
| 140 |
+
if self.use_rel_pos:
|
| 141 |
+
attn = add_decomposed_rel_pos(attn, q, self.rel_pos_h, self.rel_pos_w, (H, W), (H, W), self.interp_type)
|
| 142 |
+
attn = attn.softmax(dim=-1)
|
| 143 |
+
x = (attn @ v).view(B, self.num_heads, H, W, -1).permute(0, 2, 3, 1, 4).reshape(B, H, W, -1)
|
| 144 |
+
x = self.proj(x)
|
| 145 |
+
|
| 146 |
+
return x
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
class ResBottleneckBlock(CNNBlockBase):
|
| 150 |
+
"""
|
| 151 |
+
The standard bottleneck residual block without the last activation layer.
|
| 152 |
+
It contains 3 conv layers with kernels 1x1, 3x3, 1x1.
|
| 153 |
+
"""
|
| 154 |
+
|
| 155 |
+
def __init__(
|
| 156 |
+
self,
|
| 157 |
+
in_channels,
|
| 158 |
+
out_channels,
|
| 159 |
+
bottleneck_channels,
|
| 160 |
+
norm="LN",
|
| 161 |
+
act_layer=nn.GELU,
|
| 162 |
+
):
|
| 163 |
+
"""
|
| 164 |
+
Args:
|
| 165 |
+
in_channels (int): Number of input channels.
|
| 166 |
+
out_channels (int): Number of output channels.
|
| 167 |
+
bottleneck_channels (int): number of output channels for the 3x3
|
| 168 |
+
"bottleneck" conv layers.
|
| 169 |
+
norm (str or callable): normalization for all conv layers.
|
| 170 |
+
See :func:`layers.get_norm` for supported format.
|
| 171 |
+
act_layer (callable): activation for all conv layers.
|
| 172 |
+
"""
|
| 173 |
+
super().__init__(in_channels, out_channels, 1)
|
| 174 |
+
|
| 175 |
+
self.conv1 = Conv2d(in_channels, bottleneck_channels, 1, bias=False)
|
| 176 |
+
self.norm1 = get_norm(norm, bottleneck_channels)
|
| 177 |
+
self.act1 = act_layer()
|
| 178 |
+
|
| 179 |
+
self.conv2 = Conv2d(
|
| 180 |
+
bottleneck_channels,
|
| 181 |
+
bottleneck_channels,
|
| 182 |
+
3,
|
| 183 |
+
padding=1,
|
| 184 |
+
bias=False,
|
| 185 |
+
)
|
| 186 |
+
self.norm2 = get_norm(norm, bottleneck_channels)
|
| 187 |
+
self.act2 = act_layer()
|
| 188 |
+
|
| 189 |
+
self.conv3 = Conv2d(bottleneck_channels, out_channels, 1, bias=False)
|
| 190 |
+
self.norm3 = get_norm(norm, out_channels)
|
| 191 |
+
|
| 192 |
+
for layer in [self.conv1, self.conv2, self.conv3]:
|
| 193 |
+
weight_init.c2_msra_fill(layer)
|
| 194 |
+
for layer in [self.norm1, self.norm2]:
|
| 195 |
+
layer.weight.data.fill_(1.0)
|
| 196 |
+
layer.bias.data.zero_()
|
| 197 |
+
# zero init last norm layer.
|
| 198 |
+
self.norm3.weight.data.zero_()
|
| 199 |
+
self.norm3.bias.data.zero_()
|
| 200 |
+
|
| 201 |
+
def forward(self, x):
|
| 202 |
+
out = x
|
| 203 |
+
for layer in self.children():
|
| 204 |
+
out = layer(out)
|
| 205 |
+
|
| 206 |
+
out = x + out
|
| 207 |
+
return out
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
class Block(nn.Module):
|
| 211 |
+
"""Transformer blocks with support of window attention and residual propagation blocks"""
|
| 212 |
+
|
| 213 |
+
def __init__(
|
| 214 |
+
self,
|
| 215 |
+
dim,
|
| 216 |
+
num_heads,
|
| 217 |
+
mlp_ratio=4.0,
|
| 218 |
+
qkv_bias=True,
|
| 219 |
+
drop_path=0.0,
|
| 220 |
+
norm_layer=LayerNormWithForceFP32,
|
| 221 |
+
act_layer=nn.GELU,
|
| 222 |
+
use_rel_pos=False,
|
| 223 |
+
rel_pos_zero_init=True,
|
| 224 |
+
window_size=0,
|
| 225 |
+
use_residual_block=False,
|
| 226 |
+
input_size=None,
|
| 227 |
+
beit_like_qkv_bias=False,
|
| 228 |
+
beit_like_gamma=False,
|
| 229 |
+
interp_type="vitdet",
|
| 230 |
+
):
|
| 231 |
+
"""
|
| 232 |
+
Args:
|
| 233 |
+
dim (int): Number of input channels.
|
| 234 |
+
num_heads (int): Number of attention heads in each ViT block.
|
| 235 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 236 |
+
qkv_bias (bool): If True, add a learnable bias to query, key, value.
|
| 237 |
+
drop_path (float): Stochastic depth rate.
|
| 238 |
+
norm_layer (nn.Module): Normalization layer.
|
| 239 |
+
act_layer (nn.Module): Activation layer.
|
| 240 |
+
use_rel_pos (bool): If True, add relative positional embeddings to the attention map.
|
| 241 |
+
rel_pos_zero_init (bool): If True, zero initialize relative positional parameters.
|
| 242 |
+
window_size (int): Window size for window attention blocks. If it equals 0, then not
|
| 243 |
+
use window attention.
|
| 244 |
+
use_residual_block (bool): If True, use a residual block after the MLP block.
|
| 245 |
+
input_size (int or None): Input resolution for calculating the relative positional
|
| 246 |
+
parameter size.
|
| 247 |
+
beit_like_qkv_bias (bool)
|
| 248 |
+
beit_like_gamma (bool)
|
| 249 |
+
"""
|
| 250 |
+
super().__init__()
|
| 251 |
+
self.norm1 = norm_layer(dim)
|
| 252 |
+
self.attn = Attention(
|
| 253 |
+
dim,
|
| 254 |
+
num_heads=num_heads,
|
| 255 |
+
qkv_bias=qkv_bias,
|
| 256 |
+
use_rel_pos=use_rel_pos,
|
| 257 |
+
rel_pos_zero_init=rel_pos_zero_init,
|
| 258 |
+
input_size=input_size if window_size == 0 else (window_size, window_size),
|
| 259 |
+
beit_like_qkv_bias=beit_like_qkv_bias,
|
| 260 |
+
interp_type=interp_type,
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
self.drop_path = DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
|
| 264 |
+
self.norm2 = norm_layer(dim)
|
| 265 |
+
self.mlp = Mlp(in_features=dim, hidden_features=int(dim * mlp_ratio), act_layer=act_layer)
|
| 266 |
+
|
| 267 |
+
self.window_size = window_size
|
| 268 |
+
|
| 269 |
+
self.use_residual_block = use_residual_block
|
| 270 |
+
if use_residual_block:
|
| 271 |
+
# Use a residual block with bottleneck channel as dim // 2
|
| 272 |
+
self.residual = ResBottleneckBlock(
|
| 273 |
+
in_channels=dim,
|
| 274 |
+
out_channels=dim,
|
| 275 |
+
bottleneck_channels=dim // 2,
|
| 276 |
+
norm="LN",
|
| 277 |
+
act_layer=act_layer,
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
self.beit_like_gamma = beit_like_gamma
|
| 281 |
+
if beit_like_gamma:
|
| 282 |
+
self.gamma_1 = nn.Parameter(torch.ones((dim)), requires_grad=True)
|
| 283 |
+
self.gamma_2 = nn.Parameter(torch.ones((dim)), requires_grad=True)
|
| 284 |
+
|
| 285 |
+
def forward(self, x):
|
| 286 |
+
shortcut = x
|
| 287 |
+
x = self.norm1(x)
|
| 288 |
+
# Window partition
|
| 289 |
+
if self.window_size > 0:
|
| 290 |
+
H, W = x.shape[1], x.shape[2]
|
| 291 |
+
x, pad_hw = window_partition(x, self.window_size)
|
| 292 |
+
|
| 293 |
+
x = self.attn(x)
|
| 294 |
+
# Reverse window partition
|
| 295 |
+
if self.window_size > 0:
|
| 296 |
+
x = window_unpartition(x, self.window_size, pad_hw, (H, W))
|
| 297 |
+
|
| 298 |
+
if self.beit_like_gamma:
|
| 299 |
+
x = shortcut + self.drop_path(self.gamma_1 * x)
|
| 300 |
+
x = x + self.drop_path(self.gamma_2 * self.mlp(self.norm2(x)))
|
| 301 |
+
else:
|
| 302 |
+
x = shortcut + self.drop_path(x)
|
| 303 |
+
x = x + self.drop_path(self.mlp(self.norm2(x)))
|
| 304 |
+
|
| 305 |
+
if self.use_residual_block:
|
| 306 |
+
x = self.residual(x.permute(0, 3, 1, 2)).permute(0, 2, 3, 1)
|
| 307 |
+
|
| 308 |
+
return x
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
class ViT(Backbone):
|
| 312 |
+
"""
|
| 313 |
+
This module implements Vision Transformer (ViT) backbone in :paper:`vitdet`.
|
| 314 |
+
"Exploring Plain Vision Transformer Backbones for Object Detection",
|
| 315 |
+
https://arxiv.org/abs/2203.16527
|
| 316 |
+
"""
|
| 317 |
+
|
| 318 |
+
def __init__(
|
| 319 |
+
self,
|
| 320 |
+
img_size=1024,
|
| 321 |
+
patch_size=16,
|
| 322 |
+
in_chans=3,
|
| 323 |
+
embed_dim=768,
|
| 324 |
+
depth=12,
|
| 325 |
+
num_heads=12,
|
| 326 |
+
mlp_ratio=4.0,
|
| 327 |
+
qkv_bias=True,
|
| 328 |
+
drop_path_rate=0.0,
|
| 329 |
+
norm_layer=LayerNormWithForceFP32,
|
| 330 |
+
act_layer=nn.GELU,
|
| 331 |
+
use_abs_pos=True,
|
| 332 |
+
use_rel_pos=False,
|
| 333 |
+
rel_pos_zero_init=True,
|
| 334 |
+
window_size=0,
|
| 335 |
+
window_block_indexes=(),
|
| 336 |
+
residual_block_indexes=(),
|
| 337 |
+
use_act_checkpoint=False,
|
| 338 |
+
pretrain_img_size=224,
|
| 339 |
+
pretrain_use_cls_token=True,
|
| 340 |
+
out_feature="last_feat",
|
| 341 |
+
beit_like_qkv_bias=True,
|
| 342 |
+
beit_like_gamma=False,
|
| 343 |
+
freeze_patch_embed=False,
|
| 344 |
+
interp_type="vitdet",
|
| 345 |
+
frozen_stages=-1,
|
| 346 |
+
):
|
| 347 |
+
"""
|
| 348 |
+
Args:
|
| 349 |
+
img_size (int): Input image size.
|
| 350 |
+
patch_size (int): Patch size.
|
| 351 |
+
in_chans (int): Number of input image channels.
|
| 352 |
+
embed_dim (int): Patch embedding dimension.
|
| 353 |
+
depth (int): Depth of ViT.
|
| 354 |
+
num_heads (int): Number of attention heads in each ViT block.
|
| 355 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 356 |
+
qkv_bias (bool): If True, add a learnable bias to query, key, value.
|
| 357 |
+
drop_path_rate (float): Stochastic depth rate.
|
| 358 |
+
norm_layer (nn.Module): Normalization layer.
|
| 359 |
+
act_layer (nn.Module): Activation layer.
|
| 360 |
+
use_abs_pos (bool): If True, use absolute positional embeddings.
|
| 361 |
+
use_rel_pos (bool): If True, add relative positional embeddings to the attention map.
|
| 362 |
+
rel_pos_zero_init (bool): If True, zero initialize relative positional parameters.
|
| 363 |
+
window_size (int): Window size for window attention blocks.
|
| 364 |
+
window_block_indexes (list): Indexes for blocks using window attention.
|
| 365 |
+
residual_block_indexes (list): Indexes for blocks using conv propagation.
|
| 366 |
+
use_act_checkpoint (bool): If True, use activation checkpointing.
|
| 367 |
+
pretrain_img_size (int): input image size for pretraining models.
|
| 368 |
+
pretrain_use_cls_token (bool): If True, pretrainig models use class token.
|
| 369 |
+
out_feature (str): name of the feature from the last block.
|
| 370 |
+
beit_like_qkv_bias (bool): beit_like_model that has gamma_1 and gamma_2 in blocks and qkv_bias=False
|
| 371 |
+
beit_like_gamma (bool)
|
| 372 |
+
freeze_patch_embed (bool)
|
| 373 |
+
interp_type: "vitdet" for training / fine-ting, "beit" for eval (slightly improvement at a higher res)
|
| 374 |
+
"""
|
| 375 |
+
super().__init__()
|
| 376 |
+
self.pretrain_use_cls_token = pretrain_use_cls_token
|
| 377 |
+
|
| 378 |
+
self.patch_embed = PatchEmbed(
|
| 379 |
+
kernel_size=(patch_size, patch_size),
|
| 380 |
+
stride=(patch_size, patch_size),
|
| 381 |
+
in_chans=in_chans,
|
| 382 |
+
embed_dim=embed_dim,
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
if use_abs_pos:
|
| 386 |
+
# Initialize absolute positional embedding with pretrain image size.
|
| 387 |
+
num_patches = (pretrain_img_size // patch_size) * (pretrain_img_size // patch_size)
|
| 388 |
+
num_positions = (num_patches + 1) if pretrain_use_cls_token else num_patches
|
| 389 |
+
self.pos_embed = nn.Parameter(torch.zeros(1, num_positions, embed_dim))
|
| 390 |
+
else:
|
| 391 |
+
self.pos_embed = None
|
| 392 |
+
|
| 393 |
+
# stochastic depth decay rule
|
| 394 |
+
dpr = [x.item() for x in torch.linspace(0, drop_path_rate, depth)]
|
| 395 |
+
|
| 396 |
+
self.blocks = nn.ModuleList()
|
| 397 |
+
if beit_like_qkv_bias:
|
| 398 |
+
qkv_bias = False
|
| 399 |
+
for i in range(depth):
|
| 400 |
+
block = Block(
|
| 401 |
+
dim=embed_dim,
|
| 402 |
+
num_heads=num_heads,
|
| 403 |
+
mlp_ratio=mlp_ratio,
|
| 404 |
+
qkv_bias=qkv_bias,
|
| 405 |
+
drop_path=dpr[i],
|
| 406 |
+
norm_layer=norm_layer,
|
| 407 |
+
act_layer=act_layer,
|
| 408 |
+
use_rel_pos=use_rel_pos,
|
| 409 |
+
rel_pos_zero_init=rel_pos_zero_init,
|
| 410 |
+
window_size=window_size if i in window_block_indexes else 0,
|
| 411 |
+
use_residual_block=i in residual_block_indexes,
|
| 412 |
+
input_size=(img_size // patch_size, img_size // patch_size),
|
| 413 |
+
beit_like_qkv_bias=beit_like_qkv_bias,
|
| 414 |
+
beit_like_gamma=beit_like_gamma,
|
| 415 |
+
interp_type=interp_type,
|
| 416 |
+
)
|
| 417 |
+
if use_act_checkpoint and i > frozen_stages - 1:
|
| 418 |
+
block = checkpoint_wrapper(block)
|
| 419 |
+
self.blocks.append(block)
|
| 420 |
+
|
| 421 |
+
self._out_feature_channels = {out_feature: embed_dim}
|
| 422 |
+
self._out_feature_strides = {out_feature: patch_size}
|
| 423 |
+
self._out_features = [out_feature]
|
| 424 |
+
|
| 425 |
+
if self.pos_embed is not None:
|
| 426 |
+
nn.init.trunc_normal_(self.pos_embed, std=0.02)
|
| 427 |
+
|
| 428 |
+
self.freeze_patch_embed = freeze_patch_embed
|
| 429 |
+
self.apply(self._init_weights)
|
| 430 |
+
|
| 431 |
+
self.frozen_stages = frozen_stages
|
| 432 |
+
self._freeze_stages()
|
| 433 |
+
|
| 434 |
+
def _freeze_stages(self):
|
| 435 |
+
if self.frozen_stages >= 0:
|
| 436 |
+
self.patch_embed.eval()
|
| 437 |
+
for param in self.patch_embed.parameters():
|
| 438 |
+
param.requires_grad = False
|
| 439 |
+
|
| 440 |
+
if self.frozen_stages >= 1 and self.pos_embed is not None:
|
| 441 |
+
self.pos_embed.requires_grad = False
|
| 442 |
+
|
| 443 |
+
if self.frozen_stages >= 2:
|
| 444 |
+
for i in range(0, self.frozen_stages - 1):
|
| 445 |
+
m = self.blocks[i]
|
| 446 |
+
m.eval()
|
| 447 |
+
for name, param in m.named_parameters():
|
| 448 |
+
vit_lr_decay_rate = get_vit_lr_decay_rate(f"backbone.net.blocks.{i}.{name}", lr_decay_rate=0.9, num_layers=len(self.blocks))
|
| 449 |
+
logger.info(f"freeze blocks.{i}.{name} {param.size()} {vit_lr_decay_rate}")
|
| 450 |
+
param.requires_grad = False
|
| 451 |
+
|
| 452 |
+
def _init_weights(self, m):
|
| 453 |
+
if isinstance(m, nn.Linear):
|
| 454 |
+
nn.init.trunc_normal_(m.weight, std=0.02)
|
| 455 |
+
if isinstance(m, nn.Linear) and m.bias is not None:
|
| 456 |
+
nn.init.constant_(m.bias, 0)
|
| 457 |
+
elif isinstance(m, LayerNormWithForceFP32):
|
| 458 |
+
nn.init.constant_(m.bias, 0)
|
| 459 |
+
nn.init.constant_(m.weight, 1.0)
|
| 460 |
+
|
| 461 |
+
if self.freeze_patch_embed:
|
| 462 |
+
for n, p in self.patch_embed.named_parameters():
|
| 463 |
+
p.requires_grad = False
|
| 464 |
+
|
| 465 |
+
def forward(self, x):
|
| 466 |
+
x = self.patch_embed(x)
|
| 467 |
+
if self.pos_embed is not None:
|
| 468 |
+
x = x + get_abs_pos(
|
| 469 |
+
self.pos_embed, self.pretrain_use_cls_token, (x.shape[1], x.shape[2])
|
| 470 |
+
)
|
| 471 |
+
|
| 472 |
+
for blk in self.blocks:
|
| 473 |
+
x = blk(x)
|
| 474 |
+
|
| 475 |
+
outputs = {self._out_features[0]: x.permute(0, 3, 1, 2)}
|
| 476 |
+
return outputs
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
class SimpleFeaturePyramid(Backbone):
|
| 480 |
+
"""
|
| 481 |
+
This module implements SimpleFeaturePyramid in :paper:`vitdet`.
|
| 482 |
+
It creates pyramid features built on top of the input feature map.
|
| 483 |
+
"""
|
| 484 |
+
|
| 485 |
+
def __init__(
|
| 486 |
+
self,
|
| 487 |
+
net,
|
| 488 |
+
in_feature,
|
| 489 |
+
out_channels,
|
| 490 |
+
scale_factors,
|
| 491 |
+
top_block=None,
|
| 492 |
+
norm="LN",
|
| 493 |
+
square_pad=0,
|
| 494 |
+
):
|
| 495 |
+
"""
|
| 496 |
+
Args:
|
| 497 |
+
net (Backbone): module representing the subnetwork backbone.
|
| 498 |
+
Must be a subclass of :class:`Backbone`.
|
| 499 |
+
in_feature (str): names of the input feature maps coming
|
| 500 |
+
from the net.
|
| 501 |
+
out_channels (int): number of channels in the output feature maps.
|
| 502 |
+
scale_factors (list[float]): list of scaling factors to upsample or downsample
|
| 503 |
+
the input features for creating pyramid features.
|
| 504 |
+
top_block (nn.Module or None): if provided, an extra operation will
|
| 505 |
+
be performed on the output of the last (smallest resolution)
|
| 506 |
+
pyramid output, and the result will extend the result list. The top_block
|
| 507 |
+
further downsamples the feature map. It must have an attribute
|
| 508 |
+
"num_levels", meaning the number of extra pyramid levels added by
|
| 509 |
+
this block, and "in_feature", which is a string representing
|
| 510 |
+
its input feature (e.g., p5).
|
| 511 |
+
norm (str): the normalization to use.
|
| 512 |
+
square_pad (int): If > 0, require input images to be padded to specific square size.
|
| 513 |
+
"""
|
| 514 |
+
super(SimpleFeaturePyramid, self).__init__()
|
| 515 |
+
assert isinstance(net, Backbone)
|
| 516 |
+
|
| 517 |
+
self.scale_factors = scale_factors
|
| 518 |
+
|
| 519 |
+
input_shapes = net.output_shape()
|
| 520 |
+
strides = [int(input_shapes[in_feature].stride / scale) for scale in scale_factors]
|
| 521 |
+
_assert_strides_are_log2_contiguous(strides)
|
| 522 |
+
|
| 523 |
+
dim = input_shapes[in_feature].channels
|
| 524 |
+
self.stages = []
|
| 525 |
+
use_bias = norm == ""
|
| 526 |
+
for idx, scale in enumerate(scale_factors):
|
| 527 |
+
out_dim = dim
|
| 528 |
+
if scale == 4.0:
|
| 529 |
+
layers = [
|
| 530 |
+
nn.ConvTranspose2d(dim, dim // 2, kernel_size=2, stride=2),
|
| 531 |
+
get_norm(norm, dim // 2),
|
| 532 |
+
nn.GELU(),
|
| 533 |
+
nn.ConvTranspose2d(dim // 2, dim // 4, kernel_size=2, stride=2),
|
| 534 |
+
]
|
| 535 |
+
out_dim = dim // 4
|
| 536 |
+
elif scale == 2.0:
|
| 537 |
+
layers = [nn.ConvTranspose2d(dim, dim // 2, kernel_size=2, stride=2)]
|
| 538 |
+
out_dim = dim // 2
|
| 539 |
+
elif scale == 1.0:
|
| 540 |
+
layers = []
|
| 541 |
+
elif scale == 0.5:
|
| 542 |
+
layers = [nn.MaxPool2d(kernel_size=2, stride=2)]
|
| 543 |
+
else:
|
| 544 |
+
raise NotImplementedError(f"scale_factor={scale} is not supported yet.")
|
| 545 |
+
|
| 546 |
+
layers.extend(
|
| 547 |
+
[
|
| 548 |
+
Conv2d(
|
| 549 |
+
out_dim,
|
| 550 |
+
out_channels,
|
| 551 |
+
kernel_size=1,
|
| 552 |
+
bias=use_bias,
|
| 553 |
+
norm=get_norm(norm, out_channels),
|
| 554 |
+
),
|
| 555 |
+
Conv2d(
|
| 556 |
+
out_channels,
|
| 557 |
+
out_channels,
|
| 558 |
+
kernel_size=3,
|
| 559 |
+
padding=1,
|
| 560 |
+
bias=use_bias,
|
| 561 |
+
norm=get_norm(norm, out_channels),
|
| 562 |
+
),
|
| 563 |
+
]
|
| 564 |
+
)
|
| 565 |
+
layers = nn.Sequential(*layers)
|
| 566 |
+
|
| 567 |
+
stage = int(math.log2(strides[idx]))
|
| 568 |
+
self.add_module(f"simfp_{stage}", layers)
|
| 569 |
+
self.stages.append(layers)
|
| 570 |
+
|
| 571 |
+
self.net = net
|
| 572 |
+
self.in_feature = in_feature
|
| 573 |
+
self.top_block = top_block
|
| 574 |
+
# Return feature names are "p<stage>", like ["p2", "p3", ..., "p6"]
|
| 575 |
+
self._out_feature_strides = {"p{}".format(int(math.log2(s))): s for s in strides}
|
| 576 |
+
# top block output feature maps.
|
| 577 |
+
if self.top_block is not None:
|
| 578 |
+
for s in range(stage, stage + self.top_block.num_levels):
|
| 579 |
+
self._out_feature_strides["p{}".format(s + 1)] = 2 ** (s + 1)
|
| 580 |
+
|
| 581 |
+
self._out_features = list(self._out_feature_strides.keys())
|
| 582 |
+
self._out_feature_channels = {k: out_channels for k in self._out_features}
|
| 583 |
+
self._size_divisibility = strides[-1]
|
| 584 |
+
self._square_pad = square_pad
|
| 585 |
+
|
| 586 |
+
@property
|
| 587 |
+
def padding_constraints(self):
|
| 588 |
+
return {
|
| 589 |
+
"size_divisiblity": self._size_divisibility,
|
| 590 |
+
"square_size": self._square_pad,
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
def forward(self, x):
|
| 594 |
+
"""
|
| 595 |
+
Args:
|
| 596 |
+
x: Tensor of shape (N,C,H,W). H, W must be a multiple of ``self.size_divisibility``.
|
| 597 |
+
|
| 598 |
+
Returns:
|
| 599 |
+
dict[str->Tensor]:
|
| 600 |
+
mapping from feature map name to pyramid feature map tensor
|
| 601 |
+
in high to low resolution order. Returned feature names follow the FPN
|
| 602 |
+
convention: "p<stage>", where stage has stride = 2 ** stage e.g.,
|
| 603 |
+
["p2", "p3", ..., "p6"].
|
| 604 |
+
"""
|
| 605 |
+
bottom_up_features = self.net(x)
|
| 606 |
+
features = bottom_up_features[self.in_feature]
|
| 607 |
+
results = []
|
| 608 |
+
|
| 609 |
+
for stage in self.stages:
|
| 610 |
+
results.append(stage(features))
|
| 611 |
+
|
| 612 |
+
if self.top_block is not None:
|
| 613 |
+
if self.top_block.in_feature in bottom_up_features:
|
| 614 |
+
top_block_in_feature = bottom_up_features[self.top_block.in_feature]
|
| 615 |
+
else:
|
| 616 |
+
top_block_in_feature = results[self._out_features.index(self.top_block.in_feature)]
|
| 617 |
+
results.extend(self.top_block(top_block_in_feature))
|
| 618 |
+
assert len(self._out_features) == len(results)
|
| 619 |
+
return {f: res for f, res in zip(self._out_features, results)}
|
| 620 |
+
|
| 621 |
+
|
| 622 |
+
def get_vit_lr_decay_rate(name, lr_decay_rate=1.0, num_layers=12):
|
| 623 |
+
"""
|
| 624 |
+
Calculate lr decay rate for different ViT blocks.
|
| 625 |
+
Args:
|
| 626 |
+
name (string): parameter name.
|
| 627 |
+
lr_decay_rate (float): base lr decay rate.
|
| 628 |
+
num_layers (int): number of ViT blocks.
|
| 629 |
+
|
| 630 |
+
Returns:
|
| 631 |
+
lr decay rate for the given parameter.
|
| 632 |
+
"""
|
| 633 |
+
if name.startswith("model_vision."):
|
| 634 |
+
name = name[len("model_vision."):]
|
| 635 |
+
|
| 636 |
+
layer_id = num_layers + 1
|
| 637 |
+
if name.startswith("backbone"):
|
| 638 |
+
if ".pos_embed" in name or ".patch_embed" in name:
|
| 639 |
+
layer_id = 0
|
| 640 |
+
elif ".blocks." in name and ".residual." not in name:
|
| 641 |
+
layer_id = int(name[name.find(".blocks.") :].split(".")[2]) + 1
|
| 642 |
+
|
| 643 |
+
logger.info("get_vit_lr_decay_rate: name={} num_layers={} layer_id={} lr_decay_rate={}".format(name, num_layers, layer_id, lr_decay_rate ** (num_layers + 1 - layer_id)))
|
| 644 |
+
return lr_decay_rate ** (num_layers + 1 - layer_id)
|
approach/ovod/APE/ape/modeling/backbone/vit_eva02.py
ADDED
|
@@ -0,0 +1,625 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import math
|
| 3 |
+
from functools import partial
|
| 4 |
+
|
| 5 |
+
import fvcore.nn.weight_init as weight_init
|
| 6 |
+
import torch
|
| 7 |
+
import torch.nn as nn
|
| 8 |
+
import torch.nn.functional as F
|
| 9 |
+
|
| 10 |
+
from detectron2.layers import CNNBlockBase, Conv2d, get_norm
|
| 11 |
+
from detectron2.modeling.backbone.fpn import _assert_strides_are_log2_contiguous
|
| 12 |
+
|
| 13 |
+
from detectron2.modeling.backbone import Backbone
|
| 14 |
+
from .utils_eva02 import (
|
| 15 |
+
PatchEmbed,
|
| 16 |
+
add_decomposed_rel_pos,
|
| 17 |
+
get_abs_pos,
|
| 18 |
+
window_partition,
|
| 19 |
+
window_unpartition,
|
| 20 |
+
VisionRotaryEmbeddingFast,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
import xformers.ops as xops
|
| 25 |
+
except:
|
| 26 |
+
pass
|
| 27 |
+
|
| 28 |
+
try:
|
| 29 |
+
from apex.normalization import FusedLayerNorm
|
| 30 |
+
except:
|
| 31 |
+
pass
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
logger = logging.getLogger(__name__)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
__all__ = ["ViT", "SimpleFeaturePyramid", "get_vit_lr_decay_rate"]
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class SwiGLU(nn.Module):
|
| 43 |
+
def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.SiLU, drop=0.,
|
| 44 |
+
norm_layer=nn.LayerNorm, subln=False
|
| 45 |
+
):
|
| 46 |
+
super().__init__()
|
| 47 |
+
out_features = out_features or in_features
|
| 48 |
+
hidden_features = hidden_features or in_features
|
| 49 |
+
|
| 50 |
+
self.w1 = nn.Linear(in_features, hidden_features)
|
| 51 |
+
self.w2 = nn.Linear(in_features, hidden_features)
|
| 52 |
+
|
| 53 |
+
self.act = act_layer()
|
| 54 |
+
self.ffn_ln = norm_layer(hidden_features) if subln else nn.Identity()
|
| 55 |
+
self.w3 = nn.Linear(hidden_features, out_features)
|
| 56 |
+
|
| 57 |
+
self.drop = nn.Dropout(drop)
|
| 58 |
+
|
| 59 |
+
def forward(self, x):
|
| 60 |
+
x1 = self.w1(x)
|
| 61 |
+
x2 = self.w2(x)
|
| 62 |
+
hidden = self.act(x1) * x2
|
| 63 |
+
x = self.ffn_ln(hidden)
|
| 64 |
+
x = self.w3(x)
|
| 65 |
+
x = self.drop(x)
|
| 66 |
+
return x
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
class Attention(nn.Module):
|
| 70 |
+
def __init__(
|
| 71 |
+
self,
|
| 72 |
+
dim,
|
| 73 |
+
num_heads=8,
|
| 74 |
+
qkv_bias=True,
|
| 75 |
+
qk_scale=None,
|
| 76 |
+
attn_head_dim=None,
|
| 77 |
+
rope=None,
|
| 78 |
+
xattn=True,
|
| 79 |
+
):
|
| 80 |
+
super().__init__()
|
| 81 |
+
self.num_heads = num_heads
|
| 82 |
+
head_dim = dim // num_heads
|
| 83 |
+
if attn_head_dim is not None:
|
| 84 |
+
head_dim = attn_head_dim
|
| 85 |
+
all_head_dim = head_dim * self.num_heads
|
| 86 |
+
self.scale = qk_scale or head_dim ** -0.5
|
| 87 |
+
|
| 88 |
+
self.q_proj = nn.Linear(dim, all_head_dim, bias=False)
|
| 89 |
+
self.k_proj = nn.Linear(dim, all_head_dim, bias=False)
|
| 90 |
+
self.v_proj = nn.Linear(dim, all_head_dim, bias=False)
|
| 91 |
+
|
| 92 |
+
if qkv_bias:
|
| 93 |
+
self.q_bias = nn.Parameter(torch.zeros(all_head_dim))
|
| 94 |
+
self.v_bias = nn.Parameter(torch.zeros(all_head_dim))
|
| 95 |
+
else:
|
| 96 |
+
self.q_bias = None
|
| 97 |
+
self.v_bias = None
|
| 98 |
+
|
| 99 |
+
self.rope = rope
|
| 100 |
+
self.xattn = xattn
|
| 101 |
+
self.proj = nn.Linear(all_head_dim, dim)
|
| 102 |
+
|
| 103 |
+
def forward(self, x):
|
| 104 |
+
B, H, W, C = x.shape
|
| 105 |
+
x = x.view(B, -1, C)
|
| 106 |
+
N = H * W
|
| 107 |
+
|
| 108 |
+
q = F.linear(input=x, weight=self.q_proj.weight, bias=self.q_bias)
|
| 109 |
+
k = F.linear(input=x, weight=self.k_proj.weight, bias=None)
|
| 110 |
+
v = F.linear(input=x, weight=self.v_proj.weight, bias=self.v_bias)
|
| 111 |
+
|
| 112 |
+
q = q.reshape(B, N, self.num_heads, -1).permute(0, 2, 1, 3) # B, num_heads, N, C
|
| 113 |
+
k = k.reshape(B, N, self.num_heads, -1).permute(0, 2, 1, 3)
|
| 114 |
+
v = v.reshape(B, N, self.num_heads, -1).permute(0, 2, 1, 3)
|
| 115 |
+
|
| 116 |
+
## rope
|
| 117 |
+
q = self.rope(q).type_as(v)
|
| 118 |
+
k = self.rope(k).type_as(v)
|
| 119 |
+
|
| 120 |
+
if self.xattn and not (torch.jit.is_scripting() or torch.jit.is_tracing()):
|
| 121 |
+
q = q.permute(0, 2, 1, 3) # B, num_heads, N, C -> B, N, num_heads, C
|
| 122 |
+
k = k.permute(0, 2, 1, 3)
|
| 123 |
+
v = v.permute(0, 2, 1, 3)
|
| 124 |
+
|
| 125 |
+
x = xops.memory_efficient_attention(q, k, v)
|
| 126 |
+
x = x.reshape(B, N, -1)
|
| 127 |
+
else:
|
| 128 |
+
q = q * self.scale
|
| 129 |
+
attn = (q @ k.transpose(-2, -1))
|
| 130 |
+
attn = attn.softmax(dim=-1).type_as(x)
|
| 131 |
+
x = (attn @ v).transpose(1, 2).reshape(B, N, -1)
|
| 132 |
+
|
| 133 |
+
x = self.proj(x)
|
| 134 |
+
x = x.view(B, H, W, C)
|
| 135 |
+
|
| 136 |
+
return x
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
class ResBottleneckBlock(CNNBlockBase):
|
| 140 |
+
"""
|
| 141 |
+
The standard bottleneck residual block without the last activation layer.
|
| 142 |
+
It contains 3 conv layers with kernels 1x1, 3x3, 1x1.
|
| 143 |
+
"""
|
| 144 |
+
|
| 145 |
+
def __init__(
|
| 146 |
+
self,
|
| 147 |
+
in_channels,
|
| 148 |
+
out_channels,
|
| 149 |
+
bottleneck_channels,
|
| 150 |
+
norm="LN",
|
| 151 |
+
act_layer=nn.GELU,
|
| 152 |
+
):
|
| 153 |
+
"""
|
| 154 |
+
Args:
|
| 155 |
+
in_channels (int): Number of input channels.
|
| 156 |
+
out_channels (int): Number of output channels.
|
| 157 |
+
bottleneck_channels (int): number of output channels for the 3x3
|
| 158 |
+
"bottleneck" conv layers.
|
| 159 |
+
norm (str or callable): normalization for all conv layers.
|
| 160 |
+
See :func:`layers.get_norm` for supported format.
|
| 161 |
+
act_layer (callable): activation for all conv layers.
|
| 162 |
+
"""
|
| 163 |
+
super().__init__(in_channels, out_channels, 1)
|
| 164 |
+
|
| 165 |
+
self.conv1 = Conv2d(in_channels, bottleneck_channels, 1, bias=False)
|
| 166 |
+
self.norm1 = get_norm(norm, bottleneck_channels)
|
| 167 |
+
self.act1 = act_layer()
|
| 168 |
+
|
| 169 |
+
self.conv2 = Conv2d(
|
| 170 |
+
bottleneck_channels,
|
| 171 |
+
bottleneck_channels,
|
| 172 |
+
3,
|
| 173 |
+
padding=1,
|
| 174 |
+
bias=False,
|
| 175 |
+
)
|
| 176 |
+
self.norm2 = get_norm(norm, bottleneck_channels)
|
| 177 |
+
self.act2 = act_layer()
|
| 178 |
+
|
| 179 |
+
self.conv3 = Conv2d(bottleneck_channels, out_channels, 1, bias=False)
|
| 180 |
+
self.norm3 = get_norm(norm, out_channels)
|
| 181 |
+
|
| 182 |
+
for layer in [self.conv1, self.conv2, self.conv3]:
|
| 183 |
+
weight_init.c2_msra_fill(layer)
|
| 184 |
+
for layer in [self.norm1, self.norm2]:
|
| 185 |
+
layer.weight.data.fill_(1.0)
|
| 186 |
+
layer.bias.data.zero_()
|
| 187 |
+
# zero init last norm layer.
|
| 188 |
+
self.norm3.weight.data.zero_()
|
| 189 |
+
self.norm3.bias.data.zero_()
|
| 190 |
+
|
| 191 |
+
def forward(self, x):
|
| 192 |
+
out = x
|
| 193 |
+
for layer in self.children():
|
| 194 |
+
out = layer(out)
|
| 195 |
+
|
| 196 |
+
out = x + out
|
| 197 |
+
return out
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
class Block(nn.Module):
|
| 201 |
+
"""Transformer blocks with support of window attention and residual propagation blocks"""
|
| 202 |
+
|
| 203 |
+
def __init__(
|
| 204 |
+
self,
|
| 205 |
+
dim,
|
| 206 |
+
num_heads,
|
| 207 |
+
mlp_ratio=4*2/3,
|
| 208 |
+
qkv_bias=True,
|
| 209 |
+
drop_path=0.0,
|
| 210 |
+
norm_layer=partial(nn.LayerNorm, eps=1e-6),
|
| 211 |
+
window_size=0,
|
| 212 |
+
use_residual_block=False,
|
| 213 |
+
rope=None,
|
| 214 |
+
xattn=True,
|
| 215 |
+
):
|
| 216 |
+
"""
|
| 217 |
+
Args:
|
| 218 |
+
dim (int): Number of input channels.
|
| 219 |
+
num_heads (int): Number of attention heads in each ViT block.
|
| 220 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 221 |
+
qkv_bias (bool): If True, add a learnable bias to query, key, value.
|
| 222 |
+
drop_path (float): Stochastic depth rate.
|
| 223 |
+
norm_layer (nn.Module): Normalization layer.
|
| 224 |
+
act_layer (nn.Module): Activation layer.
|
| 225 |
+
use_rel_pos (bool): If True, add relative positional embeddings to the attention map.
|
| 226 |
+
rel_pos_zero_init (bool): If True, zero initialize relative positional parameters.
|
| 227 |
+
window_size (int): Window size for window attention blocks. If it equals 0, then not
|
| 228 |
+
use window attention.
|
| 229 |
+
use_residual_block (bool): If True, use a residual block after the MLP block.
|
| 230 |
+
input_size (int or None): Input resolution for calculating the relative positional
|
| 231 |
+
parameter size.
|
| 232 |
+
"""
|
| 233 |
+
super().__init__()
|
| 234 |
+
self.norm1 = norm_layer(dim)
|
| 235 |
+
self.attn = Attention(
|
| 236 |
+
dim,
|
| 237 |
+
num_heads=num_heads,
|
| 238 |
+
qkv_bias=qkv_bias,
|
| 239 |
+
rope=rope,
|
| 240 |
+
xattn=xattn,
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
from timm.models.layers import DropPath
|
| 244 |
+
|
| 245 |
+
self.drop_path = DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
|
| 246 |
+
self.norm2 = norm_layer(dim)
|
| 247 |
+
self.mlp = SwiGLU(
|
| 248 |
+
in_features=dim,
|
| 249 |
+
hidden_features=int(dim * mlp_ratio),
|
| 250 |
+
subln=True,
|
| 251 |
+
norm_layer=norm_layer,
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
self.window_size = window_size
|
| 255 |
+
|
| 256 |
+
self.use_residual_block = use_residual_block
|
| 257 |
+
if use_residual_block:
|
| 258 |
+
# Use a residual block with bottleneck channel as dim // 2
|
| 259 |
+
self.residual = ResBottleneckBlock(
|
| 260 |
+
in_channels=dim,
|
| 261 |
+
out_channels=dim,
|
| 262 |
+
bottleneck_channels=dim // 2,
|
| 263 |
+
norm="LN",
|
| 264 |
+
)
|
| 265 |
+
|
| 266 |
+
def forward(self, x):
|
| 267 |
+
shortcut = x
|
| 268 |
+
x = self.norm1(x)
|
| 269 |
+
|
| 270 |
+
# Window partition
|
| 271 |
+
if self.window_size > 0:
|
| 272 |
+
H, W = x.shape[1], x.shape[2]
|
| 273 |
+
x, pad_hw = window_partition(x, self.window_size)
|
| 274 |
+
|
| 275 |
+
x = self.attn(x)
|
| 276 |
+
|
| 277 |
+
# Reverse window partition
|
| 278 |
+
if self.window_size > 0:
|
| 279 |
+
x = window_unpartition(x, self.window_size, pad_hw, (H, W))
|
| 280 |
+
|
| 281 |
+
x = shortcut + self.drop_path(x)
|
| 282 |
+
x = x + self.drop_path(self.mlp(self.norm2(x)))
|
| 283 |
+
|
| 284 |
+
if self.use_residual_block:
|
| 285 |
+
x = self.residual(x.permute(0, 3, 1, 2)).permute(0, 2, 3, 1)
|
| 286 |
+
|
| 287 |
+
return x
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
class ViT(Backbone):
|
| 291 |
+
"""
|
| 292 |
+
This module implements Vision Transformer (ViT) backbone in :paper:`vitdet`.
|
| 293 |
+
"Exploring Plain Vision Transformer Backbones for Object Detection",
|
| 294 |
+
https://arxiv.org/abs/2203.16527
|
| 295 |
+
"""
|
| 296 |
+
|
| 297 |
+
def __init__(
|
| 298 |
+
self,
|
| 299 |
+
img_size=1024,
|
| 300 |
+
patch_size=16,
|
| 301 |
+
in_chans=3,
|
| 302 |
+
embed_dim=768,
|
| 303 |
+
depth=12,
|
| 304 |
+
num_heads=12,
|
| 305 |
+
mlp_ratio=4*2/3,
|
| 306 |
+
qkv_bias=True,
|
| 307 |
+
drop_path_rate=0.0,
|
| 308 |
+
norm_layer=partial(nn.LayerNorm, eps=1e-6),
|
| 309 |
+
act_layer=nn.GELU,
|
| 310 |
+
use_abs_pos=True,
|
| 311 |
+
use_rel_pos=False,
|
| 312 |
+
rope=True,
|
| 313 |
+
pt_hw_seq_len=16,
|
| 314 |
+
intp_freq=True,
|
| 315 |
+
window_size=0,
|
| 316 |
+
window_block_indexes=(),
|
| 317 |
+
residual_block_indexes=(),
|
| 318 |
+
use_act_checkpoint=False,
|
| 319 |
+
pretrain_img_size=224,
|
| 320 |
+
pretrain_use_cls_token=True,
|
| 321 |
+
out_feature="last_feat",
|
| 322 |
+
xattn=True,
|
| 323 |
+
frozen_stages=-1,
|
| 324 |
+
):
|
| 325 |
+
"""
|
| 326 |
+
Args:
|
| 327 |
+
img_size (int): Input image size.
|
| 328 |
+
patch_size (int): Patch size.
|
| 329 |
+
in_chans (int): Number of input image channels.
|
| 330 |
+
embed_dim (int): Patch embedding dimension.
|
| 331 |
+
depth (int): Depth of ViT.
|
| 332 |
+
num_heads (int): Number of attention heads in each ViT block.
|
| 333 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 334 |
+
qkv_bias (bool): If True, add a learnable bias to query, key, value.
|
| 335 |
+
drop_path_rate (float): Stochastic depth rate.
|
| 336 |
+
norm_layer (nn.Module): Normalization layer.
|
| 337 |
+
act_layer (nn.Module): Activation layer.
|
| 338 |
+
use_abs_pos (bool): If True, use absolute positional embeddings.
|
| 339 |
+
use_rel_pos (bool): If True, add relative positional embeddings to the attention map.
|
| 340 |
+
rel_pos_zero_init (bool): If True, zero initialize relative positional parameters.
|
| 341 |
+
window_size (int): Window size for window attention blocks.
|
| 342 |
+
window_block_indexes (list): Indexes for blocks using window attention.
|
| 343 |
+
residual_block_indexes (list): Indexes for blocks using conv propagation.
|
| 344 |
+
use_act_checkpoint (bool): If True, use activation checkpointing.
|
| 345 |
+
pretrain_img_size (int): input image size for pretraining models.
|
| 346 |
+
pretrain_use_cls_token (bool): If True, pretrainig models use class token.
|
| 347 |
+
out_feature (str): name of the feature from the last block.
|
| 348 |
+
"""
|
| 349 |
+
super().__init__()
|
| 350 |
+
self.pretrain_use_cls_token = pretrain_use_cls_token
|
| 351 |
+
|
| 352 |
+
self.patch_embed = PatchEmbed(
|
| 353 |
+
kernel_size=(patch_size, patch_size),
|
| 354 |
+
stride=(patch_size, patch_size),
|
| 355 |
+
in_chans=in_chans,
|
| 356 |
+
embed_dim=embed_dim,
|
| 357 |
+
)
|
| 358 |
+
|
| 359 |
+
if use_abs_pos:
|
| 360 |
+
# Initialize absolute positional embedding with pretrain image size.
|
| 361 |
+
num_patches = (pretrain_img_size // patch_size) * (pretrain_img_size // patch_size)
|
| 362 |
+
num_positions = (num_patches + 1) if pretrain_use_cls_token else num_patches
|
| 363 |
+
self.pos_embed = nn.Parameter(torch.zeros(1, num_positions, embed_dim))
|
| 364 |
+
else:
|
| 365 |
+
self.pos_embed = None
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
half_head_dim = embed_dim // num_heads // 2
|
| 369 |
+
hw_seq_len = img_size // patch_size
|
| 370 |
+
|
| 371 |
+
self.rope_win = VisionRotaryEmbeddingFast(
|
| 372 |
+
dim=half_head_dim,
|
| 373 |
+
pt_seq_len=pt_hw_seq_len,
|
| 374 |
+
ft_seq_len=window_size if intp_freq else None,
|
| 375 |
+
)
|
| 376 |
+
self.rope_glb = VisionRotaryEmbeddingFast(
|
| 377 |
+
dim=half_head_dim,
|
| 378 |
+
pt_seq_len=pt_hw_seq_len,
|
| 379 |
+
ft_seq_len=hw_seq_len if intp_freq else None,
|
| 380 |
+
)
|
| 381 |
+
|
| 382 |
+
# stochastic depth decay rule
|
| 383 |
+
dpr = [x.item() for x in torch.linspace(0, drop_path_rate, depth)]
|
| 384 |
+
|
| 385 |
+
self.blocks = nn.ModuleList()
|
| 386 |
+
for i in range(depth):
|
| 387 |
+
block = Block(
|
| 388 |
+
dim=embed_dim,
|
| 389 |
+
num_heads=num_heads,
|
| 390 |
+
mlp_ratio=mlp_ratio,
|
| 391 |
+
qkv_bias=qkv_bias,
|
| 392 |
+
drop_path=dpr[i],
|
| 393 |
+
norm_layer=norm_layer,
|
| 394 |
+
window_size=window_size if i in window_block_indexes else 0,
|
| 395 |
+
use_residual_block=i in residual_block_indexes,
|
| 396 |
+
rope=self.rope_win if i in window_block_indexes else self.rope_glb,
|
| 397 |
+
xattn=xattn
|
| 398 |
+
)
|
| 399 |
+
if use_act_checkpoint and i > frozen_stages - 1:
|
| 400 |
+
# TODO: use torch.utils.checkpoint
|
| 401 |
+
from fairscale.nn.checkpoint import checkpoint_wrapper
|
| 402 |
+
|
| 403 |
+
block = checkpoint_wrapper(block)
|
| 404 |
+
self.blocks.append(block)
|
| 405 |
+
|
| 406 |
+
self._out_feature_channels = {out_feature: embed_dim}
|
| 407 |
+
self._out_feature_strides = {out_feature: patch_size}
|
| 408 |
+
self._out_features = [out_feature]
|
| 409 |
+
|
| 410 |
+
if self.pos_embed is not None:
|
| 411 |
+
nn.init.trunc_normal_(self.pos_embed, std=0.02)
|
| 412 |
+
|
| 413 |
+
self.apply(self._init_weights)
|
| 414 |
+
|
| 415 |
+
self.frozen_stages = frozen_stages
|
| 416 |
+
self._freeze_stages()
|
| 417 |
+
|
| 418 |
+
def _freeze_stages(self):
|
| 419 |
+
if self.frozen_stages >= 0:
|
| 420 |
+
self.patch_embed.eval()
|
| 421 |
+
for param in self.patch_embed.parameters():
|
| 422 |
+
param.requires_grad = False
|
| 423 |
+
|
| 424 |
+
if self.frozen_stages >= 1 and self.pos_embed is not None:
|
| 425 |
+
self.pos_embed.requires_grad = False
|
| 426 |
+
|
| 427 |
+
if self.frozen_stages >= 2:
|
| 428 |
+
for i in range(0, self.frozen_stages - 1):
|
| 429 |
+
m = self.blocks[i]
|
| 430 |
+
m.eval()
|
| 431 |
+
for name, param in m.named_parameters():
|
| 432 |
+
vit_lr_decay_rate = get_vit_lr_decay_rate(f"backbone.net.blocks.{i}.{name}", lr_decay_rate=0.9, num_layers=len(self.blocks))
|
| 433 |
+
logger.info(f"freeze blocks.{i}.{name} {param.size()} {vit_lr_decay_rate}")
|
| 434 |
+
param.requires_grad = False
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
def _init_weights(self, m):
|
| 438 |
+
if isinstance(m, nn.Linear):
|
| 439 |
+
nn.init.trunc_normal_(m.weight, std=0.02)
|
| 440 |
+
if isinstance(m, nn.Linear) and m.bias is not None:
|
| 441 |
+
nn.init.constant_(m.bias, 0)
|
| 442 |
+
elif isinstance(m, nn.LayerNorm):
|
| 443 |
+
nn.init.constant_(m.bias, 0)
|
| 444 |
+
nn.init.constant_(m.weight, 1.0)
|
| 445 |
+
|
| 446 |
+
def forward(self, x):
|
| 447 |
+
x = self.patch_embed(x)
|
| 448 |
+
if self.pos_embed is not None:
|
| 449 |
+
x = x + get_abs_pos(
|
| 450 |
+
self.pos_embed, self.pretrain_use_cls_token, (x.shape[1], x.shape[2])
|
| 451 |
+
)
|
| 452 |
+
|
| 453 |
+
for blk in self.blocks:
|
| 454 |
+
x = blk(x)
|
| 455 |
+
|
| 456 |
+
outputs = {self._out_features[0]: x.permute(0, 3, 1, 2)}
|
| 457 |
+
return outputs
|
| 458 |
+
|
| 459 |
+
|
| 460 |
+
class SimpleFeaturePyramid(Backbone):
|
| 461 |
+
"""
|
| 462 |
+
This module implements SimpleFeaturePyramid in :paper:`vitdet`.
|
| 463 |
+
It creates pyramid features built on top of the input feature map.
|
| 464 |
+
"""
|
| 465 |
+
|
| 466 |
+
def __init__(
|
| 467 |
+
self,
|
| 468 |
+
net,
|
| 469 |
+
in_feature,
|
| 470 |
+
out_channels,
|
| 471 |
+
scale_factors,
|
| 472 |
+
top_block=None,
|
| 473 |
+
norm="LN",
|
| 474 |
+
square_pad=0,
|
| 475 |
+
):
|
| 476 |
+
"""
|
| 477 |
+
Args:
|
| 478 |
+
net (Backbone): module representing the subnetwork backbone.
|
| 479 |
+
Must be a subclass of :class:`Backbone`.
|
| 480 |
+
in_feature (str): names of the input feature maps coming
|
| 481 |
+
from the net.
|
| 482 |
+
out_channels (int): number of channels in the output feature maps.
|
| 483 |
+
scale_factors (list[float]): list of scaling factors to upsample or downsample
|
| 484 |
+
the input features for creating pyramid features.
|
| 485 |
+
top_block (nn.Module or None): if provided, an extra operation will
|
| 486 |
+
be performed on the output of the last (smallest resolution)
|
| 487 |
+
pyramid output, and the result will extend the result list. The top_block
|
| 488 |
+
further downsamples the feature map. It must have an attribute
|
| 489 |
+
"num_levels", meaning the number of extra pyramid levels added by
|
| 490 |
+
this block, and "in_feature", which is a string representing
|
| 491 |
+
its input feature (e.g., p5).
|
| 492 |
+
norm (str): the normalization to use.
|
| 493 |
+
square_pad (int): If > 0, require input images to be padded to specific square size.
|
| 494 |
+
"""
|
| 495 |
+
super(SimpleFeaturePyramid, self).__init__()
|
| 496 |
+
assert isinstance(net, Backbone)
|
| 497 |
+
|
| 498 |
+
self.scale_factors = scale_factors
|
| 499 |
+
|
| 500 |
+
input_shapes = net.output_shape()
|
| 501 |
+
strides = [int(input_shapes[in_feature].stride / scale) for scale in scale_factors]
|
| 502 |
+
_assert_strides_are_log2_contiguous(strides)
|
| 503 |
+
|
| 504 |
+
dim = input_shapes[in_feature].channels
|
| 505 |
+
self.stages = []
|
| 506 |
+
use_bias = norm == ""
|
| 507 |
+
for idx, scale in enumerate(scale_factors):
|
| 508 |
+
out_dim = dim
|
| 509 |
+
if scale == 4.0:
|
| 510 |
+
layers = [
|
| 511 |
+
nn.ConvTranspose2d(dim, dim // 2, kernel_size=2, stride=2),
|
| 512 |
+
get_norm(norm, dim // 2),
|
| 513 |
+
nn.GELU(),
|
| 514 |
+
nn.ConvTranspose2d(dim // 2, dim // 4, kernel_size=2, stride=2),
|
| 515 |
+
]
|
| 516 |
+
out_dim = dim // 4
|
| 517 |
+
elif scale == 2.0:
|
| 518 |
+
layers = [nn.ConvTranspose2d(dim, dim // 2, kernel_size=2, stride=2)]
|
| 519 |
+
out_dim = dim // 2
|
| 520 |
+
elif scale == 1.0:
|
| 521 |
+
layers = []
|
| 522 |
+
elif scale == 0.5:
|
| 523 |
+
layers = [nn.MaxPool2d(kernel_size=2, stride=2)]
|
| 524 |
+
else:
|
| 525 |
+
raise NotImplementedError(f"scale_factor={scale} is not supported yet.")
|
| 526 |
+
|
| 527 |
+
layers.extend(
|
| 528 |
+
[
|
| 529 |
+
Conv2d(
|
| 530 |
+
out_dim,
|
| 531 |
+
out_channels,
|
| 532 |
+
kernel_size=1,
|
| 533 |
+
bias=use_bias,
|
| 534 |
+
norm=get_norm(norm, out_channels),
|
| 535 |
+
),
|
| 536 |
+
Conv2d(
|
| 537 |
+
out_channels,
|
| 538 |
+
out_channels,
|
| 539 |
+
kernel_size=3,
|
| 540 |
+
padding=1,
|
| 541 |
+
bias=use_bias,
|
| 542 |
+
norm=get_norm(norm, out_channels),
|
| 543 |
+
),
|
| 544 |
+
]
|
| 545 |
+
)
|
| 546 |
+
layers = nn.Sequential(*layers)
|
| 547 |
+
|
| 548 |
+
stage = int(math.log2(strides[idx]))
|
| 549 |
+
self.add_module(f"simfp_{stage}", layers)
|
| 550 |
+
self.stages.append(layers)
|
| 551 |
+
|
| 552 |
+
self.net = net
|
| 553 |
+
self.in_feature = in_feature
|
| 554 |
+
self.top_block = top_block
|
| 555 |
+
# Return feature names are "p<stage>", like ["p2", "p3", ..., "p6"]
|
| 556 |
+
self._out_feature_strides = {"p{}".format(int(math.log2(s))): s for s in strides}
|
| 557 |
+
# top block output feature maps.
|
| 558 |
+
if self.top_block is not None:
|
| 559 |
+
for s in range(stage, stage + self.top_block.num_levels):
|
| 560 |
+
self._out_feature_strides["p{}".format(s + 1)] = 2 ** (s + 1)
|
| 561 |
+
|
| 562 |
+
self._out_features = list(self._out_feature_strides.keys())
|
| 563 |
+
self._out_feature_channels = {k: out_channels for k in self._out_features}
|
| 564 |
+
self._size_divisibility = strides[-1]
|
| 565 |
+
self._square_pad = square_pad
|
| 566 |
+
|
| 567 |
+
@property
|
| 568 |
+
def padding_constraints(self):
|
| 569 |
+
return {
|
| 570 |
+
"size_divisiblity": self._size_divisibility,
|
| 571 |
+
"square_size": self._square_pad,
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
def forward(self, x):
|
| 575 |
+
"""
|
| 576 |
+
Args:
|
| 577 |
+
x: Tensor of shape (N,C,H,W). H, W must be a multiple of ``self.size_divisibility``.
|
| 578 |
+
|
| 579 |
+
Returns:
|
| 580 |
+
dict[str->Tensor]:
|
| 581 |
+
mapping from feature map name to pyramid feature map tensor
|
| 582 |
+
in high to low resolution order. Returned feature names follow the FPN
|
| 583 |
+
convention: "p<stage>", where stage has stride = 2 ** stage e.g.,
|
| 584 |
+
["p2", "p3", ..., "p6"].
|
| 585 |
+
"""
|
| 586 |
+
bottom_up_features = self.net(x)
|
| 587 |
+
features = bottom_up_features[self.in_feature]
|
| 588 |
+
results = []
|
| 589 |
+
|
| 590 |
+
for stage in self.stages:
|
| 591 |
+
results.append(stage(features))
|
| 592 |
+
|
| 593 |
+
if self.top_block is not None:
|
| 594 |
+
if self.top_block.in_feature in bottom_up_features:
|
| 595 |
+
top_block_in_feature = bottom_up_features[self.top_block.in_feature]
|
| 596 |
+
else:
|
| 597 |
+
top_block_in_feature = results[self._out_features.index(self.top_block.in_feature)]
|
| 598 |
+
results.extend(self.top_block(top_block_in_feature))
|
| 599 |
+
assert len(self._out_features) == len(results)
|
| 600 |
+
return {f: res for f, res in zip(self._out_features, results)}
|
| 601 |
+
|
| 602 |
+
|
| 603 |
+
def get_vit_lr_decay_rate(name, lr_decay_rate=1.0, num_layers=12):
|
| 604 |
+
"""
|
| 605 |
+
Calculate lr decay rate for different ViT blocks.
|
| 606 |
+
Args:
|
| 607 |
+
name (string): parameter name.
|
| 608 |
+
lr_decay_rate (float): base lr decay rate.
|
| 609 |
+
num_layers (int): number of ViT blocks.
|
| 610 |
+
|
| 611 |
+
Returns:
|
| 612 |
+
lr decay rate for the given parameter.
|
| 613 |
+
"""
|
| 614 |
+
if name.startswith("model_vision."):
|
| 615 |
+
name = name[len("model_vision."):]
|
| 616 |
+
|
| 617 |
+
layer_id = num_layers + 1
|
| 618 |
+
if name.startswith("backbone"):
|
| 619 |
+
if ".pos_embed" in name or ".patch_embed" in name:
|
| 620 |
+
layer_id = 0
|
| 621 |
+
elif ".blocks." in name and ".residual." not in name:
|
| 622 |
+
layer_id = int(name[name.find(".blocks.") :].split(".")[2]) + 1
|
| 623 |
+
|
| 624 |
+
logger.info("get_vit_lr_decay_rate: name={} num_layers={} layer_id={} lr_decay_rate={}".format(name, num_layers, layer_id, lr_decay_rate ** (num_layers + 1 - layer_id)))
|
| 625 |
+
return lr_decay_rate ** (num_layers + 1 - layer_id)
|
approach/ovod/APE/ape/modeling/backbone/vit_eva_clip.py
ADDED
|
@@ -0,0 +1,931 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import math
|
| 3 |
+
from functools import partial
|
| 4 |
+
|
| 5 |
+
import fvcore.nn.weight_init as weight_init
|
| 6 |
+
import torch
|
| 7 |
+
import torch.nn as nn
|
| 8 |
+
import torch.nn.functional as F
|
| 9 |
+
|
| 10 |
+
from detectron2.layers import CNNBlockBase, Conv2d, get_norm
|
| 11 |
+
from detectron2.modeling.backbone.fpn import _assert_strides_are_log2_contiguous
|
| 12 |
+
|
| 13 |
+
from detectron2.modeling.backbone import Backbone
|
| 14 |
+
from .utils_eva02 import (
|
| 15 |
+
PatchEmbed,
|
| 16 |
+
add_decomposed_rel_pos,
|
| 17 |
+
get_abs_pos,
|
| 18 |
+
window_partition,
|
| 19 |
+
window_unpartition,
|
| 20 |
+
VisionRotaryEmbeddingFast,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
import xformers.ops as xops
|
| 25 |
+
except:
|
| 26 |
+
pass
|
| 27 |
+
|
| 28 |
+
try:
|
| 29 |
+
from apex.normalization import FusedLayerNorm
|
| 30 |
+
except:
|
| 31 |
+
pass
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
logger = logging.getLogger(__name__)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
__all__ = ["ViT", "SimpleFeaturePyramid", "get_vit_lr_decay_rate"]
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class DropPath(nn.Module):
|
| 42 |
+
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks)."""
|
| 43 |
+
|
| 44 |
+
def __init__(self, drop_prob=None):
|
| 45 |
+
super(DropPath, self).__init__()
|
| 46 |
+
self.drop_prob = drop_prob
|
| 47 |
+
|
| 48 |
+
def forward(self, x):
|
| 49 |
+
return drop_path(x, self.drop_prob, self.training)
|
| 50 |
+
|
| 51 |
+
def extra_repr(self) -> str:
|
| 52 |
+
return "p={}".format(self.drop_prob)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
class Mlp(nn.Module):
|
| 56 |
+
def __init__(
|
| 57 |
+
self,
|
| 58 |
+
in_features,
|
| 59 |
+
hidden_features=None,
|
| 60 |
+
out_features=None,
|
| 61 |
+
act_layer=nn.GELU,
|
| 62 |
+
norm_layer=nn.LayerNorm,
|
| 63 |
+
drop=0.0,
|
| 64 |
+
subln=False,
|
| 65 |
+
):
|
| 66 |
+
super().__init__()
|
| 67 |
+
out_features = out_features or in_features
|
| 68 |
+
hidden_features = hidden_features or in_features
|
| 69 |
+
self.fc1 = nn.Linear(in_features, hidden_features)
|
| 70 |
+
self.act = act_layer()
|
| 71 |
+
|
| 72 |
+
self.ffn_ln = norm_layer(hidden_features) if subln else nn.Identity()
|
| 73 |
+
|
| 74 |
+
self.fc2 = nn.Linear(hidden_features, out_features)
|
| 75 |
+
self.drop = nn.Dropout(drop)
|
| 76 |
+
|
| 77 |
+
def forward(self, x):
|
| 78 |
+
x = self.fc1(x)
|
| 79 |
+
x = self.act(x)
|
| 80 |
+
# x = self.drop(x)
|
| 81 |
+
# commit this for the orignal BERT implement
|
| 82 |
+
x = self.ffn_ln(x)
|
| 83 |
+
|
| 84 |
+
x = self.fc2(x)
|
| 85 |
+
x = self.drop(x)
|
| 86 |
+
return x
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
class SwiGLU(nn.Module):
|
| 90 |
+
def __init__(
|
| 91 |
+
self,
|
| 92 |
+
in_features,
|
| 93 |
+
hidden_features=None,
|
| 94 |
+
out_features=None,
|
| 95 |
+
act_layer=nn.SiLU,
|
| 96 |
+
drop=0.0,
|
| 97 |
+
norm_layer=nn.LayerNorm,
|
| 98 |
+
subln=False,
|
| 99 |
+
):
|
| 100 |
+
super().__init__()
|
| 101 |
+
out_features = out_features or in_features
|
| 102 |
+
hidden_features = hidden_features or in_features
|
| 103 |
+
|
| 104 |
+
self.w1 = nn.Linear(in_features, hidden_features)
|
| 105 |
+
self.w2 = nn.Linear(in_features, hidden_features)
|
| 106 |
+
|
| 107 |
+
self.act = act_layer()
|
| 108 |
+
self.ffn_ln = norm_layer(hidden_features) if subln else nn.Identity()
|
| 109 |
+
self.w3 = nn.Linear(hidden_features, out_features)
|
| 110 |
+
|
| 111 |
+
self.drop = nn.Dropout(drop)
|
| 112 |
+
|
| 113 |
+
def forward(self, x):
|
| 114 |
+
x1 = self.w1(x)
|
| 115 |
+
x2 = self.w2(x)
|
| 116 |
+
hidden = self.act(x1) * x2
|
| 117 |
+
x = self.ffn_ln(hidden)
|
| 118 |
+
x = self.w3(x)
|
| 119 |
+
x = self.drop(x)
|
| 120 |
+
return x
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
class Attention(nn.Module):
|
| 124 |
+
def __init__(
|
| 125 |
+
self,
|
| 126 |
+
dim,
|
| 127 |
+
num_heads=8,
|
| 128 |
+
qkv_bias=False,
|
| 129 |
+
qk_scale=None,
|
| 130 |
+
attn_drop=0.0,
|
| 131 |
+
proj_drop=0.0,
|
| 132 |
+
window_size=0,
|
| 133 |
+
attn_head_dim=None,
|
| 134 |
+
xattn=False,
|
| 135 |
+
rope=None,
|
| 136 |
+
subln=False,
|
| 137 |
+
norm_layer=nn.LayerNorm,
|
| 138 |
+
):
|
| 139 |
+
super().__init__()
|
| 140 |
+
self.num_heads = num_heads
|
| 141 |
+
head_dim = dim // num_heads
|
| 142 |
+
if attn_head_dim is not None:
|
| 143 |
+
head_dim = attn_head_dim
|
| 144 |
+
all_head_dim = head_dim * self.num_heads
|
| 145 |
+
self.scale = qk_scale or head_dim**-0.5
|
| 146 |
+
|
| 147 |
+
self.subln = subln
|
| 148 |
+
if self.subln:
|
| 149 |
+
self.q_proj = nn.Linear(dim, all_head_dim, bias=False)
|
| 150 |
+
self.k_proj = nn.Linear(dim, all_head_dim, bias=False)
|
| 151 |
+
self.v_proj = nn.Linear(dim, all_head_dim, bias=False)
|
| 152 |
+
else:
|
| 153 |
+
self.qkv = nn.Linear(dim, all_head_dim * 3, bias=False)
|
| 154 |
+
|
| 155 |
+
if qkv_bias:
|
| 156 |
+
self.q_bias = nn.Parameter(torch.zeros(all_head_dim))
|
| 157 |
+
self.v_bias = nn.Parameter(torch.zeros(all_head_dim))
|
| 158 |
+
else:
|
| 159 |
+
self.q_bias = None
|
| 160 |
+
self.v_bias = None
|
| 161 |
+
|
| 162 |
+
if window_size and False:
|
| 163 |
+
self.window_size = window_size
|
| 164 |
+
self.num_relative_distance = (2 * window_size[0] - 1) * (2 * window_size[1] - 1) + 3
|
| 165 |
+
self.relative_position_bias_table = nn.Parameter(
|
| 166 |
+
torch.zeros(self.num_relative_distance, num_heads)
|
| 167 |
+
) # 2*Wh-1 * 2*Ww-1, nH
|
| 168 |
+
# cls to token & token 2 cls & cls to cls
|
| 169 |
+
|
| 170 |
+
# get pair-wise relative position index for each token inside the window
|
| 171 |
+
coords_h = torch.arange(window_size[0])
|
| 172 |
+
coords_w = torch.arange(window_size[1])
|
| 173 |
+
coords = torch.stack(torch.meshgrid([coords_h, coords_w])) # 2, Wh, Ww
|
| 174 |
+
coords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww
|
| 175 |
+
relative_coords = (
|
| 176 |
+
coords_flatten[:, :, None] - coords_flatten[:, None, :]
|
| 177 |
+
) # 2, Wh*Ww, Wh*Ww
|
| 178 |
+
relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2
|
| 179 |
+
relative_coords[:, :, 0] += window_size[0] - 1 # shift to start from 0
|
| 180 |
+
relative_coords[:, :, 1] += window_size[1] - 1
|
| 181 |
+
relative_coords[:, :, 0] *= 2 * window_size[1] - 1
|
| 182 |
+
relative_position_index = torch.zeros(
|
| 183 |
+
size=(window_size[0] * window_size[1] + 1,) * 2, dtype=relative_coords.dtype
|
| 184 |
+
)
|
| 185 |
+
relative_position_index[1:, 1:] = relative_coords.sum(-1) # Wh*Ww, Wh*Ww
|
| 186 |
+
relative_position_index[0, 0:] = self.num_relative_distance - 3
|
| 187 |
+
relative_position_index[0:, 0] = self.num_relative_distance - 2
|
| 188 |
+
relative_position_index[0, 0] = self.num_relative_distance - 1
|
| 189 |
+
|
| 190 |
+
self.register_buffer("relative_position_index", relative_position_index)
|
| 191 |
+
else:
|
| 192 |
+
self.window_size = None
|
| 193 |
+
self.relative_position_bias_table = None
|
| 194 |
+
self.relative_position_index = None
|
| 195 |
+
|
| 196 |
+
self.attn_drop = nn.Dropout(attn_drop)
|
| 197 |
+
self.inner_attn_ln = norm_layer(all_head_dim) if subln else nn.Identity()
|
| 198 |
+
# self.proj = nn.Linear(all_head_dim, all_head_dim)
|
| 199 |
+
self.proj = nn.Linear(all_head_dim, dim)
|
| 200 |
+
self.proj_drop = nn.Dropout(proj_drop)
|
| 201 |
+
self.xattn = xattn
|
| 202 |
+
self.xattn_drop = attn_drop
|
| 203 |
+
|
| 204 |
+
self.rope = rope
|
| 205 |
+
|
| 206 |
+
def forward(self, x, rel_pos_bias=None, attn_mask=None):
|
| 207 |
+
# B, N, C = x.shape
|
| 208 |
+
|
| 209 |
+
B, H, W, C = x.shape
|
| 210 |
+
x = x.view(B, -1, C)
|
| 211 |
+
N = H * W
|
| 212 |
+
|
| 213 |
+
if self.subln:
|
| 214 |
+
q = F.linear(input=x, weight=self.q_proj.weight, bias=self.q_bias)
|
| 215 |
+
k = F.linear(input=x, weight=self.k_proj.weight, bias=None)
|
| 216 |
+
v = F.linear(input=x, weight=self.v_proj.weight, bias=self.v_bias)
|
| 217 |
+
|
| 218 |
+
q = q.reshape(B, N, self.num_heads, -1).permute(0, 2, 1, 3) # B, num_heads, N, C
|
| 219 |
+
k = k.reshape(B, N, self.num_heads, -1).permute(0, 2, 1, 3)
|
| 220 |
+
v = v.reshape(B, N, self.num_heads, -1).permute(0, 2, 1, 3)
|
| 221 |
+
else:
|
| 222 |
+
|
| 223 |
+
qkv_bias = None
|
| 224 |
+
if self.q_bias is not None:
|
| 225 |
+
qkv_bias = torch.cat(
|
| 226 |
+
(self.q_bias, torch.zeros_like(self.v_bias, requires_grad=False), self.v_bias)
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
qkv = F.linear(input=x, weight=self.qkv.weight, bias=qkv_bias)
|
| 230 |
+
qkv = qkv.reshape(B, N, 3, self.num_heads, -1).permute(
|
| 231 |
+
2, 0, 3, 1, 4
|
| 232 |
+
) # 3, B, num_heads, N, C
|
| 233 |
+
q, k, v = qkv[0], qkv[1], qkv[2]
|
| 234 |
+
|
| 235 |
+
if self.rope:
|
| 236 |
+
# slightly fast impl
|
| 237 |
+
# q_t = q[:, :, 1:, :]
|
| 238 |
+
# ro_q_t = self.rope(q_t)
|
| 239 |
+
# q = torch.cat((q[:, :, :1, :], ro_q_t), -2).type_as(v)
|
| 240 |
+
|
| 241 |
+
# k_t = k[:, :, 1:, :]
|
| 242 |
+
# ro_k_t = self.rope(k_t)
|
| 243 |
+
# k = torch.cat((k[:, :, :1, :], ro_k_t), -2).type_as(v)
|
| 244 |
+
|
| 245 |
+
## rope
|
| 246 |
+
q = self.rope(q).type_as(v)
|
| 247 |
+
k = self.rope(k).type_as(v)
|
| 248 |
+
|
| 249 |
+
if self.xattn and not (torch.jit.is_scripting() or torch.jit.is_tracing()):
|
| 250 |
+
q = q.permute(0, 2, 1, 3) # B, num_heads, N, C -> B, N, num_heads, C
|
| 251 |
+
k = k.permute(0, 2, 1, 3)
|
| 252 |
+
v = v.permute(0, 2, 1, 3)
|
| 253 |
+
|
| 254 |
+
x = xops.memory_efficient_attention(
|
| 255 |
+
q,
|
| 256 |
+
k,
|
| 257 |
+
v,
|
| 258 |
+
p=self.xattn_drop,
|
| 259 |
+
scale=self.scale,
|
| 260 |
+
)
|
| 261 |
+
x = x.reshape(B, N, -1)
|
| 262 |
+
x = self.inner_attn_ln(x)
|
| 263 |
+
x = self.proj(x)
|
| 264 |
+
x = self.proj_drop(x)
|
| 265 |
+
else:
|
| 266 |
+
q = q * self.scale
|
| 267 |
+
attn = q @ k.transpose(-2, -1)
|
| 268 |
+
|
| 269 |
+
if self.relative_position_bias_table is not None:
|
| 270 |
+
relative_position_bias = self.relative_position_bias_table[
|
| 271 |
+
self.relative_position_index.view(-1)
|
| 272 |
+
].view(
|
| 273 |
+
self.window_size[0] * self.window_size[1] + 1,
|
| 274 |
+
self.window_size[0] * self.window_size[1] + 1,
|
| 275 |
+
-1,
|
| 276 |
+
) # Wh*Ww,Wh*Ww,nH
|
| 277 |
+
relative_position_bias = relative_position_bias.permute(
|
| 278 |
+
2, 0, 1
|
| 279 |
+
).contiguous() # nH, Wh*Ww, Wh*Ww
|
| 280 |
+
attn = attn + relative_position_bias.unsqueeze(0).type_as(attn)
|
| 281 |
+
|
| 282 |
+
if rel_pos_bias is not None:
|
| 283 |
+
attn = attn + rel_pos_bias.type_as(attn)
|
| 284 |
+
|
| 285 |
+
if attn_mask is not None:
|
| 286 |
+
attn_mask = attn_mask.bool()
|
| 287 |
+
attn = attn.masked_fill(~attn_mask[:, None, None, :], float("-inf"))
|
| 288 |
+
|
| 289 |
+
attn = attn.softmax(dim=-1)
|
| 290 |
+
attn = self.attn_drop(attn)
|
| 291 |
+
|
| 292 |
+
x = (attn @ v).transpose(1, 2).reshape(B, N, -1)
|
| 293 |
+
x = self.inner_attn_ln(x)
|
| 294 |
+
x = self.proj(x)
|
| 295 |
+
x = self.proj_drop(x)
|
| 296 |
+
|
| 297 |
+
x = x.view(B, H, W, C)
|
| 298 |
+
|
| 299 |
+
return x
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
class ResBottleneckBlock(CNNBlockBase):
|
| 303 |
+
"""
|
| 304 |
+
The standard bottleneck residual block without the last activation layer.
|
| 305 |
+
It contains 3 conv layers with kernels 1x1, 3x3, 1x1.
|
| 306 |
+
"""
|
| 307 |
+
|
| 308 |
+
def __init__(
|
| 309 |
+
self,
|
| 310 |
+
in_channels,
|
| 311 |
+
out_channels,
|
| 312 |
+
bottleneck_channels,
|
| 313 |
+
norm="LN",
|
| 314 |
+
act_layer=nn.GELU,
|
| 315 |
+
):
|
| 316 |
+
"""
|
| 317 |
+
Args:
|
| 318 |
+
in_channels (int): Number of input channels.
|
| 319 |
+
out_channels (int): Number of output channels.
|
| 320 |
+
bottleneck_channels (int): number of output channels for the 3x3
|
| 321 |
+
"bottleneck" conv layers.
|
| 322 |
+
norm (str or callable): normalization for all conv layers.
|
| 323 |
+
See :func:`layers.get_norm` for supported format.
|
| 324 |
+
act_layer (callable): activation for all conv layers.
|
| 325 |
+
"""
|
| 326 |
+
super().__init__(in_channels, out_channels, 1)
|
| 327 |
+
|
| 328 |
+
self.conv1 = Conv2d(in_channels, bottleneck_channels, 1, bias=False)
|
| 329 |
+
self.norm1 = get_norm(norm, bottleneck_channels)
|
| 330 |
+
self.act1 = act_layer()
|
| 331 |
+
|
| 332 |
+
self.conv2 = Conv2d(
|
| 333 |
+
bottleneck_channels,
|
| 334 |
+
bottleneck_channels,
|
| 335 |
+
3,
|
| 336 |
+
padding=1,
|
| 337 |
+
bias=False,
|
| 338 |
+
)
|
| 339 |
+
self.norm2 = get_norm(norm, bottleneck_channels)
|
| 340 |
+
self.act2 = act_layer()
|
| 341 |
+
|
| 342 |
+
self.conv3 = Conv2d(bottleneck_channels, out_channels, 1, bias=False)
|
| 343 |
+
self.norm3 = get_norm(norm, out_channels)
|
| 344 |
+
|
| 345 |
+
for layer in [self.conv1, self.conv2, self.conv3]:
|
| 346 |
+
weight_init.c2_msra_fill(layer)
|
| 347 |
+
for layer in [self.norm1, self.norm2]:
|
| 348 |
+
layer.weight.data.fill_(1.0)
|
| 349 |
+
layer.bias.data.zero_()
|
| 350 |
+
# zero init last norm layer.
|
| 351 |
+
self.norm3.weight.data.zero_()
|
| 352 |
+
self.norm3.bias.data.zero_()
|
| 353 |
+
|
| 354 |
+
def forward(self, x):
|
| 355 |
+
out = x
|
| 356 |
+
for layer in self.children():
|
| 357 |
+
out = layer(out)
|
| 358 |
+
|
| 359 |
+
out = x + out
|
| 360 |
+
return out
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
class Block(nn.Module):
|
| 364 |
+
"""Transformer blocks with support of window attention and residual propagation blocks"""
|
| 365 |
+
|
| 366 |
+
def __init__(
|
| 367 |
+
self,
|
| 368 |
+
dim,
|
| 369 |
+
num_heads,
|
| 370 |
+
mlp_ratio=4.0,
|
| 371 |
+
qkv_bias=False,
|
| 372 |
+
qk_scale=None,
|
| 373 |
+
drop=0.0,
|
| 374 |
+
attn_drop=0.0,
|
| 375 |
+
drop_path=0.0,
|
| 376 |
+
init_values=None,
|
| 377 |
+
act_layer=nn.GELU,
|
| 378 |
+
norm_layer=partial(nn.LayerNorm, eps=1e-6),
|
| 379 |
+
window_size=0,
|
| 380 |
+
use_residual_block=False,
|
| 381 |
+
attn_head_dim=None,
|
| 382 |
+
rope=None,
|
| 383 |
+
xattn=False,
|
| 384 |
+
postnorm=False,
|
| 385 |
+
subln=False,
|
| 386 |
+
naiveswiglu=False,
|
| 387 |
+
):
|
| 388 |
+
"""
|
| 389 |
+
Args:
|
| 390 |
+
dim (int): Number of input channels.
|
| 391 |
+
num_heads (int): Number of attention heads in each ViT block.
|
| 392 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 393 |
+
qkv_bias (bool): If True, add a learnable bias to query, key, value.
|
| 394 |
+
drop_path (float): Stochastic depth rate.
|
| 395 |
+
norm_layer (nn.Module): Normalization layer.
|
| 396 |
+
act_layer (nn.Module): Activation layer.
|
| 397 |
+
use_rel_pos (bool): If True, add relative positional embeddings to the attention map.
|
| 398 |
+
rel_pos_zero_init (bool): If True, zero initialize relative positional parameters.
|
| 399 |
+
window_size (int): Window size for window attention blocks. If it equals 0, then not
|
| 400 |
+
use window attention.
|
| 401 |
+
use_residual_block (bool): If True, use a residual block after the MLP block.
|
| 402 |
+
input_size (int or None): Input resolution for calculating the relative positional
|
| 403 |
+
parameter size.
|
| 404 |
+
"""
|
| 405 |
+
super().__init__()
|
| 406 |
+
self.norm1 = norm_layer(dim)
|
| 407 |
+
self.attn = Attention(
|
| 408 |
+
dim,
|
| 409 |
+
num_heads=num_heads,
|
| 410 |
+
qkv_bias=qkv_bias,
|
| 411 |
+
qk_scale=qk_scale,
|
| 412 |
+
attn_drop=attn_drop,
|
| 413 |
+
proj_drop=drop,
|
| 414 |
+
window_size=window_size,
|
| 415 |
+
attn_head_dim=attn_head_dim,
|
| 416 |
+
rope=rope,
|
| 417 |
+
xattn=xattn,
|
| 418 |
+
subln=subln,
|
| 419 |
+
norm_layer=norm_layer,
|
| 420 |
+
)
|
| 421 |
+
|
| 422 |
+
from timm.models.layers import DropPath
|
| 423 |
+
|
| 424 |
+
self.drop_path = DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
|
| 425 |
+
self.norm2 = norm_layer(dim)
|
| 426 |
+
mlp_hidden_dim = int(dim * mlp_ratio)
|
| 427 |
+
|
| 428 |
+
if naiveswiglu:
|
| 429 |
+
self.mlp = SwiGLU(
|
| 430 |
+
in_features=dim,
|
| 431 |
+
hidden_features=mlp_hidden_dim,
|
| 432 |
+
subln=subln,
|
| 433 |
+
norm_layer=norm_layer,
|
| 434 |
+
)
|
| 435 |
+
else:
|
| 436 |
+
self.mlp = Mlp(
|
| 437 |
+
in_features=dim,
|
| 438 |
+
hidden_features=mlp_hidden_dim,
|
| 439 |
+
act_layer=act_layer,
|
| 440 |
+
subln=subln,
|
| 441 |
+
drop=drop,
|
| 442 |
+
)
|
| 443 |
+
|
| 444 |
+
if init_values is not None and init_values > 0:
|
| 445 |
+
self.gamma_1 = nn.Parameter(init_values * torch.ones((dim)), requires_grad=True)
|
| 446 |
+
self.gamma_2 = nn.Parameter(init_values * torch.ones((dim)), requires_grad=True)
|
| 447 |
+
else:
|
| 448 |
+
self.gamma_1, self.gamma_2 = None, None
|
| 449 |
+
|
| 450 |
+
self.postnorm = postnorm
|
| 451 |
+
|
| 452 |
+
self.window_size = window_size
|
| 453 |
+
|
| 454 |
+
self.use_residual_block = use_residual_block
|
| 455 |
+
if use_residual_block:
|
| 456 |
+
# Use a residual block with bottleneck channel as dim // 2
|
| 457 |
+
self.residual = ResBottleneckBlock(
|
| 458 |
+
in_channels=dim,
|
| 459 |
+
out_channels=dim,
|
| 460 |
+
bottleneck_channels=dim // 2,
|
| 461 |
+
norm="LN",
|
| 462 |
+
)
|
| 463 |
+
|
| 464 |
+
def forward(self, x, rel_pos_bias=None, attn_mask=None):
|
| 465 |
+
if self.gamma_1 is None:
|
| 466 |
+
if self.postnorm:
|
| 467 |
+
shortcut = x
|
| 468 |
+
|
| 469 |
+
# Window partition
|
| 470 |
+
if self.window_size > 0:
|
| 471 |
+
H, W = x.shape[1], x.shape[2]
|
| 472 |
+
x, pad_hw = window_partition(x, self.window_size)
|
| 473 |
+
|
| 474 |
+
x = self.attn(x, rel_pos_bias=rel_pos_bias, attn_mask=attn_mask)
|
| 475 |
+
|
| 476 |
+
# Reverse window partition
|
| 477 |
+
if self.window_size > 0:
|
| 478 |
+
x = window_unpartition(x, self.window_size, pad_hw, (H, W))
|
| 479 |
+
|
| 480 |
+
x = self.norm1(x)
|
| 481 |
+
x = shortcut + self.drop_path(x)
|
| 482 |
+
|
| 483 |
+
# x = x + self.drop_path(self.norm1(self.attn(x, rel_pos_bias=rel_pos_bias, attn_mask=attn_mask)))
|
| 484 |
+
x = x + self.drop_path(self.norm2(self.mlp(x)))
|
| 485 |
+
else:
|
| 486 |
+
shortcut = x
|
| 487 |
+
x = self.norm1(x)
|
| 488 |
+
|
| 489 |
+
# Window partition
|
| 490 |
+
if self.window_size > 0:
|
| 491 |
+
H, W = x.shape[1], x.shape[2]
|
| 492 |
+
x, pad_hw = window_partition(x, self.window_size)
|
| 493 |
+
|
| 494 |
+
x = self.attn(x, rel_pos_bias=rel_pos_bias, attn_mask=attn_mask)
|
| 495 |
+
|
| 496 |
+
# Reverse window partition
|
| 497 |
+
if self.window_size > 0:
|
| 498 |
+
x = window_unpartition(x, self.window_size, pad_hw, (H, W))
|
| 499 |
+
|
| 500 |
+
x = shortcut + self.drop_path(x)
|
| 501 |
+
|
| 502 |
+
# x = x + self.drop_path(self.attn(self.norm1(x), rel_pos_bias=rel_pos_bias, attn_mask=attn_mask))
|
| 503 |
+
x = x + self.drop_path(self.mlp(self.norm2(x)))
|
| 504 |
+
else:
|
| 505 |
+
if self.postnorm:
|
| 506 |
+
shortcut = x
|
| 507 |
+
|
| 508 |
+
# Window partition
|
| 509 |
+
if self.window_size > 0:
|
| 510 |
+
H, W = x.shape[1], x.shape[2]
|
| 511 |
+
x, pad_hw = window_partition(x, self.window_size)
|
| 512 |
+
|
| 513 |
+
x = self.attn(x, rel_pos_bias=rel_pos_bias, attn_mask=attn_mask)
|
| 514 |
+
|
| 515 |
+
# Reverse window partition
|
| 516 |
+
if self.window_size > 0:
|
| 517 |
+
x = window_unpartition(x, self.window_size, pad_hw, (H, W))
|
| 518 |
+
|
| 519 |
+
x = self.norm1(x)
|
| 520 |
+
x = shortcut + self.drop_path(self.gamma_1 * x)
|
| 521 |
+
|
| 522 |
+
# x = x + self.drop_path(self.gamma_1 * self.norm1(self.attn(x, rel_pos_bias=rel_pos_bias, attn_mask=attn_mask)))
|
| 523 |
+
x = x + self.drop_path(self.gamma_2 * self.norm2(self.mlp(x)))
|
| 524 |
+
else:
|
| 525 |
+
shortcut = x
|
| 526 |
+
x = self.norm1(x)
|
| 527 |
+
|
| 528 |
+
# Window partition
|
| 529 |
+
if self.window_size > 0:
|
| 530 |
+
H, W = x.shape[1], x.shape[2]
|
| 531 |
+
x, pad_hw = window_partition(x, self.window_size)
|
| 532 |
+
|
| 533 |
+
x = self.attn(x, rel_pos_bias=rel_pos_bias, attn_mask=attn_mask)
|
| 534 |
+
|
| 535 |
+
# Reverse window partition
|
| 536 |
+
if self.window_size > 0:
|
| 537 |
+
x = window_unpartition(x, self.window_size, pad_hw, (H, W))
|
| 538 |
+
|
| 539 |
+
x = shortcut + self.drop_path(self.gamma_1 * x)
|
| 540 |
+
|
| 541 |
+
# x = x + self.drop_path(self.gamma_1 * self.attn(self.norm1(x), rel_pos_bias=rel_pos_bias, attn_mask=attn_mask))
|
| 542 |
+
x = x + self.drop_path(self.gamma_2 * self.mlp(self.norm2(x)))
|
| 543 |
+
|
| 544 |
+
if self.use_residual_block:
|
| 545 |
+
x = self.residual(x.permute(0, 3, 1, 2)).permute(0, 2, 3, 1)
|
| 546 |
+
|
| 547 |
+
return x
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
class ViT(Backbone):
|
| 551 |
+
"""
|
| 552 |
+
This module implements Vision Transformer (ViT) backbone in :paper:`vitdet`.
|
| 553 |
+
"Exploring Plain Vision Transformer Backbones for Object Detection",
|
| 554 |
+
https://arxiv.org/abs/2203.16527
|
| 555 |
+
"""
|
| 556 |
+
|
| 557 |
+
def __init__(
|
| 558 |
+
self,
|
| 559 |
+
img_size=1024,
|
| 560 |
+
patch_size=16,
|
| 561 |
+
in_chans=3,
|
| 562 |
+
embed_dim=768,
|
| 563 |
+
depth=12,
|
| 564 |
+
num_heads=12,
|
| 565 |
+
mlp_ratio=4.0,
|
| 566 |
+
qkv_bias=False,
|
| 567 |
+
qk_scale=None,
|
| 568 |
+
drop_rate=0.0,
|
| 569 |
+
attn_drop_rate=0.0,
|
| 570 |
+
drop_path_rate=0.0,
|
| 571 |
+
norm_layer=partial(nn.LayerNorm, eps=1e-6),
|
| 572 |
+
init_values=None,
|
| 573 |
+
use_abs_pos=True,
|
| 574 |
+
use_rel_pos=False,
|
| 575 |
+
rope=False,
|
| 576 |
+
postnorm=False,
|
| 577 |
+
pt_hw_seq_len=16,
|
| 578 |
+
intp_freq=False,
|
| 579 |
+
naiveswiglu=False,
|
| 580 |
+
subln=False,
|
| 581 |
+
window_size=0,
|
| 582 |
+
window_block_indexes=(),
|
| 583 |
+
residual_block_indexes=(),
|
| 584 |
+
use_act_checkpoint=False,
|
| 585 |
+
pretrain_img_size=224,
|
| 586 |
+
pretrain_use_cls_token=True,
|
| 587 |
+
out_feature="last_feat",
|
| 588 |
+
xattn=False,
|
| 589 |
+
frozen_stages=-1,
|
| 590 |
+
):
|
| 591 |
+
"""
|
| 592 |
+
Args:
|
| 593 |
+
img_size (int): Input image size.
|
| 594 |
+
patch_size (int): Patch size.
|
| 595 |
+
in_chans (int): Number of input image channels.
|
| 596 |
+
embed_dim (int): Patch embedding dimension.
|
| 597 |
+
depth (int): Depth of ViT.
|
| 598 |
+
num_heads (int): Number of attention heads in each ViT block.
|
| 599 |
+
mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
|
| 600 |
+
qkv_bias (bool): If True, add a learnable bias to query, key, value.
|
| 601 |
+
drop_path_rate (float): Stochastic depth rate.
|
| 602 |
+
norm_layer (nn.Module): Normalization layer.
|
| 603 |
+
act_layer (nn.Module): Activation layer.
|
| 604 |
+
use_abs_pos (bool): If True, use absolute positional embeddings.
|
| 605 |
+
use_rel_pos (bool): If True, add relative positional embeddings to the attention map.
|
| 606 |
+
rel_pos_zero_init (bool): If True, zero initialize relative positional parameters.
|
| 607 |
+
window_size (int): Window size for window attention blocks.
|
| 608 |
+
window_block_indexes (list): Indexes for blocks using window attention.
|
| 609 |
+
residual_block_indexes (list): Indexes for blocks using conv propagation.
|
| 610 |
+
use_act_checkpoint (bool): If True, use activation checkpointing.
|
| 611 |
+
pretrain_img_size (int): input image size for pretraining models.
|
| 612 |
+
pretrain_use_cls_token (bool): If True, pretrainig models use class token.
|
| 613 |
+
out_feature (str): name of the feature from the last block.
|
| 614 |
+
"""
|
| 615 |
+
super().__init__()
|
| 616 |
+
self.pretrain_use_cls_token = pretrain_use_cls_token
|
| 617 |
+
|
| 618 |
+
self.patch_embed = PatchEmbed(
|
| 619 |
+
kernel_size=(patch_size, patch_size),
|
| 620 |
+
stride=(patch_size, patch_size),
|
| 621 |
+
in_chans=in_chans,
|
| 622 |
+
embed_dim=embed_dim,
|
| 623 |
+
)
|
| 624 |
+
|
| 625 |
+
if use_abs_pos:
|
| 626 |
+
# Initialize absolute positional embedding with pretrain image size.
|
| 627 |
+
num_patches = (pretrain_img_size // patch_size) * (pretrain_img_size // patch_size)
|
| 628 |
+
num_positions = (num_patches + 1) if pretrain_use_cls_token else num_patches
|
| 629 |
+
self.pos_embed = nn.Parameter(torch.zeros(1, num_positions, embed_dim))
|
| 630 |
+
else:
|
| 631 |
+
self.pos_embed = None
|
| 632 |
+
|
| 633 |
+
if rope:
|
| 634 |
+
half_head_dim = embed_dim // num_heads // 2
|
| 635 |
+
hw_seq_len = img_size // patch_size
|
| 636 |
+
self.rope_win = VisionRotaryEmbeddingFast(
|
| 637 |
+
dim=half_head_dim,
|
| 638 |
+
pt_seq_len=pt_hw_seq_len,
|
| 639 |
+
ft_seq_len=window_size if intp_freq else None,
|
| 640 |
+
)
|
| 641 |
+
self.rope_glb = VisionRotaryEmbeddingFast(
|
| 642 |
+
dim=half_head_dim,
|
| 643 |
+
pt_seq_len=pt_hw_seq_len,
|
| 644 |
+
ft_seq_len=hw_seq_len if intp_freq else None,
|
| 645 |
+
)
|
| 646 |
+
else:
|
| 647 |
+
self.rope_win = None
|
| 648 |
+
self.rope_glb = None
|
| 649 |
+
|
| 650 |
+
self.naiveswiglu = naiveswiglu
|
| 651 |
+
|
| 652 |
+
# stochastic depth decay rule
|
| 653 |
+
dpr = [x.item() for x in torch.linspace(0, drop_path_rate, depth)]
|
| 654 |
+
|
| 655 |
+
self.blocks = nn.ModuleList()
|
| 656 |
+
for i in range(depth):
|
| 657 |
+
block = Block(
|
| 658 |
+
dim=embed_dim,
|
| 659 |
+
num_heads=num_heads,
|
| 660 |
+
mlp_ratio=mlp_ratio,
|
| 661 |
+
qkv_bias=qkv_bias,
|
| 662 |
+
qk_scale=qk_scale,
|
| 663 |
+
drop=drop_rate,
|
| 664 |
+
attn_drop=attn_drop_rate,
|
| 665 |
+
drop_path=dpr[i],
|
| 666 |
+
norm_layer=norm_layer,
|
| 667 |
+
init_values=init_values,
|
| 668 |
+
window_size=window_size if i in window_block_indexes else 0,
|
| 669 |
+
postnorm=postnorm,
|
| 670 |
+
subln=subln,
|
| 671 |
+
naiveswiglu=naiveswiglu,
|
| 672 |
+
use_residual_block=i in residual_block_indexes,
|
| 673 |
+
rope=self.rope_win if i in window_block_indexes else self.rope_glb,
|
| 674 |
+
xattn=xattn,
|
| 675 |
+
)
|
| 676 |
+
if use_act_checkpoint and i > frozen_stages - 1:
|
| 677 |
+
# TODO: use torch.utils.checkpoint
|
| 678 |
+
from fairscale.nn.checkpoint import checkpoint_wrapper
|
| 679 |
+
|
| 680 |
+
block = checkpoint_wrapper(block)
|
| 681 |
+
self.blocks.append(block)
|
| 682 |
+
|
| 683 |
+
self._out_feature_channels = {out_feature: embed_dim}
|
| 684 |
+
self._out_feature_strides = {out_feature: patch_size}
|
| 685 |
+
self._out_features = [out_feature]
|
| 686 |
+
|
| 687 |
+
if self.pos_embed is not None:
|
| 688 |
+
nn.init.trunc_normal_(self.pos_embed, std=0.02)
|
| 689 |
+
|
| 690 |
+
self.apply(self._init_weights)
|
| 691 |
+
|
| 692 |
+
self.frozen_stages = frozen_stages
|
| 693 |
+
self._freeze_stages()
|
| 694 |
+
|
| 695 |
+
def _freeze_stages(self):
|
| 696 |
+
if self.frozen_stages >= 0:
|
| 697 |
+
self.patch_embed.eval()
|
| 698 |
+
for param in self.patch_embed.parameters():
|
| 699 |
+
param.requires_grad = False
|
| 700 |
+
|
| 701 |
+
if self.frozen_stages >= 1 and self.pos_embed is not None:
|
| 702 |
+
self.pos_embed.requires_grad = False
|
| 703 |
+
|
| 704 |
+
if self.frozen_stages >= 2:
|
| 705 |
+
for i in range(0, self.frozen_stages - 1):
|
| 706 |
+
m = self.blocks[i]
|
| 707 |
+
m.eval()
|
| 708 |
+
for name, param in m.named_parameters():
|
| 709 |
+
vit_lr_decay_rate = get_vit_lr_decay_rate(f"backbone.net.blocks.{i}.{name}", lr_decay_rate=0.9, num_layers=len(self.blocks))
|
| 710 |
+
logger.info(f"freeze blocks.{i}.{name} {param.size()} {vit_lr_decay_rate}")
|
| 711 |
+
param.requires_grad = False
|
| 712 |
+
|
| 713 |
+
|
| 714 |
+
def _init_weights(self, m):
|
| 715 |
+
if isinstance(m, nn.Linear):
|
| 716 |
+
nn.init.trunc_normal_(m.weight, std=0.02)
|
| 717 |
+
if isinstance(m, nn.Linear) and m.bias is not None:
|
| 718 |
+
nn.init.constant_(m.bias, 0)
|
| 719 |
+
elif isinstance(m, nn.LayerNorm):
|
| 720 |
+
nn.init.constant_(m.bias, 0)
|
| 721 |
+
nn.init.constant_(m.weight, 1.0)
|
| 722 |
+
|
| 723 |
+
def forward(self, x):
|
| 724 |
+
x = self.patch_embed(x)
|
| 725 |
+
if self.pos_embed is not None:
|
| 726 |
+
x = x + get_abs_pos(
|
| 727 |
+
self.pos_embed, self.pretrain_use_cls_token, (x.shape[1], x.shape[2])
|
| 728 |
+
)
|
| 729 |
+
|
| 730 |
+
for blk in self.blocks:
|
| 731 |
+
x = blk(x)
|
| 732 |
+
|
| 733 |
+
outputs = {self._out_features[0]: x.permute(0, 3, 1, 2)}
|
| 734 |
+
return outputs
|
| 735 |
+
|
| 736 |
+
|
| 737 |
+
class SimpleFeaturePyramid(Backbone):
|
| 738 |
+
"""
|
| 739 |
+
This module implements SimpleFeaturePyramid in :paper:`vitdet`.
|
| 740 |
+
It creates pyramid features built on top of the input feature map.
|
| 741 |
+
"""
|
| 742 |
+
|
| 743 |
+
def __init__(
|
| 744 |
+
self,
|
| 745 |
+
net,
|
| 746 |
+
in_feature,
|
| 747 |
+
out_channels,
|
| 748 |
+
scale_factors,
|
| 749 |
+
top_block=None,
|
| 750 |
+
norm="LN",
|
| 751 |
+
square_pad=0,
|
| 752 |
+
):
|
| 753 |
+
"""
|
| 754 |
+
Args:
|
| 755 |
+
net (Backbone): module representing the subnetwork backbone.
|
| 756 |
+
Must be a subclass of :class:`Backbone`.
|
| 757 |
+
in_feature (str): names of the input feature maps coming
|
| 758 |
+
from the net.
|
| 759 |
+
out_channels (int): number of channels in the output feature maps.
|
| 760 |
+
scale_factors (list[float]): list of scaling factors to upsample or downsample
|
| 761 |
+
the input features for creating pyramid features.
|
| 762 |
+
top_block (nn.Module or None): if provided, an extra operation will
|
| 763 |
+
be performed on the output of the last (smallest resolution)
|
| 764 |
+
pyramid output, and the result will extend the result list. The top_block
|
| 765 |
+
further downsamples the feature map. It must have an attribute
|
| 766 |
+
"num_levels", meaning the number of extra pyramid levels added by
|
| 767 |
+
this block, and "in_feature", which is a string representing
|
| 768 |
+
its input feature (e.g., p5).
|
| 769 |
+
norm (str): the normalization to use.
|
| 770 |
+
square_pad (int): If > 0, require input images to be padded to specific square size.
|
| 771 |
+
"""
|
| 772 |
+
super(SimpleFeaturePyramid, self).__init__()
|
| 773 |
+
assert isinstance(net, Backbone)
|
| 774 |
+
|
| 775 |
+
self.scale_factors = scale_factors
|
| 776 |
+
|
| 777 |
+
input_shapes = net.output_shape()
|
| 778 |
+
strides = [int(input_shapes[in_feature].stride / scale) for scale in scale_factors]
|
| 779 |
+
_assert_strides_are_log2_contiguous(strides)
|
| 780 |
+
|
| 781 |
+
dim = input_shapes[in_feature].channels
|
| 782 |
+
self.stages = []
|
| 783 |
+
use_bias = norm == ""
|
| 784 |
+
for idx, scale in enumerate(scale_factors):
|
| 785 |
+
out_dim = dim
|
| 786 |
+
if scale == 4.0:
|
| 787 |
+
layers = [
|
| 788 |
+
nn.ConvTranspose2d(dim, dim // 2, kernel_size=2, stride=2),
|
| 789 |
+
get_norm(norm, dim // 2),
|
| 790 |
+
nn.GELU(),
|
| 791 |
+
nn.ConvTranspose2d(dim // 2, dim // 4, kernel_size=2, stride=2),
|
| 792 |
+
]
|
| 793 |
+
out_dim = dim // 4
|
| 794 |
+
elif scale == 2.0:
|
| 795 |
+
layers = [nn.ConvTranspose2d(dim, dim // 2, kernel_size=2, stride=2)]
|
| 796 |
+
out_dim = dim // 2
|
| 797 |
+
elif scale == 1.0:
|
| 798 |
+
layers = []
|
| 799 |
+
elif scale == 0.5:
|
| 800 |
+
layers = [nn.MaxPool2d(kernel_size=2, stride=2)]
|
| 801 |
+
else:
|
| 802 |
+
raise NotImplementedError(f"scale_factor={scale} is not supported yet.")
|
| 803 |
+
|
| 804 |
+
layers.extend(
|
| 805 |
+
[
|
| 806 |
+
Conv2d(
|
| 807 |
+
out_dim,
|
| 808 |
+
out_channels,
|
| 809 |
+
kernel_size=1,
|
| 810 |
+
bias=use_bias,
|
| 811 |
+
norm=get_norm(norm, out_channels),
|
| 812 |
+
),
|
| 813 |
+
Conv2d(
|
| 814 |
+
out_channels,
|
| 815 |
+
out_channels,
|
| 816 |
+
kernel_size=3,
|
| 817 |
+
padding=1,
|
| 818 |
+
bias=use_bias,
|
| 819 |
+
norm=get_norm(norm, out_channels),
|
| 820 |
+
),
|
| 821 |
+
]
|
| 822 |
+
)
|
| 823 |
+
layers = nn.Sequential(*layers)
|
| 824 |
+
|
| 825 |
+
stage = int(math.log2(strides[idx]))
|
| 826 |
+
self.add_module(f"simfp_{stage}", layers)
|
| 827 |
+
self.stages.append(layers)
|
| 828 |
+
|
| 829 |
+
self.net = net
|
| 830 |
+
self.in_feature = in_feature
|
| 831 |
+
self.top_block = top_block
|
| 832 |
+
# Return feature names are "p<stage>", like ["p2", "p3", ..., "p6"]
|
| 833 |
+
self._out_feature_strides = {"p{}".format(int(math.log2(s))): s for s in strides}
|
| 834 |
+
# top block output feature maps.
|
| 835 |
+
if self.top_block is not None:
|
| 836 |
+
for s in range(stage, stage + self.top_block.num_levels):
|
| 837 |
+
self._out_feature_strides["p{}".format(s + 1)] = 2 ** (s + 1)
|
| 838 |
+
|
| 839 |
+
self._out_features = list(self._out_feature_strides.keys())
|
| 840 |
+
self._out_feature_channels = {k: out_channels for k in self._out_features}
|
| 841 |
+
self._size_divisibility = strides[-1]
|
| 842 |
+
self._square_pad = square_pad
|
| 843 |
+
|
| 844 |
+
@property
|
| 845 |
+
def padding_constraints(self):
|
| 846 |
+
return {
|
| 847 |
+
"size_divisiblity": self._size_divisibility,
|
| 848 |
+
"square_size": self._square_pad,
|
| 849 |
+
}
|
| 850 |
+
|
| 851 |
+
def forward(self, x):
|
| 852 |
+
"""
|
| 853 |
+
Args:
|
| 854 |
+
x: Tensor of shape (N,C,H,W). H, W must be a multiple of ``self.size_divisibility``.
|
| 855 |
+
|
| 856 |
+
Returns:
|
| 857 |
+
dict[str->Tensor]:
|
| 858 |
+
mapping from feature map name to pyramid feature map tensor
|
| 859 |
+
in high to low resolution order. Returned feature names follow the FPN
|
| 860 |
+
convention: "p<stage>", where stage has stride = 2 ** stage e.g.,
|
| 861 |
+
["p2", "p3", ..., "p6"].
|
| 862 |
+
"""
|
| 863 |
+
bottom_up_features = self.net(x)
|
| 864 |
+
features = bottom_up_features[self.in_feature]
|
| 865 |
+
results = []
|
| 866 |
+
|
| 867 |
+
for stage in self.stages:
|
| 868 |
+
results.append(stage(features))
|
| 869 |
+
# with torch.cuda.amp.autocast(enabled=False):
|
| 870 |
+
# results.append(stage(features.float()))
|
| 871 |
+
if torch.any(torch.isnan(results[-1])):
|
| 872 |
+
v = results[-1]
|
| 873 |
+
print("stage", len(results), v, v.size(), v.max(), v.min(), "all finite:", torch.all(torch.isfinite(v)), "any nan:", torch.any(torch.isnan(v)))
|
| 874 |
+
v = features
|
| 875 |
+
print(self.in_feature, v, v.size(), v.max(), v.min(), "all finite:", torch.all(torch.isfinite(v)), "any nan:", torch.any(torch.isnan(v)))
|
| 876 |
+
print("stage parameters", stage, sum([_.sum() for _ in stage.parameters()]))
|
| 877 |
+
for name, param in stage.named_parameters():
|
| 878 |
+
print(name, param.size(), param.sum(), param.max(), param.min(), "all finite:", torch.all(torch.isfinite(param)), "any nan:", torch.any(torch.isnan(param)))
|
| 879 |
+
for name, buf in stage.named_buffers():
|
| 880 |
+
print(name, buf.size(), buf.sum(), buf.max(), buf.min(), "all finite:", torch.all(torch.isfinite(buf)), "any nan:", torch.any(torch.isnan(buf)))
|
| 881 |
+
|
| 882 |
+
with torch.cuda.amp.autocast(enabled=False):
|
| 883 |
+
results.pop()
|
| 884 |
+
results.append(stage(features.float()))
|
| 885 |
+
# results[-1] = stage(features.float())
|
| 886 |
+
|
| 887 |
+
if self.top_block is not None:
|
| 888 |
+
if self.top_block.in_feature in bottom_up_features:
|
| 889 |
+
top_block_in_feature = bottom_up_features[self.top_block.in_feature]
|
| 890 |
+
else:
|
| 891 |
+
top_block_in_feature = results[self._out_features.index(self.top_block.in_feature)]
|
| 892 |
+
results.extend(self.top_block(top_block_in_feature))
|
| 893 |
+
# with torch.cuda.amp.autocast(enabled=False):
|
| 894 |
+
# results.extend(self.top_block(top_block_in_feature.float()))
|
| 895 |
+
if torch.any(torch.isnan(results[-1])):
|
| 896 |
+
v = results[-1]
|
| 897 |
+
print(len(results), v, v.size(), v.max(), v.min(), "all finite:", torch.all(torch.isfinite(v)), "any nan:", torch.any(torch.isnan(v)))
|
| 898 |
+
v = top_block_in_feature
|
| 899 |
+
print(self.top_block.in_feature, v, v.size(), v.max(), v.min(), "all finite:", torch.all(torch.isfinite(v)), "any nan:", torch.any(torch.isnan(v)))
|
| 900 |
+
print("top_block parameters", self.top_block, sum([_.sum() for _ in self.top_block.parameters()]))
|
| 901 |
+
assert len(self._out_features) == len(results)
|
| 902 |
+
return {f: res for f, res in zip(self._out_features, results)}
|
| 903 |
+
|
| 904 |
+
|
| 905 |
+
def get_vit_lr_decay_rate(name, lr_decay_rate=1.0, num_layers=12):
|
| 906 |
+
"""
|
| 907 |
+
Calculate lr decay rate for different ViT blocks.
|
| 908 |
+
Args:
|
| 909 |
+
name (string): parameter name.
|
| 910 |
+
lr_decay_rate (float): base lr decay rate.
|
| 911 |
+
num_layers (int): number of ViT blocks.
|
| 912 |
+
|
| 913 |
+
Returns:
|
| 914 |
+
lr decay rate for the given parameter.
|
| 915 |
+
"""
|
| 916 |
+
if name.startswith("model_vision."):
|
| 917 |
+
name = name[len("model_vision.") :]
|
| 918 |
+
|
| 919 |
+
layer_id = num_layers + 1
|
| 920 |
+
if name.startswith("backbone"):
|
| 921 |
+
if ".pos_embed" in name or ".patch_embed" in name:
|
| 922 |
+
layer_id = 0
|
| 923 |
+
elif ".blocks." in name and ".residual." not in name:
|
| 924 |
+
layer_id = int(name[name.find(".blocks.") :].split(".")[2]) + 1
|
| 925 |
+
|
| 926 |
+
logger.info(
|
| 927 |
+
"get_vit_lr_decay_rate: name={} num_layers={} layer_id={} lr_decay_rate={}".format(
|
| 928 |
+
name, num_layers, layer_id, lr_decay_rate ** (num_layers + 1 - layer_id)
|
| 929 |
+
)
|
| 930 |
+
)
|
| 931 |
+
return lr_decay_rate ** (num_layers + 1 - layer_id)
|
approach/ovod/APE/ape/modeling/text/bert_wrapper.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from torch import nn
|
| 3 |
+
from torch.cuda.amp import autocast
|
| 4 |
+
|
| 5 |
+
from transformers import (
|
| 6 |
+
AutoConfig,
|
| 7 |
+
AutoModelForSeq2SeqLM,
|
| 8 |
+
AutoTokenizer,
|
| 9 |
+
BertConfig,
|
| 10 |
+
BertModel,
|
| 11 |
+
RobertaConfig,
|
| 12 |
+
RobertaModel,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class Bert(nn.Module):
|
| 17 |
+
def __init__(
|
| 18 |
+
self,
|
| 19 |
+
pretrained_model_name_or_path,
|
| 20 |
+
dtype="float32",
|
| 21 |
+
**kwargs,
|
| 22 |
+
):
|
| 23 |
+
super().__init__(**kwargs)
|
| 24 |
+
|
| 25 |
+
self.dtype = getattr(torch, dtype)
|
| 26 |
+
|
| 27 |
+
self.config = BertConfig.from_pretrained(
|
| 28 |
+
pretrained_model_name_or_path=pretrained_model_name_or_path
|
| 29 |
+
)
|
| 30 |
+
self.bert_model = BertModel.from_pretrained(
|
| 31 |
+
pretrained_model_name_or_path=pretrained_model_name_or_path,
|
| 32 |
+
add_pooling_layer=False,
|
| 33 |
+
)
|
| 34 |
+
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 35 |
+
pretrained_model_name_or_path=pretrained_model_name_or_path
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
self.bert_model.eval()
|
| 39 |
+
for name, param in self.bert_model.named_parameters():
|
| 40 |
+
param.requires_grad = False
|
| 41 |
+
param.data = param.data.to(self.dtype)
|
| 42 |
+
|
| 43 |
+
self.register_buffer("unused_tensor", torch.zeros(1), False)
|
| 44 |
+
|
| 45 |
+
self.text_list_to_feature = {}
|
| 46 |
+
|
| 47 |
+
@property
|
| 48 |
+
def device(self):
|
| 49 |
+
return self.unused_tensor.device
|
| 50 |
+
|
| 51 |
+
@autocast(enabled=False)
|
| 52 |
+
@torch.no_grad()
|
| 53 |
+
def forward_text(self, text_list, cache=False):
|
| 54 |
+
|
| 55 |
+
if cache and tuple(text_list) in self.text_list_to_feature:
|
| 56 |
+
return self.text_list_to_feature[tuple(text_list)]
|
| 57 |
+
|
| 58 |
+
tokenized = self.tokenizer.batch_encode_plus(
|
| 59 |
+
text_list,
|
| 60 |
+
max_length=256,
|
| 61 |
+
padding="max_length" if True else "longest",
|
| 62 |
+
return_special_tokens_mask=True,
|
| 63 |
+
return_tensors="pt",
|
| 64 |
+
truncation=True,
|
| 65 |
+
).to(self.device)
|
| 66 |
+
|
| 67 |
+
input_ids = tokenized.input_ids # (bs, seq_len)
|
| 68 |
+
attention_mask = tokenized.attention_mask # (bs, seq_len)
|
| 69 |
+
|
| 70 |
+
max_batch_size = 500
|
| 71 |
+
if len(input_ids) > max_batch_size:
|
| 72 |
+
chunck_num = len(input_ids) // max_batch_size + 1
|
| 73 |
+
outputss = [
|
| 74 |
+
self.bert_model(
|
| 75 |
+
input_ids=input_ids[
|
| 76 |
+
chunck_id * max_batch_size : (chunck_id + 1) * max_batch_size
|
| 77 |
+
],
|
| 78 |
+
attention_mask=attention_mask[
|
| 79 |
+
chunck_id * max_batch_size : (chunck_id + 1) * max_batch_size
|
| 80 |
+
],
|
| 81 |
+
)
|
| 82 |
+
for chunck_id in range(chunck_num)
|
| 83 |
+
]
|
| 84 |
+
|
| 85 |
+
last_hidden_state = torch.cat(
|
| 86 |
+
[outputs.last_hidden_state for outputs in outputss], dim=0
|
| 87 |
+
)
|
| 88 |
+
else:
|
| 89 |
+
outputs = self.bert_model(
|
| 90 |
+
input_ids=input_ids,
|
| 91 |
+
attention_mask=attention_mask,
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
last_hidden_state = outputs.last_hidden_state
|
| 95 |
+
|
| 96 |
+
end_token_idx = input_ids.argmin(dim=-1) - 1
|
| 97 |
+
|
| 98 |
+
ret = {
|
| 99 |
+
"end_token_idx": end_token_idx,
|
| 100 |
+
"attention_mask": attention_mask,
|
| 101 |
+
"last_hidden_state": last_hidden_state,
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
if cache:
|
| 105 |
+
self.text_list_to_feature[tuple(text_list)] = ret
|
| 106 |
+
|
| 107 |
+
return ret
|
approach/ovod/APE/ape/modeling/text/clip_wrapper.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
from collections import OrderedDict
|
| 3 |
+
from typing import List, Union
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
from torch import nn
|
| 7 |
+
|
| 8 |
+
from clip.simple_tokenizer import SimpleTokenizer as _Tokenizer
|
| 9 |
+
|
| 10 |
+
__all__ = ["tokenize"]
|
| 11 |
+
|
| 12 |
+
count = 0
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class LayerNorm(nn.LayerNorm):
|
| 16 |
+
"""Subclass torch's LayerNorm to handle fp16."""
|
| 17 |
+
|
| 18 |
+
def forward(self, x: torch.Tensor):
|
| 19 |
+
orig_type = x.dtype
|
| 20 |
+
ret = super().forward(x.type(torch.float32))
|
| 21 |
+
return ret.type(orig_type)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class QuickGELU(nn.Module):
|
| 25 |
+
def forward(self, x: torch.Tensor):
|
| 26 |
+
return x * torch.sigmoid(1.702 * x)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class ResidualAttentionBlock(nn.Module):
|
| 30 |
+
def __init__(self, d_model: int, n_head: int, attn_mask: torch.Tensor = None):
|
| 31 |
+
super().__init__()
|
| 32 |
+
|
| 33 |
+
self.attn = nn.MultiheadAttention(d_model, n_head)
|
| 34 |
+
self.ln_1 = LayerNorm(d_model)
|
| 35 |
+
self.mlp = nn.Sequential(
|
| 36 |
+
OrderedDict(
|
| 37 |
+
[
|
| 38 |
+
("c_fc", nn.Linear(d_model, d_model * 4)),
|
| 39 |
+
("gelu", QuickGELU()),
|
| 40 |
+
("c_proj", nn.Linear(d_model * 4, d_model)),
|
| 41 |
+
]
|
| 42 |
+
)
|
| 43 |
+
)
|
| 44 |
+
self.ln_2 = LayerNorm(d_model)
|
| 45 |
+
self.attn_mask = attn_mask
|
| 46 |
+
|
| 47 |
+
def attention(self, x: torch.Tensor):
|
| 48 |
+
self.attn_mask = (
|
| 49 |
+
self.attn_mask.to(dtype=x.dtype, device=x.device)
|
| 50 |
+
if self.attn_mask is not None
|
| 51 |
+
else None
|
| 52 |
+
)
|
| 53 |
+
return self.attn(x, x, x, need_weights=False, attn_mask=self.attn_mask)[0]
|
| 54 |
+
|
| 55 |
+
def forward(self, x: torch.Tensor):
|
| 56 |
+
x = x + self.attention(self.ln_1(x))
|
| 57 |
+
x = x + self.mlp(self.ln_2(x))
|
| 58 |
+
return x
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class Transformer(nn.Module):
|
| 62 |
+
def __init__(self, width: int, layers: int, heads: int, attn_mask: torch.Tensor = None):
|
| 63 |
+
super().__init__()
|
| 64 |
+
self.width = width
|
| 65 |
+
self.layers = layers
|
| 66 |
+
self.resblocks = nn.Sequential(
|
| 67 |
+
*[ResidualAttentionBlock(width, heads, attn_mask) for _ in range(layers)]
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
def forward(self, x: torch.Tensor):
|
| 71 |
+
return self.resblocks(x)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class CLIPTEXT(nn.Module):
|
| 75 |
+
def __init__(
|
| 76 |
+
self,
|
| 77 |
+
embed_dim=512,
|
| 78 |
+
context_length=77,
|
| 79 |
+
vocab_size=49408,
|
| 80 |
+
transformer_width=512,
|
| 81 |
+
transformer_heads=8,
|
| 82 |
+
transformer_layers=12,
|
| 83 |
+
):
|
| 84 |
+
super().__init__()
|
| 85 |
+
|
| 86 |
+
self._tokenizer = _Tokenizer()
|
| 87 |
+
self.context_length = context_length
|
| 88 |
+
|
| 89 |
+
self.transformer = Transformer(
|
| 90 |
+
width=transformer_width,
|
| 91 |
+
layers=transformer_layers,
|
| 92 |
+
heads=transformer_heads,
|
| 93 |
+
attn_mask=self.build_attention_mask(),
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
self.vocab_size = vocab_size
|
| 97 |
+
self.token_embedding = nn.Embedding(vocab_size, transformer_width)
|
| 98 |
+
self.positional_embedding = nn.Parameter(
|
| 99 |
+
torch.empty(self.context_length, transformer_width)
|
| 100 |
+
)
|
| 101 |
+
self.ln_final = LayerNorm(transformer_width)
|
| 102 |
+
|
| 103 |
+
self.text_projection = nn.Parameter(torch.empty(transformer_width, embed_dim))
|
| 104 |
+
|
| 105 |
+
self.initialize_parameters()
|
| 106 |
+
|
| 107 |
+
def initialize_parameters(self):
|
| 108 |
+
nn.init.normal_(self.token_embedding.weight, std=0.02)
|
| 109 |
+
nn.init.normal_(self.positional_embedding, std=0.01)
|
| 110 |
+
|
| 111 |
+
proj_std = (self.transformer.width**-0.5) * ((2 * self.transformer.layers) ** -0.5)
|
| 112 |
+
attn_std = self.transformer.width**-0.5
|
| 113 |
+
fc_std = (2 * self.transformer.width) ** -0.5
|
| 114 |
+
for block in self.transformer.resblocks:
|
| 115 |
+
nn.init.normal_(block.attn.in_proj_weight, std=attn_std)
|
| 116 |
+
nn.init.normal_(block.attn.out_proj.weight, std=proj_std)
|
| 117 |
+
nn.init.normal_(block.mlp.c_fc.weight, std=fc_std)
|
| 118 |
+
nn.init.normal_(block.mlp.c_proj.weight, std=proj_std)
|
| 119 |
+
|
| 120 |
+
if self.text_projection is not None:
|
| 121 |
+
nn.init.normal_(self.text_projection, std=self.transformer.width**-0.5)
|
| 122 |
+
|
| 123 |
+
def build_attention_mask(self):
|
| 124 |
+
mask = torch.empty(self.context_length, self.context_length)
|
| 125 |
+
mask.fill_(float("-inf"))
|
| 126 |
+
mask.triu_(1) # zero out the lower diagonal
|
| 127 |
+
return mask
|
| 128 |
+
|
| 129 |
+
@property
|
| 130 |
+
def device(self):
|
| 131 |
+
return self.text_projection.device
|
| 132 |
+
|
| 133 |
+
@property
|
| 134 |
+
def dtype(self):
|
| 135 |
+
return self.text_projection.dtype
|
| 136 |
+
|
| 137 |
+
def tokenize(self, texts: Union[str, List[str]], context_length: int = 77) -> torch.LongTensor:
|
| 138 |
+
""" """
|
| 139 |
+
if isinstance(texts, str):
|
| 140 |
+
texts = [texts]
|
| 141 |
+
|
| 142 |
+
sot_token = self._tokenizer.encoder["<|startoftext|>"]
|
| 143 |
+
eot_token = self._tokenizer.encoder["<|endoftext|>"]
|
| 144 |
+
all_tokens = [[sot_token] + self._tokenizer.encode(text) + [eot_token] for text in texts]
|
| 145 |
+
result = torch.zeros(len(all_tokens), context_length, dtype=torch.long)
|
| 146 |
+
|
| 147 |
+
for i, tokens in enumerate(all_tokens):
|
| 148 |
+
if len(tokens) > context_length:
|
| 149 |
+
st = torch.randint(len(tokens) - context_length + 1, (1,))[0].item()
|
| 150 |
+
tokens = tokens[st : st + context_length]
|
| 151 |
+
result[i, : len(tokens)] = torch.tensor(tokens)
|
| 152 |
+
|
| 153 |
+
return result
|
| 154 |
+
|
| 155 |
+
def encode_text(self, text):
|
| 156 |
+
x = self.token_embedding(text).type(self.dtype) # [batch_size, n_ctx, d_model]
|
| 157 |
+
x = x + self.positional_embedding.type(self.dtype)
|
| 158 |
+
x = x.permute(1, 0, 2) # NLD -> LND
|
| 159 |
+
x = self.transformer(x)
|
| 160 |
+
x = x.permute(1, 0, 2) # LND -> NLD
|
| 161 |
+
x = self.ln_final(x).type(self.dtype)
|
| 162 |
+
x = x[torch.arange(x.shape[0]), text.argmax(dim=-1)] @ self.text_projection
|
| 163 |
+
return x
|
| 164 |
+
|
| 165 |
+
def forward(self, captions):
|
| 166 |
+
"""
|
| 167 |
+
captions: list of strings
|
| 168 |
+
"""
|
| 169 |
+
text = self.tokenize(captions).to(self.device) # B x L x D
|
| 170 |
+
features = self.encode_text(text) # B x D
|
| 171 |
+
return features
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def build_clip_text_encoder(model_path, pretrain=True):
|
| 175 |
+
logger = logging.getLogger(__name__)
|
| 176 |
+
if pretrain:
|
| 177 |
+
logger.info("Loading pretrained CLIP " + model_path)
|
| 178 |
+
import clip
|
| 179 |
+
|
| 180 |
+
print(model_path)
|
| 181 |
+
pretrained_model, _ = clip.load(model_path, device="cpu")
|
| 182 |
+
state_dict = pretrained_model.state_dict()
|
| 183 |
+
to_delete_keys = ["logit_scale", "input_resolution", "context_length", "vocab_size"] + [
|
| 184 |
+
k for k in state_dict.keys() if k.startswith("visual.")
|
| 185 |
+
]
|
| 186 |
+
for k in to_delete_keys:
|
| 187 |
+
if k in state_dict:
|
| 188 |
+
del state_dict[k]
|
| 189 |
+
|
| 190 |
+
embed_dim = state_dict["text_projection"].shape[1]
|
| 191 |
+
context_length = state_dict["positional_embedding"].shape[0]
|
| 192 |
+
vocab_size = state_dict["token_embedding.weight"].shape[0]
|
| 193 |
+
transformer_width = state_dict["ln_final.weight"].shape[0]
|
| 194 |
+
transformer_heads = transformer_width // 64
|
| 195 |
+
transformer_layers = len(
|
| 196 |
+
set(k.split(".")[2] for k in state_dict if k.startswith(f"transformer.resblocks"))
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
text_encoder = CLIPTEXT(
|
| 200 |
+
embed_dim,
|
| 201 |
+
context_length,
|
| 202 |
+
vocab_size,
|
| 203 |
+
transformer_width,
|
| 204 |
+
transformer_heads,
|
| 205 |
+
transformer_layers,
|
| 206 |
+
)
|
| 207 |
+
text_encoder.load_state_dict(state_dict)
|
| 208 |
+
|
| 209 |
+
else:
|
| 210 |
+
logger.info("Building CLIPTEXT")
|
| 211 |
+
text_encoder = CLIPTEXT(embed_dim=embed_dim)
|
| 212 |
+
return text_encoder
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
def get_clip_embeddings(text_model, vocabulary, prompt="a "):
|
| 216 |
+
if isinstance(text_model, str):
|
| 217 |
+
text_encoder = build_clip_text_encoder(text_model, pretrain=True)
|
| 218 |
+
text_encoder.eval()
|
| 219 |
+
else:
|
| 220 |
+
text_encoder = text_model
|
| 221 |
+
text_encoder.eval()
|
| 222 |
+
texts = [prompt + x for x in vocabulary]
|
| 223 |
+
emb = text_encoder(texts).detach().contiguous()
|
| 224 |
+
return emb
|
approach/ovod/APE/ape/modeling/text/clip_wrapper_eva02.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
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class EVA02CLIP(nn.Module):
|
| 9 |
+
def __init__(
|
| 10 |
+
self,
|
| 11 |
+
clip_model="EVA02-CLIP-B-16",
|
| 12 |
+
cache_dir="EVA02_CLIP_B_psz16_s8B.pt",
|
| 13 |
+
dtype="float32",
|
| 14 |
+
max_batch_size=2560,
|
| 15 |
+
):
|
| 16 |
+
super().__init__()
|
| 17 |
+
self.net, _, _ = create_model_and_transforms(
|
| 18 |
+
clip_model, pretrained=cache_dir, force_custom_clip=True
|
| 19 |
+
)
|
| 20 |
+
self.tokenizer = get_tokenizer(clip_model)
|
| 21 |
+
|
| 22 |
+
if dtype == "bfloat16":
|
| 23 |
+
self.dtype = torch.bfloat16
|
| 24 |
+
elif dtype == "float16":
|
| 25 |
+
self.dtype = torch.float16
|
| 26 |
+
else:
|
| 27 |
+
self.dtype = torch.float32
|
| 28 |
+
|
| 29 |
+
del self.net.visual
|
| 30 |
+
self.net.eval()
|
| 31 |
+
for name, param in self.net.named_parameters():
|
| 32 |
+
param.requires_grad = False
|
| 33 |
+
param.data = param.data.to(self.dtype)
|
| 34 |
+
|
| 35 |
+
self.register_buffer("unused_tensor", torch.zeros(1), False)
|
| 36 |
+
|
| 37 |
+
self.text_list_to_feature = {}
|
| 38 |
+
|
| 39 |
+
self.max_batch_size = max_batch_size
|
| 40 |
+
|
| 41 |
+
@property
|
| 42 |
+
def device(self):
|
| 43 |
+
return self.unused_tensor.device
|
| 44 |
+
|
| 45 |
+
def infer_image(self, features):
|
| 46 |
+
x = features["image"][0]
|
| 47 |
+
x = self.net.encode_image(x)
|
| 48 |
+
return x
|
| 49 |
+
|
| 50 |
+
@autocast(enabled=False)
|
| 51 |
+
@torch.no_grad()
|
| 52 |
+
def encode_text(self, text_list, cache=False):
|
| 53 |
+
if cache and tuple(text_list) in self.text_list_to_feature:
|
| 54 |
+
return self.text_list_to_feature[tuple(text_list)]
|
| 55 |
+
|
| 56 |
+
text_token = self.tokenizer(text_list, context_length=77).to(self.device)
|
| 57 |
+
|
| 58 |
+
max_batch_size = self.max_batch_size
|
| 59 |
+
if self.device.type == "cpu" or torch.cuda.mem_get_info(self.device)[0] / 1024**3 < 5:
|
| 60 |
+
max_batch_size = min(256, max_batch_size)
|
| 61 |
+
if len(text_token) > max_batch_size:
|
| 62 |
+
chunck_num = len(text_token) // max_batch_size + 1
|
| 63 |
+
encoder_outputs = torch.cat(
|
| 64 |
+
[
|
| 65 |
+
self.net.encode_text(
|
| 66 |
+
text_token[chunck_id * max_batch_size : (chunck_id + 1) * max_batch_size]
|
| 67 |
+
)
|
| 68 |
+
for chunck_id in range(chunck_num)
|
| 69 |
+
],
|
| 70 |
+
dim=0,
|
| 71 |
+
)
|
| 72 |
+
else:
|
| 73 |
+
encoder_outputs = self.net.encode_text(text_token)
|
| 74 |
+
|
| 75 |
+
ret = {
|
| 76 |
+
"last_hidden_state_eot": encoder_outputs,
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
if cache:
|
| 80 |
+
self.text_list_to_feature[tuple(text_list)] = ret
|
| 81 |
+
|
| 82 |
+
return ret
|
| 83 |
+
|
| 84 |
+
@autocast(enabled=False)
|
| 85 |
+
@torch.no_grad()
|
| 86 |
+
def forward_text(self, text_list, cache=False):
|
| 87 |
+
if cache and tuple(text_list) in self.text_list_to_feature:
|
| 88 |
+
return self.text_list_to_feature[tuple(text_list)]
|
| 89 |
+
|
| 90 |
+
text_token = self.tokenizer(text_list, context_length=77).to(self.device)
|
| 91 |
+
|
| 92 |
+
max_batch_size = self.max_batch_size
|
| 93 |
+
if self.device.type == "cpu" or torch.cuda.mem_get_info(self.device)[0] / 1024**3 < 5:
|
| 94 |
+
max_batch_size = min(256, max_batch_size)
|
| 95 |
+
if len(text_token) > max_batch_size:
|
| 96 |
+
chunck_num = len(text_token) // max_batch_size + 1
|
| 97 |
+
encoder_outputs = [
|
| 98 |
+
self.custom_encode_text(
|
| 99 |
+
text_token[chunck_id * max_batch_size : (chunck_id + 1) * max_batch_size],
|
| 100 |
+
self.net.text,
|
| 101 |
+
)
|
| 102 |
+
for chunck_id in range(chunck_num)
|
| 103 |
+
]
|
| 104 |
+
encoder_outputs_x = torch.cat([x for (x, _) in encoder_outputs], dim=0)
|
| 105 |
+
encoder_outputs_xx = torch.cat([xx for (_, xx) in encoder_outputs], dim=0)
|
| 106 |
+
else:
|
| 107 |
+
encoder_outputs_x, encoder_outputs_xx = self.custom_encode_text(
|
| 108 |
+
text_token, self.net.text
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
end_token_idx = text_token.argmax(dim=-1)
|
| 112 |
+
attention_mask = end_token_idx.new_zeros(encoder_outputs_xx.size()[:2])
|
| 113 |
+
for i in range(attention_mask.size(0)):
|
| 114 |
+
attention_mask[i, : end_token_idx[i] + 1] = 1
|
| 115 |
+
|
| 116 |
+
ret = {
|
| 117 |
+
"end_token_idx": end_token_idx,
|
| 118 |
+
"attention_mask": attention_mask,
|
| 119 |
+
"last_hidden_state": encoder_outputs_xx,
|
| 120 |
+
"last_hidden_state_eot": encoder_outputs_x,
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
if cache:
|
| 124 |
+
self.text_list_to_feature[tuple(text_list)] = ret
|
| 125 |
+
|
| 126 |
+
return ret
|
| 127 |
+
|
| 128 |
+
@autocast(enabled=False)
|
| 129 |
+
@torch.no_grad()
|
| 130 |
+
def custom_encode_text(self, text, m, normalize: bool = False):
|
| 131 |
+
cast_dtype = m.transformer.get_cast_dtype()
|
| 132 |
+
|
| 133 |
+
x = m.token_embedding(text).to(cast_dtype) # [batch_size, n_ctx, d_model]
|
| 134 |
+
|
| 135 |
+
x = x + m.positional_embedding.to(cast_dtype)
|
| 136 |
+
x = x.permute(1, 0, 2) # NLD -> LND
|
| 137 |
+
x = m.transformer(x, attn_mask=m.attn_mask)
|
| 138 |
+
x = x.permute(1, 0, 2) # LND -> NLD
|
| 139 |
+
x = m.ln_final(x) # [batch_size, n_ctx, transformer.width]
|
| 140 |
+
|
| 141 |
+
xx = x @ m.text_projection
|
| 142 |
+
|
| 143 |
+
x = x[torch.arange(x.shape[0]), text.argmax(dim=-1)] @ m.text_projection
|
| 144 |
+
|
| 145 |
+
return (
|
| 146 |
+
F.normalize(x, dim=-1) if normalize else x,
|
| 147 |
+
F.normalize(xx, dim=-1) if normalize else xx,
|
| 148 |
+
)
|
approach/ovod/APE/ape/modeling/text/eva01_clip/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contrastive Language-Image Pre-Training with EVA (EVA-CLIP)
|
| 2 |
+
|
| 3 |
+
**Table of Contents**
|
| 4 |
+
|
| 5 |
+
- [Contrastive Language-Image Pre-Training with EVA (EVA-CLIP)](#contrastive-language-image-pre-training-with-eva-eva-clip)
|
| 6 |
+
- [Model Card](#model-card)
|
| 7 |
+
- [Usage](#usage)
|
| 8 |
+
- [Acknowledgement](#acknowledgement)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
## Model Card
|
| 12 |
+
|
| 13 |
+
<div align="center">
|
| 14 |
+
|
| 15 |
+
| model name | #param. | precision | data | batch size | IN-1K zero-shot top-1 | weight |
|
| 16 |
+
|:-----------:|:------:|:------:|:------:|:------:|:------:|:------:|
|
| 17 |
+
| `eva_clip_psz14` | 1.3B | `fp16` | [LAION-400M](https://laion.ai/laion-400-open-dataset/) | 41K | 78.5 | [🤗 HF link](https://huggingface.co/BAAI/EVA/blob/main/eva_clip_psz14.pt) (`2GB`) |
|
| 18 |
+
|
| 19 |
+
</div>
|
| 20 |
+
|
| 21 |
+
> The ImageNet-1K zero-shot classification performance is higher than our paper (`78.5` *v.s.* `78.2`) because of longer training.
|
| 22 |
+
|
| 23 |
+
We choose to train a 1.3B CLIP model, not because it is easy, but because it is hard. Please refer to [this note](https://docs.google.com/document/d/1FXosAZ3wMrzThgnWR6KSkXIz4IMItq3umDGos38pJps/edit) for a glance of the challenges in training very large CLIP.
|
| 24 |
+
|
| 25 |
+
To our knowledge, EVA-CLIP is **the largest performant open-sourced CLIP model** evaluated via zero-shot classification performance.
|
| 26 |
+
We will updates the results in our paper soon.
|
| 27 |
+
For more details of EVA-CLIP, please refer to Section 2.3.5 of [our paper](https://arxiv.org/pdf/2211.07636.pdf).
|
| 28 |
+
|
| 29 |
+
We hope open-sourcing EVA-CLIP can facilitate future research in multi-modal learning, representation leaning, AIGC, *etc*.
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
## Usage
|
| 33 |
+
|
| 34 |
+
The usege of EVA-CLIP is similar to [OpenAI CLIP](https://github.com/openai/CLIP) and [Open CLIP](https://github.com/mlfoundations/open_clip).
|
| 35 |
+
Here we provide a showcase in zero-shot image classification.
|
| 36 |
+
|
| 37 |
+
First, [install PyTorch 1.7.1](https://pytorch.org/get-started/locally/) (or later) and torchvision, as well as small additional dependencies, and then install this repo as a Python package. On a CUDA GPU machine, the following will do the trick:
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
$ conda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.0
|
| 41 |
+
$ pip install ftfy regex tqdm
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
The training code of our 1.3B EVA-CLIP will be available at [FlagAI](https://github.com/FlagAI-Open/FlagAI). Please stay tuned.
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
An example:
|
| 48 |
+
```python
|
| 49 |
+
import torch
|
| 50 |
+
from eva_clip import build_eva_model_and_transforms
|
| 51 |
+
from clip import tokenize
|
| 52 |
+
from PIL import Image
|
| 53 |
+
|
| 54 |
+
eva_clip_path = "/path/to/eva_clip_psz14.pt" # https://huggingface.co/BAAI/EVA/blob/main/eva_clip_psz14.pt
|
| 55 |
+
model_name = "EVA_CLIP_g_14"
|
| 56 |
+
image_path = "CLIP.png"
|
| 57 |
+
caption = ["a diagram", "a dog", "a cat"]
|
| 58 |
+
|
| 59 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 60 |
+
model, preprocess = build_eva_model_and_transforms(model_name, pretrained=eva_clip_path)
|
| 61 |
+
model = model.to(device)
|
| 62 |
+
|
| 63 |
+
image = preprocess(Image.open(image_path)).unsqueeze(0).to(device)
|
| 64 |
+
text = tokenize(caption).to(device)
|
| 65 |
+
|
| 66 |
+
with torch.no_grad():
|
| 67 |
+
image_features = model.encode_image(image)
|
| 68 |
+
text_features = model.encode_text(text)
|
| 69 |
+
image_features /= image_features.norm(dim=-1, keepdim=True)
|
| 70 |
+
text_features /= text_features.norm(dim=-1, keepdim=True)
|
| 71 |
+
|
| 72 |
+
text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
|
| 73 |
+
|
| 74 |
+
print("Label probs:", text_probs) # prints: [1.0000e+00, 2.0857e-10, 4.8534e-12]
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
## Acknowledgement
|
| 79 |
+
EVA-CLIP is bulit with [OpenAI CLIP](https://github.com/openai/CLIP), [Open CLIP](https://github.com/mlfoundations/open_clip) and [CLIP Benchmark](https://github.com/LAION-AI/CLIP_benchmark). Thanks for their awesome work!
|
approach/ovod/APE/ape/modeling/text/eva01_clip/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# from .clip import *
|
| 2 |
+
# from .eva_clip import *
|
| 3 |
+
# from .model import *
|
| 4 |
+
# from .simple_tokenizer import *
|
| 5 |
+
# from .vit_model import *
|
| 6 |
+
|
| 7 |
+
from .eva_clip import build_eva_model_and_transforms
|
approach/ovod/APE/ape/modeling/text/eva01_clip/clip.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import hashlib
|
| 2 |
+
import os
|
| 3 |
+
import urllib
|
| 4 |
+
import warnings
|
| 5 |
+
from typing import Any, Union, List
|
| 6 |
+
from pkg_resources import packaging
|
| 7 |
+
|
| 8 |
+
import torch
|
| 9 |
+
from PIL import Image
|
| 10 |
+
from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
|
| 11 |
+
from tqdm import tqdm
|
| 12 |
+
|
| 13 |
+
from .model import build_model
|
| 14 |
+
from .simple_tokenizer import SimpleTokenizer as _Tokenizer
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
from torchvision.transforms import InterpolationMode
|
| 18 |
+
BICUBIC = InterpolationMode.BICUBIC
|
| 19 |
+
except ImportError:
|
| 20 |
+
BICUBIC = Image.BICUBIC
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if packaging.version.parse(torch.__version__) < packaging.version.parse("1.7.1"):
|
| 24 |
+
warnings.warn("PyTorch version 1.7.1 or higher is recommended")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
__all__ = ["available_models", "load", "tokenize"]
|
| 28 |
+
_tokenizer = _Tokenizer()
|
| 29 |
+
|
| 30 |
+
_MODELS = {
|
| 31 |
+
"RN50": "https://openaipublic.azureedge.net/clip/models/afeb0e10f9e5a86da6080e35cf09123aca3b358a0c3e3b6c78a7b63bc04b6762/RN50.pt",
|
| 32 |
+
"RN101": "https://openaipublic.azureedge.net/clip/models/8fa8567bab74a42d41c5915025a8e4538c3bdbe8804a470a72f30b0d94fab599/RN101.pt",
|
| 33 |
+
"RN50x4": "https://openaipublic.azureedge.net/clip/models/7e526bd135e493cef0776de27d5f42653e6b4c8bf9e0f653bb11773263205fdd/RN50x4.pt",
|
| 34 |
+
"RN50x16": "https://openaipublic.azureedge.net/clip/models/52378b407f34354e150460fe41077663dd5b39c54cd0bfd2b27167a4a06ec9aa/RN50x16.pt",
|
| 35 |
+
"RN50x64": "https://openaipublic.azureedge.net/clip/models/be1cfb55d75a9666199fb2206c106743da0f6468c9d327f3e0d0a543a9919d9c/RN50x64.pt",
|
| 36 |
+
"ViT-B/32": "https://openaipublic.azureedge.net/clip/models/40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af/ViT-B-32.pt",
|
| 37 |
+
"ViT-B/16": "https://openaipublic.azureedge.net/clip/models/5806e77cd80f8b59890b7e101eabd078d9fb84e6937f9e85e4ecb61988df416f/ViT-B-16.pt",
|
| 38 |
+
"ViT-L/14": "https://openaipublic.azureedge.net/clip/models/b8cca3fd41ae0c99ba7e8951adf17d267cdb84cd88be6f7c2e0eca1737a03836/ViT-L-14.pt",
|
| 39 |
+
"ViT-L/14@336px": "https://openaipublic.azureedge.net/clip/models/3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02/ViT-L-14-336px.pt",
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _download(url: str, root: str):
|
| 44 |
+
os.makedirs(root, exist_ok=True)
|
| 45 |
+
filename = os.path.basename(url)
|
| 46 |
+
|
| 47 |
+
expected_sha256 = url.split("/")[-2]
|
| 48 |
+
download_target = os.path.join(root, filename)
|
| 49 |
+
|
| 50 |
+
if os.path.exists(download_target) and not os.path.isfile(download_target):
|
| 51 |
+
raise RuntimeError(f"{download_target} exists and is not a regular file")
|
| 52 |
+
|
| 53 |
+
if os.path.isfile(download_target):
|
| 54 |
+
if hashlib.sha256(open(download_target, "rb").read()).hexdigest() == expected_sha256:
|
| 55 |
+
return download_target
|
| 56 |
+
else:
|
| 57 |
+
warnings.warn(f"{download_target} exists, but the SHA256 checksum does not match; re-downloading the file")
|
| 58 |
+
|
| 59 |
+
with urllib.request.urlopen(url) as source, open(download_target, "wb") as output:
|
| 60 |
+
with tqdm(total=int(source.info().get("Content-Length")), ncols=80, unit='iB', unit_scale=True, unit_divisor=1024) as loop:
|
| 61 |
+
while True:
|
| 62 |
+
buffer = source.read(8192)
|
| 63 |
+
if not buffer:
|
| 64 |
+
break
|
| 65 |
+
|
| 66 |
+
output.write(buffer)
|
| 67 |
+
loop.update(len(buffer))
|
| 68 |
+
|
| 69 |
+
if hashlib.sha256(open(download_target, "rb").read()).hexdigest() != expected_sha256:
|
| 70 |
+
raise RuntimeError(f"Model has been downloaded but the SHA256 checksum does not not match")
|
| 71 |
+
|
| 72 |
+
return download_target
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def _convert_image_to_rgb(image):
|
| 76 |
+
return image.convert("RGB")
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def _transform(n_px):
|
| 80 |
+
return Compose([
|
| 81 |
+
Resize(n_px, interpolation=BICUBIC),
|
| 82 |
+
CenterCrop(n_px),
|
| 83 |
+
_convert_image_to_rgb,
|
| 84 |
+
ToTensor(),
|
| 85 |
+
Normalize((0.48145466, 0.4578275, 0.40821073), (0.26862954, 0.26130258, 0.27577711)),
|
| 86 |
+
])
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def available_models() -> List[str]:
|
| 90 |
+
"""Returns the names of available CLIP models"""
|
| 91 |
+
return list(_MODELS.keys())
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def load(name: str, device: Union[str, torch.device] = "cuda" if torch.cuda.is_available() else "cpu", jit: bool = False, download_root: str = None):
|
| 95 |
+
"""Load a CLIP model
|
| 96 |
+
|
| 97 |
+
Parameters
|
| 98 |
+
----------
|
| 99 |
+
name : str
|
| 100 |
+
A model name listed by `clip.available_models()`, or the path to a model checkpoint containing the state_dict
|
| 101 |
+
|
| 102 |
+
device : Union[str, torch.device]
|
| 103 |
+
The device to put the loaded model
|
| 104 |
+
|
| 105 |
+
jit : bool
|
| 106 |
+
Whether to load the optimized JIT model or more hackable non-JIT model (default).
|
| 107 |
+
|
| 108 |
+
download_root: str
|
| 109 |
+
path to download the model files; by default, it uses "~/.cache/clip"
|
| 110 |
+
|
| 111 |
+
Returns
|
| 112 |
+
-------
|
| 113 |
+
model : torch.nn.Module
|
| 114 |
+
The CLIP model
|
| 115 |
+
|
| 116 |
+
preprocess : Callable[[PIL.Image], torch.Tensor]
|
| 117 |
+
A torchvision transform that converts a PIL image into a tensor that the returned model can take as its input
|
| 118 |
+
"""
|
| 119 |
+
if name in _MODELS:
|
| 120 |
+
model_path = _download(_MODELS[name], download_root or os.path.expanduser("~/.cache/clip"))
|
| 121 |
+
elif os.path.isfile(name):
|
| 122 |
+
model_path = name
|
| 123 |
+
else:
|
| 124 |
+
raise RuntimeError(f"Model {name} not found; available models = {available_models()}")
|
| 125 |
+
|
| 126 |
+
try:
|
| 127 |
+
# loading JIT archive
|
| 128 |
+
model = torch.jit.load(model_path, map_location=device if jit else "cpu").eval()
|
| 129 |
+
state_dict = None
|
| 130 |
+
except RuntimeError:
|
| 131 |
+
# loading saved state dict
|
| 132 |
+
if jit:
|
| 133 |
+
warnings.warn(f"File {model_path} is not a JIT archive. Loading as a state dict instead")
|
| 134 |
+
jit = False
|
| 135 |
+
state_dict = torch.load(model_path, map_location="cpu")
|
| 136 |
+
|
| 137 |
+
if not jit:
|
| 138 |
+
model = build_model(state_dict or model.state_dict()).to(device)
|
| 139 |
+
if str(device) == "cpu":
|
| 140 |
+
model.float()
|
| 141 |
+
return model, _transform(model.visual.input_resolution)
|
| 142 |
+
|
| 143 |
+
# patch the device names
|
| 144 |
+
device_holder = torch.jit.trace(lambda: torch.ones([]).to(torch.device(device)), example_inputs=[])
|
| 145 |
+
device_node = [n for n in device_holder.graph.findAllNodes("prim::Constant") if "Device" in repr(n)][-1]
|
| 146 |
+
|
| 147 |
+
def patch_device(module):
|
| 148 |
+
try:
|
| 149 |
+
graphs = [module.graph] if hasattr(module, "graph") else []
|
| 150 |
+
except RuntimeError:
|
| 151 |
+
graphs = []
|
| 152 |
+
|
| 153 |
+
if hasattr(module, "forward1"):
|
| 154 |
+
graphs.append(module.forward1.graph)
|
| 155 |
+
|
| 156 |
+
for graph in graphs:
|
| 157 |
+
for node in graph.findAllNodes("prim::Constant"):
|
| 158 |
+
if "value" in node.attributeNames() and str(node["value"]).startswith("cuda"):
|
| 159 |
+
node.copyAttributes(device_node)
|
| 160 |
+
|
| 161 |
+
model.apply(patch_device)
|
| 162 |
+
patch_device(model.encode_image)
|
| 163 |
+
patch_device(model.encode_text)
|
| 164 |
+
|
| 165 |
+
# patch dtype to float32 on CPU
|
| 166 |
+
if str(device) == "cpu":
|
| 167 |
+
float_holder = torch.jit.trace(lambda: torch.ones([]).float(), example_inputs=[])
|
| 168 |
+
float_input = list(float_holder.graph.findNode("aten::to").inputs())[1]
|
| 169 |
+
float_node = float_input.node()
|
| 170 |
+
|
| 171 |
+
def patch_float(module):
|
| 172 |
+
try:
|
| 173 |
+
graphs = [module.graph] if hasattr(module, "graph") else []
|
| 174 |
+
except RuntimeError:
|
| 175 |
+
graphs = []
|
| 176 |
+
|
| 177 |
+
if hasattr(module, "forward1"):
|
| 178 |
+
graphs.append(module.forward1.graph)
|
| 179 |
+
|
| 180 |
+
for graph in graphs:
|
| 181 |
+
for node in graph.findAllNodes("aten::to"):
|
| 182 |
+
inputs = list(node.inputs())
|
| 183 |
+
for i in [1, 2]: # dtype can be the second or third argument to aten::to()
|
| 184 |
+
if inputs[i].node()["value"] == 5:
|
| 185 |
+
inputs[i].node().copyAttributes(float_node)
|
| 186 |
+
|
| 187 |
+
model.apply(patch_float)
|
| 188 |
+
patch_float(model.encode_image)
|
| 189 |
+
patch_float(model.encode_text)
|
| 190 |
+
|
| 191 |
+
model.float()
|
| 192 |
+
|
| 193 |
+
return model, _transform(model.input_resolution.item())
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def tokenize(texts: Union[str, List[str]], context_length: int = 77, truncate: bool = False) -> torch.LongTensor:
|
| 197 |
+
"""
|
| 198 |
+
Returns the tokenized representation of given input string(s)
|
| 199 |
+
|
| 200 |
+
Parameters
|
| 201 |
+
----------
|
| 202 |
+
texts : Union[str, List[str]]
|
| 203 |
+
An input string or a list of input strings to tokenize
|
| 204 |
+
|
| 205 |
+
context_length : int
|
| 206 |
+
The context length to use; all CLIP models use 77 as the context length
|
| 207 |
+
|
| 208 |
+
truncate: bool
|
| 209 |
+
Whether to truncate the text in case its encoding is longer than the context length
|
| 210 |
+
|
| 211 |
+
Returns
|
| 212 |
+
-------
|
| 213 |
+
A two-dimensional tensor containing the resulting tokens, shape = [number of input strings, context_length]
|
| 214 |
+
"""
|
| 215 |
+
if isinstance(texts, str):
|
| 216 |
+
texts = [texts]
|
| 217 |
+
|
| 218 |
+
sot_token = _tokenizer.encoder["<|startoftext|>"]
|
| 219 |
+
eot_token = _tokenizer.encoder["<|endoftext|>"]
|
| 220 |
+
all_tokens = [[sot_token] + _tokenizer.encode(text) + [eot_token] for text in texts]
|
| 221 |
+
result = torch.zeros(len(all_tokens), context_length, dtype=torch.long)
|
| 222 |
+
|
| 223 |
+
for i, tokens in enumerate(all_tokens):
|
| 224 |
+
if len(tokens) > context_length:
|
| 225 |
+
if truncate:
|
| 226 |
+
tokens = tokens[:context_length]
|
| 227 |
+
tokens[-1] = eot_token
|
| 228 |
+
else:
|
| 229 |
+
raise RuntimeError(f"Input {texts[i]} is too long for context length {context_length}")
|
| 230 |
+
result[i, :len(tokens)] = torch.tensor(tokens)
|
| 231 |
+
|
| 232 |
+
return result
|
approach/ovod/APE/ape/modeling/text/eva01_clip/eva_clip.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import logging
|
| 3 |
+
import os
|
| 4 |
+
import pathlib
|
| 5 |
+
import re
|
| 6 |
+
from copy import deepcopy
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
from tkinter import E
|
| 9 |
+
from typing import Optional, Tuple, Any, Union, List
|
| 10 |
+
|
| 11 |
+
import torch
|
| 12 |
+
from torchvision.transforms import Normalize, Compose, InterpolationMode, ToTensor, Resize, CenterCrop
|
| 13 |
+
|
| 14 |
+
from .eva_model import EVA_CLIP, convert_weights_to_fp16
|
| 15 |
+
|
| 16 |
+
OPENAI_DATASET_MEAN = (0.48145466, 0.4578275, 0.40821073)
|
| 17 |
+
OPENAI_DATASET_STD = (0.26862954, 0.26130258, 0.27577711)
|
| 18 |
+
|
| 19 |
+
_MODEL_CONFIG_PATHS = [Path(__file__).parent / f"model_configs/"]
|
| 20 |
+
_MODEL_CONFIGS = {} # directory (model_name: config) of model architecture configs
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _natural_key(string_):
|
| 24 |
+
return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_.lower())]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _rescan_model_configs():
|
| 28 |
+
global _MODEL_CONFIGS
|
| 29 |
+
|
| 30 |
+
config_ext = ('.json',)
|
| 31 |
+
config_files = []
|
| 32 |
+
for config_path in _MODEL_CONFIG_PATHS:
|
| 33 |
+
if config_path.is_file() and config_path.suffix in config_ext:
|
| 34 |
+
config_files.append(config_path)
|
| 35 |
+
elif config_path.is_dir():
|
| 36 |
+
for ext in config_ext:
|
| 37 |
+
config_files.extend(config_path.glob(f'*{ext}'))
|
| 38 |
+
|
| 39 |
+
for cf in config_files:
|
| 40 |
+
with open(cf, 'r') as f:
|
| 41 |
+
model_cfg = json.load(f)
|
| 42 |
+
if all(a in model_cfg for a in ('embed_dim', 'vision_cfg', 'text_cfg')):
|
| 43 |
+
_MODEL_CONFIGS[cf.stem] = model_cfg
|
| 44 |
+
|
| 45 |
+
_MODEL_CONFIGS = {k: v for k, v in sorted(_MODEL_CONFIGS.items(), key=lambda x: _natural_key(x[0]))}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
_rescan_model_configs() # initial populate of model config registry
|
| 49 |
+
|
| 50 |
+
def list_models():
|
| 51 |
+
""" enumerate available model architectures based on config files """
|
| 52 |
+
return list(_MODEL_CONFIGS.keys())
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def add_model_config(path):
|
| 56 |
+
""" add model config path or file and update registry """
|
| 57 |
+
if not isinstance(path, Path):
|
| 58 |
+
path = Path(path)
|
| 59 |
+
_MODEL_CONFIG_PATHS.append(path)
|
| 60 |
+
_rescan_model_configs()
|
| 61 |
+
|
| 62 |
+
def get_model_config(model_name):
|
| 63 |
+
if model_name in _MODEL_CONFIGS:
|
| 64 |
+
return deepcopy(_MODEL_CONFIGS[model_name])
|
| 65 |
+
else:
|
| 66 |
+
return None
|
| 67 |
+
|
| 68 |
+
def load_state_dict(checkpoint_path: str, map_location: str='cpu', model_key='model|module|state_dict'):
|
| 69 |
+
checkpoint = torch.load(checkpoint_path, map_location=map_location)
|
| 70 |
+
|
| 71 |
+
for mk in model_key.split('|'):
|
| 72 |
+
if isinstance(checkpoint, dict) and mk in checkpoint:
|
| 73 |
+
state_dict = checkpoint[mk]
|
| 74 |
+
break
|
| 75 |
+
else:
|
| 76 |
+
state_dict = checkpoint
|
| 77 |
+
if next(iter(state_dict.items()))[0].startswith('module'):
|
| 78 |
+
state_dict = {k[7:]: v for k, v in state_dict.items()}
|
| 79 |
+
return state_dict
|
| 80 |
+
|
| 81 |
+
def load_checkpoint(model, checkpoint_path, model_key="model|module|state_dict", strict=True):
|
| 82 |
+
state_dict = load_state_dict(checkpoint_path, model_key=model_key)
|
| 83 |
+
incompatible_keys = model.load_state_dict(state_dict, strict=strict)
|
| 84 |
+
print(incompatible_keys)
|
| 85 |
+
return incompatible_keys
|
| 86 |
+
|
| 87 |
+
def create_model(
|
| 88 |
+
model_name: str,
|
| 89 |
+
pretrained: str = '',
|
| 90 |
+
precision: str = 'fp32',
|
| 91 |
+
device: torch.device = torch.device('cpu'),
|
| 92 |
+
force_quick_gelu: bool = False,
|
| 93 |
+
):
|
| 94 |
+
model_name = model_name.replace('/', '-') # for callers using old naming with / in ViT names
|
| 95 |
+
|
| 96 |
+
if model_name in _MODEL_CONFIGS:
|
| 97 |
+
logging.info(f'Loading {model_name} model config.')
|
| 98 |
+
model_cfg = deepcopy(_MODEL_CONFIGS[model_name])
|
| 99 |
+
else:
|
| 100 |
+
logging.error(f'Model config for {model_name} not found; available models {list_models()}.')
|
| 101 |
+
raise RuntimeError(f'Model config for {model_name} not found.')
|
| 102 |
+
|
| 103 |
+
if force_quick_gelu:
|
| 104 |
+
# override for use of QuickGELU on non-OpenAI transformer models
|
| 105 |
+
model_cfg["quick_gelu"] = True
|
| 106 |
+
|
| 107 |
+
model = EVA_CLIP(**model_cfg)
|
| 108 |
+
|
| 109 |
+
if pretrained:
|
| 110 |
+
load_checkpoint(model, pretrained)
|
| 111 |
+
|
| 112 |
+
model.to(device=device)
|
| 113 |
+
if precision == "fp16":
|
| 114 |
+
assert device.type != 'cpu'
|
| 115 |
+
convert_weights_to_fp16(model)
|
| 116 |
+
|
| 117 |
+
# set image / mean metadata from pretrained_cfg if available, or use default
|
| 118 |
+
model.visual.image_mean = OPENAI_DATASET_MEAN
|
| 119 |
+
model.visual.image_std = OPENAI_DATASET_STD
|
| 120 |
+
|
| 121 |
+
return model
|
| 122 |
+
|
| 123 |
+
def _convert_to_rgb(image):
|
| 124 |
+
return image.convert('RGB')
|
| 125 |
+
|
| 126 |
+
def image_transform(
|
| 127 |
+
image_size: int,
|
| 128 |
+
mean: Optional[Tuple[float, ...]] = None,
|
| 129 |
+
std: Optional[Tuple[float, ...]] = None,
|
| 130 |
+
):
|
| 131 |
+
mean = mean or OPENAI_DATASET_MEAN
|
| 132 |
+
if not isinstance(mean, (list, tuple)):
|
| 133 |
+
mean = (mean,) * 3
|
| 134 |
+
|
| 135 |
+
std = std or OPENAI_DATASET_STD
|
| 136 |
+
if not isinstance(std, (list, tuple)):
|
| 137 |
+
std = (std,) * 3
|
| 138 |
+
|
| 139 |
+
if isinstance(image_size, (list, tuple)) and image_size[0] == image_size[1]:
|
| 140 |
+
# for square size, pass size as int so that Resize() uses aspect preserving shortest edge
|
| 141 |
+
image_size = image_size[0]
|
| 142 |
+
|
| 143 |
+
normalize = Normalize(mean=mean, std=std)
|
| 144 |
+
|
| 145 |
+
transforms = [
|
| 146 |
+
Resize(image_size, interpolation=InterpolationMode.BICUBIC),
|
| 147 |
+
CenterCrop(image_size),
|
| 148 |
+
]
|
| 149 |
+
transforms.extend([
|
| 150 |
+
_convert_to_rgb,
|
| 151 |
+
ToTensor(),
|
| 152 |
+
normalize,
|
| 153 |
+
])
|
| 154 |
+
return Compose(transforms)
|
| 155 |
+
|
| 156 |
+
def build_eva_model_and_transforms(
|
| 157 |
+
model_name: str,
|
| 158 |
+
pretrained: str = '',
|
| 159 |
+
precision: str = 'fp32',
|
| 160 |
+
device: torch.device = torch.device('cpu'),
|
| 161 |
+
force_quick_gelu: bool = False,
|
| 162 |
+
image_mean: Optional[Tuple[float, ...]] = None,
|
| 163 |
+
image_std: Optional[Tuple[float, ...]] = None,
|
| 164 |
+
):
|
| 165 |
+
model = create_model(
|
| 166 |
+
model_name, pretrained, precision, device,
|
| 167 |
+
force_quick_gelu=force_quick_gelu)
|
| 168 |
+
|
| 169 |
+
image_mean = image_mean or getattr(model.visual, 'image_mean', None)
|
| 170 |
+
image_std = image_std or getattr(model.visual, 'image_std', None)
|
| 171 |
+
preprocess_val = image_transform(model.visual.image_size, mean=image_mean, std=image_std)
|
| 172 |
+
|
| 173 |
+
return model, preprocess_val
|
approach/ovod/APE/ape/modeling/text/eva01_clip/eva_model.py
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
""" CLIP Model
|
| 2 |
+
|
| 3 |
+
Adapted from https://github.com/mlfoundations/open_clip
|
| 4 |
+
|
| 5 |
+
"""
|
| 6 |
+
import math
|
| 7 |
+
from dataclasses import dataclass
|
| 8 |
+
from typing import Tuple, Union, Callable, Optional
|
| 9 |
+
from functools import partial
|
| 10 |
+
import numpy as np
|
| 11 |
+
from collections import OrderedDict
|
| 12 |
+
|
| 13 |
+
import torch
|
| 14 |
+
import torch.nn.functional as F
|
| 15 |
+
from torch import nn
|
| 16 |
+
|
| 17 |
+
from .vit_model import VisionTransformer
|
| 18 |
+
|
| 19 |
+
try:
|
| 20 |
+
from apex.normalization import FusedLayerNorm
|
| 21 |
+
except:
|
| 22 |
+
pass
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class LayerNorm(nn.LayerNorm):
|
| 26 |
+
"""Subclass torch's LayerNorm to handle fp16."""
|
| 27 |
+
|
| 28 |
+
def forward(self, x: torch.Tensor):
|
| 29 |
+
orig_type = x.dtype
|
| 30 |
+
x = F.layer_norm(x, self.normalized_shape, self.weight, self.bias, self.eps)
|
| 31 |
+
return x.to(orig_type)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class QuickGELU(nn.Module):
|
| 35 |
+
# NOTE This is slower than nn.GELU or nn.SiLU and uses more GPU memory
|
| 36 |
+
def forward(self, x: torch.Tensor):
|
| 37 |
+
return x * torch.sigmoid(1.702 * x)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class Attention(nn.Module):
|
| 41 |
+
def __init__(
|
| 42 |
+
self,
|
| 43 |
+
dim,
|
| 44 |
+
num_heads=8,
|
| 45 |
+
qkv_bias=True,
|
| 46 |
+
scaled_cosine=False,
|
| 47 |
+
scale_heads=False,
|
| 48 |
+
logit_scale_max=math.log(1. / 0.01),
|
| 49 |
+
attn_drop=0.,
|
| 50 |
+
proj_drop=0.
|
| 51 |
+
):
|
| 52 |
+
super().__init__()
|
| 53 |
+
self.scaled_cosine = scaled_cosine
|
| 54 |
+
self.scale_heads = scale_heads
|
| 55 |
+
assert dim % num_heads == 0, 'dim should be divisible by num_heads'
|
| 56 |
+
self.num_heads = num_heads
|
| 57 |
+
self.head_dim = dim // num_heads
|
| 58 |
+
self.scale = self.head_dim ** -0.5
|
| 59 |
+
self.logit_scale_max = logit_scale_max
|
| 60 |
+
|
| 61 |
+
# keeping in_proj in this form (instead of nn.Linear) to match weight scheme of original
|
| 62 |
+
self.in_proj_weight = nn.Parameter(torch.randn((dim * 3, dim)) * self.scale)
|
| 63 |
+
if qkv_bias:
|
| 64 |
+
self.in_proj_bias = nn.Parameter(torch.zeros(dim * 3))
|
| 65 |
+
else:
|
| 66 |
+
self.in_proj_bias = None
|
| 67 |
+
|
| 68 |
+
if self.scaled_cosine:
|
| 69 |
+
self.logit_scale = nn.Parameter(torch.log(10 * torch.ones((num_heads, 1, 1))))
|
| 70 |
+
else:
|
| 71 |
+
self.logit_scale = None
|
| 72 |
+
self.attn_drop = nn.Dropout(attn_drop)
|
| 73 |
+
if self.scale_heads:
|
| 74 |
+
self.head_scale = nn.Parameter(torch.ones((num_heads, 1, 1)))
|
| 75 |
+
else:
|
| 76 |
+
self.head_scale = None
|
| 77 |
+
self.out_proj = nn.Linear(dim, dim)
|
| 78 |
+
self.out_drop = nn.Dropout(proj_drop)
|
| 79 |
+
|
| 80 |
+
def forward(self, x, attn_mask: Optional[torch.Tensor] = None):
|
| 81 |
+
L, N, C = x.shape
|
| 82 |
+
q, k, v = F.linear(x, self.in_proj_weight, self.in_proj_bias).chunk(3, dim=-1)
|
| 83 |
+
q = q.contiguous().view(L, N * self.num_heads, -1).transpose(0, 1)
|
| 84 |
+
k = k.contiguous().view(L, N * self.num_heads, -1).transpose(0, 1)
|
| 85 |
+
v = v.contiguous().view(L, N * self.num_heads, -1).transpose(0, 1)
|
| 86 |
+
|
| 87 |
+
if self.logit_scale is not None:
|
| 88 |
+
attn = torch.bmm(F.normalize(q, dim=-1), F.normalize(k, dim=-1).transpose(-1, -2))
|
| 89 |
+
logit_scale = torch.clamp(self.logit_scale, max=self.logit_scale_max).exp()
|
| 90 |
+
attn = attn.view(N, self.num_heads, L, L) * logit_scale
|
| 91 |
+
attn = attn.view(-1, L, L)
|
| 92 |
+
else:
|
| 93 |
+
q = q * self.scale
|
| 94 |
+
attn = torch.bmm(q, k.transpose(-1, -2))
|
| 95 |
+
|
| 96 |
+
if attn_mask is not None:
|
| 97 |
+
if attn_mask.dtype == torch.bool:
|
| 98 |
+
new_attn_mask = torch.zeros_like(attn_mask, dtype=q.dtype)
|
| 99 |
+
new_attn_mask.masked_fill_(attn_mask, float("-inf"))
|
| 100 |
+
attn_mask = new_attn_mask
|
| 101 |
+
attn += attn_mask
|
| 102 |
+
|
| 103 |
+
attn = attn.softmax(dim=-1)
|
| 104 |
+
attn = self.attn_drop(attn)
|
| 105 |
+
|
| 106 |
+
x = torch.bmm(attn, v)
|
| 107 |
+
if self.head_scale is not None:
|
| 108 |
+
x = x.view(N, self.num_heads, L, C) * self.head_scale
|
| 109 |
+
x = x.view(-1, L, C)
|
| 110 |
+
x = x.transpose(0, 1).reshape(L, N, C)
|
| 111 |
+
x = self.out_proj(x)
|
| 112 |
+
x = self.out_drop(x)
|
| 113 |
+
return x
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class ResidualAttentionBlock(nn.Module):
|
| 117 |
+
def __init__(
|
| 118 |
+
self,
|
| 119 |
+
d_model: int,
|
| 120 |
+
n_head: int,
|
| 121 |
+
mlp_ratio: float = 4.0,
|
| 122 |
+
act_layer: Callable = nn.GELU,
|
| 123 |
+
scale_cosine_attn: bool = False,
|
| 124 |
+
scale_heads: bool = False,
|
| 125 |
+
scale_attn: bool = False,
|
| 126 |
+
scale_fc: bool = False,
|
| 127 |
+
):
|
| 128 |
+
super().__init__()
|
| 129 |
+
|
| 130 |
+
self.ln_1 = LayerNorm(d_model)
|
| 131 |
+
# FIXME torchscript issues need to be resolved for custom attention
|
| 132 |
+
# if scale_cosine_attn or scale_heads:
|
| 133 |
+
# self.attn = Attention(
|
| 134 |
+
# d_model, n_head,
|
| 135 |
+
# scaled_cosine=scale_cosine_attn,
|
| 136 |
+
# scale_heads=scale_heads,
|
| 137 |
+
# )
|
| 138 |
+
self.attn = nn.MultiheadAttention(d_model, n_head)
|
| 139 |
+
self.ln_attn = LayerNorm(d_model) if scale_attn else nn.Identity()
|
| 140 |
+
|
| 141 |
+
self.ln_2 = LayerNorm(d_model)
|
| 142 |
+
mlp_width = int(d_model * mlp_ratio)
|
| 143 |
+
self.mlp = nn.Sequential(OrderedDict([
|
| 144 |
+
("c_fc", nn.Linear(d_model, mlp_width)),
|
| 145 |
+
('ln', LayerNorm(mlp_width) if scale_fc else nn.Identity()),
|
| 146 |
+
("gelu", act_layer()),
|
| 147 |
+
("c_proj", nn.Linear(mlp_width, d_model))
|
| 148 |
+
]))
|
| 149 |
+
|
| 150 |
+
def attention(self, x: torch.Tensor, attn_mask: Optional[torch.Tensor] = None):
|
| 151 |
+
return self.attn(x, x, x, need_weights=False, attn_mask=attn_mask)[0]
|
| 152 |
+
# FIXME torchscript issues need resolving for custom attention option to work
|
| 153 |
+
# if self.use_torch_attn:
|
| 154 |
+
# return self.attn(x, x, x, need_weights=False, attn_mask=attn_mask)[0]
|
| 155 |
+
# else:
|
| 156 |
+
# return self.attn(x, attn_mask=attn_mask)
|
| 157 |
+
|
| 158 |
+
def cross_attention(self, x: torch.Tensor, context: torch.Tensor, attn_mask: Optional[torch.Tensor] = None):
|
| 159 |
+
return self.attn(x, context, context, need_weights=False, attn_mask=attn_mask)[0]
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def forward(self, x: torch.Tensor, attn_mask: Optional[torch.Tensor] = None):
|
| 163 |
+
x = x + self.ln_attn(self.attention(self.ln_1(x), attn_mask=attn_mask))
|
| 164 |
+
x = x + self.mlp(self.ln_2(x))
|
| 165 |
+
return x
|
| 166 |
+
|
| 167 |
+
class Transformer(nn.Module):
|
| 168 |
+
def __init__(self, width: int, layers: int, heads: int, mlp_ratio: float = 4.0, act_layer: Callable = nn.GELU):
|
| 169 |
+
super().__init__()
|
| 170 |
+
self.width = width
|
| 171 |
+
self.layers = layers
|
| 172 |
+
|
| 173 |
+
self.resblocks = nn.ModuleList([
|
| 174 |
+
ResidualAttentionBlock(width, heads, mlp_ratio, act_layer=act_layer)
|
| 175 |
+
for _ in range(layers)
|
| 176 |
+
])
|
| 177 |
+
|
| 178 |
+
def forward(self, x: torch.Tensor, attn_mask: Optional[torch.Tensor] = None):
|
| 179 |
+
for r in self.resblocks:
|
| 180 |
+
x = r(x, attn_mask=attn_mask)
|
| 181 |
+
return x
|
| 182 |
+
|
| 183 |
+
class TextTransformer(nn.Module):
|
| 184 |
+
def __init__(
|
| 185 |
+
self,
|
| 186 |
+
vocab_size: int,
|
| 187 |
+
width: int,
|
| 188 |
+
layers: int,
|
| 189 |
+
heads: int,
|
| 190 |
+
context_length: int,
|
| 191 |
+
embed_dim: int,
|
| 192 |
+
act_layer: Callable = nn.GELU,
|
| 193 |
+
):
|
| 194 |
+
super().__init__()
|
| 195 |
+
self.transformer = Transformer(
|
| 196 |
+
width=width,
|
| 197 |
+
layers=layers,
|
| 198 |
+
heads=heads,
|
| 199 |
+
act_layer=act_layer,
|
| 200 |
+
)
|
| 201 |
+
self.context_length = context_length
|
| 202 |
+
self.vocab_size = vocab_size
|
| 203 |
+
self.token_embedding = nn.Embedding(vocab_size, width)
|
| 204 |
+
self.positional_embedding = nn.Parameter(torch.empty(context_length, width))
|
| 205 |
+
self.ln_final = LayerNorm(width)
|
| 206 |
+
|
| 207 |
+
self.text_projection = nn.Parameter(torch.empty(width, embed_dim))
|
| 208 |
+
self.logit_scale = nn.Parameter(torch.ones([]) * np.log(1 / 0.07))
|
| 209 |
+
self.register_buffer('attn_mask', self.build_attention_mask(), persistent=False)
|
| 210 |
+
|
| 211 |
+
self.init_parameters()
|
| 212 |
+
|
| 213 |
+
def init_parameters(self):
|
| 214 |
+
nn.init.normal_(self.token_embedding.weight, std=0.02)
|
| 215 |
+
nn.init.normal_(self.positional_embedding, std=0.01)
|
| 216 |
+
nn.init.constant_(self.logit_scale, np.log(1 / 0.07))
|
| 217 |
+
|
| 218 |
+
proj_std = (self.transformer.width ** -0.5) * ((2 * self.transformer.layers) ** -0.5)
|
| 219 |
+
attn_std = self.transformer.width ** -0.5
|
| 220 |
+
fc_std = (2 * self.transformer.width) ** -0.5
|
| 221 |
+
for block in self.transformer.resblocks:
|
| 222 |
+
nn.init.normal_(block.attn.in_proj_weight, std=attn_std)
|
| 223 |
+
nn.init.normal_(block.attn.out_proj.weight, std=proj_std)
|
| 224 |
+
nn.init.normal_(block.mlp.c_fc.weight, std=fc_std)
|
| 225 |
+
nn.init.normal_(block.mlp.c_proj.weight, std=proj_std)
|
| 226 |
+
|
| 227 |
+
if self.text_projection is not None:
|
| 228 |
+
nn.init.normal_(self.text_projection, std=self.transformer.width ** -0.5)
|
| 229 |
+
|
| 230 |
+
def build_attention_mask(self):
|
| 231 |
+
# lazily create causal attention mask, with full attention between the vision tokens
|
| 232 |
+
# pytorch uses additive attention mask; fill with -inf
|
| 233 |
+
mask = torch.empty(self.context_length, self.context_length)
|
| 234 |
+
mask.fill_(float("-inf"))
|
| 235 |
+
mask.triu_(1) # zero out the lower diagonal
|
| 236 |
+
return mask
|
| 237 |
+
|
| 238 |
+
def forward_features(self, text: torch.Tensor):
|
| 239 |
+
x = self.token_embedding(text) # [batch_size, n_ctx, d_model]
|
| 240 |
+
|
| 241 |
+
x = x + self.positional_embedding
|
| 242 |
+
x = x.permute(1, 0, 2) # NLD -> LND
|
| 243 |
+
x = self.transformer(x, attn_mask=self.attn_mask)
|
| 244 |
+
x = x.permute(1, 0, 2) # LND -> NLD
|
| 245 |
+
x = self.ln_final(x)
|
| 246 |
+
|
| 247 |
+
# x.shape = [batch_size, n_ctx, transformer.width]
|
| 248 |
+
# take features from the eot embedding (eot_token is the highest number in each sequence)
|
| 249 |
+
x = x[torch.arange(x.shape[0]), text.argmax(dim=-1)]
|
| 250 |
+
return x
|
| 251 |
+
|
| 252 |
+
def forward(self, x: torch.Tensor):
|
| 253 |
+
x = self.forward_features(x)
|
| 254 |
+
if self.text_projection is not None:
|
| 255 |
+
x = x @ self.text_projection
|
| 256 |
+
return x
|
| 257 |
+
|
| 258 |
+
@dataclass
|
| 259 |
+
class CLIPVisionCfg:
|
| 260 |
+
layers: Union[Tuple[int, int, int, int], int] = 12
|
| 261 |
+
width: int = 768
|
| 262 |
+
head_width: int = 64
|
| 263 |
+
mlp_ratio: float = 4.0
|
| 264 |
+
patch_size: int = 16
|
| 265 |
+
image_size: Union[Tuple[int, int], int] = 224
|
| 266 |
+
layer_scale_init_value: float = None
|
| 267 |
+
drop_path_rate: float = 0.
|
| 268 |
+
fusedLN: bool = False
|
| 269 |
+
xattn: bool = False
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
@dataclass
|
| 273 |
+
class CLIPTextCfg:
|
| 274 |
+
context_length: int = 77
|
| 275 |
+
vocab_size: int = 49408
|
| 276 |
+
width: int = 512
|
| 277 |
+
heads: int = 8
|
| 278 |
+
layers: int = 12
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
class EVA_CLIP(nn.Module):
|
| 283 |
+
def __init__(
|
| 284 |
+
self,
|
| 285 |
+
embed_dim: int,
|
| 286 |
+
vision_cfg: CLIPVisionCfg,
|
| 287 |
+
text_cfg: CLIPTextCfg,
|
| 288 |
+
quick_gelu: bool = False,
|
| 289 |
+
):
|
| 290 |
+
super().__init__()
|
| 291 |
+
if isinstance(vision_cfg, dict):
|
| 292 |
+
vision_cfg = CLIPVisionCfg(**vision_cfg)
|
| 293 |
+
if isinstance(text_cfg, dict):
|
| 294 |
+
text_cfg = CLIPTextCfg(**text_cfg)
|
| 295 |
+
|
| 296 |
+
# OpenAI models are pretrained w/ QuickGELU but native nn.GELU is both faster and more
|
| 297 |
+
# memory efficient in recent PyTorch releases (>= 1.10).
|
| 298 |
+
act_layer = QuickGELU if quick_gelu else nn.GELU
|
| 299 |
+
|
| 300 |
+
vision_heads = vision_cfg.width // vision_cfg.head_width
|
| 301 |
+
self.visual = VisionTransformer(
|
| 302 |
+
img_size=vision_cfg.image_size,
|
| 303 |
+
patch_size=vision_cfg.patch_size,
|
| 304 |
+
num_classes=embed_dim,
|
| 305 |
+
use_mean_pooling=False,
|
| 306 |
+
init_values=vision_cfg.layer_scale_init_value,
|
| 307 |
+
embed_dim=vision_cfg.width,
|
| 308 |
+
depth=vision_cfg.layers,
|
| 309 |
+
num_heads=vision_heads,
|
| 310 |
+
mlp_ratio=vision_cfg.mlp_ratio,
|
| 311 |
+
qkv_bias=True,
|
| 312 |
+
drop_path_rate=vision_cfg.drop_path_rate,
|
| 313 |
+
norm_layer= partial(FusedLayerNorm, eps=1e-6) if vision_cfg.fusedLN else partial(nn.LayerNorm, eps=1e-6),
|
| 314 |
+
xattn=vision_cfg.xattn
|
| 315 |
+
)
|
| 316 |
+
|
| 317 |
+
self.text = TextTransformer(
|
| 318 |
+
vocab_size=text_cfg.vocab_size,
|
| 319 |
+
width=text_cfg.width,
|
| 320 |
+
layers=text_cfg.layers,
|
| 321 |
+
heads=text_cfg.heads,
|
| 322 |
+
context_length=text_cfg.context_length,
|
| 323 |
+
embed_dim=embed_dim,
|
| 324 |
+
act_layer=act_layer
|
| 325 |
+
)
|
| 326 |
+
|
| 327 |
+
def encode_image(self, image):
|
| 328 |
+
return self.visual(image)
|
| 329 |
+
|
| 330 |
+
def encode_text(self, text):
|
| 331 |
+
return self.text(text)
|
| 332 |
+
|
| 333 |
+
def forward(self, image, text):
|
| 334 |
+
if image is None:
|
| 335 |
+
return self.encode_text(text)
|
| 336 |
+
elif text is None:
|
| 337 |
+
return self.encode_image(image)
|
| 338 |
+
image_features = self.encode_image(image)
|
| 339 |
+
image_features = F.normalize(image_features, dim=-1)
|
| 340 |
+
|
| 341 |
+
text_features = self.encode_text(text)
|
| 342 |
+
text_features = F.normalize(text_features, dim=-1)
|
| 343 |
+
|
| 344 |
+
return image_features, text_features, self.text.logit_scale.exp()
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def convert_weights_to_fp16(model: nn.Module):
|
| 348 |
+
"""Convert applicable model parameters to fp16"""
|
| 349 |
+
|
| 350 |
+
def _convert_weights_to_fp16(l):
|
| 351 |
+
if isinstance(l, (nn.Conv1d, nn.Conv2d, nn.Linear)):
|
| 352 |
+
l.weight.data = l.weight.data.half()
|
| 353 |
+
if l.bias is not None:
|
| 354 |
+
l.bias.data = l.bias.data.half()
|
| 355 |
+
|
| 356 |
+
if isinstance(l, (nn.MultiheadAttention, Attention)):
|
| 357 |
+
for attr in [*[f"{s}_proj_weight" for s in ["in", "q", "k", "v"]], "in_proj_bias", "bias_k", "bias_v"]:
|
| 358 |
+
tensor = getattr(l, attr)
|
| 359 |
+
if tensor is not None:
|
| 360 |
+
tensor.data = tensor.data.half()
|
| 361 |
+
|
| 362 |
+
for name in ["text_projection", "proj"]:
|
| 363 |
+
if hasattr(l, name):
|
| 364 |
+
attr = getattr(l, name)
|
| 365 |
+
if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as F
|
| 8 |
+
from torch import nn
|
| 9 |
+
|
| 10 |
+
class Bottleneck(nn.Module):
|
| 11 |
+
expansion = 4
|
| 12 |
+
|
| 13 |
+
def __init__(self, inplanes, planes, stride=1):
|
| 14 |
+
super().__init__()
|
| 15 |
+
|
| 16 |
+
# all conv layers have stride 1. an avgpool is performed after the second convolution when stride > 1
|
| 17 |
+
self.conv1 = nn.Conv2d(inplanes, planes, 1, bias=False)
|
| 18 |
+
self.bn1 = nn.BatchNorm2d(planes)
|
| 19 |
+
|
| 20 |
+
self.conv2 = nn.Conv2d(planes, planes, 3, padding=1, bias=False)
|
| 21 |
+
self.bn2 = nn.BatchNorm2d(planes)
|
| 22 |
+
|
| 23 |
+
self.avgpool = nn.AvgPool2d(stride) if stride > 1 else nn.Identity()
|
| 24 |
+
|
| 25 |
+
self.conv3 = nn.Conv2d(planes, planes * self.expansion, 1, bias=False)
|
| 26 |
+
self.bn3 = nn.BatchNorm2d(planes * self.expansion)
|
| 27 |
+
|
| 28 |
+
self.relu = nn.ReLU(inplace=True)
|
| 29 |
+
self.downsample = None
|
| 30 |
+
self.stride = stride
|
| 31 |
+
|
| 32 |
+
if stride > 1 or inplanes != planes * Bottleneck.expansion:
|
| 33 |
+
# downsampling layer is prepended with an avgpool, and the subsequent convolution has stride 1
|
| 34 |
+
self.downsample = nn.Sequential(OrderedDict([
|
| 35 |
+
("-1", nn.AvgPool2d(stride)),
|
| 36 |
+
("0", nn.Conv2d(inplanes, planes * self.expansion, 1, stride=1, bias=False)),
|
| 37 |
+
("1", nn.BatchNorm2d(planes * self.expansion))
|
| 38 |
+
]))
|
| 39 |
+
|
| 40 |
+
def forward(self, x: torch.Tensor):
|
| 41 |
+
identity = x
|
| 42 |
+
|
| 43 |
+
out = self.relu(self.bn1(self.conv1(x)))
|
| 44 |
+
out = self.relu(self.bn2(self.conv2(out)))
|
| 45 |
+
out = self.avgpool(out)
|
| 46 |
+
out = self.bn3(self.conv3(out))
|
| 47 |
+
|
| 48 |
+
if self.downsample is not None:
|
| 49 |
+
identity = self.downsample(x)
|
| 50 |
+
|
| 51 |
+
out += identity
|
| 52 |
+
out = self.relu(out)
|
| 53 |
+
return out
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class AttentionPool2d(nn.Module):
|
| 57 |
+
def __init__(self, spacial_dim: int, embed_dim: int, num_heads: int, output_dim: int = None):
|
| 58 |
+
super().__init__()
|
| 59 |
+
self.positional_embedding = nn.Parameter(torch.randn(spacial_dim ** 2 + 1, embed_dim) / embed_dim ** 0.5)
|
| 60 |
+
self.k_proj = nn.Linear(embed_dim, embed_dim)
|
| 61 |
+
self.q_proj = nn.Linear(embed_dim, embed_dim)
|
| 62 |
+
self.v_proj = nn.Linear(embed_dim, embed_dim)
|
| 63 |
+
self.c_proj = nn.Linear(embed_dim, output_dim or embed_dim)
|
| 64 |
+
self.num_heads = num_heads
|
| 65 |
+
|
| 66 |
+
def forward(self, x, return_all_tokens=False):
|
| 67 |
+
x = x.reshape(x.shape[0], x.shape[1], x.shape[2] * x.shape[3]).permute(2, 0, 1) # NCHW -> (HW)NC
|
| 68 |
+
x = torch.cat([x.mean(dim=0, keepdim=True), x], dim=0) # (HW+1)NC
|
| 69 |
+
x = x + self.positional_embedding[:, None, :].to(x.dtype) # (HW+1)NC
|
| 70 |
+
x, _ = F.multi_head_attention_forward(
|
| 71 |
+
query=x, key=x, value=x,
|
| 72 |
+
embed_dim_to_check=x.shape[-1],
|
| 73 |
+
num_heads=self.num_heads,
|
| 74 |
+
q_proj_weight=self.q_proj.weight,
|
| 75 |
+
k_proj_weight=self.k_proj.weight,
|
| 76 |
+
v_proj_weight=self.v_proj.weight,
|
| 77 |
+
in_proj_weight=None,
|
| 78 |
+
in_proj_bias=torch.cat([self.q_proj.bias, self.k_proj.bias, self.v_proj.bias]),
|
| 79 |
+
bias_k=None,
|
| 80 |
+
bias_v=None,
|
| 81 |
+
add_zero_attn=False,
|
| 82 |
+
dropout_p=0,
|
| 83 |
+
out_proj_weight=self.c_proj.weight,
|
| 84 |
+
out_proj_bias=self.c_proj.bias,
|
| 85 |
+
use_separate_proj_weight=True,
|
| 86 |
+
training=self.training,
|
| 87 |
+
need_weights=False
|
| 88 |
+
)
|
| 89 |
+
if return_all_tokens:
|
| 90 |
+
return x
|
| 91 |
+
else:
|
| 92 |
+
return x[0]
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
class ModifiedResNet(nn.Module):
|
| 96 |
+
"""
|
| 97 |
+
A ResNet class that is similar to torchvision's but contains the following changes:
|
| 98 |
+
- There are now 3 "stem" convolutions as opposed to 1, with an average pool instead of a max pool.
|
| 99 |
+
- Performs anti-aliasing strided convolutions, where an avgpool is prepended to convolutions with stride > 1
|
| 100 |
+
- The final pooling layer is a QKV attention instead of an average pool
|
| 101 |
+
"""
|
| 102 |
+
|
| 103 |
+
def __init__(self, layers, output_dim, heads, input_resolution=224, width=64):
|
| 104 |
+
super().__init__()
|
| 105 |
+
self.output_dim = output_dim
|
| 106 |
+
self.input_resolution = input_resolution
|
| 107 |
+
|
| 108 |
+
# the 3-layer stem
|
| 109 |
+
self.conv1 = nn.Conv2d(3, width // 2, kernel_size=3, stride=2, padding=1, bias=False)
|
| 110 |
+
self.bn1 = nn.BatchNorm2d(width // 2)
|
| 111 |
+
self.conv2 = nn.Conv2d(width // 2, width // 2, kernel_size=3, padding=1, bias=False)
|
| 112 |
+
self.bn2 = nn.BatchNorm2d(width // 2)
|
| 113 |
+
self.conv3 = nn.Conv2d(width // 2, width, kernel_size=3, padding=1, bias=False)
|
| 114 |
+
self.bn3 = nn.BatchNorm2d(width)
|
| 115 |
+
self.avgpool = nn.AvgPool2d(2)
|
| 116 |
+
self.relu = nn.ReLU(inplace=True)
|
| 117 |
+
|
| 118 |
+
# residual layers
|
| 119 |
+
self._inplanes = width # this is a *mutable* variable used during construction
|
| 120 |
+
self.layer1 = self._make_layer(width, layers[0])
|
| 121 |
+
self.layer2 = self._make_layer(width * 2, layers[1], stride=2)
|
| 122 |
+
self.layer3 = self._make_layer(width * 4, layers[2], stride=2)
|
| 123 |
+
self.layer4 = self._make_layer(width * 8, layers[3], stride=2)
|
| 124 |
+
|
| 125 |
+
embed_dim = width * 32 # the ResNet feature dimension
|
| 126 |
+
self.attnpool = AttentionPool2d(input_resolution // 32, embed_dim, heads, output_dim)
|
| 127 |
+
|
| 128 |
+
def _make_layer(self, planes, blocks, stride=1):
|
| 129 |
+
layers = [Bottleneck(self._inplanes, planes, stride)]
|
| 130 |
+
|
| 131 |
+
self._inplanes = planes * Bottleneck.expansion
|
| 132 |
+
for _ in range(1, blocks):
|
| 133 |
+
layers.append(Bottleneck(self._inplanes, planes))
|
| 134 |
+
|
| 135 |
+
return nn.Sequential(*layers)
|
| 136 |
+
|
| 137 |
+
def forward(self, x, return_side_out=False, return_all_tokens=False):
|
| 138 |
+
def stem(x):
|
| 139 |
+
for conv, bn in [(self.conv1, self.bn1), (self.conv2, self.bn2), (self.conv3, self.bn3)]:
|
| 140 |
+
x = self.relu(bn(conv(x)))
|
| 141 |
+
x = self.avgpool(x)
|
| 142 |
+
return x
|
| 143 |
+
out = []
|
| 144 |
+
x = x.type(self.conv1.weight.dtype)
|
| 145 |
+
x = stem(x)
|
| 146 |
+
x = self.layer1(x)
|
| 147 |
+
if return_side_out:
|
| 148 |
+
out.append(x)
|
| 149 |
+
x = self.layer2(x)
|
| 150 |
+
if return_side_out:
|
| 151 |
+
out.append(x)
|
| 152 |
+
x = self.layer3(x)
|
| 153 |
+
if return_side_out:
|
| 154 |
+
out.append(x)
|
| 155 |
+
x = self.layer4(x)
|
| 156 |
+
if return_side_out:
|
| 157 |
+
out.append(x)
|
| 158 |
+
x = self.attnpool(x, return_all_tokens)
|
| 159 |
+
out.append(x)
|
| 160 |
+
if len(out) == 1:
|
| 161 |
+
return x
|
| 162 |
+
else:
|
| 163 |
+
return out
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
class LayerNorm(nn.LayerNorm):
|
| 167 |
+
"""Subclass torch's LayerNorm to handle fp16."""
|
| 168 |
+
|
| 169 |
+
def forward(self, x: torch.Tensor):
|
| 170 |
+
orig_type = x.dtype
|
| 171 |
+
ret = super().forward(x.type(torch.float32))
|
| 172 |
+
return ret.type(orig_type)
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
class QuickGELU(nn.Module):
|
| 176 |
+
def forward(self, x: torch.Tensor):
|
| 177 |
+
return x * torch.sigmoid(1.702 * x)
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
class ResidualAttentionBlock(nn.Module):
|
| 181 |
+
def __init__(self, d_model: int, n_head: int, attn_mask: torch.Tensor = None):
|
| 182 |
+
super().__init__()
|
| 183 |
+
|
| 184 |
+
self.attn = nn.MultiheadAttention(d_model, n_head)
|
| 185 |
+
self.ln_1 = LayerNorm(d_model)
|
| 186 |
+
self.mlp = nn.Sequential(OrderedDict([
|
| 187 |
+
("c_fc", nn.Linear(d_model, d_model * 4)),
|
| 188 |
+
("gelu", QuickGELU()),
|
| 189 |
+
("c_proj", nn.Linear(d_model * 4, d_model))
|
| 190 |
+
]))
|
| 191 |
+
self.ln_2 = LayerNorm(d_model)
|
| 192 |
+
self.attn_mask = attn_mask
|
| 193 |
+
|
| 194 |
+
def attention(self, x: torch.Tensor):
|
| 195 |
+
self.attn_mask = self.attn_mask.to(dtype=x.dtype, device=x.device) if self.attn_mask is not None else None
|
| 196 |
+
return self.attn(x, x, x, need_weights=False, attn_mask=self.attn_mask)[0]
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
def forward(self, x: torch.Tensor):
|
| 200 |
+
x = x + self.attention(self.ln_1(x))
|
| 201 |
+
x = x + self.mlp(self.ln_2(x))
|
| 202 |
+
return x
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
class Transformer(nn.Module):
|
| 206 |
+
def __init__(self, width: int, layers: int, heads: int, attn_mask: torch.Tensor = None):
|
| 207 |
+
super().__init__()
|
| 208 |
+
self.width = width
|
| 209 |
+
self.layers = layers
|
| 210 |
+
self.resblocks = nn.Sequential(*[ResidualAttentionBlock(width, heads, attn_mask) for _ in range(layers)])
|
| 211 |
+
|
| 212 |
+
def forward(self, x: torch.Tensor):
|
| 213 |
+
return self.resblocks(x)
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
class VisionTransformer(nn.Module):
|
| 217 |
+
def __init__(self, input_resolution: int, patch_size: int, width: int, layers: int, heads: int, output_dim: int):
|
| 218 |
+
super().__init__()
|
| 219 |
+
self.input_resolution = input_resolution
|
| 220 |
+
self.output_dim = output_dim
|
| 221 |
+
self.conv1 = nn.Conv2d(in_channels=3, out_channels=width, kernel_size=patch_size, stride=patch_size, bias=False)
|
| 222 |
+
|
| 223 |
+
scale = width ** -0.5
|
| 224 |
+
self.class_embedding = nn.Parameter(scale * torch.randn(width))
|
| 225 |
+
self.positional_embedding = nn.Parameter(scale * torch.randn((input_resolution // patch_size) ** 2 + 1, width))
|
| 226 |
+
self.ln_pre = LayerNorm(width)
|
| 227 |
+
self.patch_shape = (input_resolution // patch_size, ) * 2
|
| 228 |
+
|
| 229 |
+
self.patch_size = patch_size
|
| 230 |
+
|
| 231 |
+
self.transformer = Transformer(width, layers, heads)
|
| 232 |
+
|
| 233 |
+
self.ln_post = LayerNorm(width)
|
| 234 |
+
self.proj = nn.Parameter(scale * torch.randn(width, output_dim))
|
| 235 |
+
|
| 236 |
+
def interpolate_pos_encoding(self, x, w, h):
|
| 237 |
+
class_pos_embed = self.positional_embedding[0]
|
| 238 |
+
patch_pos_embed = self.positional_embedding[1:]
|
| 239 |
+
dim = x.shape[-1]
|
| 240 |
+
# we add a small number to avoid floating point error in the interpolation
|
| 241 |
+
# see discussion at https://github.com/facebookresearch/dino/issues/8
|
| 242 |
+
# w0, h0 = w + 0.1, h + 0.1
|
| 243 |
+
n, m = self.patch_shape
|
| 244 |
+
patch_pos_embed = nn.functional.interpolate(
|
| 245 |
+
patch_pos_embed.reshape(1, n, m, dim).permute(0, 3, 1, 2),
|
| 246 |
+
scale_factor=(w / n, h / m),
|
| 247 |
+
mode='bicubic',
|
| 248 |
+
)
|
| 249 |
+
assert int(w) == patch_pos_embed.shape[-2] and int(h) == patch_pos_embed.shape[-1]
|
| 250 |
+
patch_pos_embed = patch_pos_embed.permute(0, 2, 3, 1).view(-1, dim)
|
| 251 |
+
return torch.cat((class_pos_embed.unsqueeze(0), patch_pos_embed), dim=0)
|
| 252 |
+
|
| 253 |
+
def forward(self, x: torch.Tensor):
|
| 254 |
+
x = self.conv1(x) # shape = [*, width, grid, grid]
|
| 255 |
+
bsz, _, w, h = x.size()
|
| 256 |
+
x = x.reshape(x.shape[0], x.shape[1], -1) # shape = [*, width, grid ** 2]
|
| 257 |
+
x = x.permute(0, 2, 1) # shape = [*, grid ** 2, width]
|
| 258 |
+
x = torch.cat([self.class_embedding.to(x.dtype) + torch.zeros(x.shape[0], 1, x.shape[-1], dtype=x.dtype, device=x.device), x], dim=1) # shape = [*, grid ** 2 + 1, width]
|
| 259 |
+
if w != self.patch_shape[0] or h != self.patch_shape[1]:
|
| 260 |
+
x = x + self.interpolate_pos_encoding(x, w, h)
|
| 261 |
+
else:
|
| 262 |
+
x = x + self.positional_embedding.to(x.dtype)
|
| 263 |
+
x = self.ln_pre(x)
|
| 264 |
+
|
| 265 |
+
x = x.permute(1, 0, 2) # NLD -> LND
|
| 266 |
+
x = self.transformer(x)
|
| 267 |
+
x = x.permute(1, 0, 2) # LND -> NLD
|
| 268 |
+
|
| 269 |
+
x = x[:, 1:, :] ### w/o cls token
|
| 270 |
+
x = self.ln_post(x) ### norm
|
| 271 |
+
if self.proj is not None:
|
| 272 |
+
x = x @ self.proj ### proj to low dim
|
| 273 |
+
return x
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
class CLIP(nn.Module):
|
| 278 |
+
def __init__(self,
|
| 279 |
+
embed_dim: int,
|
| 280 |
+
# vision
|
| 281 |
+
image_resolution: int,
|
| 282 |
+
vision_layers: Union[Tuple[int, int, int, int], int],
|
| 283 |
+
vision_width: int,
|
| 284 |
+
vision_patch_size: int,
|
| 285 |
+
# text
|
| 286 |
+
context_length: int,
|
| 287 |
+
vocab_size: int,
|
| 288 |
+
transformer_width: int,
|
| 289 |
+
transformer_heads: int,
|
| 290 |
+
transformer_layers: int
|
| 291 |
+
):
|
| 292 |
+
super().__init__()
|
| 293 |
+
|
| 294 |
+
self.context_length = context_length
|
| 295 |
+
|
| 296 |
+
if isinstance(vision_layers, (tuple, list)):
|
| 297 |
+
vision_heads = vision_width * 32 // 64
|
| 298 |
+
self.visual = ModifiedResNet(
|
| 299 |
+
layers=vision_layers,
|
| 300 |
+
output_dim=embed_dim,
|
| 301 |
+
heads=vision_heads,
|
| 302 |
+
input_resolution=image_resolution,
|
| 303 |
+
width=vision_width
|
| 304 |
+
)
|
| 305 |
+
else:
|
| 306 |
+
vision_heads = vision_width // 64
|
| 307 |
+
self.visual = VisionTransformer(
|
| 308 |
+
input_resolution=image_resolution,
|
| 309 |
+
patch_size=vision_patch_size,
|
| 310 |
+
width=vision_width,
|
| 311 |
+
layers=vision_layers,
|
| 312 |
+
heads=vision_heads,
|
| 313 |
+
output_dim=embed_dim
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
self.transformer = Transformer(
|
| 317 |
+
width=transformer_width,
|
| 318 |
+
layers=transformer_layers,
|
| 319 |
+
heads=transformer_heads,
|
| 320 |
+
attn_mask=self.build_attention_mask()
|
| 321 |
+
)
|
| 322 |
+
|
| 323 |
+
self.vocab_size = vocab_size
|
| 324 |
+
self.token_embedding = nn.Embedding(vocab_size, transformer_width)
|
| 325 |
+
self.positional_embedding = nn.Parameter(torch.empty(self.context_length, transformer_width))
|
| 326 |
+
self.ln_final = LayerNorm(transformer_width)
|
| 327 |
+
|
| 328 |
+
self.text_projection = nn.Parameter(torch.empty(transformer_width, embed_dim))
|
| 329 |
+
self.logit_scale = nn.Parameter(torch.ones([]) * np.log(1 / 0.07))
|
| 330 |
+
|
| 331 |
+
self.initialize_parameters()
|
| 332 |
+
|
| 333 |
+
def initialize_parameters(self):
|
| 334 |
+
nn.init.normal_(self.token_embedding.weight, std=0.02)
|
| 335 |
+
nn.init.normal_(self.positional_embedding, std=0.01)
|
| 336 |
+
|
| 337 |
+
if isinstance(self.visual, ModifiedResNet):
|
| 338 |
+
if self.visual.attnpool is not None:
|
| 339 |
+
std = self.visual.attnpool.c_proj.in_features ** -0.5
|
| 340 |
+
nn.init.normal_(self.visual.attnpool.q_proj.weight, std=std)
|
| 341 |
+
nn.init.normal_(self.visual.attnpool.k_proj.weight, std=std)
|
| 342 |
+
nn.init.normal_(self.visual.attnpool.v_proj.weight, std=std)
|
| 343 |
+
nn.init.normal_(self.visual.attnpool.c_proj.weight, std=std)
|
| 344 |
+
|
| 345 |
+
for resnet_block in [self.visual.layer1, self.visual.layer2, self.visual.layer3, self.visual.layer4]:
|
| 346 |
+
for name, param in resnet_block.named_parameters():
|
| 347 |
+
if name.endswith("bn3.weight"):
|
| 348 |
+
nn.init.zeros_(param)
|
| 349 |
+
|
| 350 |
+
proj_std = (self.transformer.width ** -0.5) * ((2 * self.transformer.layers) ** -0.5)
|
| 351 |
+
attn_std = self.transformer.width ** -0.5
|
| 352 |
+
fc_std = (2 * self.transformer.width) ** -0.5
|
| 353 |
+
for block in self.transformer.resblocks:
|
| 354 |
+
nn.init.normal_(block.attn.in_proj_weight, std=attn_std)
|
| 355 |
+
nn.init.normal_(block.attn.out_proj.weight, std=proj_std)
|
| 356 |
+
nn.init.normal_(block.mlp.c_fc.weight, std=fc_std)
|
| 357 |
+
nn.init.normal_(block.mlp.c_proj.weight, std=proj_std)
|
| 358 |
+
|
| 359 |
+
if self.text_projection is not None:
|
| 360 |
+
nn.init.normal_(self.text_projection, std=self.transformer.width ** -0.5)
|
| 361 |
+
|
| 362 |
+
def build_attention_mask(self):
|
| 363 |
+
# lazily create causal attention mask, with full attention between the vision tokens
|
| 364 |
+
# pytorch uses additive attention mask; fill with -inf
|
| 365 |
+
mask = torch.empty(self.context_length, self.context_length)
|
| 366 |
+
mask.fill_(float("-inf"))
|
| 367 |
+
mask.triu_(1) # zero out the lower diagonal
|
| 368 |
+
return mask
|
| 369 |
+
|
| 370 |
+
@property
|
| 371 |
+
def dtype(self):
|
| 372 |
+
return self.visual.conv1.weight.dtype
|
| 373 |
+
|
| 374 |
+
def encode_image(self, image):
|
| 375 |
+
return self.visual(image.type(self.dtype))
|
| 376 |
+
|
| 377 |
+
def encode_text(self, text):
|
| 378 |
+
x = self.token_embedding(text).type(self.dtype) # [batch_size, n_ctx, d_model]
|
| 379 |
+
|
| 380 |
+
x = x + self.positional_embedding.type(self.dtype)
|
| 381 |
+
x = x.permute(1, 0, 2) # NLD -> LND
|
| 382 |
+
x = self.transformer(x)
|
| 383 |
+
x = x.permute(1, 0, 2) # LND -> NLD
|
| 384 |
+
x = self.ln_final(x).type(self.dtype)
|
| 385 |
+
|
| 386 |
+
# x.shape = [batch_size, n_ctx, transformer.width]
|
| 387 |
+
# take features from the eot embedding (eot_token is the highest number in each sequence)
|
| 388 |
+
x = x[torch.arange(x.shape[0]), text.argmax(dim=-1)] @ self.text_projection
|
| 389 |
+
|
| 390 |
+
return x
|
| 391 |
+
|
| 392 |
+
def forward(self, image, text):
|
| 393 |
+
image_features = self.encode_image(image)
|
| 394 |
+
text_features = self.encode_text(text)
|
| 395 |
+
|
| 396 |
+
# normalized features
|
| 397 |
+
image_features = image_features / image_features.norm(dim=-1, keepdim=True)
|
| 398 |
+
text_features = text_features / text_features.norm(dim=-1, keepdim=True)
|
| 399 |
+
|
| 400 |
+
# cosine similarity as logits
|
| 401 |
+
logit_scale = self.logit_scale.exp()
|
| 402 |
+
logits_per_image = logit_scale * image_features @ text_features.t()
|
| 403 |
+
logits_per_text = logits_per_image.t()
|
| 404 |
+
|
| 405 |
+
# shape = [global_batch_size, global_batch_size]
|
| 406 |
+
return logits_per_image, logits_per_text
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
def convert_weights(model: nn.Module):
|
| 410 |
+
"""Convert applicable model parameters to fp16"""
|
| 411 |
+
|
| 412 |
+
def _convert_weights_to_fp16(l):
|
| 413 |
+
if isinstance(l, (nn.Conv1d, nn.Conv2d, nn.Linear)):
|
| 414 |
+
l.weight.data = l.weight.data.half()
|
| 415 |
+
if l.bias is not None:
|
| 416 |
+
l.bias.data = l.bias.data.half()
|
| 417 |
+
|
| 418 |
+
if isinstance(l, nn.MultiheadAttention):
|
| 419 |
+
for attr in [*[f"{s}_proj_weight" for s in ["in", "q", "k", "v"]], "in_proj_bias", "bias_k", "bias_v"]:
|
| 420 |
+
tensor = getattr(l, attr)
|
| 421 |
+
if tensor is not None:
|
| 422 |
+
tensor.data = tensor.data.half()
|
| 423 |
+
|
| 424 |
+
for name in ["text_projection", "proj"]:
|
| 425 |
+
if hasattr(l, name):
|
| 426 |
+
attr = getattr(l, name)
|
| 427 |
+
if attr is not None:
|
| 428 |
+
attr.data = attr.data.half()
|
| 429 |
+
|
| 430 |
+
model.apply(_convert_weights_to_fp16)
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
def build_model(state_dict: dict):
|
| 435 |
+
vit = "visual.proj" in state_dict
|
| 436 |
+
|
| 437 |
+
if vit:
|
| 438 |
+
vision_width = state_dict["visual.conv1.weight"].shape[0]
|
| 439 |
+
vision_layers = len([k for k in state_dict.keys() if k.startswith("visual.") and k.endswith(".attn.in_proj_weight")])
|
| 440 |
+
vision_patch_size = state_dict["visual.conv1.weight"].shape[-1]
|
| 441 |
+
grid_size = round((state_dict["visual.positional_embedding"].shape[0] - 1) ** 0.5)
|
| 442 |
+
image_resolution = vision_patch_size * grid_size
|
| 443 |
+
else:
|
| 444 |
+
counts: list = [len(set(k.split(".")[2] for k in state_dict if k.startswith(f"visual.layer{b}"))) for b in [1, 2, 3, 4]]
|
| 445 |
+
vision_layers = tuple(counts)
|
| 446 |
+
vision_width = state_dict["visual.layer1.0.conv1.weight"].shape[0]
|
| 447 |
+
output_width = round((state_dict["visual.attnpool.positional_embedding"].shape[0] - 1) ** 0.5)
|
| 448 |
+
vision_patch_size = None
|
| 449 |
+
assert output_width ** 2 + 1 == state_dict["visual.attnpool.positional_embedding"].shape[0]
|
| 450 |
+
image_resolution = output_width * 32
|
| 451 |
+
|
| 452 |
+
embed_dim = state_dict["text_projection"].shape[1]
|
| 453 |
+
context_length = state_dict["positional_embedding"].shape[0]
|
| 454 |
+
vocab_size = state_dict["token_embedding.weight"].shape[0]
|
| 455 |
+
transformer_width = state_dict["ln_final.weight"].shape[0]
|
| 456 |
+
transformer_heads = transformer_width // 64
|
| 457 |
+
transformer_layers = len(set(k.split(".")[2] for k in state_dict if k.startswith(f"transformer.resblocks")))
|
| 458 |
+
|
| 459 |
+
model = CLIP(
|
| 460 |
+
embed_dim,
|
| 461 |
+
image_resolution, vision_layers, vision_width, vision_patch_size,
|
| 462 |
+
context_length, vocab_size, transformer_width, transformer_heads, transformer_layers
|
| 463 |
+
)
|
| 464 |
+
|
| 465 |
+
for key in ["input_resolution", "context_length", "vocab_size"]:
|
| 466 |
+
if key in state_dict:
|
| 467 |
+
del state_dict[key]
|
| 468 |
+
|
| 469 |
+
convert_weights(model)
|
| 470 |
+
model.load_state_dict(state_dict)
|
| 471 |
+
return model.eval()
|
approach/ovod/APE/ape/modeling/text/eva01_clip/model_configs/EVA_CLIP_g_14.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"embed_dim": 1024,
|
| 3 |
+
"vision_cfg": {
|
| 4 |
+
"image_size": 224,
|
| 5 |
+
"layers": 40,
|
| 6 |
+
"width": 1408,
|
| 7 |
+
"head_width": 88,
|
| 8 |
+
"mlp_ratio": 4.3637,
|
| 9 |
+
"patch_size": 14,
|
| 10 |
+
"drop_path_rate": 0.0
|
| 11 |
+
},
|
| 12 |
+
"text_cfg": {
|
| 13 |
+
"context_length": 77,
|
| 14 |
+
"vocab_size": 49408,
|
| 15 |
+
"width": 768,
|
| 16 |
+
"heads": 12,
|
| 17 |
+
"layers": 12
|
| 18 |
+
}
|
| 19 |
+
}
|