Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: output with shape [1, 767, 1022] doesn't match the broadcast shape [3, 767, 1022] #70

Open
sdwiodhi opened this issue Aug 12, 2024 · 3 comments

Comments

@sdwiodhi
Copy link

I entered a 3-channel color picture of the picture, but got an error. Hope to get the author's answer

@bigmb
Copy link
Owner

bigmb commented Aug 13, 2024

Can you share more details on the error? (Line and input data shape)

@ZMingzhu
Copy link

I meet the same problem.

Successfully created the main directory './model' 
Successfully created the prediction directory './model/pred' of dice loss
Successfully created the model directory './model/Unet_D_15_4' 
/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torch/optim/lr_scheduler.py:138: UserWarning: Detected call of `lr_scheduler.step()` before `optimizer.step()`. In PyTorch 1.1.0 and later, you should call them in the opposite order: `optimizer.step()` before `lr_scheduler.step()`.  Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate
  warnings.warn("Detected call of `lr_scheduler.step()` before `optimizer.step()`. "
/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torch/optim/lr_scheduler.py:163: UserWarning: The epoch parameter in `scheduler.step()` was not necessary and is being deprecated where possible. Please use `scheduler.step()` to step the scheduler. During the deprecation, if epoch is different from None, the closed form is used instead of the new chainable form, where available. Please open an issue if you are unable to replicate your use case: https://github.com/pytorch/pytorch/issues/new/choose.
  warnings.warn(EPOCH_DEPRECATION_WARNING, UserWarning)
/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torch/optim/lr_scheduler.py:807: UserWarning: To get the last learning rate computed by the scheduler, please use `get_last_lr()`.
  warnings.warn("To get the last learning rate computed by the scheduler, "
/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torch/nn/functional.py:1967: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
  warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
Traceback (most recent call last):
  File "/data/VSNET/Unet-Segmentation-Pytorch-Nest-of-Unets-master/pytorch_run.py", line 295, in <module>
    s_label = data_transform(im_label)
  File "/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torchvision/transforms/transforms.py", line 95, in __call__
    img = t(img)
  File "/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torchvision/transforms/transforms.py", line 270, in forward
    return F.normalize(tensor, self.mean, self.std, self.inplace)
  File "/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torchvision/transforms/functional.py", line 360, in normalize
    return F_t.normalize(tensor, mean=mean, std=std, inplace=inplace)
  File "/root/anaconda3/envs/UCTransNet/lib/python3.9/site-packages/torchvision/transforms/functional_tensor.py", line 940, in normalize
    return tensor.sub_(mean).div_(std)
RuntimeError: output with shape [1, 1080, 1440] doesn't match the broadcast shape [3, 1080, 1440]

Please tell how to solve it? Thank you!!

@bigmb
Copy link
Owner

bigmb commented Dec 19, 2024

Can you check your mean/std values and your image channels during the transform function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants