What you ultimately want is a SegmentationItemList
I guess. The class hierarchy for this is
ItemList > ImageList > SegmentationItemList
I believe and you will have to make changes in both ItemList
and ImageList
I think, because the ItemList
will ultimately determine the number of things in your dataset, which you will probably want to be the number of total tiles. If this is not the number of tiles you might have to think harder about are my tiles still nicely shuffled?
What I propose is to change the items
in ItemList.__init__
(which holds your image paths) somehow like this:
list(zip(items*4, [t for t in range(num_tiles) for _ in range(num_im)]))
(Make a TiledItemList
extending ItemList
, overriding the __init__
)
so that you can access that tile information in your get
function that you replace in ImageList
in order to load the correct tile. (Make a TiledImageList
extending TiledItemList
, mostly copying the contents from the original, except for get
)
I am not sure if something breaks if you make items
a list of tuples. you might also just extend the path there by your tile number and cut the path in the ImageList.get
.
When you have changed those two (maybe as a TiledItemList
, TiledImageList
), I think making it work for segmentation is as easy as
class TiledSegmentationItemList(TiledImageList):
"`ItemList` suitable for segmentation tasks."
_label_cls,_square_show_res = SegmentationLabelList,False
(which is the standard SegmentationItemList
implementation extending your tiled version instead)
Make sure to check out https://docs.fast.ai/tutorial.itemlist.html and the according source code of ItemList
, ImageList
and SegmentationItemList
Edit:
You have to create a TiledSegmentationLabelList
replacing the SegmentationLabelList
as well I think (which should also just use your Tiled classes instead of the original)