DeepSceneSeg/EfficientPS

Semantic Segmentation in

GabrieleGalimberti-GaleSelector opened this issue · 1 comments

Hi,
Question:
In the code of cityscapes_save_predictions.py this part in the code is the panoptic segmentation with the semantic segmentation encode ?

pan_pred, cat_pred, _ = result[0]
imageId = imgName.replace("_leftImg8bit.png", "")
inputFileName = imgName
outputFileName = imgName.replace("_leftImg8bit.png", "_panoptic.png")
img = Image.open(os.path.join(path, imgName))
out_path = os.path.join(out_dir, outputFileName)
sem = cat_pred[pan_pred].numpy()
sem_tmp = sem.copy()
sem_tmp[sem==255] = colors.shape[0] - 1
sem_img = Image.fromarray(colors[sem_tmp])
is_background = (sem < 11) | (sem == 255)
pan_pred = pan_pred.numpy() 
pan_pred[is_background] = 0

for example: in the output of the cityscapes_save_predictions.py there are cars with the same color without distinct color for each instance.

Thanks for watching!

We opt for same color for same class visualization scheme where the instances are differentiated with a white border around each instance.
contours = find_boundaries(pan_pred, mode="outer", background=0).astype(np.uint8) * 255
contours = dilation(contours)

        contours = np.expand_dims(contours, -1).repeat(4, -1)
        contours_img = Image.fromarray(contours, mode="RGBA")

        out = Image.blend(img, sem_img, 0.5).convert(mode="RGBA")
        out = Image.alpha_composite(out, contours_img)

The above lines of code are responsible for the white edges around each instance. We opt for this visualization scheme since different colors for different instances doesn't convey the class of the instance.