Skip to content

Commit

Permalink
Label -> StringLabel, description of ImageEncoder
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Kornuta <[email protected]>
  • Loading branch information
tkornuta-nvidia committed Jun 3, 2020
1 parent 6613d40 commit eee4c1e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions nemo/collections/cv/modules/data_layers/cifar100_datalayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from torchvision.transforms import Compose, Resize, ToTensor

from nemo.backends.pytorch.nm import DataLayerNM
from nemo.core.neural_types import AxisKind, AxisType, ClassificationTarget, ImageValue, Index, Label, NeuralType
from nemo.core.neural_types import AxisKind, AxisType, ClassificationTarget, ImageValue, Index, NeuralType, StringLabel
from nemo.utils.decorators import add_port_docs

__all__ = ['CIFAR100DataLayer']
Expand Down Expand Up @@ -172,9 +172,9 @@ def output_ports(self):
elements_type=ImageValue(), # uint8, <0-255>
),
"coarse_targets": NeuralType(tuple('B'), elements_type=ClassificationTarget()),
"coarse_labels": NeuralType(tuple('B'), elements_type=Label()), # Labels is string!
"coarse_labels": NeuralType(tuple('B'), elements_type=StringLabel()), # Labels is string!
"fine_targets": NeuralType(tuple('B'), elements_type=ClassificationTarget()),
"fine_labels": NeuralType(tuple('B'), elements_type=Label()), # Labels is string!
"fine_labels": NeuralType(tuple('B'), elements_type=StringLabel()), # Labels is string!
}

def __len__(self):
Expand Down
4 changes: 2 additions & 2 deletions nemo/collections/cv/modules/data_layers/mnist_datalayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
AxisType,
ClassificationTarget,
Index,
Label,
NeuralType,
NormalizedImageValue,
StringLabel,
)
from nemo.utils.decorators import add_port_docs

Expand Down Expand Up @@ -110,7 +110,7 @@ def output_ports(self):
elements_type=NormalizedImageValue(), # float, <0-1>
),
"targets": NeuralType(tuple('B'), elements_type=ClassificationTarget()), # Target are ints!
"labels": NeuralType(tuple('B'), elements_type=Label()), # Labels is string!
"labels": NeuralType(tuple('B'), elements_type=StringLabel()), # Labels is string!
}

def __len__(self):
Expand Down
4 changes: 3 additions & 1 deletion nemo/collections/cv/modules/trainables/image_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@

class ImageEncoder(TrainableNM):
"""
Class
Neural Module implementing a general-usage image encoderds.
It encapsulates several models from TorchVision (VGG16, ResNet152 and DensNet121, naming a few).
Offers two operation modes and can return: image embeddings vs feature maps.
"""

def __init__(
Expand Down
6 changes: 3 additions & 3 deletions nemo/core/neural_types/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
'Index',
'ImageValue',
'NormalizedImageValue',
'Label',
'StringLabel',
]

import abc
Expand Down Expand Up @@ -219,9 +219,9 @@ class ClassificationTarget(Target):
"""


class Label(ElementType):
class StringLabel(ElementType):
"""
Type representing an element being a target value.
Type representing an label being a string with class name (e.g. the "hamster" class in CIFAR100).
"""


Expand Down

0 comments on commit eee4c1e

Please sign in to comment.