Skip to content

Commit

Permalink
fix: duplicate classifications in same label row crashes embeddings (#…
Browse files Browse the repository at this point in the history
…225)

fix: avoid shadowing variables

fix: check that label row has classification answer
  • Loading branch information
frederik-encord authored Mar 3, 2023
1 parent 6cb22ad commit 4f82b9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/encord_active/lib/dataset/summary_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
from dataclasses import dataclass, field
from pathlib import Path

Expand Down Expand Up @@ -93,6 +94,12 @@ def get_all_annotation_numbers(project_paths: ProjectFileStructure) -> Annotatio

for classification in data_unit["labels"].get("classifications", []):
classificationHash = classification["classificationHash"]
if classificationHash not in label_row_meta["classification_answers"]:
logging.warning(
"Couldn't find the classification answer. Something is probably wrong with the label row"
)
continue

classification_answer_item = label_row_meta["classification_answers"][classificationHash][
"classifications"
][0]
Expand Down
4 changes: 2 additions & 2 deletions src/encord_active/lib/embeddings/cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def generate_cnn_classification_embeddings(iterator: Iterator) -> List[LabelEmbe
)
)
# NOTE: since we only support one one classification for now
classification_answers = answers[0] if len(answers) else None
identified_answers = answers[0] if len(answers) else None

entry = LabelEmbedding(
url=data_unit["data_link"],
Expand All @@ -256,7 +256,7 @@ def generate_cnn_classification_embeddings(iterator: Iterator) -> List[LabelEmbe
name=classification["name"],
dataset_title=iterator.dataset_title,
embedding=embedding,
classification_answers=classification_answers,
classification_answers=identified_answers,
)
collections.append(entry)

Expand Down

0 comments on commit 4f82b9d

Please sign in to comment.