segmentation_models.pytorch
segmentation_models.pytorch copied to clipboard
Output n_class is less than len(class_name) in training?
Hi, Thanks for your work. I used your code to train a multi-class segmentation task. I have 10 classes, but after training, the output mask just have 8 classes( using np.unique). Do you know how this happend? Thanks for your reply!
I make sure that in dataset part, I input all 10 classes name. Note that the two classes( nose, eyebrow) that not be detected are more smaller than other class, is that the reason? My config is :
ENCODER = 'resnet34'
ENCODER_WEIGHTS = 'imagenet'
CLASSES = ['background','face', 'skin', 'clothes', 'hair', 'eye', 'eyeball', 'mouth', 'nose', 'eyebrow']
ACTIVATION = 'softmax2d'
pr_mask = (pr_mask.squeeze().cpu().numpy().round()) # (10, 512, 512) But after np.argmax: vi_mask = np.argmax(pr_mask, axis=0) n = np.unique(vi_mask) # here just have 8 classes: [0,1,2,3,4,5,6,7] , not included 8,9
Or my config is not ok for segmentation of smaller part?
I have a similar problem where my output has 4 classes whereas I expect 5. The training seems to be fine and the the IoU(during training) seems quite high as well. @ymzlygw Have you found a solution yet?
@qubvel Have you ever encountered this problem?
Your model does not predict some classes, don't see anything strange here suppose you have classes: car, road, sky, grass but on the picture you have only: road, grass and sky
in that case if model not predict "car" and number of predicted classes is less than number of total classes, and that's correct
Thanks for the reply, what you are saying is obviously true but in my case I am doing inference only on the train set and I have a really low loss and a really high IoU which makes me think that I am obviously missing something. The model should atleast overfit. I dont expect you to debug the problem for me ofcourse, was just wondering if this has been encountered before.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.