0

from the item it seems to be a pretty obvious issue right?

But for the life of me I swear I have 21 labels and 21 classes.

So just as a sanity check I thought i'd ask!

  1. I have a load of training images (640,640)
  2. I've gone through them and used DataTurks to annotate the data.
  3. From that I've created a set of PNG masks where I've used 255 for blank space then tan Int for the corresponding number to make an NP array to then convert to a png.
  4. I've then followed this sagemaker example for segmentation which seems to work until I run ss_model.fit.

This is where I start to get some errors. The full log can be seen in this Gist

The first error to jump out at me is:

label maps not provided, using defaults.

Which is strange as I believe I've loaded them correctly in S3 <bucket>/label_map/train_label_map.json

That label map looks like so : Gist (Perhaps it fails as it's not valid JSON however I was copying how another sagemaker example uses it?)

The second error to jump out is the one in the title.

Now it could be that my masks are competely wrong (I'm still very new to ML) but them look like this but 640x640:

[ 
   255, 255, 255
   255, 2, 2,
   255, 2, 2
]

Where 255 is null and 2 is the annotation.

Could this error be because I'm not including the 255: "null" in the label_map ?

Any insight would be really helpful! Thanks.

Jack
  • 2,891
  • 11
  • 48
  • 65
  • So interestingly, I removed my label_map and set the number of classes to 22 to include the 225 and it is now working. I've yet to actually test the model due to AWS constraints but still not entirely happy why the map didn't work! – Jack Jan 27 '19 at 10:14

1 Answers1

1

-- But for the life of me I swear I have 21 labels and 21 classes.

If you have 21 classes, the maximum label should be 20 and not 21, therefore the error is thrown. Label indices start at 0. Notes for this can be found at the documentation page.

From your comment on your post, it seems like you have 23 classes if you have to set number of classes to 22. num_classes is only for classes and does not include the 255 or hole class. Note that the algorithm will work with no error if you give num_classes > you number of labels. This is because the num_classes parameter is used to create the softmax layer. If you have a num_classes more than the actual number of labels seen, some labels are simply not learnt.

Diving a little deeper, the label map in the link that you shared is wrong. Label maps only accept ints and not strings. Its an int-int mapping. Following on, it is not simply enough to have the label_map in the S3 bucket, it needs to provided as a data channel into the algorithm while creating the training job.