Unet_binary segmentation

i have 6 classes.It’s a standard dataset so I can’t add more data.its a lung disease segmentation dataset.maybe I can try with augmentation.please let me know what augmentation techniques u used to get rid of the problem other than default augmentations in fastai @harikrishnanrajeev

@digitalspecialists

Are there any methods in fastai or pytorch that automatically can apply offset tiles during inference? My Unet is definitely struggling with edge accuracy so looking for a way of improving upon this!

Was also thinking about experimenting with a different loss function that weights boundary higher, but haven’t gotten to this yet.

Hi,

Ia m training a Unet learner and using dice (built-in metric) co-efficient and dice_mean (as shown below). However I am getting the metric score more than 1. I am not sure the reason behind this. Is this as expected or am I doing something wrong.

dice mean:

def dice_mean(input, target):
“Dice coefficient metric for binary target.”

# Threshold targs
n = target.shape[0]
input = input.argmax(dim=1).view(n,-1)
target = target.view(n,-1) 

# Compute dice
intersect = (input * target).sum(dim=1).float()
union = (input + target).sum(dim=1).float()    
dice = 2. * intersect / union

# Replace zero union values with 1
dice[union == 0.] = 1

# Return mean
return dice.mean()

42

Hello FastAi forum,

I am attempting something similar to this with my own data for a project. I have followed the steps in: https://www.kaggle.com/tanlikesmath/ultrasound-nerve-segmentation-with-fastai/data and gotten all the way up to the databunch. However then it says that I have 0 images in train or path. I am really new to machine learning and I need to finish this project. Any help is appreciated!
ModelBa|133x500

may be the path is not correct. try checking that.

this is my path. so it should be correct in the code: C:\Users\ahrial.young\Desktop\inout\train
there seems to be an issue with get_y_fn, but I’m not sure what it is

@imrandude how did you define a custom function to sort out this issue? i have the same problem and mask is not applying to the image when I put div=True!! in a case of dive=False it gives me device-side assert triggered… error.

You will have to debug your code for this to identify where its erring out. In my case I had to modify the base function “open_image” with

if div: x.div_(34)
return cls(x)

In the last two lines. I can have a look if you can share your notebook and code.

Hi embirbud, I also have a test on the potsdam of ISPRS dataset but I can not get the right result. Can you share the code including the data prepare and the training procedure? Appreciate it !

I added the following custom function because of having a 3 channel training labels:

class SegLabelListCustom(SegmentationLabelList):
def open(self, fn): return open_mask(fn, div=True, convert_mode=‘RGB’)

class SegItemListCustom(SegmentationItemList):
_label_cls = SegLabelListCustom

But I got the following error after running learn.lr_find():

AttributeError: Can’t get attribute ‘SegItemListCustom’ on <module ‘main’ from ‘/opt/render/project/src/.venv/bin/gunicorn’>

After a lot of search, I figured out that windows has some issues with the parallel processing modules of fastai. To solve the issue, I changed the number of workers to zero and it worked:
databunch(bs=bs, num_workers=0)