Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
deepdraw
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
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
medai
software
deepdraw
Commits
e32c1ca8
Commit
e32c1ca8
authored
4 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[script.significance] Implement checkpointing for patch difference evaluation
parent
c392a74f
No related branches found
No related tags found
No related merge requests found
Pipeline
#41313
failed
4 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/ip/binseg/script/significance.py
+46
-7
46 additions, 7 deletions
bob/ip/binseg/script/significance.py
with
46 additions
and
7 deletions
bob/ip/binseg/script/significance.py
+
46
−
7
View file @
e32c1ca8
...
...
@@ -194,15 +194,19 @@ def _eval_patches(
return
retval
def
_eval_differences
(
perf1
,
perf
2
,
evaluate
,
dataset
,
size
,
stride
,
outdir
,
figure
,
nproc
):
def
_eval_differences
(
names
,
perf
s
,
evaluate
,
dataset
,
size
,
stride
,
outdir
,
figure
,
nproc
,
checkpointdir
):
"""
Evaluate differences in the performance patches between two systems
Parameters
----------
perf1, perf2 : dict
A dictionary as returned by :py:func:`_eval_patches`
names : :py:class:`tuple` of :py:class:`str`
Names of the first and second systems
perfs : :py:class:`tuple` of :py:class:`dict`
Dictionaries for the patch performances of each system, as returned by
:py:func:`_eval_patches`
evaluate : str
Name of the dataset key to use from ``dataset`` to evaluate (typically,
...
...
@@ -235,6 +239,11 @@ def _eval_differences(perf1, perf2, evaluate, dataset, size, stride, outdir,
``1`` avoids completely the use of multiprocessing and runs all chores
in the current processing context.
checkpointdir : str
If set to a string (instead of ``None``), then stores a cached version
of the patch performances on disk, for a particular difference between
systems.
Returns
-------
...
...
@@ -246,7 +255,28 @@ def _eval_differences(perf1, perf2, evaluate, dataset, size, stride, outdir,
"""
perf_diff
=
dict
([(
k
,
perf1
[
k
][
"
df
"
].
copy
())
for
k
in
perf1
])
if
checkpointdir
is
not
None
:
chkpt_fname
=
os
.
path
.
join
(
checkpointdir
,
f
"
{
names
[
0
]
}
-
{
names
[
1
]
}
-
{
evaluate
}
-
"
\
f
"
{
size
[
0
]
}
x
{
size
[
1
]
}
+
{
stride
[
0
]
}
x
{
stride
[
1
]
}
-
{
figure
}
.pkl.gz
"
)
os
.
makedirs
(
os
.
path
.
dirname
(
chkpt_fname
),
exist_ok
=
True
)
if
os
.
path
.
exists
(
chkpt_fname
):
logger
.
info
(
f
"
Loading checkpoint from
{
chkpt_fname
}
...
"
)
# loads and returns checkpoint from file
try
:
with
__import__
(
'
gzip
'
).
GzipFile
(
chkpt_fname
,
"
r
"
)
as
f
:
return
__import__
(
'
pickle
'
).
load
(
f
)
except
EOFError
as
e
:
logger
.
warning
(
f
"
Could not load patch performance from
"
\
f
"
{
chkpt_fname
}
:
{
e
}
. Calculating...
"
)
else
:
logger
.
debug
(
f
"
Checkpoint not available at
{
chkpt_fname
}
.
"
\
f
"
Calculating...
"
)
else
:
chkpt_fname
=
None
perf_diff
=
dict
([(
k
,
perfs
[
0
][
k
][
"
df
"
].
copy
())
for
k
in
perfs
[
0
]])
# we can subtract these
to_subtract
=
(
...
...
@@ -260,9 +290,9 @@ def _eval_differences(perf1, perf2, evaluate, dataset, size, stride, outdir,
for
k
in
perf_diff
:
for
col
in
to_subtract
:
perf_diff
[
k
][
col
]
-=
perf
2
[
k
][
"
df
"
][
col
]
perf_diff
[
k
][
col
]
-=
perf
s
[
1
]
[
k
][
"
df
"
][
col
]
ret
urn
visual_performances
(
ret
val
=
visual_performances
(
dataset
,
evaluate
,
perf_diff
,
...
...
@@ -273,6 +303,14 @@ def _eval_differences(perf1, perf2, evaluate, dataset, size, stride, outdir,
outdir
,
)
# cache patch performance for later use, if necessary
if
chkpt_fname
is
not
None
:
logger
.
debug
(
f
"
Storing checkpoint at
{
chkpt_fname
}
...
"
)
with
__import__
(
'
gzip
'
).
GzipFile
(
chkpt_fname
,
"
w
"
)
as
f
:
__import__
(
'
pickle
'
).
dump
(
retval
,
f
)
return
retval
@click.command
(
entry_point_group
=
"
bob.ip.binseg.config
"
,
...
...
@@ -522,6 +560,7 @@ def significance(
else
os
.
path
.
join
(
output_folder
,
"
diff
"
)),
figure
,
parallel
,
checkpoint_folder
,
)
# loads all figures for the given threshold
...
...
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