unsqueeze(0) won’t work in this case, as it seems your input has too many dimensions.
You would rather want to squeeze() a certain dimension, e.g. dim0 or dim1.
Also, your input is incompatible for conv layers, which expect your input to have the shape [batch_size, channels, height, width].
After squeezing, try using images_v = images_v.permute(0, 3, 1, 2).
If you’ll get an error stating your input is non-contiguous, call images_v = images_v.contiguous() in it.
Also, Variables are deprecated since PyTorch 0.4.0, so you can just use tensors in newer versions.
It the mentioned shape [1, 1, 512, 512, 3] referring to image_v or images_v[:, index, :, :]?
Try to make sure you are passing the input data to your model as [batch_size, channels, height, width].
now the shape is torch.Size([4, 3, 512, 512]) with out indexing !!!
and RuntimeError: Given groups=1, weight of size [64, 1, 3, 3], expected input[4, 3, 512, 512] to have 1 channels, but got 3 channels instead
and my input is on gray scale with one channel
Does the shape change for some iterations, i.e. do you sometimes see a shape of [4, 3, 512, 512] while other times just [512, 512, 3]?
It seems your first conv uses in_channels=1, which is fine for grayscale images.
Do you manually create/transform your images to have 3 channels? PIL and OpenCV should load them as single-channel grayscale images.
i changed to gray scale using cv2.COLOR_BGR2GRAY
no the shape is just torch.Size([4, 3, 512, 512])
by running
image_v = images_v.squeeze(0).permute(0, 3, 1, 2)
cv2.COLOR_BGR2GRAY should completely remove the color channel as far as I know, so somehow there are still 3 channels being created. You might want to check your Dataset and the shapes of the image after loading.
you are right , the problem is with costum validation data set
it gives the shape as flowwing
for images torch.Size([1, 4, 512, 512, 3])
for mask torch.Size([1, 4, 512, 512])
@ptrblck
i am having this error
ValueError: operands could not be broadcast together with shapes (1,584,565) (512,512)
the original mask is with the size (1,584,565 ) how can i change the size , i tried the cv2 but it did not work
I’m not sure as I’m not familiar with your code, but it could represent the number of channels.
Preprocessing should be done in all datasets (using the same parameters as for the training).
Data augmentation is usually only done during training, although you could also use test time augmentation, average your predictions, and hope for a slight performance boost.
What have you tried so far? Doesn’t cv2.resize() work?