test_databases.py 8.51 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):
29
30
31
32
33
34
    for file in database.all_files():
        annotations = database.annotations(file)
        if annotations is not None:
            assert isinstance(annotations, dict)
            assert 'reye' in annotations
            assert 'leye' in annotations
Manuel Günther's avatar
Manuel Günther committed
35
36


37
@db_available('arface')
Manuel Günther's avatar
Manuel Günther committed
38
def test_arface():
39
40
    database = bob.bio.base.load_resource('arface', 'database', preferred_package='bob.bio.face')
    try:
41
42
43
44
45
46
47
48
49
50
51
52
        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)
53
54
55
56
        _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
57
58


59
@db_available('banca')
Manuel Günther's avatar
Manuel Günther committed
60
def test_banca():
61
62
    database = bob.bio.base.load_resource('banca', 'database', preferred_package='bob.bio.face')
    try:
63
        check_database_zt(database)
64
65
66
67
        _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
68
69


70
@db_available('caspeal')
Manuel Günther's avatar
Manuel Günther committed
71
def test_caspeal():
72
73
    database = bob.bio.base.load_resource('caspeal', 'database', preferred_package='bob.bio.face')
    try:
74
75
        check_database(database)
        check_database(database, protocol='aging')
76
77
78
79
        _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
80
81


82
83
84
85
86
87
88
89
90
91
92
#@db_available('frgc')
#def test_frgc():
#    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
93

94
95
96
97
98
99
100
101
102
103
@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
104

105
@db_available('gbu')
Manuel Günther's avatar
Manuel Günther committed
106
def test_gbu():
107
108
    database = bob.bio.base.load_resource('gbu', 'database', preferred_package='bob.bio.face')
    try:
109
110
111
112
113
114
115
116
117
118
119
120
121
122
        check_database(database, models_depend=True)
        check_database(database, protocol='Bad', models_depend=True)
        check_database(database, protocol = 'Ugly', models_depend=True)
        _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)
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)
Manuel Günther's avatar
Manuel Günther committed
127
128


129
@db_available('lfw')
Manuel Günther's avatar
Manuel Günther committed
130
def test_lfw():
131
132
    database = bob.bio.base.load_resource('lfw-restricted', 'database', preferred_package='bob.bio.face')
    try:
133
134
135
136
        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)
137
138
139
140
        _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
141
142


143
@db_available('mobio')
Manuel Günther's avatar
Manuel Günther committed
144
def test_mobio():
145
146
    database = bob.bio.base.load_resource('mobio-image', 'database', preferred_package='bob.bio.face')
    try:
147
148
149
150
151
152
        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)
153
154
155
156
157
158
    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)
159
    except Exception as e:
160
161
        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
162
163


164
@db_available('multipie')
Manuel Günther's avatar
Manuel Günther committed
165
def test_multipie():
166
167
    database = bob.bio.base.load_resource('multipie', 'database', preferred_package='bob.bio.face')
    try:
168
169
170
        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)
171
172
173
174
175
176
177
178
179
    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)
180
    except Exception as e:
181
182
        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
183
184


185
@db_available('scface')
Manuel Günther's avatar
Manuel Günther committed
186
def test_scface():
187
188
    database = bob.bio.base.load_resource('scface', 'database', preferred_package='bob.bio.face')
    try:
189
        check_database_zt(database)
190
191
192
193
        _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
194
195


196
@db_available('xm2vts')
Manuel Günther's avatar
Manuel Günther committed
197
def test_xm2vts():
198
199
    database = bob.bio.base.load_resource('xm2vts', 'database', preferred_package='bob.bio.face')
    try:
200
201
202
203
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')
def test_replay():
    database = bob.bio.base.load_resource('replay', 'database', preferred_package='bob.bio.face')
    try:
        check_database(database, groups=('dev', 'eval'))
213
214
215
216
        _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)