def build_model(self, mobile=False, show=False):
     if mobile:
         self.model = create_hourglass_network(self.num_classes, self.num_stacks, self.inres, self.outres, bottleneck_mobile)
     else:
         self.model = create_hourglass_network(self.num_classes, self.num_stacks, self.inres, self.outres, bottleneck_block)
     # show model summary and layer name
     if show :
         self.model.summary()
def main():
    model = create_hourglass_network(16, 2, (256, 256), (64, 64))
    model.summary()
    print(len(model.output_layers))
    plot_model(model, 'hg_s2.png', show_shapes=True)
    for layer in model.output_layers:
        print(layer.output_shape)
Ejemplo n.º 3
0
def main():
    model = create_hourglass_network(16, 8, (256, 256), (64, 64),
                                     bottleneck_mobile)
    model.summary()
    print len(model.output_layers)
    #plot_model(model, 'hg_s2.png', show_shapes=True)
    for layer in model.output_layers:
        print layer.output_shape
Ejemplo n.º 4
0
    def build_model(self, mobile=False, show=True):
        if mobile:
            self.model = create_hourglass_network(self.num_classes,
                                                  self.num_stacks,
                                                  self.num_channels,
                                                  self.inres, self.outres,
                                                  bottleneck_mobile)
        else:
            self.model = create_hourglass_network(self.num_classes,
                                                  self.num_stacks,
                                                  self.num_channels,
                                                  self.inres, self.outres,
                                                  bottleneck_block)
        # show model summary and layer name
        if show:
            self.model.summary()
            model_json = self.model.to_json()

            with open("HourglassNet.json", "w") as json_file:
                json_file.write(model_json)

        return self.model
Ejemplo n.º 5
0
            wandb.config.downsample_ratio),  # 100ms
        'min_peak_height':
        0.3,
    })

    mit_loader_train = MITLoader('train', wandb.config)
    mit_loader_val = MITLoader('valid', wandb.config)
    training_set = DataGenerator(mit_loader_train, wandb.config.batch_size)
    validation_set = DataGenerator(mit_loader_val, wandb.config.batch_size)

    print('#batch_train, #batch_valid: {}, {}'.format(len(training_set),
                                                      len(validation_set)))

    model = create_hourglass_network(
        len(wandb.config.labels), wandb.config.number_hourglass_modules,
        wandb.config.number_inner_channels,
        (int(wandb.config.sampling_rate * wandb.config.length_s), 1),
        bottleneck_block, wandb.config.hourglass_module_layers)
    model.summary()
    model.compile(optimizer='adam',
                  loss=focal_loss(
                      length_head_ignore=int(wandb.config.sampling_rate *
                                             wandb.config.head_ignore_s *
                                             wandb.config.downsample_ratio),
                      length_tail_ignore=int(wandb.config.sampling_rate *
                                             wandb.config.tail_ignore_s *
                                             wandb.config.downsample_ratio)),
                  run_eagerly=False)

    model.fit(
        training_set,