Example #1
0
    def test_vgg19_2(self):
        if self.data_dir is None:
            unittest.TestCase.skipTest(self, "DLPY_DATA_DIR is not set in the environment variables")

        model1 = VGG19(self.s, model_table='VGG19', n_classes=1000, n_channels=3, 
                       width=224, height=224, scale=1,
                       offsets=(103.939, 116.779, 123.68),
                       pre_trained_weights=True,
                       pre_trained_weights_file=self.data_dir+'VGG_ILSVRC_19_layers.caffemodel.h5',
                       include_top=True)

        model2 = VGG19(self.s, model_table='VGG19', n_classes=1000, n_channels=3, 
                       width=224, height=224, scale=1,
                       offsets=None,
                       random_crop=None,
                       pre_trained_weights=True,
                       pre_trained_weights_file=self.data_dir+'VGG_ILSVRC_19_layers.caffemodel.h5',
                       include_top=True)

        self.assertRaises(ValueError, 
                               lambda:VGG19(self.s, model_table='VGG19',
                                            n_classes=1000, n_channels=3, width=224, height=224, scale=1,
                                            offsets=None,
                                            random_crop='wrong_val',
                                            pre_trained_weights=True,
                                            pre_trained_weights_file=self.data_dir+'VGG_ILSVRC_19_layers.caffemodel.h5',
                                            include_top=True))
    def test_vgg19(self):
        from dlpy.applications import VGG19
        model = VGG19(self.s)
        model.print_summary()

        # test random_crop and mutation
        model1 = VGG19(self.s, model_table='VGG16', n_classes=1000, n_channels=3,
                       width=224, height=224, scale=1,
                       offsets=None,
                       random_crop='unique',
                       random_flip='hv',
                       random_mutation='random',
                       include_top=True)
        model1.print_summary()
        res1 = self.s.fetch(table=model1.model_name, sortby='_dllayerid_')
        print(res1)

        self.assertEqual(res1['Fetch'].iloc[10, 3], 4)
        self.assertEqual(res1['Fetch'].iloc[4, 3], 2)
    def test_vgg19_2(self):
        if self.data_dir is None:
            unittest.TestCase.skipTest(self, "DLPY_DATA_DIR is not set in the environment variables")
        file_dependency = self.data_dir + 'VGG_ILSVRC_19_layers.caffemodel.h5'
        if not file_exist_on_server(self.s, file_dependency):
            unittest.TestCase.skipTest(self, "File, {}, not found.".format(file_dependency))

        model1 = VGG19(self.s, model_table='VGG19', n_classes=1000, n_channels=3,
                       width=224, height=224, scale=1,
                       offsets=(103.939, 116.779, 123.68),
                       pre_trained_weights=True,
                       pre_trained_weights_file=self.data_dir + 'VGG_ILSVRC_19_layers.caffemodel.h5',
                       include_top=True)

        model2 = VGG19(self.s, model_table='VGG19', n_classes=1000, n_channels=3,
                       width=224, height=224, scale=1,
                       offsets=None,
                       random_crop=None,
                       pre_trained_weights=True,
                       pre_trained_weights_file=self.data_dir + 'VGG_ILSVRC_19_layers.caffemodel.h5',
                       include_top=True)

        self.assertRaises(ValueError,
                          lambda: VGG19(self.s, model_table='VGG19',
                                        n_classes=1000, n_channels=3, width=224, height=224, scale=1,
                                        offsets=None,
                                        random_crop='wrong_val',
                                        pre_trained_weights=True,
                                        pre_trained_weights_file=self.data_dir + 'VGG_ILSVRC_19_layers.caffemodel.h5',
                                        include_top=True))
        # test random_crop and mutation
        model3 = VGG19(self.s, model_table='VGG16', n_classes=1000, n_channels=3,
                       width=224, height=224, scale=1,
                       offsets=None,
                       random_crop='unique',
                       random_flip='hv',
                       random_mutation='random',
                       pre_trained_weights=True,
                       pre_trained_weights_file=self.data_dir + 'VGG_ILSVRC_16_layers.caffemodel.h5',
                       include_top=True)
        model3.print_summary()
Example #4
0
 def test_vgg19(self):
     from dlpy.applications import VGG19
     model = VGG19(self.s)
     model.print_summary()