neural_network #4
@ -18,9 +18,8 @@ def create_training_data():
|
|||||||
category_index = CATEGORIES.index(category)
|
category_index = CATEGORIES.index(category)
|
||||||
for img in os.listdir(path):
|
for img in os.listdir(path):
|
||||||
try:
|
try:
|
||||||
img = np.reshape(img,(-1,28))
|
|
||||||
img_array = cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
|
img_array = cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
|
||||||
new_array = np.reshape(img_array, (-1, 28))
|
new_array = cv2.resize(img_array, (IMG_SIZE,IMG_SIZE))
|
||||||
training_data_label.append(category_index)
|
training_data_label.append(category_index)
|
||||||
training_data_images.append(new_array)
|
training_data_images.append(new_array)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -43,7 +43,7 @@ if __name__ == '__main__':
|
|||||||
train(model, 100)
|
train(model, 100)
|
||||||
|
|
||||||
# def accuracy(expected, predicted):
|
# def accuracy(expected, predicted):
|
||||||
# return len([_ for e, p in zip(expected, predicted) if e == p]) / len(expected)
|
# return len([1 for e, p in zip(expected, predicted) if e == p]) / len(expected)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# predicted = [model(image).argmax() for image in train_images]
|
# predicted = [model(image).argmax() for image in train_images]
|
||||||
|
Loading…
Reference in New Issue
Block a user