Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Model predictions should not be normalized before saving to disk, leads to incorrect results #325

@yalaudah

Description

@yalaudah

In the file cv_lib/cv_lib/utils.py, the function mask_to_disk normalizes the model prediction before saving. This should not happen, as it will cause the saved results to be incorrect.

def image_to_disk(mask, fname, cmap_name="seismic"):
    """
    write segmentation image to disk using a particular colormap
    """
    cmap = plt.get_cmap(cmap_name)
    Image.fromarray(cmap(normalize(mask), bytes=True)).save(fname)

Specifically, the "normalization" should be done relative to the num_classes value that is specific to the dataset, and not to the model predictions. This is because:

  • If all the predicted values from the model were the same (regardless of the class), the result would lead to division by zero, which is undefined.
  • If the results of the model for two samples where different, but the relative values were the same, then the saved results would be the same for the different predictions, which is obviously incorrect.

We should also make sure that the Normalize() function in the same file properly handles division by zero.

Metadata

Metadata

Assignees

Labels

Prior: ShowStopperBlocks a releaseType: BugSomething isn't workingType: Correctnessanything to do with repo being technically correct

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions