Open constantinpape opened 5 hours ago
Hi @jalexs82 ,
When I check the shape of the data loader output, I'm getting 'torch.Size([1, 3, 512, 512])' and 'torch.Size([1, 1, 512, 512])' for the image and label respectively.
This is surprising. The shape of the labels should be torch.Size([1, 4, 512, 512])
. If the label transform is PerObjectDistanceTransform
is used the 4 channels should automatically be created.
Could you maybe share a few sample images and labels of your data? (3-4 would be enough). That would be the easiest way to check what's going wrong.
I've also checked several times to see if it is pulling any labels that have no object, and it always has an object.
The problem you report is not related to empty labels.
Hi @jalexs82,
Re: issue with output label channels:
It looks like you are not passing the label_transform
argument to the dataloaders. You can do this using:
train_loader = torch_em.default_segmentation_loader(
...,
label_transform=label_transform,
sampler=MinInstanceSampler(min_size=25), # I would recommend using the sampler with filtering smaller objects, as the label transform filters them out later on, which might causes troubles.
)
val_loader = torch_em.default_segmentation_loader(
...,
label_transform=label_transform,
sampler=MinInstanceSampler(min_size=25), # same recommendation as above
)
Let us know if this works. If you still have issues, I would recommend to do as @constantinpape recommended, share a few sample images and respective labels of your data.
I'm also working with RGB data, but I'm running into a slightly different problem. I have a folder with RGB images in .tif format (reshaped so that the RGB channel is first). I have set up the data loader using both option 1 and 2. Here is my version of option 2:
When I run the training script, I'm getting the following error:
When I check the shape of the data loader output, I'm getting 'torch.Size([1, 3, 512, 512])' and 'torch.Size([1, 1, 512, 512])' for the image and label respectively. I've also checked several times to see if it is pulling any labels that have no object, and it always has an object.
Originally posted by @jalexs82 in https://github.com/computational-cell-analytics/micro-sam/issues/701#issuecomment-2387209037