Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.vein
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.bio.vein
Commits
7d4f35d3
Commit
7d4f35d3
authored
7 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Allow to view sample using a database name
parent
12b3da0c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!35
3DFV and multiple fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/bio/vein/script/view_sample.py
+76
-18
76 additions, 18 deletions
bob/bio/vein/script/view_sample.py
with
76 additions
and
18 deletions
bob/bio/vein/script/view_sample.py
+
76
−
18
View file @
7d4f35d3
...
@@ -12,12 +12,13 @@ Usage: %(prog)s [-v...] [-s <path>] <database> <processed> <stem> [<stem>...]
...
@@ -12,12 +12,13 @@ Usage: %(prog)s [-v...] [-s <path>] <database> <processed> <stem> [<stem>...]
Arguments:
Arguments:
<database> Path to the database with the image to be inspected
<database> Name of the database to use for creating the model (options are:
"
fv3d
"
or
"
verafinger
"
)
<processed> Path with the directory holding the preprocessed and extracted
<processed> Path with the directory holding the preprocessed and extracted
sub-directories containing the processing results of a
sub-directories containing the processing results of a
bob.bio.vein toolchain
bob.bio.vein toolchain
<stem> Name of the object on the database to display, with the root
or
<stem> Name of the object on the database to display, with
out
the root
the extension
or
the extension
Options:
Options:
...
@@ -31,13 +32,13 @@ Options:
...
@@ -31,13 +32,13 @@ Options:
Examples:
Examples:
Visualize to processing toolchain over a single image
Visualize to processing toolchain over a single image
of VERA finger vein:
$ %(prog)s
/database
/mc client/sample
$ %(prog)s
verafinger
/mc client/sample
Visualize multiple masks (like in a proof-sheet):
Visualize multiple masks (like in a proof-sheet):
$ %(prog)s
/database
/mc client/sample1 client/sample2
$ %(prog)s
verafinger
/mc client/sample1 client/sample2
"""
"""
...
@@ -46,6 +47,10 @@ import os
...
@@ -46,6 +47,10 @@ import os
import
sys
import
sys
import
numpy
import
numpy
import
schema
import
docopt
import
bob.core
import
bob.core
logger
=
bob
.
core
.
log
.
setup
(
"
bob.bio.vein
"
)
logger
=
bob
.
core
.
log
.
setup
(
"
bob.bio.vein
"
)
...
@@ -148,6 +153,41 @@ def proof_figure(title, image, mask, image_pp, binary=None):
...
@@ -148,6 +153,41 @@ def proof_figure(title, image, mask, image_pp, binary=None):
return
fig
return
fig
def
validate
(
args
):
'''
Validates command-line arguments, returns parsed values
This function uses :py:mod:`schema` for validating :py:mod:`docopt`
arguments. Logging level is not checked by this procedure (actually, it is
ignored) and must be previously setup as some of the elements here may use
logging for outputing information.
Parameters:
args (dict): Dictionary of arguments as defined by the help message and
returned by :py:mod:`docopt`
Returns
dict: Validate dictionary with the same keys as the input and with values
possibly transformed by the validation procedure
Raises:
schema.SchemaError: in case one of the checked options does not validate.
'''
sch
=
schema
.
Schema
({
'
<database>
'
:
lambda
n
:
n
in
(
'
fv3d
'
,
'
verafinger
'
),
str
:
object
,
#ignores strings we don't care about
},
ignore_extra_keys
=
True
)
return
sch
.
validate
(
args
)
def
main
(
user_input
=
None
):
def
main
(
user_input
=
None
):
if
user_input
is
not
None
:
if
user_input
is
not
None
:
...
@@ -155,7 +195,6 @@ def main(user_input=None):
...
@@ -155,7 +195,6 @@ def main(user_input=None):
else
:
else
:
argv
=
sys
.
argv
[
1
:]
argv
=
sys
.
argv
[
1
:]
import
docopt
import
pkg_resources
import
pkg_resources
completions
=
dict
(
completions
=
dict
(
...
@@ -169,22 +208,41 @@ def main(user_input=None):
...
@@ -169,22 +208,41 @@ def main(user_input=None):
version
=
completions
[
'
version
'
],
version
=
completions
[
'
version
'
],
)
)
# Sets-up logging
try
:
verbosity
=
int
(
args
[
'
--verbose
'
])
from
.validate
import
setup_logger
bob
.
core
.
log
.
set_verbosity_level
(
logger
,
verbosity
)
logger
=
setup_logger
(
'
bob.bio.vein
'
,
args
[
'
--verbose
'
])
args
=
validate
(
args
)
except
schema
.
SchemaError
as
e
:
sys
.
exit
(
e
)
if
args
[
'
<database>
'
]
==
'
fv3d
'
:
from
..configurations.fv3d
import
database
as
db
elif
args
[
'
<database>
'
]
==
'
verafinger
'
:
from
..configurations.verafinger
import
database
as
db
else
:
raise
schema
.
SchemaError
(
'
Database %s is not supported
'
%
\
args
[
'
<database>
'
])
database_replacement
=
"
%s/.bob_bio_databases.txt
"
%
os
.
environ
[
"
HOME
"
]
db
.
replace_directories
(
database_replacement
)
all_files
=
db
.
objects
()
# Loads the image, the mask and save it to a PNG file
# Loads the image, the mask and save it to a PNG file
for
stem
in
args
[
'
<stem>
'
]:
for
stem
in
args
[
'
<stem>
'
]:
image
=
bob
.
bio
.
base
.
load
(
os
.
path
.
join
(
args
[
'
<database>
'
],
stem
+
'
.png
'
))
f
=
[
k
for
k
in
all_files
if
k
.
path
==
stem
]
image
=
numpy
.
rot90
(
image
,
k
=-
1
)
if
len
(
f
)
==
0
:
pp
=
bob
.
io
.
base
.
HDF5File
(
os
.
path
.
join
(
args
[
'
<processed>
'
],
raise
RuntimeError
(
'
File with stem
"
%s
"
does not exist on
"
%s
"'
%
\
'
preprocessed
'
,
stem
+
'
.hdf5
'
))
stem
,
args
[
'
<database>
'
])
f
=
f
[
0
]
image
=
f
.
load
(
db
.
original_directory
,
db
.
original_extension
)
pp_name
=
f
.
make_path
(
os
.
path
.
join
(
args
[
'
<processed>
'
],
'
preprocessed
'
),
extension
=
'
.hdf5
'
)
pp
=
bob
.
io
.
base
.
HDF5File
(
pp_name
)
mask
=
pp
.
read
(
'
mask
'
)
mask
=
pp
.
read
(
'
mask
'
)
image_pp
=
pp
.
read
(
'
image
'
)
image_pp
=
pp
.
read
(
'
image
'
)
binary_path
=
os
.
path
.
join
(
args
[
'
<processed>
'
],
'
extracted
'
,
stem
+
'
.hdf5
'
)
try
:
if
os
.
path
.
exists
(
binary_path
):
binary
=
f
.
load
(
os
.
path
.
join
(
args
[
'
<processed>
'
],
'
extracted
'
))
binary
=
bob
.
io
.
base
.
load
(
binary_path
)
except
:
else
:
binary
=
None
binary
=
None
fig
=
proof_figure
(
stem
,
image
,
mask
,
image_pp
,
binary
)
fig
=
proof_figure
(
stem
,
image
,
mask
,
image_pp
,
binary
)
if
args
[
'
--save
'
]:
if
args
[
'
--save
'
]:
...
...
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