changed create_training_data function

This commit is contained in:
piowyg 2021-05-30 12:20:22 +02:00
parent 74460231d2
commit 34bf6076f2
2 changed files with 2 additions and 3 deletions

View File

@ -18,9 +18,8 @@ def create_training_data():
category_index = CATEGORIES.index(category)
for img in os.listdir(path):
try:
img = np.reshape(img,(-1,28))
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_images.append(new_array)
except Exception as e:

View File

@ -43,7 +43,7 @@ if __name__ == '__main__':
train(model, 100)
# 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]