sacmehta / ESPNet

ESPNet: Efficient Spatial Pyramid of Dilated Convolutions for Semantic Segmentation
https://sacmehta.github.io/ESPNet/
MIT License
538 stars 111 forks source link

Inverse class probability weights #85

Open ghost opened 1 year ago

ghost commented 1 year ago

also: if class# range from 0 to 19 (20 classes), it would be hist = np.histogram(label_img, range=[0,self.classes-1],self.classes)[0]

I think there are issues with the calculation of the class weights?

In train/loadData.py, I don't think "hist = np.histogram(label_img, self.classes)" has the desired result. In the absence of range, np.histogram will use the min and max value of the array...

Should it not be "hist = np.delete(np.histogram(label_img, range=[0,self.classes],self.classes+1)[0],[0])" ? (i.e. for 20 classes, range is [0,20] with 21 bins, and bin "0" gets discarded)

I'd be glad to understand why I'm wrong otherwise :)

Nicolas.