I have noticed some interesting results when using UnetClassifier with ignore_classes.
First if you only have 3 classes, such as with this code
data = prepare_data(data_path, batch_size=32, chip_size=224, num_workers=0)
data.classes
The output is : ['NoData', '1', '2']
model = UnetClassifier(data,backbone='resnet34', ignore_classes=[0])
The above line will error with the complaint:
Exception: `ignore_classes` parameter can only be used when the dataset has more than 2 classes.
But the stats.txt file shows 3 classes. Snippet below
images = 134 *12*224*224
features = 2279
features per image = [min = 1, mean = 17.01, max = 67]
classes = 3
cls name cls value images
0 0 125
1 1 120
2 2 117
Seems like a bug to me, but the workaround is to create a fake class (say class 10) and re-export the tiles again and replace the above code with:
model = UnetClassifier(data,backbone='resnet34', ignore_classes=[0,10])
I have also noticed that when using ignore_classes parameters the ‘dice’ statistics in the training data output is usually pretty poor, such as 50-60.
epoch train_loss valid_loss accuracy dice time
…
568 0.541224 0.451169 0.823589 0.658838 00:04
569 0.539253 0.448183 0.822532 0.660908 00:04
As opposed to when there is no 0 class (i.e. [Nodata]) you will normally get high 90 dice results. I assume this is most likely because the dice algorithm is calculating on the [NoData] areas, when I don’t think it should. So therefore results will be highly dependent on the amount of [NoData] areas you have.