Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.db.pola_thermal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.db.pola_thermal
Commits
4935de26
Commit
4935de26
authored
7 years ago
by
Jaden
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into docs-url-fix
parents
64d8c280
ad119baf
No related branches found
No related tags found
1 merge request
!1
Update to new docs server location
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/db/pola_thermal/query.py
+120
-130
120 additions, 130 deletions
bob/db/pola_thermal/query.py
with
120 additions
and
130 deletions
bob/db/pola_thermal/query.py
+
120
−
130
View file @
4935de26
...
...
@@ -27,143 +27,133 @@ from .driver import Interface
SQLITE_FILE
=
Interface
().
files
()[
0
]
class
Database
(
bob
.
db
.
base
.
SQLiteDatabase
):
"""
Wrapper class for the Near-Infrared and Visible-Light (NIVL) Dataset
"""
def
__init__
(
self
,
original_directory
=
None
,
original_extension
=
None
):
# call base class constructors to open a session to the database
super
(
Database
,
self
).
__init__
(
SQLITE_FILE
,
File
)
self
.
original_directory
=
original_directory
self
.
original_extension
=
original_extension
class
Database
(
bob
.
db
.
base
.
SQLiteDatabase
):
"""
Wrapper class for the Near-Infrared and Visible-Light (NIVL) Dataset
def
protocols
(
self
):
return
PROTOCOLS
def
purposes
(
self
):
return
PURPOSES
def
annotations
(
self
,
file
,
annotation_type
=
"
eyes_center
"
):
"""
This function returns the annotations for the given file id as a dictionary.
**Parameters**
file: :py:class:`bob.db.base.File`
The File object you want to retrieve the annotations for,
**Return**
A dictionary of annotations, for face images usually something like {
'
leye
'
:(le_y,le_x),
'
reye
'
:(re_y,re_x), ...},
or None if there are no annotations for the given file ID (which is the case in this base class implementation).
"""
return
file
.
annotations
(
annotation_type
=
annotation_type
)
def
__init__
(
self
,
original_directory
=
None
,
original_extension
=
None
):
# call base class constructors to open a session to the database
super
(
Database
,
self
).
__init__
(
SQLITE_FILE
,
File
,
original_directory
,
original_extension
)
def
objects
(
self
,
groups
=
None
,
protocol
=
None
,
purposes
=
None
,
model_ids
=
None
,
**
kwargs
):
"""
This function returns lists of File objects, which fulfill the given restrictions.
"""
#Checking inputs
groups
=
self
.
check_parameters_for_validity
(
groups
,
"
group
"
,
GROUPS
)
protocols
=
self
.
check_parameters_for_validity
(
protocol
,
"
protocol
"
,
PROTOCOLS
)
purposes
=
self
.
check_parameters_for_validity
(
purposes
,
"
purpose
"
,
PURPOSES
)
#You need to select only one protocol
if
(
len
(
protocols
)
>
1
):
raise
ValueError
(
"
Please, select only one of the following protocols {0}
"
.
format
(
protocols
))
#Querying
query
=
self
.
query
(
bob
.
db
.
pola_thermal
.
File
,
bob
.
db
.
pola_thermal
.
Protocol_File_Association
).
join
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
).
join
(
bob
.
db
.
pola_thermal
.
Client
)
#filtering
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
group
.
in_
(
groups
))
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
protocol
.
in_
(
protocols
))
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
purpose
.
in_
(
purposes
))
if
model_ids
is
not
None
and
not
"
probe
"
in
purposes
:
if
type
(
model_ids
)
is
not
list
and
type
(
model_ids
)
is
not
tuple
:
model_ids
=
[
model_ids
]
#if you provide a client object as input and not the ids
if
type
(
model_ids
[
0
])
is
bob
.
db
.
pola_thermal
.
Client
:
model_aux
=
[]
for
m
in
model_ids
:
model_aux
.
append
(
m
.
id
)
model_ids
=
model_aux
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Client
.
id
.
in_
(
model_ids
))
raw_files
=
query
.
all
()
files
=
[]
for
f
in
raw_files
:
f
[
0
].
group
=
f
[
1
].
group
f
[
0
].
purpose
=
f
[
1
].
purpose
f
[
0
].
protocol
=
f
[
1
].
protocol
files
.
append
(
f
[
0
])
return
files
def
get_client_by_id
(
self
,
client_id
):
"""
Get the client object from its ID
"""
def
protocols
(
self
):
return
PROTOCOLS
query
=
self
.
query
(
bob
.
db
.
pola_thermal
.
Client
).
filter
(
bob
.
db
.
pola_thermal
.
Client
.
id
==
client_id
)
assert
len
(
query
.
all
())
==
1
return
query
.
all
()[
0
]
def
purposes
(
self
):
return
PURPOSES
def
annotations
(
self
,
file
,
annotation_type
=
"
eyes_center
"
):
"""
This function returns the annotations for the given file id as a dictionary.
**Parameters**
file: :py:class:`bob.db.base.File`
The File object you want to retrieve the annotations for,
**Return**
A dictionary of annotations, for face images usually something like {
'
leye
'
:(le_y,le_x),
'
reye
'
:(re_y,re_x), ...},
or None if there are no annotations for the given file ID (which is the case in this base class implementation).
"""
return
file
.
annotations
(
annotation_type
=
annotation_type
)
def
objects
(
self
,
groups
=
None
,
protocol
=
None
,
purposes
=
None
,
model_ids
=
None
,
**
kwargs
):
"""
This function returns lists of File objects, which fulfill the given restrictions.
"""
# Checking inputs
groups
=
self
.
check_parameters_for_validity
(
groups
,
"
group
"
,
GROUPS
)
protocols
=
self
.
check_parameters_for_validity
(
protocol
,
"
protocol
"
,
PROTOCOLS
)
purposes
=
self
.
check_parameters_for_validity
(
purposes
,
"
purpose
"
,
PURPOSES
)
# You need to select only one protocol
if
(
len
(
protocols
)
>
1
):
raise
ValueError
(
"
Please, select only one of the following protocols {0}
"
.
format
(
protocols
))
# Querying
query
=
self
.
query
(
bob
.
db
.
pola_thermal
.
File
,
bob
.
db
.
pola_thermal
.
Protocol_File_Association
).
join
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
).
join
(
bob
.
db
.
pola_thermal
.
Client
)
# filtering
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
group
.
in_
(
groups
))
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
protocol
.
in_
(
protocols
))
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
purpose
.
in_
(
purposes
))
if
model_ids
is
not
None
and
not
"
probe
"
in
purposes
:
if
type
(
model_ids
)
is
not
list
and
type
(
model_ids
)
is
not
tuple
:
model_ids
=
[
model_ids
]
# if you provide a client object as input and not the ids
if
type
(
model_ids
[
0
])
is
bob
.
db
.
pola_thermal
.
Client
:
model_aux
=
[]
for
m
in
model_ids
:
model_aux
.
append
(
m
.
id
)
model_ids
=
model_aux
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Client
.
id
.
in_
(
model_ids
))
raw_files
=
query
.
all
()
files
=
[]
for
f
in
raw_files
:
f
[
0
].
group
=
f
[
1
].
group
f
[
0
].
purpose
=
f
[
1
].
purpose
f
[
0
].
protocol
=
f
[
1
].
protocol
files
.
append
(
f
[
0
])
return
files
def
get_client_by_id
(
self
,
client_id
):
"""
Get the client object from its ID
"""
query
=
self
.
query
(
bob
.
db
.
pola_thermal
.
Client
).
filter
(
bob
.
db
.
pola_thermal
.
Client
.
id
==
client_id
)
assert
len
(
query
.
all
())
==
1
return
query
.
all
()[
0
]
def
model_ids
(
self
,
protocol
=
None
,
groups
=
None
):
# Checking inputs
groups
=
self
.
check_parameters_for_validity
(
groups
,
"
group
"
,
GROUPS
)
protocols
=
self
.
check_parameters_for_validity
(
protocol
,
"
protocol
"
,
PROTOCOLS
)
# You need to select only one protocol
if
(
len
(
protocols
)
>
1
):
raise
ValueError
(
"
Please, select only one of the following protocols {0}
"
.
format
(
protocols
))
# Querying
query
=
self
.
query
(
bob
.
db
.
pola_thermal
.
Client
).
join
(
bob
.
db
.
pola_thermal
.
File
).
join
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
)
# filtering
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
group
.
in_
(
groups
))
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
protocol
.
in_
(
protocols
))
return
[
c
.
id
for
c
in
query
.
all
()]
def
groups
(
self
,
protocol
=
None
,
**
kwargs
):
"""
This function returns the list of groups for this database.
"""
return
GROUPS
def
clients
(
self
,
protocol
=
None
,
groups
=
None
):
# Checking inputs
groups
=
self
.
check_parameters_for_validity
(
groups
,
"
group
"
,
GROUPS
)
protocols
=
self
.
check_parameters_for_validity
(
protocol
,
"
protocol
"
,
PROTOCOLS
)
# You need to select only one protocol
if
(
len
(
protocols
)
>
1
):
raise
ValueError
(
"
Please, select only one of the following protocols {0}
"
.
format
(
protocols
))
# Querying
query
=
self
.
query
(
bob
.
db
.
pola_thermal
.
Client
).
join
(
bob
.
db
.
pola_thermal
.
File
).
join
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
)
# filtering
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
group
.
in_
(
groups
))
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
protocol
.
in_
(
protocols
))
def
model_ids
(
self
,
protocol
=
None
,
groups
=
None
):
#Checking inputs
groups
=
self
.
check_parameters_for_validity
(
groups
,
"
group
"
,
GROUPS
)
protocols
=
self
.
check_parameters_for_validity
(
protocol
,
"
protocol
"
,
PROTOCOLS
)
#You need to select only one protocol
if
(
len
(
protocols
)
>
1
):
raise
ValueError
(
"
Please, select only one of the following protocols {0}
"
.
format
(
protocols
))
#Querying
query
=
self
.
query
(
bob
.
db
.
pola_thermal
.
Client
).
join
(
bob
.
db
.
pola_thermal
.
File
).
join
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
)
#filtering
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
group
.
in_
(
groups
))
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
protocol
.
in_
(
protocols
))
return
[
c
.
id
for
c
in
query
.
all
()]
def
groups
(
self
,
protocol
=
None
,
**
kwargs
):
"""
This function returns the list of groups for this database.
"""
return
GROUPS
def
clients
(
self
,
protocol
=
None
,
groups
=
None
):
#Checking inputs
groups
=
self
.
check_parameters_for_validity
(
groups
,
"
group
"
,
GROUPS
)
protocols
=
self
.
check_parameters_for_validity
(
protocol
,
"
protocol
"
,
PROTOCOLS
)
#You need to select only one protocol
if
(
len
(
protocols
)
>
1
):
raise
ValueError
(
"
Please, select only one of the following protocols {0}
"
.
format
(
protocols
))
#Querying
query
=
self
.
query
(
bob
.
db
.
pola_thermal
.
Client
).
join
(
bob
.
db
.
pola_thermal
.
File
).
join
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
)
#filtering
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
group
.
in_
(
groups
))
query
=
query
.
filter
(
bob
.
db
.
pola_thermal
.
Protocol_File_Association
.
protocol
.
in_
(
protocols
))
return
query
.
all
()
return
query
.
all
()
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