Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MaggotUBA-adapter
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nyx
MaggotUBA-adapter
Commits
44bfff72
Commit
44bfff72
authored
1 year ago
by
François LAURENT
Browse files
Options
Downloads
Patches
Plain Diff
automatic file selection delegated to taggingbackends
parent
5d744c14
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!12
Set of commits to be tagged v0.19
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/maggotuba/models/predict_model.py
+7
-36
7 additions, 36 deletions
src/maggotuba/models/predict_model.py
with
7 additions
and
36 deletions
src/maggotuba/models/predict_model.py
+
7
−
36
View file @
44bfff72
...
...
@@ -5,6 +5,10 @@ import numpy as np
import
logging
import
os.path
tracking_data_file_extensions
=
(
'
.spine
'
,
'
.outline
'
,
'
.csv
'
,
'
.mat
'
,
'
.hdf5
'
)
def
predict_model
(
backend
,
**
kwargs
):
"""
This function generates predicted labels for all the input data.
...
...
@@ -25,17 +29,16 @@ def predict_model(backend, **kwargs):
input_files
=
backend
.
list_interim_files
(
group_by_directories
=
True
)
if
not
input_files
:
input_files
=
backend
.
list_input_files
(
group_by_directories
=
True
)
input_files
=
supported_input_files
(
input_files
)
assert
0
<
len
(
input_files
)
# initialize output labels
input_files_and_labels
=
backend
.
prepare_labels
(
input_files
)
input_files_and_labels
=
backend
.
prepare_labels
(
input_files
,
single_input
=
True
,
allowed_file_extensions
=
tracking_data_file_extensions
)
assert
0
<
len
(
input_files_and_labels
)
# load the model
model_files
=
backend
.
list_model_files
()
config_files
=
[
file
for
file
in
model_files
config_files
=
[
file
for
file
in
model_files
if
file
.
name
.
endswith
(
'
config.json
'
)]
if
len
(
config_files
)
==
0
:
raise
RuntimeError
(
f
"
no config files found for tagger:
{
backend
.
model_instance
}
"
)
...
...
@@ -200,38 +203,6 @@ def apply_filters(labels, post_filters):
return
labels
def
supported_input_files
(
files
):
if
isinstance
(
files
,
dict
):
files_
=
{}
for
d
,
fs
in
files
.
items
():
fs
=
supported_input_files
(
fs
)
if
fs
:
files_
[
d
]
=
fs
files
=
files_
else
:
files
=
[
f
for
f
in
files
if
supported_input_file
(
f
)]
return
files
def
supported_input_file
(
file
):
if
isinstance
(
file
,
str
):
file
=
os
.
path
.
basename
(
file
)
else
:
file
=
file
.
name
if
file
.
startswith
(
'
trx
'
)
and
file
.
endswith
(
'
.mat
'
):
return
True
elif
file
.
endswith
(
'
.spine
'
)
or
file
.
endswith
(
'
.outline
'
):
return
True
elif
file
.
endswith
(
'
.json
'
)
or
file
.
endswith
(
'
.label
'
)
or
\
file
.
endswith
(
'
.labels
'
)
or
file
.
endswith
(
'
.nyxlabel
'
):
return
True
elif
file
.
endswith
(
'
.csv
'
):
return
True
elif
file
.
endswith
(
'
.hdf5
'
):
return
True
else
:
return
False
from
taggingbackends.main
import
main
if
__name__
==
"
__main__
"
:
...
...
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