I ran into a somewhat related issue. I didn’t know where to log it so I’ll just put it here. When calling .save() on a mask which is a ImageSegment object, there is no concrete implementation so it falls back to the .save() implementation defined for the Image object. This is problematic because in the .save() method, the pixel values are all multiplied by a factor of 255 scaling the class values which for some cases will result in lost class values when subsequently calling open_mask() on a saved mask.
I ran into this issue and thought I’d put it here but a quick fix would be to add an implementation of the .save() method inside ImageSegment which would do something like this without transforming the pixel values:
def save_mask(mask, fn:PathOrStr):
"Save the image to `fn`."
x = image2np(mask.data).astype(np.uint8)
PIL.Image.fromarray(x).save(fn)