Closed ZZH86 closed 1 year ago
Hello, thanks for your interest. Are you using our dataset, right? If yes, you should preprocess the dataset in order to have both the images and the masks of the same dimension. In fact, as we stated in the papers, the GSD of the images and the masks is different. Thank you again!
Hi, The following error occurred when I ran it, How should I solve it?
`(3dcd_3) ch@Server:/mnt/data/ch/code2D/3DCD_V2$ python train.py --config="MTBIT" Loading experiment ./config/MTBIT.yaml Logs and/or checkpoints will be stored on ./results/MTBIT/ Config file correctly saved! train.py --config=MTBIT {'model': {'model': 'mtbit_resnet18', '2d_loss': 'bce', '3d_loss': 'mse', 'exclude_zeros': False, 'num_classes': 2, 'pretraining_strategy': 'imagenet', 'feature_extractor_arch': 'resnet18', 'checkpoints_path': None, 'loss_weights': [1, 3], '2d_loss_weights': [0.05, 0.95], 'class_ignored': 9999, 'restore_checkpoints': '3d', 'freeze_encoder': False}, 'optim': {'num_epochs': 300, 'lr': 0.0001, 'optim_type': 'adamw', 'momentum': 0.9, 'nesterov': False, 'beta': [0.9, 0.999], 'end_lr': 5e-06, 'weight_decay': 0.001, 'lr_schedule_type': 'step_lr', 'step': 300, 'gamma': 0.75, 'last_epoch': 10}, 'data': {'max_value': 30, 'min_value': -25, 'augmentations': True, 'mean': [0.5896145210542503, 0.6210658017517566, 0.591661801751776], 'std': [0.1898555514094201, 0.19114699478664082, 0.21242997453209553], 'train': {'path': '/mnt/data/ch/code2D/data/3DCD/train/', 'batch_size': 15}, 'val': {'path': '/mnt/data/ch/code2D/data/3DCD/val/'}, 'test': {'path': '/mnt/data/ch/code2D/data/3DCD/test/'}}} /mnt/data/ch/.conda/envs/3dcd_3/lib/python3.8/site-packages/albumentations/augmentations/transforms.py:1149: FutureWarning: This class has been deprecated. Please use RandomBrightnessContrast warnings.warn( /mnt/data/ch/.conda/envs/3dcd_3/lib/python3.8/site-packages/albumentations/augmentations/transforms.py:1175: FutureWarning: RandomContrast has been deprecated. Please use RandomBrightnessContrast warnings.warn( Encoder selected: resnet18 Pretrained with the following strategy: imagenet Model selected: mtbit_resnet18 Optimizer selected: adamw Scheduler selected: step_lr No checkpoints founded Trainable parameters: 13387691, total parameters 13387691 Epoch: 1 - Learning rate: 0.0001 0%| | 0/22 [00:00<?, ?it/s]/mnt/data/ch/.conda/envs/3dcd_3/lib/python3.8/site-packages/torch/nn/functional.py:3631: 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. warnings.warn(
MASK 3D: -23.5570068359375 16.35302734375 MASK 3D NORM: -0.9475275278091431 0.5037463903427124 OUT 3D: -0.9598515033721924 0.9171762466430664 /mnt/data/ch/.conda/envs/3dcd_3/lib/python3.8/site-packages/torch/nn/modules/loss.py:520: UserWarning: Using a target size (torch.Size([15, 200, 200])) that is different to the input size (torch.Size([15, 400, 400])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. return F.mse_loss(input, target, reduction=self.reduction) 0%| | 0/22 [00:02<?, ?it/s] Traceback (most recent call last): File "train.py", line 212, in loss3d = criterion3d(out3d.squeeze(dim=1), mask3d) #, exclude_zeros = exclude_zeros) File "/mnt/data/ch/.conda/envs/3dcd_3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/mnt/data/ch/.conda/envs/3dcd_3/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 520, in forward return F.mse_loss(input, target, reduction=self.reduction) File "/mnt/data/ch/.conda/envs/3dcd_3/lib/python3.8/site-packages/torch/nn/functional.py", line 3111, in mse_loss expanded_input, expanded_target = torch.broadcast_tensors(input, target) File "/mnt/data/ch/.conda/envs/3dcd_3/lib/python3.8/site-packages/torch/functional.py", line 72, in broadcast_tensors return _VF.broadcast_tensors(tensors) # type: ignore[attr-defined] RuntimeError: The size of tensor a (400) must match the size of tensor b (200) at non-singleton dimension 2 `
MIBIT.yaml `# Model parameters. model: model: "mtbit_resnet18" 2d_loss: 'bce' 3d_loss: 'mse' exclude_zeros: False num_classes: 2 pretraining_strategy: "imagenet" feature_extractor_arch: "resnet18" checkpoints_path: loss_weights: [1,3] 2d_loss_weights: [0.05, 0.95] class_ignored: 9999 restore_checkpoints: '3d' freeze_encoder: False optim: num_epochs: 300 lr: 0.0001 optim_type: "adamw" momentum: 0.9 nesterov: False beta: [0.9, 0.999] end_lr: 0.000005 weight_decay: 0.001 lr_schedule_type: "step_lr" step: 300 gamma: 0.75 last_epoch: 10
data: max_value: 30 min_value: -25 augmentations: True mean: [0.5896145210542503, 0.6210658017517566, 0.591661801751776] std: [0.1898555514094201, 0.19114699478664082, 0.21242997453209553] train: path: '/mnt/data/ch/code2D/data/3DCD/train/' batch_size: 15 val: path: '/mnt/data/ch/code2D/data/3DCD/val/' test: path: '/mnt/data/ch/code2D/data/3DCD/test/' #Ogni volta eliminare i checkpoint`