Skip to content

Commit 846d021

Browse files
author
Diego Ardila
committed
Merge branch 'master' into da-fix-version
2 parents 5dda057 + f992507 commit 846d021

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

nucleus/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ANNOTATION_UPDATE_KEY = "update"
1212
AUTOTAGS_KEY = "autotags"
1313

14+
CLASS_PDF_KEY = "class_pdf"
1415
CONFIDENCE_KEY = "confidence"
1516
DATASET_ID_KEY = "dataset_id"
1617
DATASET_ITEM_IDS_KEY = "dataset_item_ids"

nucleus/prediction.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Y_KEY,
1717
WIDTH_KEY,
1818
HEIGHT_KEY,
19+
CLASS_PDF_KEY,
1920
CONFIDENCE_KEY,
2021
VERTICES_KEY,
2122
ANNOTATIONS_KEY,
@@ -54,6 +55,7 @@ def __init__(
5455
confidence: Optional[float] = None,
5556
annotation_id: Optional[str] = None,
5657
metadata: Optional[Dict] = None,
58+
class_pdf: Optional[Dict] = None,
5759
):
5860
super().__init__(
5961
label=label,
@@ -67,11 +69,13 @@ def __init__(
6769
metadata=metadata,
6870
)
6971
self.confidence = confidence
72+
self.class_pdf = class_pdf
7073

7174
def to_payload(self) -> dict:
7275
payload = super().to_payload()
7376
if self.confidence is not None:
7477
payload[CONFIDENCE_KEY] = self.confidence
78+
payload[CLASS_PDF_KEY] = self.class_pdf
7579

7680
return payload
7781

@@ -89,6 +93,7 @@ def from_json(cls, payload: dict):
8993
confidence=payload.get(CONFIDENCE_KEY, None),
9094
annotation_id=payload.get(ANNOTATION_ID_KEY, None),
9195
metadata=payload.get(METADATA_KEY, {}),
96+
class_pdf=payload.get(CLASS_PDF_KEY, {}),
9297
)
9398

9499

@@ -102,6 +107,7 @@ def __init__(
102107
confidence: Optional[float] = None,
103108
annotation_id: Optional[str] = None,
104109
metadata: Optional[Dict] = None,
110+
class_pdf: Optional[Dict] = None,
105111
):
106112
super().__init__(
107113
label=label,
@@ -112,11 +118,13 @@ def __init__(
112118
metadata=metadata,
113119
)
114120
self.confidence = confidence
121+
self.class_pdf = class_pdf
115122

116123
def to_payload(self) -> dict:
117124
payload = super().to_payload()
118125
if self.confidence is not None:
119126
payload[CONFIDENCE_KEY] = self.confidence
127+
payload[CLASS_PDF_KEY] = self.class_pdf
120128

121129
return payload
122130

@@ -131,4 +139,5 @@ def from_json(cls, payload: dict):
131139
confidence=payload.get(CONFIDENCE_KEY, None),
132140
annotation_id=payload.get(ANNOTATION_ID_KEY, None),
133141
metadata=payload.get(METADATA_KEY, {}),
142+
class_pdf=payload.get(CLASS_PDF_KEY, {}),
134143
)

tests/helpers.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,31 @@ def reference_id_from_url(url):
8787
]
8888
TEST_SEGMENTATION_PREDICTIONS = TEST_SEGMENTATION_ANNOTATIONS
8989

90+
TEST_BOX_MODEL_PDF = {
91+
box_annotation["label"]: 1 / len(TEST_BOX_ANNOTATIONS)
92+
for box_annotation in TEST_BOX_ANNOTATIONS
93+
}
94+
95+
TEST_POLYGON_MODEL_PDF = {
96+
polygon_annotation["label"]: 1 / len(TEST_POLYGON_ANNOTATIONS)
97+
for polygon_annotation in TEST_POLYGON_ANNOTATIONS
98+
}
99+
90100
TEST_BOX_PREDICTIONS = [
91-
{**TEST_BOX_ANNOTATIONS[i], "confidence": 0.10 * i}
101+
{
102+
**TEST_BOX_ANNOTATIONS[i],
103+
"confidence": 0.10 * i,
104+
"class_pdf": TEST_BOX_MODEL_PDF,
105+
}
92106
for i in range(len(TEST_BOX_ANNOTATIONS))
93107
]
94108

95109
TEST_POLYGON_PREDICTIONS = [
96-
{**TEST_POLYGON_ANNOTATIONS[i], "confidence": 0.10 * i}
110+
{
111+
**TEST_POLYGON_ANNOTATIONS[i],
112+
"confidence": 0.10 * i,
113+
"class_pdf": TEST_POLYGON_MODEL_PDF,
114+
}
97115
for i in range(len(TEST_POLYGON_ANNOTATIONS))
98116
]
99117

tests/test_dataset.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ def test_annotate_async(dataset: Dataset):
288288
"processed": 2,
289289
},
290290
"segmentation_upload": {
291-
"errors": [],
292291
"ignored": 0,
293292
"n_errors": 0,
294293
"processed": 1,
@@ -324,7 +323,6 @@ def test_annotate_async_with_error(dataset: Dataset):
324323
"processed": 1,
325324
},
326325
"segmentation_upload": {
327-
"errors": [],
328326
"ignored": 0,
329327
"n_errors": 0,
330328
"processed": 1,

tests/test_prediction.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ def test_mixed_pred_upload_async(model_run: ModelRun):
297297
"processed": 2,
298298
},
299299
"segmentation_upload": {
300-
"errors": [],
301300
"ignored": 0,
302301
"n_errors": 0,
303302
"processed": 1,
@@ -334,7 +333,6 @@ def test_mixed_pred_upload_async_with_error(model_run: ModelRun):
334333
"processed": 1,
335334
},
336335
"segmentation_upload": {
337-
"errors": [],
338336
"ignored": 0,
339337
"n_errors": 0,
340338
"processed": 1,

0 commit comments

Comments
 (0)