@@ -263,6 +263,10 @@ def makeAnnotationAndMedia(dsFolder: types.GirderModel):
263
263
264
264
def stream ():
265
265
z = ziputil .ZipGenerator ()
266
+ nestedExcludeBelowThreshold = excludeBelowThreshold
267
+ nestedTypeFilter = typeFilter
268
+ if nestedTypeFilter is None :
269
+ nestedTypeFilter = set ()
266
270
for dsFolder in dsFolders :
267
271
zip_path = f"./{ dsFolder ['name' ]} /"
268
272
try :
@@ -291,25 +295,23 @@ def makeDiveJson():
291
295
annotations = crud_annotation .get_annotations (dsFolder )
292
296
tracks = annotations ['tracks' ]
293
297
294
- if excludeBelowThreshold :
298
+ if nestedExcludeBelowThreshold :
295
299
thresholds = fromMeta (dsFolder , "confidenceFilters" , {})
296
- if thresholds is None :
297
- thresholds = {}
300
+ if thresholds is None :
301
+ thresholds = {}
298
302
299
- updated_tracks = []
300
- if typeFilter is None :
301
- typeFilter = set ()
303
+ updated_tracks = {}
302
304
for t in tracks :
303
- track = models .Track (** t )
304
- if (not excludeBelowThreshold ) or track .exceeds_thresholds (thresholds ):
305
+ track = models .Track (** tracks [ t ] )
306
+ if (not nestedExcludeBelowThreshold ) or track .exceeds_thresholds (thresholds ):
305
307
# filter by types if applicable
306
- if typeFilter :
307
- confidence_pairs = [item for item in track .confidencePairs if item [0 ] in typeFilter ]
308
+ if nestedTypeFilter :
309
+ confidence_pairs = [item for item in track .confidencePairs if item [0 ] in nestedTypeFilter ]
308
310
# skip line if no confidence pairs
309
311
if not confidence_pairs :
310
312
continue
311
- updated_tracks . append [ track ]
312
- annotations ['tracks' ] = updated_tracks
313
+ updated_tracks [ t ] = tracks [ t ]
314
+ annotations ['tracks' ] = updated_tracks
313
315
yield json .dumps (annotations )
314
316
315
317
for data in z .addFile (makeMetajson , Path (f'{ zip_path } meta.json' )):
0 commit comments