DWSF icon indicating copy to clipboard operation
DWSF copied to clipboard

张量尺寸错误 RuntimeError: output with shape [1, 128, 128] doesn't match the broadcast shape [3, 128, 128]

Open luizz8416 opened this issue 2 years ago • 8 comments

完整的报错信息 Train Epoch: 0 [0/394] D_loss: 1.4287535548210144 = DisF:0.9066857099533081 + DisT:0.5220678448677063 En_De_loss: 0.6271777153015137 = Gen:0.5223720073699951 + En:1.126967191696167=MSE-0.49768513441085815+MSSIM-125.85639953613281, De:0.4012618660926819 Traceback (most recent call last): File "train_ed.py", line 90, in for batch_idx, batch_data in enumerate(train_loader): File "E:\anaconda3\envs\DWSF\lib\site-packages\torch\utils\data\dataloader.py", line 628, in next data = self._next_data() File "E:\anaconda3\envs\DWSF\lib\site-packages\torch\utils\data\dataloader.py", line 671, in _next_data data = self.dataset_fetcher.fetch(index) # may raise StopIteration File "E:\anaconda3\envs\DWSF\lib\site-packages\torch\utils\data_utils\fetch.py", line 58, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "E:\anaconda3\envs\DWSF\lib\site-packages\torch\utils\data_utils\fetch.py", line 58, in data = [self.dataset[idx] for idx in possibly_batched_index] File "E:\pyqt\DWSF-main\utils\dataset.py", line 29, in getitem image = self.tranform(image) File "E:\anaconda3\envs\DWSF\lib\site-packages\torchvision\transforms\transforms.py", line 95, in call img = t(img) File "E:\anaconda3\envs\DWSF\lib\site-packages\torch\nn\modules\module.py", line 1194, in call_impl return forward_call(*input, **kwargs) File "E:\anaconda3\envs\DWSF\lib\site-packages\torchvision\transforms\transforms.py", line 270, in forward return F.normalize(tensor, self.mean, self.std, self.inplace) File "E:\anaconda3\envs\DWSF\lib\site-packages\torchvision\transforms\functional.py", line 360, in normalize return F_t.normalize(tensor, mean=mean, std=std, inplace=inplace) File "E:\anaconda3\envs\DWSF\lib\site-packages\torchvision\transforms\functional_tensor.py", line 940, in normalize return tensor.sub(mean).div(std) RuntimeError: output with shape [1, 128, 128] doesn't match the broadcast shape [3, 128, 128]

luizz8416 avatar Nov 29 '23 13:11 luizz8416

I also encountered this problem at runtime. I think it was caused by the fact that the paper was using a color image dataset. I used the following to fix it: delete the black and white images in the dataset because they have a channel count of 1.

SodalimeZero avatar Dec 08 '23 07:12 SodalimeZero

I also encountered this problem at runtime. I think it was caused by the fact that the paper was using a color image dataset. I used the following to fix it: delete the black and white images in the dataset because they have a channel count of 1. 谢谢你,我之后再训练分割模型的时候发现耗时非常久(大概4-5天),请问你完成分割模型的训练了吗?

luizz8416 avatar Dec 08 '23 07:12 luizz8416

没有。。我看论文用的A100显卡,我实验室只有两张3090,还要大家一起用

SodalimeZero avatar Dec 09 '23 01:12 SodalimeZero

其实我认为作者可以公开一下训练好的模型hhh

SodalimeZero avatar Dec 09 '23 01:12 SodalimeZero

至少给个差不多的预训练嘛2333

Map1e0823 avatar Jan 04 '24 09:01 Map1e0823

I also encountered this problem at runtime. I think it was caused by the fact that the paper was using a color image dataset. I used the following to fix it: delete the black and white images in the dataset because they have a channel count of 1. dataset.py中将图像读取设置为RGB image = Image.open(self.filepath+'/'+self.filelist[item]).convert('RGB')

Ontheroad123 avatar Feb 24 '24 15:02 Ontheroad123

I also encountered this problem at runtime. I think it was caused by the fact that the paper was using a color image dataset. I used the following to fix it: delete the black and white images in the dataset because they have a channel count of 1. 谢谢你,我之后再训练分割模型的时候发现耗时非常久(大概4-5天),请问你完成分割模型的训练了吗?

请问你之后完成训练了吗

Jraytheon01 avatar Mar 26 '24 06:03 Jraytheon01

I also encountered this problem at runtime. I think it was caused by the fact that the paper was using a color image dataset. I used the following to fix it: delete the black and white images in the dataset because they have a channel count of 1. 谢谢你,我之后再训练分割模型的时候发现耗时非常久(大概4-5天),请问你完成分割模型的训练了吗?

请问你之后完成训练了吗

我只是训练了一个demo只有1000张,和你的情况不一样

Ontheroad123 avatar Mar 26 '24 07:03 Ontheroad123