Lekshmi
Lekshmi

Reputation: 81

Viewing images from pickle file in python

I am a newbie in Machine Learning.I have a dataset of images present in .p format(pickle).

How to view the images present inside the file ? I seached the internet but I didn't any appropriate answers. Please help me to solve this issue.

Code I used:

import pandas as pd
import pickle
objects = []
with (open("full_CNN_train.p", "rb")) as openfile:
    while True:
        try:
            objects.append(pickle.load(openfile))
        except EOFError:
            break
        
print(objects)

My output when I tried pickle.load()

enter image description here

Upvotes: 0

Views: 4500

Answers (2)

Taylr Cawte
Taylr Cawte

Reputation: 612

Just load the pickle file, and use the "imshow" method to visualize.

import pickle
import matplotlib.pyplot as plt

pkl = open('pickled_image.pickle', 'rb')
im = pickle.load(pkl)

plt.imshow(im)

Upvotes: 1

BotKevin
BotKevin

Reputation: 17

It's probably just a standard image matrix, just try using matplotlib.pyplot.imshow()

from matplotlib import pyplot as plt

img = ... # pickle load or whatever

plt.imshow(img)
plt.show()

Upvotes: 2

Related Questions