示例#1
0
 def train(self, dataset, batch_size, checkpoint_dir, steps_per_epoch,
           nb_epocs, testing_ratio, validation_ratio, validation_steps):
     '''
     Starts training of the model with data provided by dataset.
     '''
     generator = self._get_data_generator(dataset, testing_ratio,
                                          validation_ratio)
     dataset_generator = generator.fcn_data_generator(
         batch_size, self.patch_size, self.no_classes)
     validation_generator = generator.fcn_data_generator(
         batch_size, self.patch_size, self.no_classes, dataset='validation')
     start_training(checkpoint_dir,
                    self.model,
                    dataset_generator,
                    steps_per_epoch,
                    nb_epocs,
                    callbacks=[],
                    validation_generator=validation_generator,
                    validation_steps=validation_steps)
示例#2
0
 def train(self, dataset, batch_size, checkpoint_dir, samples_per_epoc,
           nb_epocs, testing_ratio, validation_ratio,
           nb_validation_samples):
     '''
     Starts training of the model with data provided by dataset.
     '''
     patch_size = self.input_shape[1:3]
     generator = self._get_data_generator(dataset, testing_ratio,
                                          validation_ratio)
     dataset_generator = generator.grid_dataset_generator(
         batch_size, patch_size, self.grid_size)
     validation_generator = generator.grid_dataset_generator(
         batch_size, patch_size, self.grid_size, dataset='validation')
     start_training(checkpoint_dir,
                    self.model,
                    dataset_generator,
                    samples_per_epoc,
                    nb_epocs,
                    callbacks=[],
                    validation_generator=validation_generator,
                    nb_val_samples=nb_validation_samples)
示例#3
0
        bb_out = Convolution2D(4, 1, 1, border_mode='same')(model)

        model = Model(base_model.input, output=[class_out, bb_out])

        optimizer = Adam(lr=1e-5, beta_1=0.9, beta_2=0.999, epsilon=1e-08, decay=0.0)

        model.compile(optimizer=optimizer,
                      loss={'class_out': 'binary_crossentropy', 'bb_out': 'mean_squared_error'})
        logger.info('Compiled fc with output:{}', model.output)
        return model


if __name__ == '__main__':
    dataset_dir = '/data/lrz/hm-cell-tracking/sequences_A549/annotations'
    checkpoint_dir = '/data/training/yolo'
    nb_objects = 5
    batch_size = 100
    samples_per_epoc = 5000
    nb_epocs = 500
    patch_size = (224, 224)
    grid_size = (32, 32)

    detector = YoloDetector(ResNet50, 'activation_48')
    model = detector.build_model(nb_objects)

    dataset = ImageDataset(dataset_dir)
    dataset_generator = dataset.grid_patch_dataset_generator(batch_size, patch_size, grid_size=grid_size,
                                                             nb_objects=nb_objects)
    start_training(dataset_dir, checkpoint_dir, model, dataset_generator, samples_per_epoc, nb_epocs)
示例#4
0
    dataset_dir = '/data/lrz/hm-cell-tracking/sequences_A549/annotations'
    checkpoint_dir = '/data/training/cnn_conv3'
    batch_size = 20
    no_of_objects = 5
    input_shape = (64, 64, 3)
    samples_per_epoc = 80000
    nb_epocs = 1000

    model = cnn_conv3(input_shape=input_shape, out_size=no_of_objects)

    image_dataset = ImageDataset(dataset_dir)
    dataset_generator = image_dataset.patch_dataset_generator(
        batch_size,
        patch_size=input_shape[:2],
        no_of_objects=no_of_objects,
        dataset='training')
    validation_generator = image_dataset.patch_dataset_generator(
        batch_size,
        patch_size=input_shape[:2],
        no_of_objects=no_of_objects,
        dataset='validation')
    nb_val_samples = 100
    start_training(dataset_dir,
                   checkpoint_dir,
                   model,
                   dataset_generator,
                   samples_per_epoc,
                   nb_epocs,
                   validation_generator=validation_generator,
                   nb_val_samples=nb_val_samples)