test_databases.py 10 KB
Newer Older
Manuel Günther's avatar
Manuel Günther committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Manuel Guenther <Manuel.Guenther@idiap.ch>
# @date: Thu May 24 10:41:42 CEST 2012
#
# Copyright (C) 2011-2012 Idiap Research Institute, Martigny, Switzerland
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from nose.plugins.skip import SkipTest

import bob.bio.base
24
from bob.bio.base.test.utils import db_available
25
from bob.bio.base.test.test_database_implementations import check_database, check_database_zt
Manuel Günther's avatar
Manuel Günther committed
26
27


28
def _check_annotations(database, topleft=False):
29
30
31
32
    for file in database.all_files():
        annotations = database.annotations(file)
        if annotations is not None:
            assert isinstance(annotations, dict)
33
34
35
36
37
38
            if topleft:
                assert 'topleft' in annotations
                assert 'bottomright' in annotations
            else:
                assert 'reye' in annotations
                assert 'leye' in annotations
Manuel Günther's avatar
Manuel Günther committed
39
40


41
@db_available('arface')
Manuel Günther's avatar
Manuel Günther committed
42
def test_arface():
43
44
    database = bob.bio.base.load_resource('arface', 'database', preferred_package='bob.bio.face')
    try:
45
46
47
48
49
50
51
52
53
54
55
56
        check_database(database, groups=('dev', 'eval'))
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)


@db_available('atnt')
def test_atnt():
    database = bob.bio.base.load_resource('atnt', 'database', preferred_package='bob.bio.face')
    try:
        check_database(database)
57
58
59
60
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
61
62


63
@db_available('banca')
Manuel Günther's avatar
Manuel Günther committed
64
def test_banca():
65
66
    database = bob.bio.base.load_resource('banca', 'database', preferred_package='bob.bio.face')
    try:
67
        check_database_zt(database)
68
69
70
71
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
72
73


74
@db_available('caspeal')
Manuel Günther's avatar
Manuel Günther committed
75
def test_caspeal():
76
77
    database = bob.bio.base.load_resource('caspeal', 'database', preferred_package='bob.bio.face')
    try:
78
79
        check_database(database)
        check_database(database, protocol='aging')
80
81
82
83
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
84
85


86
#@db_available('frgc')
Amir Mohammadi's avatar
Amir Mohammadi committed
87
# def test_frgc():
88
89
90
91
92
93
94
95
96
#    import xml.sax
#    database = bob.bio.base.load_resource('frgc', 'database', preferred_package='bob.bio.face')
#    try:
#        _check_database(database, models_depend=True)
#        _check_database(database, protocol='2.0.2', models_depend=True)
#        _check_annotations(database)
#    except xml.sax.SAXException as e:
#        raise SkipTest(
#            "The database could not be opened, probably the original directory is wrong. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
97

98
99
100
101
102
103
104
105
106
107
@db_available('cuhk_cufs')
def test_cuhk_cufs():
    database = bob.bio.base.load_resource('cuhk_cufs', 'database', preferred_package='bob.bio.face')
    try:
        check_database(database)
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)

Manuel Günther's avatar
Manuel Günther committed
108

109
@db_available('gbu')
Manuel Günther's avatar
Manuel Günther committed
110
def test_gbu():
111
112
    database = bob.bio.base.load_resource('gbu', 'database', preferred_package='bob.bio.face')
    try:
113
114
        check_database(database, models_depend=True)
        check_database(database, protocol='Bad', models_depend=True)
Amir Mohammadi's avatar
Amir Mohammadi committed
115
        check_database(database, protocol='Ugly', models_depend=True)
116
117
118
119
120
121
122
123
124
125
126
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)


@db_available('ijba')
def test_ijba():
    database = bob.bio.base.load_resource('ijba', 'database', preferred_package='bob.bio.face')
    try:
        check_database(database)
127
128
129
130
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
131
132


133
@db_available('lfw')
Manuel Günther's avatar
Manuel Günther committed
134
def test_lfw():
135
136
    database = bob.bio.base.load_resource('lfw-restricted', 'database', preferred_package='bob.bio.face')
    try:
137
138
139
140
        check_database(database, training_depends=True, models_depend=True)
        check_database(database, groups=('dev', 'eval'), protocol='fold1', training_depends=True, models_depend=True)
        check_database(bob.bio.base.load_resource('lfw-unrestricted', 'database', preferred_package='bob.bio.face'),
                       training_depends=True, models_depend=True)
