Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TaggingBackends
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nyx
TaggingBackends
Commits
f4ebd759
Commit
f4ebd759
authored
2 years ago
by
François LAURENT
Browse files
Options
Downloads
Patches
Plain Diff
implements
larvatagger.jl#103
parent
0e34318e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#99735
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/taggingbackends/data/labels.py
+25
-2
25 additions, 2 deletions
src/taggingbackends/data/labels.py
with
25 additions
and
2 deletions
src/taggingbackends/data/labels.py
+
25
−
2
View file @
f4ebd759
...
@@ -84,6 +84,7 @@ class Labels:
...
@@ -84,6 +84,7 @@ class Labels:
self
.
secondarylabelspec
=
None
self
.
secondarylabelspec
=
None
self
.
_tracking
=
tracking
self
.
_tracking
=
tracking
self
.
_input_labels
=
None
self
.
_input_labels
=
None
self
.
decodingspec
=
None
#
#
self
.
filepath
=
None
# unused attribute; may help to manage data
self
.
filepath
=
None
# unused attribute; may help to manage data
# dependencies in the future
# dependencies in the future
...
@@ -360,7 +361,18 @@ class Labels:
...
@@ -360,7 +361,18 @@ class Labels:
"""
"""
Decode the label indices as text (`str` or `list` of `str`).
Decode the label indices as text (`str` or `list` of `str`).
Text labels are picked in `labelspec`.
Text labels are picked in `labelspec`, or `decodingspec` instead if defined.
`decodingspec` is set to decode the encoded output from a tagger that
defines redundant labels, which are remapped onto labels in `labelspec`.
These may include several sections in their config file, including
`original_behavior_labels`, `behavior_labels`, `remapped_behavior_labels`.
Note that `decodingspec` should not be set to decode a label file. A label
file should use and mention the remapped labels only, if the latter are
defined by the tagger used to generate the label file. In the case of
decoding a label file, `labelspec` only should be defined in the `Labels`
object.
"""
"""
def
decode
(
self
,
label
=
None
):
def
decode
(
self
,
label
=
None
):
if
label
is
None
:
if
label
is
None
:
...
@@ -370,7 +382,10 @@ class Labels:
...
@@ -370,7 +382,10 @@ class Labels:
elif
isinstance
(
label
,
dict
):
elif
isinstance
(
label
,
dict
):
decoded
=
{
t
:
self
.
decode
(
l
)
for
t
,
l
in
label
.
items
()}
decoded
=
{
t
:
self
.
decode
(
l
)
for
t
,
l
in
label
.
items
()}
else
:
else
:
labelset
=
self
.
full_label_list
if
self
.
decodingspec
is
None
:
labelset
=
self
.
full_label_list
else
:
labelset
=
self
.
decodingspec
if
isinstance
(
label
,
int
):
if
isinstance
(
label
,
int
):
decoded
=
labelset
[
label
-
1
]
decoded
=
labelset
[
label
-
1
]
elif
isinstance
(
label
,
str
):
elif
isinstance
(
label
,
str
):
...
@@ -380,6 +395,14 @@ class Labels:
...
@@ -380,6 +395,14 @@ class Labels:
decoded
=
[
labelset
[
l
-
1
]
for
l
in
label
]
decoded
=
[
labelset
[
l
-
1
]
for
l
in
label
]
return
decoded
return
decoded
def
load_model_config
(
self
,
config
):
try
:
self
.
labelspec
=
config
[
"
remapped_behavior_labels
"
]
except
KeyError
:
self
.
labelspec
=
config
[
"
behavior_labels
"
]
else
:
self
.
decodingspec
=
config
[
"
behavior_labels
"
]
class
LabelEncoder
(
json
.
JSONEncoder
):
class
LabelEncoder
(
json
.
JSONEncoder
):
def
default
(
self
,
labels
):
def
default
(
self
,
labels
):
if
isinstance
(
labels
,
Labels
):
if
isinstance
(
labels
,
Labels
):
...
...
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