Skip to content

Commit aa576bf

Browse files
committed
nits
1 parent 0b1945e commit aa576bf

File tree

3 files changed

+12
-39
lines changed

3 files changed

+12
-39
lines changed

nucleus/annotation.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,6 @@ def from_json(cls, payload: dict):
3434
else:
3535
return SegmentationAnnotation.from_json(payload)
3636

37-
# def from_json(cls, payload: dict):
38-
# if payload.get(TYPE_KEY, None) == BOX_TYPE:
39-
# geometry = payload.get(GEOMETRY_KEY, {})
40-
# return BoxAnnotation(
41-
# label=payload.get(LABEL_KEY, 0),
42-
# x=geometry.get(X_KEY, 0),
43-
# y=geometry.get(Y_KEY, 0),
44-
# width=geometry.get(WIDTH_KEY, 0),
45-
# height=geometry.get(HEIGHT_KEY, 0),
46-
# reference_id=payload.get(REFERENCE_ID_KEY, None),
47-
# item_id=payload.get(DATASET_ITEM_ID_KEY, None),
48-
# annotation_id=payload.get(ANNOTATION_ID_KEY, None),
49-
# metadata=payload.get(METADATA_KEY, {}),
50-
# )
51-
# elif payload.get(TYPE_KEY, None) == POLYGON_TYPE:
52-
# geometry = payload.get(GEOMETRY_KEY, {})
53-
# return PolygonAnnotation(
54-
# label=payload.get(LABEL_KEY, 0),
55-
# vertices=geometry.get(VERTICES_KEY, []),
56-
# reference_id=payload.get(REFERENCE_ID_KEY, None),
57-
# item_id=payload.get(DATASET_ITEM_ID_KEY, None),
58-
# annotation_id=payload.get(ANNOTATION_ID_KEY, None),
59-
# metadata=payload.get(METADATA_KEY, {}),
60-
# )
61-
# else:
62-
# return SegmentationAnnotation(
63-
# mask_url=payload.get(MASK_URL_KEY),
64-
# annotations=[
65-
# Segment.from_json(ann)
66-
# for ann in payload.get(ANNOTATIONS_KEY, [])
67-
# ],
68-
# reference_id=payload.get(REFERENCE_ID_KEY, None),
69-
# item_id=payload.get(ITEM_ID_KEY, None),
70-
# )
71-
7237

7338
class Segment:
7439
def __init__(

nucleus/model_run.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,15 @@ def _format_prediction_response(
129129
annotation_payload = response.get(ANNOTATIONS_KEY, None)
130130
if annotation_payload:
131131
annotation_response = {}
132-
for (type_key, type_cls) in zip([BOX_TYPE, POLYGON_TYPE, SEGMENTATION_TYPE],
133-
[BoxPrediction, PolygonPrediction, SegmentationPrediction]):
132+
for (type_key, type_cls) in zip(
133+
[BOX_TYPE, POLYGON_TYPE, SEGMENTATION_TYPE],
134+
[BoxPrediction, PolygonPrediction, SegmentationPrediction],
135+
):
134136
if type_key in annotation_payload:
135-
annotation_response[type_key] = [type_cls.from_json(ann) for ann in annotation_payload[type_key]]
137+
annotation_response[type_key] = [
138+
type_cls.from_json(ann)
139+
for ann in annotation_payload[type_key]
140+
]
136141
return annotation_response
137142
else: # An error occurred
138143
return response

tests/helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ def assert_segmentation_annotation_matches_dict(
156156
annotation_dict["annotations"]
157157
)
158158

159-
for instance_segment, dict_segment in zip(sorted(annotation_instance.annotations, key = lambda i: i.index), sorted(annotation_dict["annotations"], key = lambda i: i["index"])):
159+
for instance_segment, dict_segment in zip(
160+
sorted(annotation_instance.annotations, key=lambda i: i.index),
161+
sorted(annotation_dict["annotations"], key=lambda i: i["index"]),
162+
):
160163
assert instance_segment.index == dict_segment["index"]
161164
assert instance_segment.label == dict_segment["label"]
162165

0 commit comments

Comments
 (0)