HRNet / HRNet-Semantic-Segmentation

The OCR approach is rephrased as Segmentation Transformer: https://arxiv.org/abs/1909.11065. This is an official implementation of semantic segmentation for HRNet. https://arxiv.org/abs/1908.07919
Other
3.09k stars 683 forks source link

RuntimeError: stack expects each tensor to be equal size, but got [423, 187] at entry 0 and [318, 140] at entry 1 #223

Open LvShuaiChao opened 3 years ago

LvShuaiChao commented 3 years ago

D:\Program\Anaconda3\envs\torch_1.8\python.exe E:/Documents/Desktop/HRNet/segmentation/HRNet-Semantic-Segmentation-pytorch-v1.1/tools/test.py Namespace(cfg='../experiments/lip/seg_hrnet_w48_473x473_sgd_lr7e-3_wd5e-4_bs_40_epoch150.yaml', opts=[]) {'AUTO_RESUME': False, 'CUDNN': CfgNode({'BENCHMARK': True, 'DETERMINISTIC': False, 'ENABLED': True}), 'DATASET': {'DATASET': 'lip', 'EXTRA_TRAIN_SET': '', 'NUM_CLASSES': 20, 'ROOT': '../data/', 'TEST_SET': 'lip/testvalList.txt', 'TRAIN_SET': 'lip/trainList.txt'}, 'DEBUG': {'DEBUG': False, 'SAVE_BATCH_IMAGES_GT': False, 'SAVE_BATCH_IMAGES_PRED': False, 'SAVE_HEATMAPS_GT': False, 'SAVE_HEATMAPS_PRED': False}, 'GPUS': (0,), 'LOG_DIR': 'log', 'LOSS': {'CLASS_BALANCE': True, 'OHEMKEEP': 131072, 'OHEMTHRES': 0.9, 'USE_OHEM': False}, 'MODEL': {'EXTRA': {'FINAL_CONV_KERNEL': 1, 'STAGE1': {'BLOCK': 'BOTTLENECK', 'FUSE_METHOD': 'SUM', 'NUM_BLOCKS': [4], 'NUM_CHANNELS': [64], 'NUM_MODULES': 1, 'NUM_RANCHES': 1}, 'STAGE2': {'BLOCK': 'BASIC', 'FUSE_METHOD': 'SUM', 'NUM_BLOCKS': [4, 4], 'NUM_BRANCHES': 2, 'NUM_CHANNELS': [48, 96], 'NUM_MODULES': 1}, 'STAGE3': {'BLOCK': 'BASIC', 'FUSE_METHOD': 'SUM', 'NUM_BLOCKS': [4, 4, 4], 'NUM_BRANCHES': 3, 'NUM_CHANNELS': [48, 96, 192], 'NUM_MODULES': 4}, 'STAGE4': {'BLOCK': 'BASIC', 'FUSE_METHOD': 'SUM', 'NUM_BLOCKS': [4, 4, 4, 4], 'NUM_BRANCHES': 4, 'NUM_CHANNELS': [48, 96, 192, 384], 'NUM_MODULES': 3}}, 'NAME': 'seg_hrnet', 'PRETRAINED': '../pretrained_models/hrnet_lip_5583_torch04.pth'}, 'OUTPUT_DIR': 'output', 'PIN_MEMORY': True, 'PRINT_FREQ': 10, 'RANK': 0, 'TEST': {'BASE_SIZE': 473, 'BATCH_SIZE_PER_GPU': 2, 'CENTER_CROP_TEST': False, 'FLIP_TEST': True, 'IMAGE_SIZE': [473, 473], 'MODEL_FILE': '../pretrained_models/hrnet_lip_5583_torch04.pth', 'MULTI_SCALE': False, 'NUM_SAMPLES': 0, 'SCALE_LIST': [1]}, 'TRAIN': {'BASE_SIZE': 473, 'BATCH_SIZE_PER_GPU': 2, 'BEGIN_EPOCH': 0, 'DOWNSAMPLERATE': 1, 'END_EPOCH': 2, 'EXTRA_EPOCH': 0, 'EXTRA_LR': 0.001, 'FLIP': True, 'IGNORE_LABEL': 255, 'IMAGE_SIZE': [473, 473], 'LR': 0.007, 'LR_FACTOR': 0.1, 'LR_STEP': [90, 110], 'MOMENTUM': 0.9, 'MULTI_SCALE': True, 'NESTEROV': False, 'NUM_SAMPLES': 0, 'OPTIMIZER': 'sgd', 'RESUME': True, 'SCALE_FACTOR': 11, 'SHUFFLE': True, 'WD': 0.0005}, 'WORKERS': 0} => creating output\lip\seg_hrnet_w48_473x473_sgd_lr7e-3_wd5e-4_bs_40_epoch150 => creating log\lip\seg_hrnet\seg_hrnet_w48_473x473_sgd_lr7e-3_wd5e-4_bs_40_epoch150_2021-05-02-01-06 => init weights from normal distribution => loading pretrained model ../pretrained_models/hrnet_lip_5583_torch04.pth

models.seg_hrnet.get_seg_model D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\nn\functional.py:3458: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. "See the documentation of nn.Upsample for details.".format(mode) D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\nn\functional.py:3328: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.")

Total Parameters: 65,860,100

Total Multiply Adds (For Convolution and Linear Layers only): 75.98179006576538 GFLOPs

Number of Layers Conv2d : 307 layers BatchNorm2d : 306 layers ReLU : 269 layers Bottleneck : 4 layers BasicBlock : 104 layers HighResolutionModule : 8 layers
=> loading model from ../pretrained_models/hrnet_lip_5583_torch04.pth

10000 1 2 0%| | 0/5000 [00:00<?, ?it/s] Traceback (most recent call last): File "E:/Documents/Desktop/HRNet/segmentation/HRNet-Semantic-Segmentation-pytorch-v1.1/tools/test.py", line 148, in main() File "E:/Documents/Desktop/HRNet/segmentation/HRNet-Semantic-Segmentation-pytorch-v1.1/tools/test.py", line 140, in main sv_dir=final_outputdir) File "E:\Documents\Desktop\HRNet\segmentation\HRNet-Semantic-Segmentation-pytorch-v1.1\tools..\lib\core\function.py", line 204, in test for , batch in enumerate(tqdm(testloader)): File "D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\tqdm\std.py", line 1178, in iter for obj in iterable: File "D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\utils\data\dataloader.py", line 517, in next data = self._next_data() File "D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\utils\data\dataloader.py", line 557, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\utils\data_utils\fetch.py", line 47, in fetch return self.collate_fn(data) File "D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\utils\data_utils\collate.py", line 83, in default_collate return [default_collate(samples) for samples in transposed] File "D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\utils\data_utils\collate.py", line 83, in return [default_collate(samples) for samples in transposed] File "D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\utils\data_utils\collate.py", line 63, in default_collate return default_collate([torch.as_tensor(b) for b in batch]) File "D:\Program\Anaconda3\envs\torch_1.8\lib\site-packages\torch\utils\data_utils\collate.py", line 55, in default_collate return torch.stack(batch, 0, out=out) RuntimeError: stack expects each tensor to be equal size, but got [423, 187] at entry 0 and [318, 140] at entry 1

Process finished with exit code 1