May 2020
Intermediate to advanced
404 pages
10h 52m
English
As mentioned earlier, it is not possible to directly view the images in your downloaded image files. So, we will now create a function in Python that the matplotlib module will be able to use to display the images in the files:
def loadImageFile(fileimage): f = open(fileimage, "rb") f.read(16) pixels = 28*28 images_arr = [] while True: try: img = [] for j in range(pixels): pix = ord(f.read(1)) img.append(pix / 255) images_arr.append(img) except: break f.close() image_sets = np.array(images_arr) return image_sets
The preceding loadImageFile function takes a single parameter, which is the name of the file that contains the images. We have two such files available for us in our downloaded files folder: ...
Read now
Unlock full access