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/')
|
||||
|
||||
DATADIR = relative_path + 'LearningData'
|
||||
CATEGORIES = ['Full', 'Empty']
|
||||
IMG_SIZE = 70 # specify on which size we want to transform the photos for example 50x50px
|
||||
CATEGORIES = ['Full', 'Empty'] # labels
|
||||
IMG_SIZE = 150 # specify on which size we want to transform the photos for example 50x50px
|
||||
NAME = 'plate-cnn-64x2-{}'.format(int(time.time()))
|
||||
|
||||
training_data = []
|
||||
X = [] # feature 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():
|
||||
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.save(relative_path + 'SavedModels/plate-64x2-cnn.model')
|
||||
model.save(relative_path + 'SavedModels/{}.model'.format(NAME))
|
||||
|
||||
|
||||
def use_model_to_predict(name):
|
||||
@ -128,7 +135,7 @@ def use_model_to_predict(name):
|
||||
plt.show()
|
||||
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')])
|
||||
|
||||
print(prediction)
|
||||
@ -139,7 +146,7 @@ def use_model_to_predict(name):
|
||||
def text_speech(font: str, size: int, text: str, color, background, x, y, bold: bool, bubble: bool, screen):
|
||||
global textRect
|
||||
font = pygame.font.SysFont(None, size)
|
||||
#font = pygame.font.Font(font, size)
|
||||
# font = pygame.font.Font(font, size)
|
||||
font.set_bold(bold)
|
||||
textSurf = font.render(text, True, color).convert_alpha()
|
||||
if bubble:
|
||||
@ -155,6 +162,7 @@ def text_speech(font: str, size: int, text: str, color, background, x, y, bold:
|
||||
textRect.center = (x, y)
|
||||
screen.blit(textSurf, textRect)
|
||||
|
||||
|
||||
# save_dataset()
|
||||
# use_model_to_predict('test-full-5')
|
||||
# creat_model()
|
||||
#use_model_to_predict('test-0')
|
||||
creat_model()
|
||||
|