141
142
143
144
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
145
146


147
@db_available('mobio')
Manuel Günther's avatar
Manuel Günther committed
148
def test_mobio():
149
150
    database = bob.bio.base.load_resource('mobio-image', 'database', preferred_package='bob.bio.face')
    try:
151
152
153
154
155
156
        check_database_zt(database, models_depend=True)
        check_database_zt(database, protocol='female', models_depend=True)
        check_database_zt(bob.bio.base.load_resource('mobio-male', 'database', preferred_package='bob.bio.face'),
                          models_depend=True)
        check_database_zt(bob.bio.base.load_resource('mobio-female', 'database', preferred_package='bob.bio.face'),
                          models_depend=True)
157
158
159
160
161
162
    except IOError as e:
        raise SkipTest(
            "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)

    try:
        _check_annotations(database)
163
    except Exception as e:
164
165
        raise SkipTest(
            "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
166
167


168
@db_available('multipie')
Manuel Günther's avatar
Manuel Günther committed
169
def test_multipie():
170
171
    database = bob.bio.base.load_resource('multipie', 'database', preferred_package='bob.bio.face')
    try:
172
173
174
        check_database_zt(database, training_depends=True)
        check_database_zt(bob.bio.base.load_resource('multipie-pose', 'database', preferred_package='bob.bio.face'),
                          training_depends=True)
175
176
177
178
179
180
181
182
183
    except IOError as e:
        raise SkipTest(
            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
    except ValueError as e:
        raise SkipTest(
            "The database could not queried; probably the protocol is missing inside the db.sql3 file. Here is the error: '%s'" % e)

    try:
        _check_annotations(database)
184
    except Exception as e:
185
186
        raise SkipTest(
            "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
187
188


189
@db_available('scface')
Manuel Günther's avatar
Manuel Günther committed
190
def test_scface():
191
192
    database = bob.bio.base.load_resource('scface', 'database', preferred_package='bob.bio.face')
    try:
193
        check_database_zt(database)
194
195
196
197
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
Manuel Günther's avatar
Manuel Günther committed
198
199


200
@db_available('xm2vts')
Manuel Günther's avatar
Manuel Günther committed
201
def test_xm2vts():
202
203
    database = bob.bio.base.load_resource('xm2vts', 'database', preferred_package='bob.bio.face')
    try:
204
205
206
207
208
209
210
211
212
        check_database(database, groups=('dev', 'eval'))
        check_database(database, groups=('dev', 'eval'), protocol='darkened-lp1')
        _check_annotations(database)
    except IOError as e:
        raise SkipTest(
            "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)


@db_available('replay')
Amir Mohammadi's avatar
Amir Mohammadi committed
213
214
215
216
def test_replay_licit():
    database = bob.bio.base.load_resource('replay-img-licit', 'database', preferred_package='bob.bio.face')
    try:
        check_database(database, groups=('dev', 'eval'))
217
        _check_annotations(database, topleft=True)
Amir Mohammadi's avatar
Amir Mohammadi committed
218
219
220
221
222
223
224
225
226
227
    except IOError as e:
        raise SkipTest(
            "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)


@db_available('replay')
def test_replay_spoof():
    database = bob.bio.base.load_resource('replay-img-spoof', 'database', preferred_package='bob.bio.face')
    try:
        check_database(database, groups=('dev', 'eval'))
228
        _check_annotations(database, topleft=True)
Amir Mohammadi's avatar
Amir Mohammadi committed
229
230
231
232
233
234
235
236
    except IOError as e:
        raise SkipTest(
            "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)


@db_available('replaymobile')
def test_replaymobile_licit():
    database = bob.bio.base.load_resource('replaymobile-img-licit', 'database', preferred_package='bob.bio.face')
237
238
    try:
        check_database(database, groups=('dev', 'eval'))
239
        _check_annotations(database, topleft=True)
240
241
242
    except IOError as e:
        raise SkipTest(
            "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
243
244
245


@db_available('replaymobile')
Amir Mohammadi's avatar
Amir Mohammadi committed
246
247
def test_replaymobile_spoof():
    database = bob.bio.base.load_resource('replaymobile-img-spoof', 'database', preferred_package='bob.bio.face')
248
249
    try:
        check_database(database, groups=('dev', 'eval'))
250
        _check_annotations(database, topleft=True)
251
252
253
    except IOError as e:
        raise SkipTest(
            "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)