31
31
POSITION_KEY ,
32
32
REFERENCE_ID_KEY ,
33
33
TAXONOMY_NAME_KEY ,
34
+ TRACK_REFERENCE_ID_KEY ,
34
35
TYPE_KEY ,
35
36
VERTICES_KEY ,
36
37
VISIBLE_KEY ,
@@ -109,6 +110,7 @@ class BoxAnnotation(Annotation): # pylint: disable=R0902
109
110
annotation_id="image_1_car_box_1",
110
111
metadata={"vehicle_color": "red"},
111
112
embedding_vector=[0.1423, 1.432, ..., 3.829],
113
+ track_reference_id="car_a",
112
114
)
113
115
114
116
Parameters:
@@ -135,10 +137,12 @@ class BoxAnnotation(Annotation): # pylint: disable=R0902
135
137
136
138
Coordinate metadata may be provided to enable the Map Chart in the Nucleus Dataset charts page.
137
139
These values can be specified as `{ "lat": 52.5, "lon": 13.3, ... }`.
138
-
139
140
embedding_vector: Custom embedding vector for this object annotation.
140
141
If any custom object embeddings have been uploaded previously to this dataset,
141
142
this vector must match the dimensions of the previously ingested vectors.
143
+ track_reference_id: A unique string to identify the annotation as part of a group.
144
+ For instance, multiple "car" annotations across several dataset items may have
145
+ the same `track_reference_id` such as "red_car".
142
146
"""
143
147
144
148
label : str
@@ -150,6 +154,7 @@ class BoxAnnotation(Annotation): # pylint: disable=R0902
150
154
annotation_id : Optional [str ] = None
151
155
metadata : Optional [Dict ] = None
152
156
embedding_vector : Optional [list ] = None
157
+ track_reference_id : Optional [str ] = None
153
158
154
159
def __post_init__ (self ):
155
160
self .metadata = self .metadata if self .metadata else {}
@@ -169,6 +174,7 @@ def from_json(cls, payload: dict):
169
174
annotation_id = payload .get (ANNOTATION_ID_KEY , None ),
170
175
metadata = payload .get (METADATA_KEY , {}),
171
176
embedding_vector = payload .get (EMBEDDING_VECTOR_KEY , None ),
177
+ track_reference_id = payload .get (TRACK_REFERENCE_ID_KEY , None ),
172
178
)
173
179
174
180
def to_payload (self ) -> dict :
@@ -185,6 +191,7 @@ def to_payload(self) -> dict:
185
191
ANNOTATION_ID_KEY : self .annotation_id ,
186
192
METADATA_KEY : self .metadata ,
187
193
EMBEDDING_VECTOR_KEY : self .embedding_vector ,
194
+ TRACK_REFERENCE_ID_KEY : self .track_reference_id ,
188
195
}
189
196
190
197
def __eq__ (self , other ):
@@ -198,6 +205,7 @@ def __eq__(self, other):
198
205
and self .annotation_id == other .annotation_id
199
206
and sorted (self .metadata .items ()) == sorted (other .metadata .items ())
200
207
and self .embedding_vector == other .embedding_vector
208
+ and self .track_reference_id == other .track_reference_id
201
209
)
202
210
203
211
@@ -237,6 +245,7 @@ class LineAnnotation(Annotation):
237
245
reference_id="person_image_1",
238
246
annotation_id="person_image_1_line_1",
239
247
metadata={"camera_mode": "portrait"},
248
+ track_reference_id="face_human",
240
249
)
241
250
242
251
Parameters:
@@ -252,13 +261,17 @@ class LineAnnotation(Annotation):
252
261
attach to this annotation. Strings, floats and ints are supported best
253
262
by querying and insights features within Nucleus. For more details see
254
263
our `metadata guide <https://nucleus.scale.com/docs/upload-metadata>`_.
264
+ track_reference_id: A unique string to identify the annotation as part of a group.
265
+ For instance, multiple "car" annotations across several dataset items may have
266
+ the same `track_reference_id` such as "red_car".
255
267
"""
256
268
257
269
label : str
258
270
vertices : List [Point ]
259
271
reference_id : str
260
272
annotation_id : Optional [str ] = None
261
273
metadata : Optional [Dict ] = None
274
+ track_reference_id : Optional [str ] = None
262
275
263
276
def __post_init__ (self ):
264
277
self .metadata = self .metadata if self .metadata else {}
@@ -287,6 +300,7 @@ def from_json(cls, payload: dict):
287
300
reference_id = payload [REFERENCE_ID_KEY ],
288
301
annotation_id = payload .get (ANNOTATION_ID_KEY , None ),
289
302
metadata = payload .get (METADATA_KEY , {}),
303
+ track_reference_id = payload .get (TRACK_REFERENCE_ID_KEY , None ),
290
304
)
291
305
292
306
def to_payload (self ) -> dict :
@@ -299,6 +313,7 @@ def to_payload(self) -> dict:
299
313
REFERENCE_ID_KEY : self .reference_id ,
300
314
ANNOTATION_ID_KEY : self .annotation_id ,
301
315
METADATA_KEY : self .metadata ,
316
+ TRACK_REFERENCE_ID_KEY : self .track_reference_id ,
302
317
}
303
318
return payload
304
319
@@ -318,6 +333,7 @@ class PolygonAnnotation(Annotation):
318
333
annotation_id="image_2_bus_polygon_1",
319
334
metadata={"vehicle_color": "yellow"},
320
335
embedding_vector=[0.1423, 1.432, ..., 3.829],
336
+ track_reference_id="school_bus",
321
337
)
322
338
323
339
Parameters:
@@ -336,6 +352,9 @@ class PolygonAnnotation(Annotation):
336
352
embedding_vector: Custom embedding vector for this object annotation.
337
353
If any custom object embeddings have been uploaded previously to this dataset,
338
354
this vector must match the dimensions of the previously ingested vectors.
355
+ track_reference_id: A unique string to identify the annotation as part of a group.
356
+ For instance, multiple "car" annotations across several dataset items may have
357
+ the same `track_reference_id` such as "red_car".
339
358
"""
340
359
341
360
label : str
@@ -344,6 +363,7 @@ class PolygonAnnotation(Annotation):
344
363
annotation_id : Optional [str ] = None
345
364
metadata : Optional [Dict ] = None
346
365
embedding_vector : Optional [list ] = None
366
+ track_reference_id : Optional [str ] = None
347
367
348
368
def __post_init__ (self ):
349
369
self .metadata = self .metadata if self .metadata else {}
@@ -373,6 +393,7 @@ def from_json(cls, payload: dict):
373
393
annotation_id = payload .get (ANNOTATION_ID_KEY , None ),
374
394
metadata = payload .get (METADATA_KEY , {}),
375
395
embedding_vector = payload .get (EMBEDDING_VECTOR_KEY , None ),
396
+ track_reference_id = payload .get (TRACK_REFERENCE_ID_KEY , None ),
376
397
)
377
398
378
399
def to_payload (self ) -> dict :
@@ -386,6 +407,7 @@ def to_payload(self) -> dict:
386
407
ANNOTATION_ID_KEY : self .annotation_id ,
387
408
METADATA_KEY : self .metadata ,
388
409
EMBEDDING_VECTOR_KEY : self .embedding_vector ,
410
+ TRACK_REFERENCE_ID_KEY : self .track_reference_id ,
389
411
}
390
412
return payload
391
413
@@ -450,6 +472,7 @@ class KeypointsAnnotation(Annotation):
450
472
reference_id="image_2",
451
473
annotation_id="image_2_face_keypoints_1",
452
474
metadata={"face_direction": "forward"},
475
+ track_reference_id="face_1",
453
476
)
454
477
455
478
Parameters:
@@ -468,6 +491,9 @@ class KeypointsAnnotation(Annotation):
468
491
attach to this annotation. Strings, floats and ints are supported best
469
492
by querying and insights features within Nucleus. For more details see
470
493
our `metadata guide <https://nucleus.scale.com/docs/upload-metadata>`_.
494
+ track_reference_id: A unique string to identify the annotation as part of a group.
495
+ For instance, multiple "car" annotations across several dataset items may have
496
+ the same `track_reference_id` such as "red_car".
471
497
"""
472
498
473
499
label : str
@@ -477,6 +503,7 @@ class KeypointsAnnotation(Annotation):
477
503
reference_id : str
478
504
annotation_id : Optional [str ] = None
479
505
metadata : Optional [Dict ] = None
506
+ track_reference_id : Optional [str ] = None
480
507
481
508
def __post_init__ (self ):
482
509
self .metadata = self .metadata or {}
@@ -518,6 +545,7 @@ def from_json(cls, payload: dict):
518
545
reference_id = payload [REFERENCE_ID_KEY ],
519
546
annotation_id = payload .get (ANNOTATION_ID_KEY , None ),
520
547
metadata = payload .get (METADATA_KEY , {}),
548
+ track_reference_id = payload .get (TRACK_REFERENCE_ID_KEY , None ),
521
549
)
522
550
523
551
def to_payload (self ) -> dict :
@@ -532,6 +560,7 @@ def to_payload(self) -> dict:
532
560
REFERENCE_ID_KEY : self .reference_id ,
533
561
ANNOTATION_ID_KEY : self .annotation_id ,
534
562
METADATA_KEY : self .metadata ,
563
+ TRACK_REFERENCE_ID_KEY : self .track_reference_id ,
535
564
}
536
565
return payload
537
566
@@ -573,7 +602,8 @@ class CuboidAnnotation(Annotation): # pylint: disable=R0902
573
602
yaw=0,
574
603
reference_id="pointcloud_1",
575
604
annotation_id="pointcloud_1_car_cuboid_1",
576
- metadata={"vehicle_color": "green"}
605
+ metadata={"vehicle_color": "green"},
606
+ track_reference_id="red_car",
577
607
)
578
608
579
609
Parameters:
@@ -590,6 +620,9 @@ class CuboidAnnotation(Annotation): # pylint: disable=R0902
590
620
annotation. Strings, floats and ints are supported best by querying
591
621
and insights features within Nucleus. For more details see our `metadata
592
622
guide <https://nucleus.scale.com/docs/upload-metadata>`_.
623
+ track_reference_id: A unique string to identify the annotation as part of a group.
624
+ For instance, multiple "car" annotations across several dataset items may have
625
+ the same `track_reference_id` such as "red_car".
593
626
"""
594
627
595
628
label : str
@@ -599,6 +632,7 @@ class CuboidAnnotation(Annotation): # pylint: disable=R0902
599
632
reference_id : str
600
633
annotation_id : Optional [str ] = None
601
634
metadata : Optional [Dict ] = None
635
+ track_reference_id : Optional [str ] = None
602
636
603
637
def __post_init__ (self ):
604
638
self .metadata = self .metadata if self .metadata else {}
@@ -614,6 +648,7 @@ def from_json(cls, payload: dict):
614
648
reference_id = payload [REFERENCE_ID_KEY ],
615
649
annotation_id = payload .get (ANNOTATION_ID_KEY , None ),
616
650
metadata = payload .get (METADATA_KEY , {}),
651
+ track_reference_id = payload .get (TRACK_REFERENCE_ID_KEY , None ),
617
652
)
618
653
619
654
def to_payload (self ) -> dict :
@@ -631,6 +666,8 @@ def to_payload(self) -> dict:
631
666
payload [ANNOTATION_ID_KEY ] = self .annotation_id
632
667
if self .metadata :
633
668
payload [METADATA_KEY ] = self .metadata
669
+ if self .track_reference_id :
670
+ payload [TRACK_REFERENCE_ID_KEY ] = self .track_reference_id
634
671
635
672
return payload
636
673
@@ -772,11 +809,10 @@ def to_payload(self) -> dict:
772
809
MASK_URL_KEY : self .mask_url ,
773
810
ANNOTATIONS_KEY : [ann .to_payload () for ann in self .annotations ],
774
811
ANNOTATION_ID_KEY : self .annotation_id ,
812
+ REFERENCE_ID_KEY : self .reference_id ,
775
813
# METADATA_KEY: self.metadata, # TODO(sc: 422637)
776
814
}
777
815
778
- payload [REFERENCE_ID_KEY ] = self .reference_id
779
-
780
816
return payload
781
817
782
818
def has_local_files_to_upload (self ) -> bool :
@@ -822,7 +858,8 @@ class CategoryAnnotation(Annotation):
822
858
label="dress",
823
859
reference_id="image_1",
824
860
taxonomy_name="clothing_type",
825
- metadata={"dress_color": "navy"}
861
+ metadata={"dress_color": "navy"},
862
+ track_reference_id="blue_and_black_dress",
826
863
)
827
864
828
865
Parameters:
@@ -834,12 +871,16 @@ class CategoryAnnotation(Annotation):
834
871
Strings, floats and ints are supported best by querying and insights
835
872
features within Nucleus. For more details see our `metadata guide
836
873
<https://nucleus.scale.com/docs/upload-metadata>`_.
874
+ track_reference_id: A unique string to identify the annotation as part of a group.
875
+ For instance, multiple "car" annotations across several dataset items may have
876
+ the same `track_reference_id` such as "red_car".
837
877
"""
838
878
839
879
label : str
840
880
reference_id : str
841
881
taxonomy_name : Optional [str ] = None
842
882
metadata : Optional [Dict ] = None
883
+ track_reference_id : Optional [str ] = None
843
884
844
885
def __post_init__ (self ):
845
886
self .metadata = self .metadata if self .metadata else {}
@@ -851,6 +892,7 @@ def from_json(cls, payload: dict):
851
892
reference_id = payload [REFERENCE_ID_KEY ],
852
893
taxonomy_name = payload .get (TAXONOMY_NAME_KEY , None ),
853
894
metadata = payload .get (METADATA_KEY , {}),
895
+ track_reference_id = payload .get (TRACK_REFERENCE_ID_KEY , None ),
854
896
)
855
897
856
898
def to_payload (self ) -> dict :
@@ -860,6 +902,7 @@ def to_payload(self) -> dict:
860
902
GEOMETRY_KEY : {},
861
903
REFERENCE_ID_KEY : self .reference_id ,
862
904
METADATA_KEY : self .metadata ,
905
+ TRACK_REFERENCE_ID_KEY : self .track_reference_id ,
863
906
}
864
907
if self .taxonomy_name is not None :
865
908
payload [TAXONOMY_NAME_KEY ] = self .taxonomy_name
@@ -874,6 +917,7 @@ class MultiCategoryAnnotation(Annotation):
874
917
reference_id : str
875
918
taxonomy_name : Optional [str ] = None
876
919
metadata : Optional [Dict ] = None
920
+ track_reference_id : Optional [str ] = None
877
921
878
922
def __post_init__ (self ):
879
923
self .metadata = self .metadata if self .metadata else {}
@@ -885,6 +929,7 @@ def from_json(cls, payload: dict):
885
929
reference_id = payload [REFERENCE_ID_KEY ],
886
930
taxonomy_name = payload .get (TAXONOMY_NAME_KEY , None ),
887
931
metadata = payload .get (METADATA_KEY , {}),
932
+ track_reference_id = payload .get (TRACK_REFERENCE_ID_KEY , None ),
888
933
)
889
934
890
935
def to_payload (self ) -> dict :
@@ -894,6 +939,7 @@ def to_payload(self) -> dict:
894
939
GEOMETRY_KEY : {},
895
940
REFERENCE_ID_KEY : self .reference_id ,
896
941
METADATA_KEY : self .metadata ,
942
+ TRACK_REFERENCE_ID_KEY : self .track_reference_id ,
897
943
}
898
944
if self .taxonomy_name is not None :
899
945
payload [TAXONOMY_NAME_KEY ] = self .taxonomy_name
0 commit comments