CQFIO / PhotographicImageSynthesis

Photographic Image Synthesis with Cascaded Refinement Networks
https://cqf.io/ImageSynthesis/
1.25k stars 226 forks source link

print_semantic_map in helpers not working as expected #14

Closed jkschin closed 6 years ago

jkschin commented 6 years ago

Perhaps the inputs are supposed to be a different format, but changing it to this works much better for me.

def print_semantic_map(semantic,path):
    dataset=Dataset('cityscapes')
    prediction=np.argmax(semantic,axis=3) # this used to be axis=2 and had a transpose before this
    prediction=np.squeeze(prediction) # added this 
    color_image=dataset.palette[prediction.ravel()].reshape((prediction.shape[0],prediction.shape[1],3))
    row,col,dump=np.where(np.sum(semantic,axis=2)==0)
    color_image[row,col,:]=0
    scipy.misc.imsave(path,color_image)

Once this is done, we can simply print using:

a = get_semantic_map('../cityscapes_data/gtFine/train/aachen/aachen_000000_000019_gtFine_color.png')
print_semantic_map(a, 'test.png')

@CQFIO perhaps you have another intended use for this function?

jkschin commented 6 years ago

P.S. simply changing this

semantic=semantic.transpose([1,2,3,0])

and ensuring that the input semantic has a dimension of 19 works as well.

CQFIO commented 6 years ago

This was originally intended for the Caffe format. I should have changed it Tensorflow format. Thanks for pointing out the problem.