@@ -68,106 +68,6 @@ def get_annotation_comparison_dicts_from_labels(labels):
6868 return labels_ndjson
6969
7070
71- def get_annotation_comparison_dicts_from_export (export_result , data_row_id ,
72- project_id ):
73- exported_data_row = [
74- dr for dr in export_result if dr ['data_row' ]['id' ] == data_row_id
75- ][0 ]
76- exported_label = exported_data_row ['projects' ][project_id ]['labels' ][0 ]
77- exported_annotations = exported_label ['annotations' ]
78- converted_annotations = []
79- if exported_label ['label_kind' ] == 'Video' :
80- frames = []
81- instances = []
82- for frame_id , frame in exported_annotations ['frames' ].items ():
83- frames .append ({'index' : int (frame_id )})
84- for object in frame ['objects' ].values ():
85- instances .append ({'name' : object ['name' ]})
86- converted_annotations .append (
87- {'masks' : {
88- 'frames' : frames ,
89- 'instances' : instances ,
90- }})
91- else :
92- exported_annotations = list (
93- itertools .chain (* exported_annotations .values ()))
94- for annotation in exported_annotations :
95- if annotation ['name' ] == 'radio' :
96- converted_annotations .append ({
97- 'name' : annotation ['name' ],
98- 'answer' : {
99- 'name' : annotation ['radio_answer' ]['name' ]
100- }
101- })
102- elif annotation ['name' ] == 'checklist' :
103- converted_annotations .append ({
104- 'name' :
105- annotation ['name' ],
106- 'answer' : [{
107- 'name' : answer ['name' ]
108- } for answer in annotation ['checklist_answers' ]]
109- })
110- elif annotation ['name' ] == 'text' :
111- converted_annotations .append ({
112- 'name' : annotation ['name' ],
113- 'answer' : annotation ['text_answer' ]['content' ]
114- })
115- return converted_annotations
116-
117- radio_annotation = lb_types .ClassificationAnnotation (
118- name = "radio" ,
119- value = lb_types .Radio (answer = lb_types .ClassificationAnswer (
120- name = "second_radio_answer" )))
121- checklist_annotation = lb_types .ClassificationAnnotation (
122- name = "checklist" ,
123- value = lb_types .Checklist (answer = [
124- lb_types .ClassificationAnswer (name = "option1" ),
125- lb_types .ClassificationAnswer (name = "option2" )
126- ]))
127- text_annotation = lb_types .ClassificationAnnotation (
128- name = "text" , value = lb_types .Text (answer = "sample text" ))
129-
130- video_mask_annotation = lb_types .VideoMaskAnnotation (frames = [
131- lb_types .MaskFrame (
132- index = 10 ,
133- instance_uri =
134- "https://storage.googleapis.com/labelbox-datasets/video-sample-data/mask_example.png"
135- )
136- ],
137- instances = [
138- lb_types .MaskInstance (
139- color_rgb = (255 ,
140- 255 ,
141- 255 ),
142- name =
143- "segmentation_mask"
144- )
145- ])
146-
147- test_params = [[
148- 'html' , lb_types .HTMLData ,
149- [radio_annotation , checklist_annotation , text_annotation ]
150- ],
151- [
152- 'audio' , lb_types .AudioData ,
153- [radio_annotation , checklist_annotation , text_annotation ]
154- ], ['video' , lb_types .VideoData , [video_mask_annotation ]]]
155-
156-
157- def get_annotation_comparison_dicts_from_labels (labels ):
158- labels_ndjson = list (NDJsonConverter .serialize (labels ))
159- for annotation in labels_ndjson :
160- annotation .pop ('uuid' )
161- annotation .pop ('dataRow' )
162-
163- if 'masks' in annotation :
164- for frame in annotation ['masks' ]['frames' ]:
165- frame .pop ('instanceURI' )
166- for instance in annotation ['masks' ]['instances' ]:
167- instance .pop ('colorRGB' )
168- return labels_ndjson
169-
170-
17171def get_annotation_comparison_dicts_from_export (export_result , data_row_id ,
17272 project_id ):
17373 exported_data_row = [
0 commit comments