Esempio n. 1
0
    def test_vgg16(self):
        from dlpy.applications import VGG16

        pd.set_option('display.max_columns', 40)

        model = VGG16(self.s)
        model.print_summary()
        res = self.s.fetch(table=model.model_name, sortby='_dllayerid_')
        print(res)

        # test random_crop and mutation
        model1 = VGG16(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)
Esempio n. 2
0
    def test_vgg16_2(self):
        if self.data_dir is None:
            unittest.TestCase.skipTest(self, "DLPY_DATA_DIR is not set in the environment variables")

        model1 = VGG16(self.s, model_table='VGG16', 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_16_layers.caffemodel.h5',
                       include_top=True)

        model2 = VGG16(self.s, model_table='VGG16', 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_16_layers.caffemodel.h5',
                       include_top=True)

        self.assertRaises(ValueError, 
                               lambda:VGG16(self.s, model_table='VGG16',
                                            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_16_layers.caffemodel.h5',
                                            include_top=True))
Esempio n. 3
0
def initialize_network(s):

    model_name = request.form.get('model', 'VGG16')
    resize_x = request.form.get('resizeX', 224)
    resize_y = request.form.get('resizeY', 224)

    import sys
    sys.path.append(app.config.get('DLPY_PATH'))
    from dlpy.applications import VGG16

    try:
        with Capturing() as dlpy_out:
            model1 = VGG16(conn=s,
                           model_table='VGG16',
                           n_classes=None,
                           n_channels=3,
                           width=224,
                           height=224)
        resp = dict(messages=dlpy_out)
        session['current_network'] = 'VGG16'
        session['current_network_tbl'] = 'VGG16'
    except Exception as ex:
        print(str(ex))
        resp = dict(messages=['Error initializing model'])

    return jsonify(resp)
    def test_vgg16_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_16_layers.caffemodel.h5'
        if not file_exist_on_server(self.s, file_dependency):
            unittest.TestCase.skipTest(self, "File, {}, not found.".format(file_dependency))

        model1 = VGG16(self.s, model_table='VGG16', 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_16_layers.caffemodel.h5',
                       include_top=True)
        model1.print_summary()

        model2 = VGG16(self.s, model_table='VGG16', 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_16_layers.caffemodel.h5',
                       include_top=True)
        model2.print_summary()

        self.assertRaises(ValueError,
                          lambda: VGG16(self.s, model_table='VGG16',
                                        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_16_layers.caffemodel.h5',
                                        include_top=True))

        # test random_crop and mutation
        model3 = VGG16(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()
Esempio n. 5
0
 def test_vgg16(self):
     from dlpy.applications import VGG16
     model = VGG16(self.s)
     model.print_summary()