podprojekt kacper update

This commit is contained in:
s444349 2020-05-07 17:07:57 +02:00
parent b9fda1e459
commit b12fa77b91

View File

@ -4,6 +4,7 @@ from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense, BatchNormalization from keras.layers import Activation, Dropout, Flatten, Dense, BatchNormalization
from keras import backend as K from keras import backend as K
img_width, img_height = 299, 299 img_width, img_height = 299, 299
train_data_dir = 'resources/zbior_uczacy' train_data_dir = 'resources/zbior_uczacy'
@ -13,9 +14,8 @@ nb_validation_samples = 1574
epochs = 1 epochs = 1
batch_size = 16 batch_size = 16
def stworzModel(): def stworzModel():
if K.image_data_format() == 'channels_first': if K.image_data_format() == 'channels_first':
input_shape = (3, img_width, img_height) input_shape = (3, img_width, img_height)
else: else:
@ -42,6 +42,7 @@ def stworzModel():
model.add(Activation('softmax')) model.add(Activation('softmax'))
return model return model
def trainModel(): def trainModel():
model = stworzModel() model = stworzModel()
model.compile(loss='categorical_crossentropy', model.compile(loss='categorical_crossentropy',
@ -80,6 +81,7 @@ def trainModel():
model.save_weights('nowy_wytrenowany.h5') model.save_weights('nowy_wytrenowany.h5')
def przewidz(path): def przewidz(path):
model = stworzModel() model = stworzModel()
model.load_weights('wytrenowany.h5') model.load_weights('wytrenowany.h5')
@ -97,4 +99,3 @@ def przewidz(path):
return "paper" return "paper"
elif kategoria == 3: elif kategoria == 3:
return "plastic" return "plastic"