Last active
November 20, 2019 01:07
-
-
Save f-rumblefish/f75e00b59261f27ba540cbacfa9cb02d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.applications.mobilenet import MobileNet | |
from keras.models import Model | |
from keras.layers import Dense, GlobalAveragePooling2D | |
# parameters for architecture | |
input_shape = (224, 224, 3) | |
num_classes = 6 | |
conv_size = 32 | |
# parameters for training | |
batch_size = 32 | |
num_epochs = 20 | |
# load MobileNet from Keras | |
MobileNet_model = MobileNet(include_top=False, input_shape=input_shape) | |
# add custom Layers | |
x = MobileNet_model.output | |
x = GlobalAveragePooling2D()(x) | |
x = Dense(512, activation="relu")(x) | |
Custom_Output = Dense(num_classes, activation='softmax')(x) | |
# define the input and output of the model | |
model = Model(inputs = MobileNet_model.input, outputs = Custom_Output) | |
# compile the model | |
model.compile(loss='categorical_crossentropy', | |
optimizer='adam', | |
metrics=['accuracy']) | |
model.summary() | |
# train the model | |
history = model.fit(x_train, y_train, | |
batch_size=batch_size, | |
epochs=num_epochs, | |
verbose=1, | |
validation_split=0.1) |
which version of mobilenet is this? V1 or V2?
And is there a way to make it realtime like YOLO?
x_train was not declared.
So there is an error.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
which version of mobilenet is this? V1 or V2?
And is there a way to make it realtime like YOLO?