Python Forum
How to save predictions made by an autoencoder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to save predictions made by an autoencoder
#1
I've been practicing with this template for image reconstruction using an autoencoder:

https://github.com/bnsreenu/python_for_m...le_V1.0.py

In the template, a prediction is created for only one image and the image is shown but not saved.

I've made some changes so predictions are created for all the images in the folder, rather than just a single image e.g.
#Original einstein image for prediction as monalisa
img3_data=[]
path3 = (r"('einstein_mona_lisa/")
files=os.listdir(path3)
for i in tqdm(files):
    img3=cv2.imread(path3+'/'+i,1)  #Change 0 to 1 for color images
    img3 = cv2.cvtColor(img3, cv2.COLOR_BGR2RGB)#Changing BGR to RGB to show images in true colors
    img3=cv2.resize(img3,(SIZE, SIZE))
    img3_data.append(img_to_array(img3))

img_array3 = np.reshape(img3_data, (len(img3_data), SIZE, SIZE, 3))
img_array3 = img_array3.astype('float32') / 255.
However, I don't know how to save copies of these images once they have been predicted. Can you suggest code to save the predictions please?

At the moment it just shows a solitary image and none of the predictions are saved automatically.
pred = model.predict(img_array3)

imshow(pred[0].reshape(SIZE,SIZE,3))
Any advice on the best way to save the various predictions generated would be much appreciated.

For info: I am using Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] in Spyder
Many thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Autoencoder for Data Augmentation of numerical Dataset in Python Marvin93 2 3,312 Jul-10-2020, 07:18 PM
Last Post: Marvin93
  Utilize input predictions for Supervised Learning donnertrud 2 1,856 May-20-2020, 12:45 PM
Last Post: donnertrud
  Basic data analysis and predictions mates 15 6,752 Mar-14-2020, 09:06 PM
Last Post: mates
  stacked autoencoder training JohnMarie 0 2,622 Feb-24-2019, 12:23 AM
Last Post: JohnMarie
  How to use a tfrecord file for training an autoencoder JohnMarie 6 4,562 Feb-22-2019, 06:35 PM
Last Post: JohnMarie
  Merge Predictions with whole data set mayanksrivastava 0 3,570 Jun-29-2017, 11:39 AM
Last Post: mayanksrivastava

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020