AttributeError: 'SegDataSample' object has no attribute 'gt_edge_map'
Thanks for your error report and we appreciate it a lot.
Checklist
- I have searched related issues but cannot get the expected help.
- The bug has not been fixed in the latest version.
Describe the bug When I ran the pidnet_s on my own seg dataset, I got this error: "AttributeError: 'SegDataSample' object has no attribute 'gt_edge_map'".
Reproduction
-
What command or script did you run? python .\tools\train.py .\configs\pidnet\pidnet-s_2xb6-6k_224x224-feces.py. "feces" is the name of my dataset.
-
Did you make any modifications on the code or config? Did you understand what you have modified? Yes, I know the meaning of config file, and I just modified the crop_size.
Environment
sys.platform: win32
Python: 3.8.17 (default, Jul 5 2023, 20:44:21) [MSC v.1916 64 bit (AMD64)]
CUDA available: True
numpy_random_seed: 2147483648
GPU 0: NVIDIA GeForce RTX 3080
CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7
NVCC: Cuda compilation tools, release 11.7, V11.7.64
MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.28.29334 版
GCC: n/a
PyTorch: 1.13.1+cu117
PyTorch compiling details: PyTorch built with:
- C++ Version: 199711
- MSVC 192829337
- Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
- OpenMP 2019
- LAPACK is enabled (usually provided by MKL)
- CPU capability usage: AVX2
- CUDA Runtime 11.7
- 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=com pute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
- CuDNN 8.5
- Magma 2.5.4
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.7, CUDNN_VERSION=8.5.0, CXX_COMPILER=C:/actions-runner/_work/pytorch/pytorch/builder/windows/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openm p:experimental -IC:/actions-runner/_work/pytorch/pytorch/builder/windows/mkl/include -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AV X2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,
TorchVision: 0.14.1+cu117 OpenCV: 4.8.0 MMEngine: 0.8.4 MMSegmentation: 1.1.0
Error traceback
09/26 17:01:39 - mmengine - INFO - Config: checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/pidnet/pidnet-s_imagenet1k_20230306-715e6273.pth' class_weight = [ 0.8, 0.9, 1.1, 1.1, ] crop_size = ( 224, 224, ) data_preprocessor = dict( bgr_to_rgb=True, mean=[ 123.675, 116.28, 103.53, ], pad_val=0, seg_pad_val=255, size=( 224, 224, ), std=[ 58.395, 57.12, 57.375, ], type='SegDataPreProcessor') data_root = 'D:\Allcode\mmlab\mmsegmentation-dev-1.x\data\data' dataset_type = 'Feces' default_hooks = dict( checkpoint=dict(by_epoch=False, interval=200, type='CheckpointHook'), logger=dict(interval=5, log_metric_by_epoch=False, type='LoggerHook'), param_scheduler=dict(type='ParamSchedulerHook'), sampler_seed=dict(type='DistSamplerSeedHook'), timer=dict(type='IterTimerHook'), visualization=dict(type='SegVisualizationHook')) default_scope = 'mmseg' env_cfg = dict( cudnn_benchmark=True, dist_cfg=dict(backend='nccl'), mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0)) img_ratios = [ 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, ] img_scale = ( 448, 448, ) iters = 6000 launcher = 'none' load_from = None log_level = 'INFO' log_processor = dict(by_epoch=False) model = dict( backbone=dict( act_cfg=dict(inplace=True, type='ReLU'), align_corners=False, channels=32, in_channels=3, init_cfg=dict( checkpoint= 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/pidnet/pidnet-s_imagenet1k_20230306-715e6273.pth', type='Pretrained'), norm_cfg=dict(requires_grad=True, type='SyncBN'), num_branch_blocks=3, num_stem_blocks=2, ppm_channels=96, type='PIDNet'), data_preprocessor=dict( bgr_to_rgb=True, mean=[ 123.675, 116.28, 103.53, ], pad_val=0, seg_pad_val=255, size=( 224, 224, ), std=[ 58.395, 57.12, 57.375, ], type='SegDataPreProcessor'), decode_head=dict( act_cfg=dict(inplace=True, type='ReLU'), align_corners=True, channels=128, in_channels=128, loss_decode=[ dict( class_weight=[ 0.8, 0.9, 1.1, 1.1, ], loss_weight=0.4, type='CrossEntropyLoss', use_sigmoid=False), dict( class_weight=[ 0.8, 0.9, 1.1, 1.1, ], loss_weight=1.0, min_kept=131072, thres=0.9, type='OhemCrossEntropy'), dict(loss_weight=20.0, type='BoundaryLoss'), dict( class_weight=[ 0.8, 0.9, 1.1, 1.1, ], loss_weight=1.0, min_kept=131072, thres=0.9, type='OhemCrossEntropy'), ], norm_cfg=dict(requires_grad=True, type='SyncBN'), num_classes=4, type='PIDHead'), test_cfg=dict(mode='whole'), train_cfg=dict(), type='EncoderDecoder') norm_cfg = dict(requires_grad=True, type='SyncBN') optim_wrapper = dict( clip_grad=None, optimizer=dict(lr=0.01, momentum=0.9, type='SGD', weight_decay=0.0005), type='OptimWrapper') optimizer = dict(lr=0.01, momentum=0.9, type='SGD', weight_decay=0.0005) param_scheduler = [ dict( begin=0, by_epoch=False, end=6000, eta_min=0, power=0.9, type='PolyLR'), ] randomness = dict(seed=304) resume = False test_cfg = dict(type='TestLoop') test_dataloader = dict( batch_size=1, dataset=dict( data_prefix=dict( img_path='images/validation', seg_map_path='annotations/validation'), data_root='D:\Allcode\mmlab\mmsegmentation-dev-1.x\data\data', pipeline=[ dict(type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 448, 448, ), type='Resize'), dict(type='LoadAnnotations'), dict(type='PackSegInputs'), ], type='Feces'), num_workers=2, persistent_workers=True, sampler=dict(shuffle=False, type='DefaultSampler')) test_evaluator = dict( iou_metrics=[ 'mDice', 'mIoU', 'mFscore', ], type='IoUMetric') test_pipeline = [ dict(type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 448, 448, ), type='Resize'), dict(type='LoadAnnotations'), dict(type='PackSegInputs'), ] train_cfg = dict(max_iters=6000, type='IterBasedTrainLoop', val_interval=200) train_dataloader = dict( batch_size=64, dataset=dict( dataset=dict( data_prefix=dict( img_path='images/training', seg_map_path='annotations/training'), data_root='D:\Allcode\mmlab\mmsegmentation-dev-1.x\data\data', pipeline=[ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations'), dict( keep_ratio=True, ratio_range=( 0.5, 2.0, ), scale=( 448, 448, ), type='RandomResize'), dict(prob=0.5, type='RandomFlip'), dict(type='PhotoMetricDistortion'), dict( cat_max_ratio=0.75, crop_size=( 224, 224, ), type='RandomCrop'), dict(type='PackSegInputs'), ], type='Feces'), times=40000, type='RepeatDataset'), num_workers=4, persistent_workers=True, sampler=dict(shuffle=True, type='InfiniteSampler')) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations'), dict( keep_ratio=True, ratio_range=( 0.5, 2.0, ), scale=( 448, 448, ), type='RandomResize'), dict(cat_max_ratio=0.75, crop_size=( 224, 224, ), type='RandomCrop'), dict(prob=0.5, type='RandomFlip'), dict(type='PhotoMetricDistortion'), dict(edge_width=4, type='GenerateEdge'), dict(type='PackSegInputs'), ] tta_model = dict(type='SegTTAModel') tta_pipeline = [ dict(backend_args=None, type='LoadImageFromFile'), dict( transforms=[ [ dict(keep_ratio=True, scale_factor=0.5, type='Resize'), dict(keep_ratio=True, scale_factor=0.75, type='Resize'), dict(keep_ratio=True, scale_factor=1.0, type='Resize'), dict(keep_ratio=True, scale_factor=1.25, type='Resize'), dict(keep_ratio=True, scale_factor=1.5, type='Resize'), dict(keep_ratio=True, scale_factor=1.75, type='Resize'), ], [ dict(direction='horizontal', prob=0.0, type='RandomFlip'), dict(direction='horizontal', prob=1.0, type='RandomFlip'), ], [ dict(type='LoadAnnotations'), ], [ dict(type='PackSegInputs'), ], ], type='TestTimeAug'), ] val_cfg = dict(type='ValLoop') val_dataloader = dict( batch_size=1, dataset=dict( data_prefix=dict( img_path='images/validation', seg_map_path='annotations/validation'), data_root='D:\Allcode\mmlab\mmsegmentation-dev-1.x\data\data', pipeline=[ dict(type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 448, 448, ), type='Resize'), dict(type='LoadAnnotations'), dict(type='PackSegInputs'), ], type='Feces'), num_workers=2, persistent_workers=True, sampler=dict(shuffle=False, type='DefaultSampler')) val_evaluator = dict( iou_metrics=[ 'mDice', 'mIoU', 'mFscore', ], type='IoUMetric') vis_backends = [ dict(type='LocalVisBackend'), dict(type='TensorboardVisBackend'), ] visualizer = dict( name='visualizer', type='SegLocalVisualizer', vis_backends=[ dict(type='LocalVisBackend'), dict(type='TensorboardVisBackend'), ]) work_dir = './work_dirs\pidnet-s_2xb6-6k_224x224-feces'
2023-09-26 17:01:40.657974: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2023-09-26 17:01:40.658149: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
d:\allcode\mmlab\mmsegmentation-dev-1.x\mmseg\models\builder.py:36: UserWarning: build_loss would be deprecated soon, please use mmseg.registry.MODELS.build()
warnings.warn('build_loss would be deprecated soon, please use '
d:\allcode\mmlab\mmsegmentation-dev-1.x\mmseg\models\losses\cross_entropy_loss.py:235: UserWarning: Default avg_non_ignore is False, if you would like to ignore the certain label and average loss over non-ignore labels, which is the same with PyTorch officia
l cross_entropy, set avg_non_ignore=True.
warnings.warn(
09/26 17:01:41 - mmengine - INFO - Distributed training is not used, all SyncBatchNorm (SyncBN) layers in the model will be automatically reverted to BatchNormXd layers if they are used.
d:\allcode\mmlab\mmsegmentation-dev-1.x\mmseg\engine\hooks\visualization_hook.py:61: UserWarning: The draw is False, it means that the hook for visualization will not take effect. The results will NOT be visualized or stored.
warnings.warn('The draw is False, it means that the '
09/26 17:01:41 - mmengine - INFO - Hooks will be executed in the following order:
before_run:
(VERY_HIGH ) RuntimeInfoHook
(BELOW_NORMAL) LoggerHook
before_train: (VERY_HIGH ) RuntimeInfoHook (NORMAL ) IterTimerHook (VERY_LOW ) CheckpointHook
before_train_epoch: (VERY_HIGH ) RuntimeInfoHook (NORMAL ) IterTimerHook (NORMAL ) DistSamplerSeedHook
before_train_iter: (VERY_HIGH ) RuntimeInfoHook (NORMAL ) IterTimerHook
after_train_iter: (VERY_HIGH ) RuntimeInfoHook (NORMAL ) IterTimerHook (NORMAL ) SegVisualizationHook (BELOW_NORMAL) LoggerHook (LOW ) ParamSchedulerHook (VERY_LOW ) CheckpointHook
after_train_epoch: (NORMAL ) IterTimerHook (LOW ) ParamSchedulerHook (VERY_LOW ) CheckpointHook
before_val: (VERY_HIGH ) RuntimeInfoHook
before_val_epoch: (NORMAL ) IterTimerHook
before_val_iter: (NORMAL ) IterTimerHook
after_val_iter: (NORMAL ) IterTimerHook (NORMAL ) SegVisualizationHook (BELOW_NORMAL) LoggerHook
after_val_epoch: (VERY_HIGH ) RuntimeInfoHook (NORMAL ) IterTimerHook (BELOW_NORMAL) LoggerHook (LOW ) ParamSchedulerHook (VERY_LOW ) CheckpointHook
after_val: (VERY_HIGH ) RuntimeInfoHook
after_train: (VERY_HIGH ) RuntimeInfoHook (VERY_LOW ) CheckpointHook
before_test: (VERY_HIGH ) RuntimeInfoHook
before_test_epoch: (NORMAL ) IterTimerHook
before_test_iter: (NORMAL ) IterTimerHook
after_test_iter: (NORMAL ) IterTimerHook (NORMAL ) SegVisualizationHook (BELOW_NORMAL) LoggerHook
(VERY_HIGH ) RuntimeInfoHook (NORMAL ) IterTimerHook (BELOW_NORMAL) LoggerHook
after_test: (VERY_HIGH ) RuntimeInfoHook
after_run: (BELOW_NORMAL) LoggerHook
09/26 17:02:04 - mmengine - WARNING - The prefix is not set in metric class IoUMetric.
09/26 17:02:09 - mmengine - INFO - Loads checkpoint by http backend from path: https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/pidnet/pidnet-s_imagenet1k_20230306-715e6273.pth
09/26 17:02:10 - mmengine - WARNING - "FileClient" will be deprecated in future. Please use io functions in https://mmengine.readthedocs.io/en/latest/api/fileio.html#file-io
09/26 17:02:10 - mmengine - WARNING - "HardDiskBackend" is the alias of "LocalBackend" and the former will be deprecated in future.
09/26 17:02:10 - mmengine - INFO - Checkpoints will be saved to D:\Allcode\mmlab\mmsegmentation-dev-1.x\work_dirs\pidnet-s_2xb6-6k_224x224-feces.
Traceback (most recent call last):
File ".\tools\train.py", line 104, in
how can you fix this problem?
Is there any answer, I also have this problem
Please modify the pipeline of train_dataloader in the last generated PIDNet configuration file, and add dict(edge_width=4, type='GenerateEdge') to dict(type='PackSegInputs') to solve this problem.