Hi,
I have RGB label-images with 6 labels.
codes = array([‘Impervious_surfaces’,‘Building’,‘Low_vegetation’,‘Tree’,‘Car’,‘Clutter_background’])
below is hoe they are encoded in RGB channel.
colors_LU ={‘Impervious_surfaces’: array([255, 255, 255]),
‘Building’: array([ 0, 0, 255]),
‘Low_vegetation’: array([0, 255, 255]),
‘Tree’: array([0, 255, 0]),
‘Car’: array([ 255, 255, 0]),
‘Clutter_background’: array([ 255, 0, 0])}
using
mask = open_mask(get_y_fn(img_f))
mask.show(figsize=(5,5), alpha =1)
I get…mask.data
tensor([[[255, 255, 255, …, 255, 255, 255],
[255, 255, 255, …, 255, 255, 255],
[255, 255, 255, …, 255, 255, 255],
…,
[ 29, 29, 29, …, 255, 255, 255],
[ 29, 29, 29, …, 255, 255, 255],
[ 29, 29, 29, …, 255, 255, 255]]]))
So not for 0 to 5.
By examining the I figured that there are indeed 6 classes inside, which seem to be gray representations of RGB colors for each class.
{‘Impervious_surfaces’: 255,
‘Building’: 29,
‘Low_vegetation’: 178,
‘Tree’: 149,
‘Car’: 225,
‘Clutter_background’: 76}
I am using following to create the data source
src = (SegmentationItemList.from_folder(path)
.split_by_folder(train = ‘train’, valid = ‘valid’)
.label_from_func(get_y_fn, classes=codes))
data = (src.transform(get_transforms(), tfm_y=True, size = size)
.databunch(bs=bs)
.normalize(imagenet_stats))
This creates a problem where numbers in the mask are > number of classes, so I was getting that CUDA error.
I got around that by creating dummy classes (0-255), but then I start running out of memory, even with image size reduced to 200.
I do not know how to solve this problem. Dividing by 255 does not help me, since I have > 2 classes.
Any help would be much appreciated.