avalonstrel/GatedConvolution_pytorch

How to generate mask_flist.txt and how to turn my mask.png to mask.pkl?

dengyueyun666 opened this issue · 3 comments

I want to know how to generate mask pkl file? Can you upload an example code file?
And how to generate flist.txt?
Thanks!

By the way, you pre-trained model file seems to be broken.

@dengyueyun666 can you please tell how to create mask.pkl from mask.png and what is numpy.array in it??

This code will work.

@staticmethod
def read_val_mask(path):
        """
        Read masks from val mask data
        """
        ## non-mask : 0 / mask : 1  256x256x1

        if path.endswith("pkl"):
            mask = pkl.load(open(path, 'rb'))

        else:
            mask = Image.open(path)
            mask = np.array(mask)
            mask[mask != 0] = 1

            mask = np.expand_dims(mask, axis=2)

        return mask

The pkl is just the numpy.array of the images.