예제 #1
0
 def setUp(self):
     if not self.skip:
         self.database = RoseYoutuDatabase(os.environ['ROSE_YOUTU_PATH'])
     else:
         self.database = RoseYoutuDatabase('/home')  # Dummy path
     self.available_common_pais = [0, 1, 6, 7]
     self.available_common_capture_devices = [2, 3]
     self.available_common_lightning = [2]
     self.available_common_face_resolution = [0, 1, 2]
예제 #2
0
class UnitTestRoseYoutuDatabase(unittest.TestCase):
    skip = not DatabasesPathChecker.check_if_environment_is_defined_for("ROSE_YOUTU_PATH")
    reason = "ROSE_YOUTU_PATH has not been found. Impossible to run these tests"

    def setUp(self):
        if not self.skip:
            self.database = RoseYoutuDatabase(os.environ['ROSE_YOUTU_PATH'])
        else:
            self.database = RoseYoutuDatabase('/home')  # Dummy path
        self.available_common_pais = [0, 1, 6, 7]
        self.available_common_capture_devices = [2, 3]
        self.available_common_lightning = [2]
        self.available_common_face_resolution = [0, 1, 2]

    def test_constructor_with_non_existing_path(self):
        self.assertRaises(IOError,
                          lambda: RoseYoutuDatabase('wrong_path')
                          )

    def test_name_static_method(self):
        self.assertEqual(RoseYoutuDatabase.name(), 'rose-youtu')

    def test_is_a_collection_of_databases_static_method(self):
        self.assertFalse(RoseYoutuDatabase.is_a_collection_of_databases())

    @unittest.skipIf(skip, reason)
    def test_get_all_accesses(self):
        dict_all_accesses = self.database.get_all_accesses()

        self.assertEqual(len(dict_all_accesses['Train']), 1389)
        self.assertEqual(len(dict_all_accesses['Dev']), 359)
        self.assertEqual(len(dict_all_accesses['Test']), 1749)

    def test_get_all_labels(self):
        dict_all_labels = self.database.get_all_labels()

        self.assertEqual(len(dict_all_labels['Train']), 1389)
        self.assertEqual(len(dict_all_labels['Dev']), 359)
        self.assertEqual(len(dict_all_labels['Test']), 1749)

    def test_get_ground_truth_protocol_grandtest(self):
        dict_ground_truth = self.database.get_ground_truth('grandtest')

        self.assertEqual(len(dict_ground_truth['Train']), 1389)
        self.assertEqual(len(dict_ground_truth['Dev']), 359)
        self.assertEqual(len(dict_ground_truth['Test']), 1749)

    def test_common_labels_are_ok(self):
        dict_all_labels = self.database.get_all_labels()
        for subset, subset_dict in dict_all_labels.items():
            for basename, labels_dict in subset_dict.items():
                self.assertIn(labels_dict['common_pai'], self.available_common_pais)
                self.assertIn(labels_dict['common_capture_device'], self.available_common_capture_devices)
                self.assertIn(labels_dict['common_lightning'], self.available_common_lightning)
                self.assertIn(labels_dict['common_face_resolution'], self.available_common_face_resolution)
예제 #3
0
def main():
    databases = {
        '3dmad              (grandtest)': ThreedmadDatabase.info(),
        'aggregate-database (grandtest)': AggregateDatabase.info(),
        'casia-fasd         (grandtest)': CasiaFasdDatabase.info(),
        'casia-surf         (grandtest)': CasiaSurfDatabase.info(),
        'csmad              (grandtest)': CsmadDatabase.info(),
        'hkbu               (grandtest)': HkbuDatabase.info(),
        'msu_mfsd           (grandtest)': MsuMfsdDatabase.info(),
        'oulu_npu           (grandtest)': OuluNpuDatabase.info(),
        'replay-attack      (grandtest)': ReplayAttackDatabase.info(),
        'replay-mobile      (grandtest)': ReplayMobileDatabase.info(),
        'rose-youtu         (grandtest)': RoseYoutuDatabase.info(),
        'siw                (grandtest)': SiwDatabase.info(),
        'uvad               (grandtest)': UvadDatabase.info()
    }

    table = []
    for db in sorted(databases):
        database_row = [
            db, databases[db]['users'], databases[db]["Train videos"],
            databases[db]["Dev videos"], databases[db]["Test videos"]
        ]
        table.append(database_row)

    headers = [
        "Database", "Number of Users", "Train videos", "Dev videos",
        "Test videos"
    ]
    print("bob.gradiant.face.databases:")
    print(tabulate(table, headers, tablefmt="fancy_grid"))
def main():

    database = RoseYoutuDatabase(
        '/media/data/databases/BBDD/AntiSpoofing/RoseYoutu2008')
    dict_all_accesses = database.get_all_accesses()

    ied_per_subset = {'Train': [], 'Dev': [], 'Test': []}

    for subset, accesses in dict_all_accesses.items():
        for access in accesses:
            ied = _get_ied_per_from_access(
                os.path.join(access.base_path, access.name + '.h5'))
            ied_per_subset[subset].append(ied)

    hover = HoverTool(tooltips=[
        ("index", "$index"),
        ("Count", "($y)"),
        ("IED (px)", "($x)"),
    ])

    fig_bokeh = figure(plot_width=900,
                       plot_height=700,
                       tools=[hover, 'pan', 'wheel_zoom', 'box_zoom', 'reset'],
                       toolbar_location="above")
    fig_bokeh.title.text = " Histogram  | " + database.name() + " database  |"
    fig_bokeh.title.align = "left"
    fig_bokeh.title.text_color = "black"
    fig_bokeh.title.text_font_size = "13px"
    fig_bokeh.xaxis.axis_label = "IED (px)"
    fig_bokeh.yaxis.axis_label = "Count"

    hist_train, edges_train = np.histogram(ied_per_subset['Train'],
                                           bins='auto')
    hist_dev, edges_dev = np.histogram(ied_per_subset['Dev'], bins='auto')
    hist_test, edges_test = np.histogram(ied_per_subset['Test'], bins='auto')

    fig_bokeh.quad(top=hist_train,
                   bottom=0,
                   left=edges_train[:-1],
                   right=edges_train[1:],
                   fill_color="greenyellow",
                   line_color="darkgreen",
                   fill_alpha=0.5,
                   line_alpha=0.5,
                   legend='Train')

    fig_bokeh.quad(top=hist_dev,
                   bottom=0,
                   left=edges_dev[:-1],
                   right=edges_dev[1:],
                   fill_color="firebrick",
                   line_color="darkred",
                   fill_alpha=0.5,
                   line_alpha=0.5,
                   legend='Dev')

    fig_bokeh.quad(top=hist_test,
                   bottom=0,
                   left=edges_test[:-1],
                   right=edges_test[1:],
                   fill_color="navy",
                   line_color="darkblue",
                   fill_alpha=0.5,
                   line_alpha=0.5,
                   legend='Test')

    fig_bokeh.legend.location = "top_right"
    fig_bokeh.legend.background_fill_color = "darkgrey"
    fig_bokeh.legend.click_policy = "hide"

    output_file('/home/mlorenzo/histogram.html')
    save(fig_bokeh)
예제 #5
0
 def test_is_a_collection_of_databases_static_method(self):
     self.assertFalse(RoseYoutuDatabase.is_a_collection_of_databases())
예제 #6
0
 def test_name_static_method(self):
     self.assertEqual(RoseYoutuDatabase.name(), 'rose-youtu')
예제 #7
0
 def test_constructor_with_non_existing_path(self):
     self.assertRaises(IOError,
                       lambda: RoseYoutuDatabase('wrong_path')
                       )