2019-07-19 06:21 AM
I'm running a Cifar10 Keras CNN Pre-trained model basically an image recognition model my labels are :
0 - airplane
1 - automobile
2 - bird
3 - cat
4 - deer
5 - dog
6 - frog
7 - horse
8 - ship
9 - truck
The image array is stored as HWC format or Height-Width-Channel, a 32x32 RGB color image with 32 x 32 x 3 = 3072 values.
how can I enter the input image in the custom data test for validation in MXCUBE (x-cube-ai package) do I need to normalize the data ?
for example cat = {226,221,195,247,241,227,246,239,227,243,237,225,243,237,222,243,236,220,241,234,218,239,229,213,237...183}
2019-07-31 06:55 AM
I wrote a Python Script to do this for me.
from __future__ import print_function
import keras
from keras.datasets import cifar10
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten,BatchNormalization
from keras.layers import Conv2D, MaxPooling2D
import os
batch_size = 32
num_classes = 10
epochs = 100
data_augmentation = True
num_predictions = 20
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
print('x_train shape:', x_train.shape)
print(x_train.shape[0], 'train samples')
print(x_test.shape[0], 'test samples')
print(y_test)
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)
num_data_test=1000 #Zuweisun wieviele Bilder getestet werden sollen
a=x_test[0].reshape(1,3072)
np.savetxt('csv-cifar10-test-1.csv',a,delimiter=',')
b=y_test[0].reshape(1,10)
np.savetxt('csv-cifar10-label-1.csv',b,delimiter=',')
#new_a=np.delete(x_test,slice(1000,1,10000))
new_a=x_test.reshape(10000,3072)
np.savetxt('csv-cifar10-test-10000.csv',new_a,delimiter=',')
num_data_test=1000
num_pixel=3072
import numpy as np
#print(new_a)
data=np.zeros((num_data_test,num_pixel))
label=np.zeros((1000,10))
print(f)
for a in range(num_data_test):
data[a]=x_test[a].reshape(1,3072)
label[a]=y_test[a].reshape(1,10)
np.savetxt('csv-cifar10-test-1000.csv',data,delimiter=',')
np.savetxt('csv-cifar10-label-1000.csv',label,delimiter=',')
Load the validation Software on the MCU and use the csv files for Validation.
Edit: Ignore line 34. This file cannot be used to validate.