Пример #1
0
def predict(input_x):
    out = ""
    #if len(input_x) != (28*28):
    #print("The input image or input array is shaped incorrectly. Expecting a 28x28 image.")
    '''
    for i in xrange(0,28):
        out = out+"\n"
	    for( j in xrange(0,28)):
            if (input_x[(i*28)+j]>0.5):
	            out = out + "1"
	        else:
		        out = out + "0"

    '''
    #print( "Input image array: \n", out)

    E = evaluate_model()
    #E.__init__()
    prediction = E.evaluate_model(
        model_version=20,
        input=np.float32(input_x.reshape(28, 28)).flatten().reshape(
            1, 784))  #FIRST ENTRY IS SAME AS ALL ENTRIES FOR CLASSIFIER
    #print("\nPREDICTION CLASSIFIED:",prediction[0])
    #prediction = int(random.random()*9.9) #Current prediction is random

    return prediction[0]
Пример #2
0
def predict(input_x):
    x = ""
    array = []
    array.append([])
    if len(input_x) != (28 * 28):
        print "The input image or input array is shaped incorrectly. Expecting a 28x28 image."
    for i in xrange(0, 28):
        x = x + "\n"
        for j in xrange(0, 28):
            if input_x[(i * 28) + j] > 0.5:
                x = x + "1"
                array[0].append(1)
            else:
                x = x + "0"
                array[0].append(0)
    print "Input image array: \n", x
    #Fill in this function to correctly predict the class the image array corresponds to
    #Fill in this function to correctly predict the class the image array corresponds to
    #Fill in this function to correctly predict the class the image array corresponds to
    #Fill in this function to correctly predict the class the image array corresponds to
    prediction = emc.evaluate_model()
    pre_result = prediction.evaluate_model(1, array)
    return pre_result
Пример #3
0
import numpy as np

## makes sure these imports point to correct directory and correct files
import tf_classify_sensed_image as emc  # evaluation file, takes one image in 28x28 and outputs class
import tf_train_model_ASSIGNMENT_FILE as tm  # file we created in recitaiton

# get mnist as example
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)

# model number
model = 1

## code calls the training file we created in recitation to train model
#model_train = tm.build_train()                  ### comment line out for evaluation only
#model_train.build_train_network(model)          ### comment line out for evaluation only

# get single mnist image for evaluation
batch_xs, batch_ys = mnist.test.next_batch(1)
#print(batch_xs)
print(batch_ys)

# code opens saved trained model created by code above
model_eval = emc.evaluate_model()
image = model_eval.evaluate_model(model_version=model, input=batch_xs)

# prints out classification and correct label
print('Classification:')
print(image)
print('Correct Label:')
print(np.where(batch_ys[0] == 1))