Current best practice for Unet_learner binary segmentation?

(Less ) #1

I’ve spent half a day and followed through the long unet binary classification thread and several others here on the board plus lots of testing in Jupyter, but I’m still hitting issues…so my question:

What is the current best practice for doing binary unet segmentation? Are we still suppposed to do the subclassing? ala:

class MySegmentationLabelList(SegmentationLabelList):
def open(self, fn): return open_mask(fn, div=True)

class MySegmentationItemList(ItemList):
"ItemList suitable for segmentation tasks."
_label_cls,_square_show_res = MySegmentationLabelList,False
src = (MySegmentationItemList(fnames)
.label_from_func(get_y_fn , classes=classes))

or can we now just use SegmentationItemList and push a div=True in there somewhere to ensure its a mask of 1/0?

I’m going to go browse the source code b/c there’s way too many various recommendations on the various threads and some are now obsolete (i.e. using ImageItemList) so I’m unclear what exactly is the current proper way to do the binary segmentation.

Any input would be appreciated!


(Less ) #2

After reading the code and revisiting the various threads, this is how I’m doing my subclassing for now:

class BinaryLabelList(SegmentationLabelList):
    def open(self, fn): return open_mask(fn, div=True)

class BinaryItemList(SegmentationItemList):
    _label_cls = BinaryLabelList

and then creating the dataset as:
codes = np.array([‘background’,‘watch’]); codes

src = (BinaryItemList(fnames)
    .label_from_func(get_y_fn , classes=codes))

tfms = get_transforms(flip_vert=True)

data = (src.transform(tfms, size=100, tfm_y=True)
        .databunch(bs=bs, num_workers=4)
1 Like

(Ashutosh Raj) #3

How to visualise binary classification result of unet learner? My output is not showing anything.