def png_to_array(path, res=(256, 256)): img = imread(path, flatten=True) if (img.max() <= 0.0): raise ValueError("empty image. imgname: " + path) return preprocess_image(img, res)