Compare commits
No commits in common. "0824aaa0cfdc2c59cdbc9cd8c4f269585a1e2c67" and "6a364be40ee62c84d47c909e1cd539b0221e3681" have entirely different histories.
0824aaa0cf
...
6a364be40e
Binary file not shown.
@ -1,38 +0,0 @@
|
||||
from keras.preprocessing.image import ImageDataGenerator
|
||||
from keras.models import Sequential
|
||||
from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
|
||||
|
||||
train_data_dir = "garbage_photos"
|
||||
|
||||
input_shape = (150, 150, 3)
|
||||
num_classes = 5
|
||||
batch_size = 32
|
||||
epochs = 20
|
||||
|
||||
train_datagen = ImageDataGenerator(rescale=1./255)
|
||||
|
||||
train_generator = train_datagen.flow_from_directory(
|
||||
train_data_dir,
|
||||
target_size=(input_shape[0], input_shape[1]),
|
||||
batch_size=batch_size,
|
||||
class_mode='categorical'
|
||||
)
|
||||
|
||||
model = Sequential()
|
||||
model.add(Conv2D(32, (3, 3), activation='relu', input_shape=input_shape))
|
||||
model.add(MaxPooling2D(pool_size=(2, 2)))
|
||||
model.add(Conv2D(64, (3, 3), activation='relu'))
|
||||
model.add(MaxPooling2D(pool_size=(2, 2)))
|
||||
model.add(Conv2D(128, (3, 3), activation='relu'))
|
||||
model.add(MaxPooling2D(pool_size=(2, 2)))
|
||||
model.add(Flatten())
|
||||
model.add(Dense(128, activation='relu'))
|
||||
model.add(Dense(num_classes, activation='softmax'))
|
||||
|
||||
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
|
||||
|
||||
model.fit(train_generator, epochs=epochs)
|
||||
|
||||
classes = train_generator.class_indices
|
||||
|
||||
model.save("neuralModel.h5")
|
Loading…
Reference in New Issue
Block a user