Skip to content

Commit

Permalink
change 'None' to '-1' for unlabeled items
Browse files Browse the repository at this point in the history
  • Loading branch information
yasakova-anastasia committed May 14, 2021
1 parent 1dfdf63 commit 9f86f55
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions datumaro/plugins/mnist_csv_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class MnistCsvPath:
IMAGE_SIZE = 28
NONE_LABEL = -1

class MnistCsvExtractor(SourceExtractor):
def __init__(self, path, subset=None):
Expand Down Expand Up @@ -61,11 +62,8 @@ def _load_items(self, path):
for i, data in enumerate(annotation_table):
data = data.split(',')
item_anno = []
try:
label = int(data[0])
except ValueError:
label = None
if label != None:
label = int(data[0])
if label != MnistCsvPath.NONE_LABEL:
item_anno.append(Label(label))

if 0 < len(meta):
Expand Down Expand Up @@ -106,7 +104,7 @@ def apply(self):
for item in subset:
anns = [a.label for a in item.annotations
if a.type == AnnotationType.label]
label = None
label = MnistCsvPath.NONE_LABEL
if anns:
label = anns[0]

Expand Down

0 comments on commit 9f86f55

Please sign in to comment.