tlc.integration.detectron2.register_coco_instances¶
A drop-in replacement for detectron2.data.datasets.register_coco_instances
Module Contents¶
Functions¶
Function |
Description |
|---|---|
Register a COCO dataset in Detectron2’s standard format. |
API¶
- register_coco_instances(
- name: str,
- metadata: dict,
- json_file: str,
- image_root: str | None,
- revision_url: str = '',
- project_name: str = '',
- keep_crowd_annotations: bool = True,
- task: Literal[detect, segment] = 'detect',
- mask_format: Literal[bitmask, polygon] = 'polygon',
Register a COCO dataset in Detectron2’s standard format.
This method works as a drop-in replacement for detectron2.data.datasets.register_coco_instances.
- References:
The original function reads the json file and uses
pycocoapito construct a list of dicts which are then registered under the keynamein detectron’sDatasetCatalog.These dicts have the following format:
{ "file_name": "COCO_train2014_000000000009.jpg", "height": 480, "width": 640, "image_id": 9, "annotations": [ { "bbox": [97.84, 12.43, 424.93, 407.73], "bbox_mode": 1, "category_id": 16, "iscrowd": 0, "segmentation": [[...]] }, ... ] }
This function also registers a list of dicts under the key
namein detectron’sDatasetCatalog, but before the data is generated, aTableis resolved. The first time the function is called with a given signature, a 3LCTableis created. On subsequent calls, the Table is replaced with the most recent descendant of the root table. If the resolved table contains a sample weight column, its value is sent along in the list of dicts under the keyweight.- Parameters:
name – the name that identifies a dataset, e.g. “coco_2014_train”.
metadata – extra metadata associated with this dataset.
json_file – path to the json instance annotation file.
image_root – directory which contains all the images.
Noneif the file_name contains a complete path.revision_url – url to a specific revision of the table. If not provided, the latest revision will be used. If the revision is not a descendant of the initial table, an error will be raised.
project_name – the name of the project.
keep_crowd_annotations – Whether to keep annotations with
iscrowd=1.task – the task to register the dataset for.
mask_format – the format to use for the masks (only used when task is “segment”). Corresponds to the detectron2 config
INPUT.MASK_FORMAT.
- Returns:
None