Hi zzzf!



 zzzf:

I converted it into one-hot (N, #Class, H, W) for training.
…
how can I efficiently convert transform an RGB valued mask into integer indexed?


To convert a one-hot-encoded class-label mask into an integer-class-label
mask (e.g., shape = [N, nClass, H, W] → shape = [N, H, W]), you
take torch.argmax (one_hot_mask, dim = 1) along the class dimension.
As for your question about how to convert an RGB-valued mask, the issue
is how your class labels are encoded into your color channels (which is
something you haven’t told us).  You have said that you can convert RGB
into one-hot, so you could apparently use a two-step procedure where you
first convert RGB to one-hot, and then apply argmax().
Best.
K. Frank