Skip to content

Instantly share code, notes, and snippets.

@aferriss
Created December 9, 2015 00:33
Show Gist options
  • Save aferriss/e80a120e0f9dc39b307f to your computer and use it in GitHub Desktop.
Save aferriss/e80a120e0f9dc39b307f to your computer and use it in GitHub Desktop.
Small script for extracting images out of the svhn dataset
import scipy.io
import numpy as np
from PIL import Image
np.set_printoptions(threshold=np.nan)
mat = scipy.io.loadmat('train_32x32.mat')
arr = np.array(mat["X"])
for i in range(5000):
img = Image.fromarray(arr[:,:,:,i], 'RGB')
img.save("svhn"+str(i)+".jpg")
print "saving: " + str(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment