JorgeSebastianML / Dataset-for-semantic-segmentation

Trasnform Dataset for library of semantic segmentation as Amazing-Semantic-Segmentation
GNU General Public License v3.0
0 stars 0 forks source link

Requesting help with Dataset Format #1

Closed varungupta31 closed 2 years ago

varungupta31 commented 2 years ago

Hi @dronclick I'm trying to implement the binary semantic segmentation using the Amazing-Semantic-Segmentation repo, and need some help with the dataset format. You are referring to the same repo, right? If yes, kindly help me out with the following:

My label images either have [0,0,0] (void) and [1,1,1] (foreground). calling np.unique(label_img) gives me [0,1] (thus, there are no other pixels other than these)

My class_dict.csv contains:

name r g b
Void 0 128 0
Traffic_Sign 255 255 255

and evaluated_classes.txt contains:

Void
Traffic_Sign

When I run the train.py on my custom data, I get ValueError: cannot select an axis to squeeze out which has size not equal to one However, when I run the exact same train.py using the CamVid data, my model starts to train.

What am I missing out? Thanks.

JorgeSebastianML commented 2 years ago

Hi @varungupta31 when I used the amazing repository, I realized that the labels or masks that must be passed must be in grayscale, where each shade of the pixel indicates the class to which it corresponds, for example all pixels with value 0 it is class 0, with value 1 it is class 1, .. value n class n

varungupta31 commented 2 years ago

Thank you for your reply, That is exactly what I'm doing. I have class 0, and class 1. So, all my images have either 0,0,0 pixels or 1,1,1.

Error

File "/home2/varungupta/Amazing-Semantic-Segmentation/utils/data_generator.py", line 75, in _get_batches_of_transformed_samples
    label = one_hot(label, self.num_classes)
  File "/home2/varungupta/Amazing-Semantic-Segmentation/utils/utils.py", line 122, in one_hot
    label = np.squeeze(label, axis=-1)
  File "<__array_function__ internals>", line 6, in squeeze
  File "/home2/varungupta/miniconda3/envs/fcnkeras/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 1495, in squeeze
    return squeeze(axis=axis)
ValueError: cannot select an axis to squeeze out which has size not equal to one

I have been scratching my head figuring out how my dataset images are not as per the requirements. I run the same train.py command with default images, the code starts to train, but when I replace the images with mine, it fails.

Were you using the same dimensions, 960x720?

If feasible, please look into this image file i'm passing as a label (has the same size, same name with 'L' appended in the end). 20210812162031_0060__55__obstacle-delineator__43_mask_L

If you check this image, it has either 0,0,0 or 1,1,1, but is of 256x512.

varungupta31 commented 2 years ago

I figured it out.

My labels images for some reason were not Grayscale, as third channel was also being loaded.

Converted them to grayscale and now it works.

Thank you :)