Example #1
0
    # CREATE MODEL
    model = ResNet50(include_top=False,
                     input_shape=(None, None, 3),
                     weights='imagenet')
    x = model.output
    x = SpatialPyramidPooling([1, 2, 3, 6])(x)
    predictions = Dense(classes, activation='softmax')(x)
    model = Model(inputs=model.input,
                  outputs=predictions,
                  name='resnet50spp_pretrained')
    return model


if __name__ == "__main__":
    start = datetime.now()
    model = make_model()

    model.summary()
    util = ModelUtils(epochs=100)
    util.get_train_data()
    util.get_val_data()
    util.get_test_data()
    util.mean_subtraction()
    util.train(model)
    util.evaluate()
    util.save()
    util.confusion_matrix()
    util.plot_loss_accuracy()

    time_elapsed = datetime.now() - start
    print('Time elapsed (hh:mm:ss.ms) {}'.format(time_elapsed))
Example #2
0
from datetime import datetime
from utils.model_utils import ModelUtils
from keras.layers import Dense, Dropout, Flatten, Activation, Conv2D, GlobalAveragePooling2D
from keras.models import Model

ACTIVATION='Mish'
if __name__ == "__main__":
    start = datetime.now()
    # CREATE MODEL 

    # # this is the model we will train
    vgg = VGG19(input_shape=(224, 224, 3), classes=3, activation=ACTIVATION, include_top=False, weights='imagenet')
    model = vgg.model()
    # model = set_non_trainable(model)
    x = model.output
    x=Dense(4096,activation=ACTIVATION)(x) 
    x=Dense(4096,activation=ACTIVATION)(x) 
    x=Dense(3,activation='softmax')(x) 
    model = Model(model.input, x, name='vgg19')
    model.summary()
    util = ModelUtils(epochs=20)
    util.get_train_data(resize=(224,224))

    util.train(model, name=ACTIVATION)
    util.evaluate()
    util.save(name=ACTIVATION)
    util.confusion_matrix(title=model.name)
    util.plot_loss_accuracy(path=model.name+'.json', name=model.name)
    
    time_elapsed = datetime.now() - start 
    print('Time elapsed (hh:mm:ss.ms) {}'.format(time_elapsed))