Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.face
Commits
022bde8d
Commit
022bde8d
authored
Nov 02, 2016
by
Manuel Günther
Browse files
Implemented IJBA database interface correctly
parent
b96e367c
Pipeline
#5168
passed with stages
in 45 minutes and 29 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/face/config/database/ijba.py
0 → 100644
View file @
022bde8d
#!/usr/bin/env python
from
bob.bio.face.database
import
IJBABioDatabase
ijba_directory
=
"[YOUR_IJBA_DIRECTORY]"
database
=
IJBABioDatabase
(
original_directory
=
ijba_directory
,
protocol
=
'search_split1'
)
bob/bio/face/database/ijba.py
View file @
022bde8d
...
...
@@ -4,33 +4,60 @@
# Sat 20 Aug 15:43:10 CEST 2016
"""
IJBA database implementation of bob.bio.base.database.Database interface.
It is an extension of
an SQL-based
database interface, which directly talks to IJBA database, for
IJBA database implementation of bob.bio.base.database.
Bio
Database interface.
It is an extension of
the
database interface, which directly talks to IJBA database, for
verification experiments (good to use in bob.bio.base framework).
"""
from
.database
import
FaceBioFile
from
bob.bio.base.database
import
BioDatabase
,
BioFile
from
bob.bio.base.database
import
BioDatabase
,
BioFileSet
import
os
class
IJBABioFile
(
FaceBioFile
):
def
__init__
(
self
,
f
):
super
(
IJBABioFile
,
self
).
__init__
(
client_id
=
f
.
client_id
,
path
=
f
.
path
,
file_id
=
f
.
id
)
self
.
f
=
f
def
make_path
(
self
,
directory
,
extension
):
# add file ID to the path, so that a unique path is generated (there might be several identities in each physical file)
return
str
(
os
.
path
.
join
(
directory
or
''
,
self
.
path
+
"-"
+
str
(
self
.
id
)
+
(
extension
or
''
)))
class
IJBABioFileSet
(
BioFileSet
):
def
__init__
(
self
,
template
):
super
(
IJBABioFileSet
,
self
).
__init__
(
file_set_id
=
template
.
id
,
files
=
[
IJBABioFile
(
f
)
for
f
in
template
.
files
],
path
=
template
.
path
)
class
IJBABioDatabase
(
BioDatabase
):
"""
Implements verification API for querying IJBA database.
"""
def
__init__
(
self
,
**
kwargs
):
# call base class constructors to open a session to the database
super
(
IJBABioDatabase
,
self
).
__init__
(
name
=
'ijba'
,
**
kwargs
)
from
bob.db.ijba.query
import
Database
as
LowLevelDatabase
self
.
__db
=
LowLevelDatabase
()
def
model_ids_with_protocol
(
self
,
groups
=
None
,
protocol
=
"search_split1"
,
**
kwargs
):
return
self
.
__db
.
model_ids
(
groups
=
groups
,
protocol
=
protocol
)
def
objects
(
self
,
groups
=
None
,
protocol
=
"search_split1"
,
purposes
=
None
,
model_ids
=
None
,
**
kwargs
):
retval
=
self
.
__db
.
objects
(
groups
=
groups
,
protocol
=
protocol
,
purposes
=
purposes
,
model_ids
=
model_ids
,
**
kwargs
)
return
[
FaceBioFile
(
client_id
=
f
.
client_id
,
path
=
f
.
path
,
file_id
=
f
.
id
)
for
f
in
retval
]
"""
Implements verification API for querying IJBA database.
"""
def
__init__
(
self
,
**
kwargs
):
# call base class constructors to open a session to the database
super
(
IJBABioDatabase
,
self
).
__init__
(
name
=
'ijba'
,
models_depend_on_protocol
=
True
,
training_depends_on_protocol
=
True
,
**
kwargs
)
import
bob.db.ijba
self
.
_db
=
bob
.
db
.
ijba
.
Database
()
def
uses_probe_file_sets
(
self
):
return
True
def
model_ids_with_protocol
(
self
,
groups
=
None
,
protocol
=
"search_split1"
,
**
kwargs
):
return
self
.
_db
.
model_ids
(
groups
=
groups
,
protocol
=
protocol
)
def
objects
(
self
,
groups
=
None
,
protocol
=
"search_split1"
,
purposes
=
None
,
model_ids
=
None
,
**
kwargs
):
return
[
IJBABioFile
(
f
)
for
f
in
self
.
_db
.
objects
(
groups
=
groups
,
protocol
=
protocol
,
purposes
=
purposes
,
model_ids
=
model_ids
,
**
kwargs
)]
def
object_sets
(
self
,
groups
=
None
,
protocol
=
"search_split1"
,
purposes
=
None
,
model_ids
=
None
):
return
[
IJBABioFileSet
(
t
)
for
t
in
self
.
_db
.
object_sets
(
groups
=
groups
,
protocol
=
protocol
,
purposes
=
purposes
,
model_ids
=
model_ids
)]
def
annotations
(
self
,
biofile
):
return
self
.
_db
.
annotations
(
biofile
.
f
)
def
client_id_from_model_id
(
self
,
model_id
,
group
=
'dev'
):
return
self
.
_db
.
get_client_id_from_model_id
(
model_id
)
bob/bio/face/test/test_databases.py
View file @
022bde8d
...
...
@@ -25,13 +25,14 @@ from bob.bio.base.test.utils import db_available
from
bob.bio.base.test.test_database_implementations
import
check_database
,
check_database_zt
def
_check_annotations
(
database
):
def
_check_annotations
(
database
,
require_eyes
=
True
):
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
if
require_eyes
:
assert
'reye'
in
annotations
assert
'leye'
in
annotations
@
db_available
(
'arface'
)
...
...
@@ -119,8 +120,8 @@ def test_gbu():
def
test_ijba
():
database
=
bob
.
bio
.
base
.
load_resource
(
'ijba'
,
'database'
,
preferred_package
=
'bob.bio.face'
)
try
:
check_database
(
database
)
_check_annotations
(
database
)
check_database
(
database
,
models_depend
=
True
,
training_depends
=
True
)
_check_annotations
(
database
,
require_eyes
=
False
)
except
IOError
as
e
:
raise
SkipTest
(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'"
%
e
)
...
...
setup.py
View file @
022bde8d
...
...
@@ -109,11 +109,12 @@ setup(
'bob.bio.database'
:
[
'arface = bob.bio.face.config.database.arface:database'
,
'atnt = bob.bio.face.config.database.atnt:database'
,
'atnt = bob.bio.face.config.database.atnt:database'
,
'banca = bob.bio.face.config.database.banca_english:database'
,
'caspeal = bob.bio.face.config.database.caspeal:database'
,
'frgc = bob.bio.face.config.database.frgc:database'
,
'gbu = bob.bio.face.config.database.gbu:database'
,
'ijba = bob.bio.face.config.database.ijba:database'
,
'lfw-restricted = bob.bio.face.config.database.lfw_restricted:database'
,
'lfw-unrestricted = bob.bio.face.config.database.lfw_unrestricted:database'
,
'mobio-male = bob.bio.face.config.database.mobio_male:database'
,
# MOBIO gender-dependent training
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment