Skip to content

Commit 7d24edb

Browse files
committed
upload folders struct
1 parent a3744d1 commit 7d24edb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

roboflow/core/workspace.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,19 @@ def _save_annotation(image_id, imagedesc):
369369

370370
if isinstance(labelmap, str):
371371
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:
373385
return None, None
374386

375387
annotation, upload_time, _retry_attempts = project.save_annotation(

0 commit comments

Comments
 (0)