Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
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
bob
bob.learn.tensorflow
Commits
55f2356e
Commit
55f2356e
authored
7 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
filter existing files
parent
fa2835e7
No related branches found
No related tags found
1 merge request
!33
Changes to the biogenerator
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/script/predict_bio.py
+16
-6
16 additions, 6 deletions
bob/learn/tensorflow/script/predict_bio.py
with
16 additions
and
6 deletions
bob/learn/tensorflow/script/predict_bio.py
+
16
−
6
View file @
55f2356e
...
@@ -140,6 +140,14 @@ def make_output_path(output_dir, key):
...
@@ -140,6 +140,14 @@ def make_output_path(output_dir, key):
return
os
.
path
.
join
(
output_dir
,
key
+
'
.hdf5
'
)
return
os
.
path
.
join
(
output_dir
,
key
+
'
.hdf5
'
)
def
non_existing_files
(
paths
,
force
=
False
):
if
force
:
return
range
(
len
(
paths
))
for
i
,
path
in
enumerate
(
paths
):
if
not
os
.
path
.
isfile
(
path
):
yield
i
def
save_predictions
(
pool
,
output_dir
,
key
,
pred_buffer
):
def
save_predictions
(
pool
,
output_dir
,
key
,
pred_buffer
):
outpath
=
make_output_path
(
output_dir
,
key
)
outpath
=
make_output_path
(
output_dir
,
key
)
create_directories_safe
(
os
.
path
.
dirname
(
outpath
))
create_directories_safe
(
os
.
path
.
dirname
(
outpath
))
...
@@ -172,9 +180,6 @@ def main(argv=None):
...
@@ -172,9 +180,6 @@ def main(argv=None):
hooks
=
getattr
(
config
,
'
hooks
'
,
None
)
hooks
=
getattr
(
config
,
'
hooks
'
,
None
)
load_data
=
getattr
(
config
,
'
load_data
'
,
None
)
load_data
=
getattr
(
config
,
'
load_data
'
,
None
)
# TODO(amir): implement force and pre-filtering
raise
ValueError
(
"
This script is not fully implemented yet!
"
)
# Sets-up logging
# Sets-up logging
set_verbosity_level
(
logger
,
verbosity
)
set_verbosity_level
(
logger
,
verbosity
)
...
@@ -190,6 +195,12 @@ def main(argv=None):
...
@@ -190,6 +195,12 @@ def main(argv=None):
start
,
end
=
indices
(
biofiles
,
number_of_parallel_jobs
)
start
,
end
=
indices
(
biofiles
,
number_of_parallel_jobs
)
biofiles
=
biofiles
[
start
:
end
]
biofiles
=
biofiles
[
start
:
end
]
# filter the existing files
paths
=
(
make_output_path
(
output_dir
,
f
.
make_path
(
""
,
""
))
for
f
in
biofiles
)
indexes
=
non_existing_files
(
paths
,
force
)
biofiles
=
(
biofiles
[
i
]
for
i
in
indexes
)
generator
=
BioGenerator
(
generator
=
BioGenerator
(
database
,
biofiles
,
load_data
=
load_data
,
database
,
biofiles
,
load_data
=
load_data
,
multiple_samples
=
multiple_samples
)
multiple_samples
=
multiple_samples
)
...
@@ -218,9 +229,8 @@ def main(argv=None):
...
@@ -218,9 +229,8 @@ def main(argv=None):
else
:
else
:
save_predictions
(
pool
,
output_dir
,
last_key
,
pred_buffer
)
save_predictions
(
pool
,
output_dir
,
last_key
,
pred_buffer
)
last_key
=
key
last_key
=
key
# else below is for the for loop
# save the final returned key as well:
else
:
save_predictions
(
pool
,
output_dir
,
key
,
pred_buffer
)
save_predictions
(
pool
,
output_dir
,
key
,
pred_buffer
)
finally
:
finally
:
pool
.
close
()
pool
.
close
()
pool
.
join
()
pool
.
join
()
...
...
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