Skip to content

Commit 70b1ac0

Browse files
authored
Gu/fix test v2 (#1592)
1 parent 07f5a35 commit 70b1ac0

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

libs/labelbox/src/labelbox/data/serialization/coco/annotation.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,18 @@ def rle_decoding(rle_arr: List[int], w: int, h: int) -> np.ndarray:
2626
return mask.reshape((w, h)).T
2727

2828

29-
def get_annotation_lookup(
30-
annotations: List[Union[ClassificationAnnotation, ObjectAnnotation,
31-
VideoMaskAnnotation, ScalarMetric,
32-
ConfusionMatrixMetric, RelationshipAnnotation]]
33-
) -> defaultdict[Any, list]:
29+
def get_annotation_lookup(annotations):
3430
"""Get annotations from Label.annotations objects
3531
3632
Args:
3733
annotations (Label.annotations): Annotations attached to labelbox Label object used as private method
3834
"""
3935
annotation_lookup = defaultdict(list)
4036
for annotation in annotations:
41-
annotation_lookup[getattr(annotation, 'image_id', None) or
42-
getattr(annotation, 'name', None)].append(annotation)
43-
return annotation_lookup
37+
# Provide a default value of None if the attribute doesn't exist
38+
attribute_value = getattr(annotation, 'image_id', None) or getattr(annotation, 'name', None)
39+
annotation_lookup[attribute_value].append(annotation)
40+
return annotation_lookup
4441

4542

4643
class SegmentInfo(pydantic_compat.BaseModel):

0 commit comments

Comments
 (0)