Read (SVHN) Dataset in python
Asked Answered
H

1

9

I would like to read using python the following dataset: http://ufldl.stanford.edu/housenumbers/train_32x32.mat

I had loaded this mat file using io.loadmat('train_32x32.mat') but when I am trying to show an images from the above numpy array, I do not get the image with good resolution and coloring.

Any idea how to read and to plot images from this dataset?

Hampden answered 21/3, 2015 at 17:4 Comment(1)
For digitStruct.mat, non-readable by scipy.io, h5py or tables, I used github.com/prijip/Py-Gsvhn-DigitStruct-Reader and it worked.Refrigeration
B
12

The output of the loadmat function is a dictionary. See the code below:

import numpy as np
import scipy.io as sio
import matplotlib.pyplot as plt
%matplotlib inline

image_ind = 10
train_data = sio.loadmat('train_32x32.mat')

# access to the dict
x_train = train_data['X']
y_train = train_data['y']

# show sample
plt.imshow(x_train[:,:,:,image_ind])
plt.show()


print y_train[image_ind]
Boxberry answered 23/8, 2016 at 22:27 Comment(2)
Hi, just a question. What about the testing data? Is there a testing set too? Thanks :)Rodrickrodrigez
Yes. You can find the test data here:Boxberry

© 2022 - 2024 — McMap. All rights reserved.