How to convert n number of images (in jpg format) to .p (pickle) format?

Question:

I have a folder abc with images in .jpg format.
I need to convert these images to single xyz.p (pickled) file. How to pickle these images?

I want to implement something like this:

> import pickle  
> training_file = "dataset/train.p"  
> with open(training_file, mode='rb') as f: 
>     train = pickle.load(f)  X_train, y_train = train['features'], train['labels']
Asked By: Sajjad Manal

||

Answers:

please try this :

file = open('data.pkl', 'wb') 
pickle.dump(image, file)
file.close()
Answered By: Shabana
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.