@@ -132,16 +132,16 @@ def _build_image_and_annotation_maps(annotationFiles):
132132 )
133133 if parsedType == "coco" :
134134 for imageRef in parsed ["images" ]:
135- imgRefMap [f" { filename } / { imageRef ['file_name' ]} " ] = imageRef
135+ imgRefMap [os . path . join ( filename , imageRef ['file_name' ]) ] = imageRef
136136 for annotation in parsed ["annotations" ]:
137- annotationMap [f" { dirname } / { annotation ['image_id' ]} " ].append (annotation )
137+ annotationMap [os . path . join ( dirname , annotation ['image_id' ]) ].append (annotation )
138138 return imgRefMap , annotationMap
139139
140140
141141def _filterIndividualAnnotations (image , annotation , format , imgRefMap , annotationMap ):
142142 parsed = annotation ["parsed" ]
143143 if format == "coco" :
144- imgReference = imgRefMap .get (f" { annotation ['file' ]} / { image ['name' ]} " )
144+ imgReference = imgRefMap .get (os . path . join ( annotation ['file' ], image ['name' ]) )
145145 if imgReference :
146146 # workaround to make Annotations.js correctly identify this as coco in the backend
147147 fake_annotation = {
@@ -153,7 +153,9 @@ def _filterIndividualAnnotations(image, annotation, format, imgRefMap, annotatio
153153 "iscrowd" : 0 ,
154154 }
155155 _annotation = {"name" : "annotation.coco.json" }
156- annotations_for_image = annotationMap .get (f"{ image ['dirname' ]} /{ imgReference ['id' ]} " , [])
156+ annotations_for_image = annotationMap .get (
157+ os .path .join (image ['dirname' ], imgReference ['id' ]), []
158+ )
157159 _annotation ["rawText" ] = json .dumps (
158160 {
159161 "info" : parsed ["info" ],
@@ -255,7 +257,7 @@ def _map_labelmaps_to_annotations(annotations, labelmaps):
255257 if not labelmaps :
256258 return
257259 labelmapmap = {lm ["dirname" ]: lm for lm in labelmaps }
258- rootLabelmap = labelmapmap .get ("/" )
260+ rootLabelmap = labelmapmap .get (os . sep )
259261 if len (labelmapmap ) < len (labelmaps ):
260262 print ("warning: unexpectedly found multiple labelmaps per directory" )
261263 print ([lm ["file" ] for lm in labelmaps ])
0 commit comments