Open ZhangYouyi opened 11 months ago
yes i think you are right
i am defined my metainfo in config file and pass
metainfo = { 'classes': ('whale',), }
and
train_dataloader = dict(
batch_size=1,
num_workers=2,
persistent_workers=True,
# sampler=dict(type='Balanced_sampler', shuffle=True),
sampler=dict(type='DefaultSampler', shuffle=True),
batch_sampler=dict(type='AspectRatioBatchSampler'),
dataset=dict(
type=dataset_type,
# data_root=data_root,
data_root='/media/pc2041/data/vip_lab/whale/whale_data/balanced_sampler/',
metainfo=metainfo,
ann_file='train.json',
data_prefix=dict(img='./'),
filter_cfg=dict(filter_empty_gt=False, min_size=32),
pipeline=train_pipeline,
backend_args=backend_args))
now when I inspect the dataset instance using VSCODE debugger I get the following
In MMDetection-3.0.0, to solve this problem temporarily, we can override CocoDataset
as the following python snippet
@DATASETS.register_module()
class CustomDataset(CocoDataset):
"""Customized Dataset for COCO detection format."""
METAINFO = {
'classes': (
'a', 'b', 'c'
)
}
, and update dataset type to be CustomDataset
in the corresponding config file.
@ZhangYouyi When I evaluate mmdet on my custom dataset as same format as COCO, I have the same problem which leads to"out of range" error in line 243 of coco_metric.py.
Although cocoapi is initialized by the specific annotation file, but its metainfo is still as same as coco, i.e. 80 classes.
In MMDetection-3.3.0, it can be solved by set "metainfo" in the config file as follow:
I'm not sure if this the common case, but with that approach inference with config like that is not working as expected (wrt to class indexes). To get the proper class_id:class_name map I've had to take my coco_annotations.json, get categories from that and -1 to all categories.
Checklist
Describe the bug mmdet.datasets.coco.CocoDataset may not support
metainfo
through config file.Reproduction
metainfo
config in config file referring to Prepare a config.Environment
sys.platform: linux Python: 3.7.3 CUDA available: True TorchVision: 0.13.0+cu116 OpenCV: 4.5.5 MMEngine: 0.7.3 MMDetection: 3.0.0+
Error traceback