Hi Cassie!



 MA_CASANDRA_QUILANG:

my predictions are way to false because my model tends to classify every pixel as backgroudn despite having a small loss value. I read about class imbalance


Class imbalance is likely an issue you will need to deal with.  Have
you tried the weight argument passed to the CrossEntropyLoss
constructor?  One typically weights each class in inverse proportion
to its frequency of appearance.  (If you are using the functional version
of cross entropy, torch.nn.functional.cross_entropy(), it also
has such a weight argument.)


(i am hoping to segment it according to the 60 categories I defined).


One experiment you could try is to combine your 60 different categories
into one “garbage” class, and train a two-class problem: background
(i.e., not garbage) vs. garbage.  This will reduce the class imbalance,
because your garbage class will occur much more frequently than
any individual one of your 60 classes.  Of course, you may still have a
background / garbage imbalance, and may still want to use the weight
argument.
If you try this experiment, I would advise that you still treat this as a
multi-class problem (that happens to have only two classes), and
still use CrossEntropyLoss, rather than reformulating it as a binary
classification problem (that uses something like BCEWithLogitsLoss).
The idea is to get your current code working on a problem without as
much class imbalance, only changing your code as much as necessary.
Good luck.
K. Frank