.npy is the file extension for numpy arrays - you can read them using numpy.load :
import numpy as np img_array = np.load('filename.npy')
One of the easiest ways to view them is to use the matplotlib imshow function:
from matplotlib import pyplot as plt plt.imshow(img_array, cmap='gray') plt.show()
You can also use a PIL or pillow :
from PIL import Image im = Image.fromarray(img_array)
These functions are not part of the Python standard library, so you may need to install matplotlib and / or PIL / pillow if you have not already done so. I also assume that the files are either 2D [rows, cols] (black and white) or 3D [rows, cols, rgb(a)] (color) arrays of pixel values. If this is not the case, then you will have to tell us more about the format of arrays, for example, what img_array.shape and img_array.dtype .

ali_m source share