Skip to content

Instantly share code, notes, and snippets.

@bigsnarfdude
Last active July 20, 2016 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigsnarfdude/44625ea46099b4e953e7eaf272d8b9c3 to your computer and use it in GitHub Desktop.
Save bigsnarfdude/44625ea46099b4e953e7eaf272d8b9c3 to your computer and use it in GitHub Desktop.
rehydrate mnist using python
import csv
import numpy
import cv2
import matplotlib.pyplot as plt
reader = csv.reader(open('train.csv','rb'))
header = reader.next()
read_data = []
for row in reader:
read_data.append(row)
print("Working on:")
data = numpy.array(read_data)
ro = numpy.zeros((28,28,3))
print(data.shape)
for image_number in range(data.shape[0]):
label = read_data[image_number][0]
for i in range(0,27):
for j in range(0,27):
ro[i,j,0] = data[image_number,j+i*28]
ro[i,j,1] = data[image_number,j+i*28]
ro[i,j,2] = data[image_number,j+i*28]
cv2.imwrite('image_' + label + '_' + str(image_number) + '_' + '.jpg', ro)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment