SPADE-Tensorflow icon indicating copy to clipboard operation
SPADE-Tensorflow copied to clipboard

Potential mismatching image/label paths and gray scale image related problems

Open YuhuaBillChen opened this issue 5 years ago • 0 comments

Hi Junho,

Really a great work and I was very happy to try out your implementation.

However, I notice a potential problem for the path name matching in the Image_data preprocess. Because the result list from glob is not sorted, the order from both image and segmap path lists might be consistent but in my case they are totally messed up. Therefore I changed the code into:

        self.image = sorted(glob(self.img_dataset_path + '/*.*'), key=os.path.basename)
        self.segmap = sorted(glob(self.segmap_dataset_path + '/*.*'), key=os.path.basename)
        self.segmap_test = sorted(glob(self.segmap_test_dataset_path + '/*.*'), key=os.path.basename)

The 2nd issue is that when using gray-scale image, the VGGLoss part raises error complaining shape mismatching. I modified the code in vgg19_keras.py, VGGLoss's call function:

        if x.shape[-1] == 1:
            x = tf.tile(x, [1, 1, 1, 3])
        if y.shape[-1] == 1:
            y = tf.tile(y, [1, 1, 1, 3])

Just repeat the single channel into 3 to resolve the shape problem.

The last one is in the sample imaging saving, simply add

    if img.shape[-1] == 1:
        img = img[..., 0]

after https://github.com/taki0112/SPADE-Tensorflow/blob/master/utils.py#L208

Thank you again for your nice work, hope those lines would be helpful.

Best, Yuhua (Bill)

YuhuaBillChen avatar Aug 28 '19 19:08 YuhuaBillChen