File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -369,7 +369,19 @@ def _save_annotation(image_id, imagedesc):
369
369
370
370
if isinstance (labelmap , str ):
371
371
labelmap = load_labelmap (labelmap )
372
- else :
372
+ elif project .type == "classification" :
373
+ # Infer class name from parent folder for classification projects
374
+ # imagedesc['dirname'] is like '/dogs' or 'subfolder/dogs' relative to dataset root.
375
+ # We want the immediate parent folder name.
376
+ potential_class_name = os .path .basename (imagedesc ["dirname" ].strip ("/" ))
377
+ if potential_class_name and potential_class_name != "." : # Ensure it's a valid dir name
378
+ annotation_path = potential_class_name
379
+ # If potential_class_name is empty or '.', annotation_path remains None,
380
+ # meaning this image (e.g. in dataset root for classification) won't get a class label.
381
+
382
+ # If annotation_path is still None at this point (e.g., not classification and no annofile,
383
+ # or classification image in root, or other unhandled cases), then no annotation will be saved.
384
+ if annotation_path is None :
373
385
return None , None
374
386
375
387
annotation , upload_time , _retry_attempts = project .save_annotation (
You can’t perform that action at this time.
0 commit comments