@@ -60,6 +60,22 @@ def serialize_model(self, handler):
60
60
return res
61
61
62
62
63
+ class FrameLocation (BaseModel ):
64
+ end : int
65
+ start : int
66
+
67
+
68
+ class VideoSupported (BaseModel ):
69
+ # Note that frames are only allowed as top level inferences for video
70
+ frames : Optional [List [FrameLocation ]] = None
71
+
72
+ @model_serializer (mode = "wrap" )
73
+ def serialize_model (self , handler ):
74
+ res = handler (self )
75
+ # This means these are no video frames ..
76
+ if self .frames is None :
77
+ res .pop ("frames" )
78
+ return res
63
79
64
80
65
81
class NDTextSubclass (NDAnswer ):
@@ -226,14 +242,13 @@ def from_common(
226
242
name = name ,
227
243
schema_id = feature_schema_id ,
228
244
uuid = uuid ,
229
- frames = extra .get ("frames" ),
230
245
message_id = message_id ,
231
246
confidence = text .confidence ,
232
247
custom_metrics = text .custom_metrics ,
233
248
)
234
249
235
250
236
- class NDChecklist (NDAnnotation , NDChecklistSubclass ):
251
+ class NDChecklist (NDAnnotation , NDChecklistSubclass , VideoSupported ):
237
252
@model_serializer (mode = "wrap" )
238
253
def serialize_model (self , handler ):
239
254
res = handler (self )
@@ -280,7 +295,7 @@ def from_common(
280
295
)
281
296
282
297
283
- class NDRadio (NDAnnotation , NDRadioSubclass ):
298
+ class NDRadio (NDAnnotation , NDRadioSubclass , VideoSupported ):
284
299
@classmethod
285
300
def from_common (
286
301
cls ,
@@ -410,8 +425,7 @@ def to_common(
410
425
def from_common (
411
426
cls ,
412
427
annotation : Union [
413
- ClassificationAnnotation ,
414
- VideoClassificationAnnotation ,
428
+ ClassificationAnnotation , VideoClassificationAnnotation
415
429
],
416
430
data : GenericDataRowData ,
417
431
) -> Union [NDTextSubclass , NDChecklistSubclass , NDRadioSubclass ]:
@@ -434,8 +448,7 @@ def from_common(
434
448
@staticmethod
435
449
def lookup_classification (
436
450
annotation : Union [
437
- ClassificationAnnotation ,
438
- VideoClassificationAnnotation ,
451
+ ClassificationAnnotation , VideoClassificationAnnotation
439
452
],
440
453
) -> Union [NDText , NDChecklist , NDRadio ]:
441
454
return {Text : NDText , Checklist : NDChecklist , Radio : NDRadio }.get (
0 commit comments