black0017 / MedicalZooPytorch

A pytorch-based deep learning framework for multi-modal 2D/3D medical image segmentation
MIT License
1.72k stars 299 forks source link

The error message "Expected 5-dimensional input for 5-dimensional weight [8, 3, 3, 3, 3], but got 4-dimensional input of size [4, 384, 128, 48] instead" indicates that there is a mismatch between the expected input dimensions (5-dimensional) and the actual input dimensions provided (4-dimensional). #34

Open Wuchen057 opened 8 months ago

Wuchen057 commented 8 months ago

After replacing the getitem method in line 77 of the file lib->medloaders>mrbrains2018.py with the following code, the error disappears and the training can proceed normally.

def __getitem__(self, index):
    t1_path, ir_path, flair_path, seg_path = self.list[index]
    t1_data, ir_data, flair_data, seg_data = np.load(t1_path), np.load(ir_path), np.load(flair_path), np.load(
        seg_path)

    return torch.FloatTensor(t1_data.copy()).unsqueeze(0), torch.FloatTensor(ir_data.copy()).unsqueeze(0), \
        torch.FloatTensor(flair_data.copy()).unsqueeze(0), torch.FloatTensor(seg_data.copy())

20240221150317 20240221150516

littlewhite132 commented 7 months ago

非常感谢! it really helps

littlewhite132 commented 7 months ago

Hello, after correcting this mistake, I successfully trained the MRBrainS model. However, when I ran inference, I encountered an error: FileNotFoundError: [Errno 2] No such file or directory: './datasets/mrbrains_2018/training/mrbrains_2018-classes-4-list-train-samples-1.txt'. My training data was downloaded from the official website. How can I obtain this txt file?