Beispiel #1
0
import numpy as np
from keras.optimizers import SGD, RMSprop, Adagrad, Adadelta, Adam, Adamax, Nadam
from sklearn.metrics import classification_report, confusion_matrix
from data import get_data_generators
from utils import *
from keras.models import load_model

batch_size = 8
image_size = 256
epochs = [5, 15]

callbacks = models.get_callbacks()

class_weights = {0: 0.5, 1: 1.0}

train_generator, val_generator, test_generator = get_data_generators(
    image_size, batch_size, 'GRY', 'abnormality', 'vgg')

# model = models.create_vgg_model(image_size=256, dropout=0.5)

#
# print("Stage 1 - Transfer Learning:")
#
# model.compile(loss='binary_crossentropy', optimizer=Adam(0.001), metrics=['accuracy'])
#
# history = model.fit(train_generator,
#                     steps_per_epoch=train_generator.samples // batch_size,
#                     epochs=epochs[0],
#                     callbacks=callbacks,
#                     validation_data=val_generator,
#                     validation_steps=val_generator.samples // batch_size,
#                     class_weight=class_weights,
from keras_preprocessing.image import ImageDataGenerator
import models
import keras
import numpy as np
import pandas as pd
import os
from sklearn.metrics import classification_report, confusion_matrix
from utils import *
from data import get_data_generators
from keras.optimizers import SGD, RMSprop, Adagrad, Adadelta, Adam, Adamax, Nadam

image_size = 128
batch_size = 16
epoch = 30

train_generator, val_generator, test_generator = get_data_generators(image_size=image_size, batch_size=batch_size,
                                                                     data='RGB', task='abnormality', model=None)


callbacks = models.get_callbacks(folder="checkpoints/custom/")

class_weights = {0: 1.0,
                1: 1.0}


model = models.create_custom_model3(size=image_size)


model.compile(loss='binary_crossentropy', optimizer=Adam(0.001), metrics=['accuracy'])


history = model.fit(train_generator,
Beispiel #3
0
from keras.applications.resnet50 import ResNet50 as ResNet, preprocess_input
from keras_preprocessing.image import ImageDataGenerator
import models
import numpy as np
from keras.optimizers import SGD, RMSprop, Adagrad, Adadelta, Adam, Adamax, Nadam
from sklearn.metrics import classification_report, confusion_matrix
from data import get_data_generators
from utils import *

batch_size = 16
image_size = 256
epochs = [5, 15]

callbacks = models.get_callbacks()

train_generator, val_generator, test_generator = get_data_generators(
    image_size, batch_size, 'GRY', 'diagnosis-4class', 'vgg')

model = models.create_vgg_model(image_size=256, dropout=0.5, classes=4)

print("Stage 1:")

model.compile(loss='categorical_crossentropy',
              optimizer=Adam(0.001),
              metrics=['accuracy'])

history = model.fit(train_generator,
                    steps_per_epoch=train_generator.samples // batch_size,
                    epochs=epochs[0],
                    callbacks=callbacks,
                    validation_data=val_generator,
                    validation_steps=val_generator.samples // batch_size,
from keras.optimizers import SGD, RMSprop, Adagrad, Adadelta, Adam, Adamax, Nadam
from sklearn.metrics import classification_report, confusion_matrix
from data import get_data_generators
from utils import *

batch_size = 16
image_size = 256
epochs = [3, 5, 30]

callbacks = models.get_callbacks()

class_weights = {0: 0.5, 1: 1.0}

#opt = Adam()

train_generator, val_generator, test_generator = get_data_generators(
    image_size, batch_size, 'GRY', 'diagnosis-2class', model='resnet')

model = models.create_ResNet50_model()

print("Stage 1:")

model.compile(loss='binary_crossentropy',
              optimizer=Adam(0.001),
              metrics=['accuracy'])

history = model.fit(train_generator,
                    steps_per_epoch=train_generator.samples // batch_size,
                    epochs=epochs[0],
                    callbacks=callbacks,
                    validation_data=val_generator,
                    validation_steps=val_generator.samples // batch_size,
import models
import keras
import numpy as np
import pandas as pd
import os
from sklearn.metrics import classification_report, confusion_matrix
from utils import *
from data import get_data_generators

image_size = 256
batch_size = 16
epoch = 30

train_generator, val_generator, test_generator = get_data_generators(
    image_size=image_size,
    batch_size=batch_size,
    data='RGB',
    task='diagnosis-2class',
    model='custom')

callbacks = models.get_callbacks()

class_weights = {0: 0.5, 1: 1.0}

#opt = Adam()

model = models.create_custom_model()
# model.compile(loss='binary_crossentropy',
#               optimizer=opt,
#               metrics=['accuracy'])

model.compile(loss='binary_crossentropy',