Improving model, fix plate prediction
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 360 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 41 KiB |
@ -22,14 +22,21 @@ current_path = os.path.dirname(__file__)
|
|||||||
relative_path = os.path.join(current_path, 'Data/')
|
relative_path = os.path.join(current_path, 'Data/')
|
||||||
|
|
||||||
DATADIR = relative_path + 'LearningData'
|
DATADIR = relative_path + 'LearningData'
|
||||||
CATEGORIES = ['Full', 'Empty']
|
CATEGORIES = ['Full', 'Empty'] # labels
|
||||||
IMG_SIZE = 70 # specify on which size we want to transform the photos for example 50x50px
|
IMG_SIZE = 150 # specify on which size we want to transform the photos for example 50x50px
|
||||||
NAME = 'plate-cnn-64x2-{}'.format(int(time.time()))
|
NAME = 'plate-cnn-64x2-{}'.format(int(time.time()))
|
||||||
|
|
||||||
training_data = []
|
training_data = []
|
||||||
X = [] # feature set
|
X = [] # feature set
|
||||||
y = [] # label set
|
y = [] # label set
|
||||||
|
|
||||||
|
'''
|
||||||
|
layer size | conv leyer |
|
||||||
|
64 | 1 | loss: 0.0443 - accuracy: 0.9942 - val_loss: 0.3614 - val_accuracy: 0.7692
|
||||||
|
64 | 2 | loss: 0.0931 - accuracy: 0.9625 - val_loss: 0.4772 - val_accuracy: 0.8462
|
||||||
|
64 | 3 |
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
def create_training_data():
|
def create_training_data():
|
||||||
for category in CATEGORIES:
|
for category in CATEGORIES:
|
||||||
@ -115,7 +122,7 @@ def creat_model():
|
|||||||
|
|
||||||
model.fit(X, y, batch_size=32, epochs=10, validation_split=0.1, callbacks=[tenserboard])
|
model.fit(X, y, batch_size=32, epochs=10, validation_split=0.1, callbacks=[tenserboard])
|
||||||
|
|
||||||
model.save(relative_path + 'SavedModels/plate-64x2-cnn.model')
|
model.save(relative_path + 'SavedModels/{}.model'.format(NAME))
|
||||||
|
|
||||||
|
|
||||||
def use_model_to_predict(name):
|
def use_model_to_predict(name):
|
||||||
@ -128,7 +135,7 @@ def use_model_to_predict(name):
|
|||||||
plt.show()
|
plt.show()
|
||||||
return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1)
|
return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1)
|
||||||
|
|
||||||
model = tf.keras.models.load_model(relative_path + 'SavedModels/plate-64x2-cnn.model')
|
model = tf.keras.models.load_model(relative_path + 'SavedModels/plate-cnn-64x1-1590497461.model')
|
||||||
prediction = model.predict([prepare(relative_path + 'TestData/' + name + '.jpg')])
|
prediction = model.predict([prepare(relative_path + 'TestData/' + name + '.jpg')])
|
||||||
|
|
||||||
print(prediction)
|
print(prediction)
|
||||||
@ -155,6 +162,7 @@ def text_speech(font: str, size: int, text: str, color, background, x, y, bold:
|
|||||||
textRect.center = (x, y)
|
textRect.center = (x, y)
|
||||||
screen.blit(textSurf, textRect)
|
screen.blit(textSurf, textRect)
|
||||||
|
|
||||||
|
|
||||||
# save_dataset()
|
# save_dataset()
|
||||||
# use_model_to_predict('test-full-5')
|
#use_model_to_predict('test-0')
|
||||||
# creat_model()
|
creat_model()
|
||||||
|