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.52k stars 591 forks source link

ERROR: assert hasattr(dataset, 'flag') #358

Closed cjyiiiing closed 2 years ago

cjyiiiing commented 2 years ago

I used the command python tools/train.py ./configs/vid/temporal_roi_align/mydata_selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py --device 1 to train Temporal ROI Align on my custom dataset, But I meet one error. The output is

Traceback (most recent call last): File "tools/train.py", line 179, in main() File "tools/train.py", line 175, in main meta=meta) File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/apis/train.py", line 93, in train_model seed=cfg.seed) for ds in dataset File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/apis/train.py", line 93, in seed=cfg.seed) for ds in dataset File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/datasets/builder.py", line 60, in build_dataloader sampler = GroupSampler(dataset, samples_per_gpu) if shuffle else None File "/home/fwq2/.conda/envs/open-mmlab/lib/python3.7/site-packages/mmdet/datasets/samplers/group_sampler.py", line 13, in init assert hasattr(dataset, 'flag') AssertionError

I have searched related issues but still cannot fix this error.

mydata_selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py:

_base_ = [
    '../../_base_/models/faster_rcnn_r50_dc5.py',
    '../../_base_/datasets/imagenet_vid_fgfa_style.py',
    '../../_base_/default_runtime.py'
]
dataset_type = 'CocoVideoDataset'
classes = ('target',)
num_classes = 1
data_root = '/home/fwq2/lab/cjy/dataset/mydata_OD/dataset/'

model = dict(
    type='SELSA',
    detector=dict(
        roi_head=dict(
            type='SelsaRoIHead',
            bbox_roi_extractor=dict(
                type='TemporalRoIAlign',
                roi_layer=dict(
                    type='RoIAlign', output_size=7, sampling_ratio=2),
                out_channels=512,
                featmap_strides=[16],
                num_most_similar_points=2,
                num_temporal_attention_blocks=4, 
),
            bbox_head=dict(
                type='SelsaBBoxHead',
                num_classes=num_classes,
                num_shared_fcs=3,
                aggregator=dict(
                    type='SelsaAggregator',
                    in_channels=1024,
                    num_attention_blocks=16)))))

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'])
        ])
]

# dataset settings
data = dict(
    samples_per_gpu = 1,
    workers_per_gpu = 2,
    train=[dict(
        type=dataset_type,
        classes = classes,
        ann_file = data_root + 'annotations/train.json',
        img_prefix = data_root + 'train/',
        pipeline = train_pipeline,
        # ref_img_sampler = None
        ref_img_sampler = dict(
            num_ref_imgs = 9,  
            frame_range = 9, 
            filter_key_img = True, 
            method = 'bilateral_uniform'),
        test_mode=True
    )],
    val=dict(
        type=dataset_type,
        classes = classes,
        ann_file = data_root + 'annotations/val.json',
        img_prefix = data_root + 'val/',
        pipeline = test_pipeline,
        ref_img_sampler=None,
        test_mode=True,
    ),
    test=dict(
        type=dataset_type,
        classes = classes,
        ann_file = data_root + 'annotations/val.json',
        img_prefix = data_root + 'val/',
        pipeline = test_pipeline,
        ref_img_sampler=None,
        test_mode=True,
    ))

# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(
    _delete_=True, grad_clip=dict(max_norm=35, norm_type=2))
# learning policy
lr_config = dict(
    policy='step',
    warmup='linear',
    warmup_iters=500,
    warmup_ratio=1.0 / 3,
    step=[2, 5])
# runtime settings
total_epochs = 7
evaluation = dict(metric=['bbox'], interval=1)
gpu_ids = range(0,)

my environment:

fatal: not a git repository (or any parent up to mount point /home) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). sys.platform: linux Python: 3.7.11 (default, Jul 27 2021, 14:32:16) [GCC 7.5.0] CUDA available: True GPU 0,1: Quadro RTX 8000 CUDA_HOME: /usr/local/cuda NVCC: Cuda compilation tools, release 10.2, V10.2.89 GCC: gcc (SUSE Linux) 7.5.0 PyTorch: 1.6.0 PyTorch compiling details: PyTorch built with:

  • GCC 7.3
  • C++ Version: 201402
  • Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v1.5.0 (Git Hash e2ac1fac44c5078ca927cb9b90e1b3066a0b2ed0)
  • OpenMP 201511 (a.k.a. OpenMP 4.5)
  • NNPACK is enabled
  • CPU capability usage: AVX2
  • CUDA Runtime 10.1
  • NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_37,code=compute_37
  • CuDNN 7.6.3
  • Magma 2.5.2
  • Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF,

TorchVision: 0.7.0 OpenCV: 4.5.4 MMCV: 1.3.18 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 10.1 MMTracking: 0.8.0+

GT9505 commented 2 years ago

Please use dist_train.sh to train models. Please refer to here to train VID methods.

cjyiiiing commented 2 years ago

I use this command now: bash ./tools/dist_train.sh ./configs/vid/temporal_roi_align/mydata_selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py 2 --work-dir ./mydata_selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid/

but still have the same error:

Traceback (most recent call last): File "./tools/train.py", line 179, in main() File "./tools/train.py", line 175, in main meta=meta) File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/apis/train.py", line 93, in train_model seed=cfg.seed) for ds in dataset File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/apis/train.py", line 93, in seed=cfg.seed) for ds in dataset File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/datasets/builder.py", line 49, in build_dataloader world_size, rank) File "/home/fwq2/.conda/envs/open-mmlab/lib/python3.7/site-packages/mmdet/datasets/samplers/group_sampler.py", line 90, in init assert hasattr(self.dataset, 'flag') AssertionError Traceback (most recent call last): File "./tools/train.py", line 179, in main() File "./tools/train.py", line 175, in main meta=meta) File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/apis/train.py", line 93, in train_model seed=cfg.seed) for ds in dataset File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/apis/train.py", line 93, in seed=cfg.seed) for ds in dataset File "/home/fwq2/lab/cjy/VOD/mmtracking/mmtrack/datasets/builder.py", line 49, in build_dataloader world_size, rank) File "/home/fwq2/.conda/envs/open-mmlab/lib/python3.7/site-packages/mmdet/datasets/samplers/group_sampler.py", line 90, in init assert hasattr(self.dataset, 'flag') AssertionError Traceback (most recent call last): File "/home/fwq2/.conda/envs/open-mmlab/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/home/fwq2/.conda/envs/open-mmlab/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/fwq2/.conda/envs/open-mmlab/lib/python3.7/site-packages/torch/distributed/launch.py", line 261, in main() File "/home/fwq2/.conda/envs/open-mmlab/lib/python3.7/site-packages/torch/distributed/launch.py", line 257, in main cmd=cmd) subprocess.CalledProcessError: Command '['/home/fwq2/.conda/envs/open-mmlab/bin/python', '-u', './tools/train.py', '--local_rank=1', './configs/vid/temporal_roi_align/mydata_selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py', '--launcher', 'pytorch', '--work-dir', './mydata_selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid/']' returned non-zero exit status 1.

GT9505 commented 2 years ago

Please set test_mode=False in the training dataset of your config, since test_mode=True means the dataset runing in testing mode.

Adeelyousaf commented 2 years ago

Hi, I am facing the same error. 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