class_names = train_data_manager.class_names
num_classes = len(class_names)
exit(0)
val_data_manager = CSVDataManager(val_dataset, val_split, class_names, False)
val_data = val_data_manager.load_data()

# generator
prior_boxes = to_point_form(create_prior_boxes())
train_sequencer = SequenceManager(train_data, 'train', prior_boxes,
                                  batch_size, box_scale_factors, num_classes)

val_sequencer = SequenceManager(val_data, 'val', prior_boxes,
                                batch_size, box_scale_factors, num_classes)

# model
multibox_loss = MultiboxLoss(num_classes, negative_positive_ratio, batch_size)
model = SSD300(image_shape, num_classes, weights_path)
model.compile(optimizer, loss=multibox_loss.compute_loss)

# callbacks
if not os.path.exists(model_path):
    os.makedirs(model_path)

checkpoint = ModelCheckpoint(save_path, verbose=1, period=1)
log = CSVLogger(model_path + 'SSD_scratch.log')
learning_rate_manager = LearningRateManager(learning_rate, decay, step_epochs)
learning_rate_schedule = LearningRateScheduler(learning_rate_manager.schedule)
tbCallBack = TensorBoard(log_dir='./Graph/', histogram_freq=0, batch_size=batch_size, write_graph=True)

callbacks = [checkpoint, log, learning_rate_schedule, tbCallBack]
Beispiel #2
0
import keras.backend as K

# parameters
dataset_name = 'VOC2012'
batch_size = 5
num_classes = 21
negative_positive_ratio = 3
prior_boxes = to_point_form(create_prior_boxes())

# loading training data
data_manager = DataManager(dataset_name, 'train')
train_data = data_manager.load_data()
arg_to_class = data_manager.arg_to_class
# loading validation data
val_data = DataManager(dataset_name, 'val').load_data()

# generating output
data = ImageGenerator(train_data, val_data, prior_boxes, batch_size)
generator = data.flow('train')
output_1 = next(generator)[1]['predictions']
output_2 = next(generator)[1]['predictions']

multibox_loss = MultiboxLoss(num_classes, negative_positive_ratio, batch_size)

output_1 = K.variable(output_1)
output_2 = K.variable(output_2)
loss = multibox_loss.compute_loss(output_1, output_2)
session = K.get_session()
loss = loss.eval(session=session)
print(loss)