Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.bio.vein
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bob
bob.bio.vein
Commits
eb0079a5
Commit
eb0079a5
authored
Sep 01, 2017
by
André Anjos
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mlp trainer for watershed masker
parent
309ecf20
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
463 additions
and
0 deletions
+463
-0
bob/bio/vein/script/markdet.py
bob/bio/vein/script/markdet.py
+291
-0
bob/bio/vein/script/validate.py
bob/bio/vein/script/validate.py
+172
-0
No files found.
bob/bio/vein/script/markdet.py
0 → 100644
View file @
eb0079a5
This diff is collapsed.
Click to expand it.
bob/bio/vein/script/validate.py
0 → 100644
View file @
eb0079a5
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
'''Utilities for command-line option validation'''
import
os
import
glob
import
schema
import
logging
logger
=
logging
.
getLogger
(
__name__
)
def
setup_logger
(
name
,
level
):
'''Sets up and checks a verbosity level respects min and max boundaries
Parameters:
name (str): The name of the logger to setup
v (int): A value indicating the verbosity that must be set
Returns:
logging.Logger: A standard Python logger that can be used to log messages
Raises:
schema.SchemaError: If the verbosity level exceeds the maximum allowed of 4
'''
import
bob.core
logger
=
bob
.
core
.
log
.
setup
(
name
)
if
not
(
0
<=
level
<
4
):
raise
schema
.
SchemaError
(
"there can be only up to 3 -v's in a command-line"
)
# Sets-up logging
bob
.
core
.
log
.
set_verbosity_level
(
logger
,
level
)
return
logger
def
make_dir
(
p
):
'''Checks if a path exists, if it doesn't, creates it
Parameters:
p (str): The path to check
Returns
bool: ``True``, always
'''
if
not
os
.
path
.
exists
(
p
):
logger
.
info
(
"Creating directory `
%
s'..."
,
p
)
os
.
makedirs
(
p
)
return
True
def
check_path_does_not_exist
(
p
):
'''Checks if a path exists, if it does, raises an exception
Parameters:
p (str): The path to check
Returns:
bool: ``True``, always
Raises:
schema.SchemaError: if the path exists
'''
if
os
.
path
.
exists
(
p
):
raise
schema
.
SchemaError
(
"path to {} exists"
.
format
(
p
))
return
True
def
check_path_exists
(
p
):
'''Checks if a path exists, if it doesn't, raises an exception
Parameters:
p (str): The path to check
Returns:
bool: ``True``, always
Raises:
schema.SchemaError: if the path doesn't exist
'''
if
not
os
.
path
.
exists
(
p
):
raise
schema
.
SchemaError
(
"path to {} does not exist"
.
format
(
p
))
return
True
def
check_model_does_not_exist
(
p
):
'''Checks if the path to any potential model file does not exist
Parameters:
p (str): The path to check
Returns:
bool: ``True``, always
Raises:
schema.SchemaError: if the path exists
'''
files
=
glob
.
glob
(
p
+
'.*'
)
if
files
:
raise
schema
.
SchemaError
(
"{} already exists"
.
format
(
files
))
return
True
def
open_multipage_pdf_file
(
s
):
'''Returns an opened matplotlib multi-page file
Parameters:
p (str): The path to the file to open
Returns:
matplotlib.backends.backend_pdf.PdfPages: with the handle to the multipage
PDF file
Raises:
schema.SchemaError: if the path exists
'''
import
matplotlib.pyplot
as
mpl
from
matplotlib.backends.backend_pdf
import
PdfPages
return
PdfPages
(
s
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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