Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.pad.base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.pad.base
Commits
10fa106b
There was a problem fetching the pipeline summary.
Commit
10fa106b
authored
7 years ago
by
Pavel KORSHUNOV
Browse files
Options
Downloads
Patches
Plain Diff
re-usable bio-pad-filelist interface
parent
f392d512
No related branches found
No related tags found
1 merge request
!45
Allow PAD filelist database to be used in vulnerability experiments
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/pad/base/database/PadBioFileDB.py
+14
-15
14 additions, 15 deletions
bob/pad/base/database/PadBioFileDB.py
with
14 additions
and
15 deletions
bob/pad/base/database/PadBioFileDB.py
+
14
−
15
View file @
10fa106b
...
...
@@ -6,7 +6,7 @@ used by both verification and PAD experiments.
from
bob.pad.base.database
import
PadFile
from
bob.pad.base.database
import
FileListPadDatabase
from
bob.bio.base.database
import
BioDatabase
from
bob.bio.base.database
import
FileList
BioDatabase
from
bob.bio.base.database.file
import
BioFile
import
bob.io.base
...
...
@@ -66,7 +66,7 @@ class HighPadDatabase(FileListPadDatabase):
**
kwargs
)
class
HighBioDatabase
(
BioDatabase
):
class
HighBioDatabase
(
FileList
BioDatabase
):
"""
Implements verification API for querying High database.
"""
...
...
@@ -90,7 +90,7 @@ class HighBioDatabase(BioDatabase):
original_directory
=
original_directory
,
original_extension
=
original_extension
,
**
kwargs
)
self
.
_
_
pad_db
=
HighPadDatabase
(
filelists_directory
=
filelists_directory
,
self
.
_pad_db
=
HighPadDatabase
(
filelists_directory
=
filelists_directory
,
db_name
=
db_name
,
file_class
=
file_class
,
original_directory
=
original_directory
,
...
...
@@ -100,7 +100,7 @@ class HighBioDatabase(BioDatabase):
self
.
low_level_group_names
=
(
'
train
'
,
'
dev
'
,
'
eval
'
)
self
.
high_level_group_names
=
(
'
world
'
,
'
dev
'
,
'
eval
'
)
def
_
_convert_protocol
(
self
,
protocol
=
None
):
def
_convert_protocol
(
self
,
protocol
=
None
):
"""
This conversion of the protocol with appended
'
-licit
'
or
'
-spoof
'
is a hack for verification experiments.
To adapt spoofing databases to the verification experiments, we need to be able to split a given protocol
...
...
@@ -134,7 +134,7 @@ class HighBioDatabase(BioDatabase):
return
protocol
,
modifier
def
_
_convert_purposes
(
self
,
purposes
,
modifier
):
def
_convert_purposes
(
self
,
purposes
,
modifier
):
"""
We assume there is no enrollment data, since
PAD File database has real and attack lists only,
...
...
@@ -152,12 +152,11 @@ class HighBioDatabase(BioDatabase):
if
isinstance
(
purposes
,
str
):
purposes
=
[
purposes
]
el
s
e
:
el
if
purposes
is
not
Non
e
:
purposes
=
list
(
purposes
)
# licit scenario considers genuine data only
# we return all real data
if
modifier
==
'
licit
'
:
purposes
=
[
'
real
'
]
# spoof scenario uses spoofed data for probe
...
...
@@ -166,11 +165,11 @@ class HighBioDatabase(BioDatabase):
# Hence, we request both real and attack data
if
modifier
==
'
spoof
'
:
# we return real and attack data
purposes
=
[
'
real
'
,
'
attack
'
]
purposes
.
append
(
'
attack
'
)
return
purposes
def
_
_filter_by_model_ids
(
self
,
objects
,
model_ids
):
def
_filter_by_model_ids
(
self
,
objects
,
model_ids
):
"""
From all File objects, keep only those, whose client_id is in model_ids
Args:
...
...
@@ -212,7 +211,7 @@ class HighBioDatabase(BioDatabase):
groups
=
self
.
convert_names_to_lowlevel
(
groups
,
self
.
low_level_group_names
,
self
.
high_level_group_names
)
# we also need to convert protocol name (it can have either '-licit' or '-spoof' appendix)
# to the expected protocol name without appendix
return
self
.
_
_
pad_db
.
client_ids
(
protocol
=
self
.
_
_
convert_protocol
(
protocol
)[
0
],
groups
=
groups
,
**
kwargs
)
return
self
.
_pad_db
.
client_ids
(
protocol
=
self
.
_convert_protocol
(
protocol
)[
0
],
groups
=
groups
,
**
kwargs
)
def
arrange_by_client
(
self
,
files
):
client_files
=
{}
...
...
@@ -263,18 +262,18 @@ class HighBioDatabase(BioDatabase):
groups
=
self
.
high_level_group_names
groups
=
self
.
convert_names_to_lowlevel
(
groups
,
self
.
low_level_group_names
,
self
.
high_level_group_names
)
protocol
,
modifier
=
self
.
_
_
convert_protocol
(
protocol
)
purposes
=
self
.
_
_
convert_purposes
(
purposes
,
modifier
)
protocol
,
modifier
=
self
.
_convert_protocol
(
protocol
)
purposes
=
self
.
_convert_purposes
(
purposes
,
modifier
)
# Query the underline PAD database
objects
=
self
.
_
_
pad_db
.
objects
(
protocol
=
protocol
,
groups
=
groups
,
purposes
=
purposes
,
**
kwargs
)
objects
=
self
.
_pad_db
.
objects
(
protocol
=
protocol
,
groups
=
groups
,
purposes
=
purposes
,
**
kwargs
)
# note that PAD database does not know anything about model_ids, so these are ignored
# Hence, for the spoofing protocol, we need to filter out the files and
# keep only those that belong to model_ids
# We also modify the client_id to reflect that it is an attack
if
modifier
==
'
spoof
'
and
model_ids
is
not
None
:
objects
=
self
.
_
_
filter_by_model_ids
(
objects
,
model_ids
)
objects
=
self
.
_filter_by_model_ids
(
objects
,
model_ids
)
# make sure to return BioFile representation of a file, not the database one
return
[
HighPadFile
(
client_id
=
f
.
client_id
,
path
=
f
.
path
,
file_id
=
f
.
path
,
attack_type
=
f
.
attack_type
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment