I am having problems working with image segmentation with DataBlocks following the DataBlock tutorial and The Walk with Fastai 2. The masks I pass as targets for training are displayed blank when calling DataBlock data loaders’ show_batch function.
I recently found the DataBlock’s summary function and am currently analysing what it shows. At the moment I am wondering what the final sample should show. For me it looks like this:
Building one sample
Pipeline: PILBase.create
starting from
photos/v4/masks/mask.tif
applying PILBase.create gives
PILImage mode=RGB size=4000x4000
Pipeline: <lambda> -> PILBase.create
starting from
photos/v4/masks/mask.tif
applying <lambda> gives
photos/v4/masks/mask.tif
applying PILBase.create gives
PILMask mode=L size=4000x4000
Final sample: (PILImage mode=RGB size=4000x4000, PILMask mode=L size=4000x4000)
-
If I understand correctly the final sample is a mask as an image and the same mask as PILMask. Is it how it should be?
-
Also, before it says that the DataBlock, I guess, found 16 items, which is the correct number of input and target pairs I pass (8 images, 8 masks). After that, it says
2 datasets of sizes 13,3
. I am confused about it. What does it mean? 13+3 is 16. However, shouldn’t it be2 datasets of sizes 8, 8
?
My directory setup is:
- a directory ‘photos’ which I write to code as
train_path
. - the directory has folders ‘v1’ through ‘v8’ in it
- Every vX folder contains two folders: ‘photo’ and ‘mask’ where each contains appropriate photos.
My guess is that I am not passing the input and target mask correctly because I haven’t seen anyone passing photos in this setup. However, I want to keep the set up that way, because later I will put more input and target photos in them
- Earlier I mentioned the problem with mask. In the summery I found
Setting up after_batch: Pipeline: IntToFloatTensor -- {'div': 255.0, 'div_mask': 1}
. As I read around it converts input into tensor. I assume, that ‘div_mask’ states for to divide mask pixel values - not to change them. Could it be some way changing it to fix the mask problem I am having?
I use a custom get_msk methodget_msk = lambda o: 'photos/{}/masks/mask.tif'.format(o.parts[1])
. I create a PILMask using it and print it. It does show the mask I am expecting, so the file itself is fine.
Thank you