open-mmlab / mmtracking

OpenMMLab Video Perception Toolbox. It supports Video Object Detection (VID), Multiple Object Tracking (MOT), Single Object Tracking (SOT), Video Instance Segmentation (VIS) with a unified framework.
https://mmtracking.readthedocs.io/en/latest/
Apache License 2.0
3.56k stars 598 forks source link

.conda/envs/mm_tracking/lib/python3.7/site-packages/mmdet/datasets/samplers/group_sampler.py", line 90, in init assert hasattr(self.dataset, 'flag') AssertionError #639

Open Adeelyousaf opened 2 years ago

Adeelyousaf commented 2 years ago

Hi, I am facing the same error https://github.com/open-mmlab/mmtracking/issues/358 And, I have tried the above given solutions but still no luck.

bash ./tools/dist_train.sh /configs/vid/temporal_roi_align/selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py 2

Traceback (most recent call last): File "./tools/train.py", line 251, in main() File "./tools/train.py", line 247, in main meta=meta) File "/home/ad358172/AY/mmtracking/mmtrack/apis/train.py", line 96, in train_model for ds in dataset File "/home/ad358172/AY/mmtracking/mmtrack/apis/train.py", line 96, in for ds in dataset File "/home/ad358172/AY/mmtracking/mmtrack/datasets/builder.py", line 93, in build_dataloader world_size, rank) File "/home/ad358172/.conda/envs/mm_tracking/lib/python3.7/site-packages/mmdet/datasets/samplers/group_sampler.py", line 90, in init assert hasattr(self.dataset, 'flag') AssertionError

my environment details are: TorchVision: 0.9.0 OpenCV: 4.6.0 MMCV: 1.6.1 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 11.1 MMTracking: 0.13.0+904407e

I have not modified the code, I am trying to run the given ILSVRC example

JingweiZhang12 commented 2 years ago

Can you print the details of self.datasets here?

Adeelyousaf commented 2 years ago

This is the configuration file I am using dataset_type = 'ImagenetVIDDataset' data_root = '/home/c3-0/datasets/ILSVRC2017data/ILSVRC/' img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [ dict(type='LoadMultiImagesFromFile'), dict(type='SeqLoadAnnotations', with_bbox=True, with_track=True), dict(type='SeqResize', img_scale=(1000, 600), keep_ratio=True), dict(type='SeqRandomFlip', share_params=True, flip_ratio=0.5), dict(type='SeqNormalize', img_norm_cfg), dict(type='SeqPad', size_divisor=16), dict( type='VideoCollect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_instance_ids']), dict(type='ConcatVideoReferences'), dict(type='SeqDefaultFormatBundle', ref_prefix='ref') ] test_pipeline = [ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(1000, 600), flip=False, transforms=[ dict(type='Resize', keep_ratio=True), dict(type='RandomFlip'), dict(type='Normalize', img_norm_cfg), dict(type='Pad', size_divisor=16), dict(type='ImageToTensor', keys=['img']), dict(type='VideoCollect', keys=['img']) ]) ] data = dict( samples_per_gpu=1, workers_per_gpu=2, train=[ dict( type=dataset_type, ann_file='/home/c3-0/datasets/ILSVRC2017/Annotations/VID/imagenet_vid_train.json', img_prefix=data_root + 'Data/VID', ref_img_sampler=dict( num_ref_imgs=1, frame_range=9, filter_key_img=False, method='uniform'), pipeline=train_pipeline), dict( type=dataset_type, load_as_video=False, ann_file='/home/c3-0/datasets/ILSVRC2017/Lists/imagenet_det_30plus1cls.json', img_prefix=data_root + 'Data/DET', ref_img_sampler=dict( num_ref_imgs=1, frame_range=0, filter_key_img=False, method='uniform'), pipeline=train_pipeline) ], val=dict( type=dataset_type, ann_file='/home/c3-0/datasets/ILSVRC2017/Annotations/VID/imagenet_vid_val.json', img_prefix=data_root + 'Data/VID', ref_img_sampler=None, pipeline=test_pipeline, test_mode=True), test=dict( type=dataset_type, ann_file='/home/c3-0/datasets/ILSVRC2017/Annotations/VID/imagenet_vid_val.json', img_prefix=data_root + 'Data/VID', ref_img_sampler=None, pipeline=test_pipeline, test_mode=True))

Adeelyousaf commented 2 years ago

here is the snipet of self.dataset

image

JingweiZhang12 commented 2 years ago

Werid, do you use the latest mmtracking? Let me explain the internal details: the ImageNetVIDDataset inferient from the CustomDataset in mmdet. The initilization of this class sets the flag: https://github.com/open-mmlab/mmdetection/blob/master/mmdet/datasets/custom.py#L126. May it help you.

dawnlh commented 2 years ago

@JingweiZhang12 @Adeelyousaf Hi~ I met the same error as mentioned above, but I find that the error of "assert hasattr(self.dataset, 'flag') AssertionError" is in fact caused by the config of "test_mode=True" in val's dict setting.

val=dict( type=dataset_type, ann_file='/home/c3-0/datasets/ILSVRC2017/Annotations/VID/imagenet_vid_val.json', img_prefix=data_root + 'Data/VID', ref_img_sampler=None, pipeline=test_pipeline, test_mode=True),

Specifically, with test_mode=True, the _set_group_flag() funciton https://github.com/open-mmlab/mmdetection/blob/master/mmdet/datasets/custom.py#L126 will be skipped for val dataset, and thus 'flag' key will not be added. These will cause AssertionError hasattr(self.dataset, 'flag') in GroupSampler(Sampler) init. I'm not sure is it a bug, or it's just a mistake of the config demo in the tutorial https://mmtracking.readthedocs.io/zh_CN/latest/tutorials/config_vid.html.

dawnlh commented 2 years ago

And by the way, in val dict's config, its pipeline is set to test_pipeline (according to the tutorial), but in https://github.com/open-mmlab/mmtracking/blob/be8a7afbd719b7846a76caca74dd7f331036cdc3/tools/train.py#L188, the pipeline is set to train_pipeline. It's confusing, why not directly set the val_pipeline to train_pipeline in the config file?