Create your own dataset for machine learning, same format as CIFAR-10 dataset, via PIL and numpy
Refers:
http://www.cs.toronto.edu/~kriz/cifar.html
https://www.tensorflow.org/tutorials/deep_cnn
The CIFAR-10 dataset consists of 60000 32x32 colour images in 10 classes.
ClixSense Click on the cat job use the image that its size is 128 x 96 px, and
the image is cat or dog, no other type.
I want to use CNN to do machine learning for this job.
I collected some images now.
The key python codes to append one image with label to the dataset is as below:
from PIL import Image
import numpy as np im = Image.open(filename)
im = (np.array(im))
r = im[:,:,0].flatten()
g = im[:,:,1].flatten()
b = im[:,:,2].flatten()
if iscat:
label = [0]
else:
label = [1]
out = np.array(list(label) + list(r) + list(g) + list(b), np.uint8)
out.tofile(dataset)
http://www.cs.toronto.edu/~kriz/cifar.html
https://www.tensorflow.org/tutorials/deep_cnn
The CIFAR-10 dataset consists of 60000 32x32 colour images in 10 classes.
ClixSense Click on the cat job use the image that its size is 128 x 96 px, and
the image is cat or dog, no other type.
I want to use CNN to do machine learning for this job.
I collected some images now.
The key python codes to append one image with label to the dataset is as below:
from PIL import Image
import numpy as np im = Image.open(filename)
im = (np.array(im))
r = im[:,:,0].flatten()
g = im[:,:,1].flatten()
b = im[:,:,2].flatten()
if iscat:
label = [0]
else:
label = [1]
out = np.array(list(label) + list(r) + list(g) + list(b), np.uint8)
out.tofile(dataset)
Comments
Post a Comment