Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
7a1281a6
Unverified
Commit
7a1281a6
authored
Aug 15, 2022
by
vfdev
Committed by
GitHub
Aug 15, 2022
Browse files
[proto] Clean-up Label.to_categories (#6419)
* [proto] Clean-up Label.to_categories * Fixed flake8
parent
4db84b04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
torchvision/prototype/features/_label.py
torchvision/prototype/features/_label.py
+5
-5
No files found.
torchvision/prototype/features/_label.py
View file @
7a1281a6
from
__future__
import
annotations
from
__future__
import
annotations
from
typing
import
Any
,
cast
,
Optional
,
Sequence
,
Union
from
typing
import
Any
,
Optional
,
Sequence
,
Union
import
torch
import
torch
from
torch
vision.prototype.utils._internal
import
apply_recursively
from
torch
.utils._pytree
import
tree_map
from
._feature
import
_Feature
from
._feature
import
_Feature
...
@@ -43,10 +43,10 @@ class Label(_Feature):
...
@@ -43,10 +43,10 @@ class Label(_Feature):
return
cls
(
categories
.
index
(
category
),
categories
=
categories
,
**
kwargs
)
return
cls
(
categories
.
index
(
category
),
categories
=
categories
,
**
kwargs
)
def
to_categories
(
self
)
->
Any
:
def
to_categories
(
self
)
->
Any
:
if
not
self
.
categories
:
if
self
.
categories
is
None
:
raise
RuntimeError
()
raise
RuntimeError
(
"Label does not have categories"
)
return
apply_recursively
(
lambda
idx
:
cast
(
Sequence
[
str
],
self
.
categories
)
[
idx
],
self
.
tolist
())
return
tree_map
(
lambda
idx
:
self
.
categories
[
idx
],
self
.
tolist
())
class
OneHotLabel
(
_Feature
):
class
OneHotLabel
(
_Feature
):
...
...
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