Hi everyone, i have 6 class for semantic segmentation with deeplabv3.i’m using pytorch segmentation model for training.As I remember,the each layer of input must represent one class to train but I notice that some colormaps on image are not be same with annot. tool. How can I fix it and what is this the problem ?
DATALOADER
# read data
image = cv2.imread(self.images_fps[i])
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
mask = cv2.imread(self.masks_fps[i])
mask = cv2.cvtColor(mask, cv2.COLOR_BGR2RGB)
print("Output Mask",mask.shape)
print("1:",np.unique(mask[:,:,0]))
print("2:",np.unique(mask[:,:,1]))
print("3:",np.unique(mask[:,:,2]))
temp = np.zeros(shape=(mask.shape[0],mask.shape[1],len(CLASSES)), dtype=np.uint8)
#print for logging
for index,color in enumerate(self.COLORS):
print(f"Color: {color} Code: {CLASSES[index]}")
for i in range(mask.shape[0]):
for k in range(mask.shape[1]):
if(mask[i,k] == color).all():
#print("mask[i,k]: ",mask[i,k])
temp[i,k,index] = 1
print(f"Mask {index}",np.unique(temp[:,:,index]))
print(f"Mask --{index}",np.unique(temp[:,:,index]))
mask = temp
TRANING MODEL LOADER
model = smp.DeepLabV3(
encoder_name=ENCODER,
encoder_weights=ENCODER_WEIGHTS,
classes=len(CLASSES),
activation=ACTIVATION
CLASSES = ['background','car','crack', 'lane', 'pothole', 'road']
ENCODER = 'timm-mobilenetv3_small_075'
ENCODER_WEIGHTS = 'imagenet'
ACTIVATION = 'softmax2d'
DEVICE = 'cuda
)