Maintaining directory structure after uploading

I am trying to upload face images of different people and then for every different person, make bounding boxes for the foreheads. I firstly want to train an object detection model for detecting the forehead using bounding boxes.

I already have the annotations in the following directory structure:

data/
1/
  1.jpg
  1.txt
  2.jpg
  2.txt
  ..
  classes.txt
2/
  1.jpg
  1.txt
  2.jpg
  2.txt
  ..
  classes.txt
.
.
542/
  ..

And as I am detecting only one object, classes.txt has one object detection label - forehead.
When I upload a part of this dataset to Roboflow for detection, It correctly identifies the bounding boxes and the class forehead. There are some poor annotations which I want to correct and re-download the dataset in the same directory structure as those extractions will be used for further classification. But Roboflow doesn’t maintain this structure anymore and the there are multiple images with the same name like 1.jpg, so downloading won’t give me back the original person classes.

Is there a way in which roboflow can keep the directory structure intact or should I relabel my image and annotation files to something more meaningful like 127_1.jpg and 127_1.txt?

Roboflow doesn’t support this kind of folder structure. Renaming your images might be your best bet. You can probably do this with a script similar to this: command line - Rename a file to parent directory's name in terminal - Ask Ubuntu

Yes I will just rename, upload, annotate, re-download and rename. It would be good if this feature of directory structure is made in Roboflow as the current model just assumes that classification and detection will be done with the same existing classes. For research purposes, one might want to consider detection as the first step and use some other classification model.

Hi @cs-mshah, for the 2-stage detection, would it suffice to use our Isolate Objects feature to convert the area within the bounding boxes to images for the classification model?

^ if you use this process, you can generate versions with Isolate Objects to export in a classification-compatible format, and leave Isolate Objects off for dataset versions you generate for object detection.

Additionally, we do have options for upload in classification projects that labels the images in uploaded folder with the name of the folder:

I tried to see the Isolate objects feature and download the dataset in the clip format. But what it does is that as there is only a single class in detection - forehead, it makes this as one class while downloading.

Although this is correct from an object detection point of view that there is a single class, it is not what I want as this forehead is coming from different people.

Its like I want to first train a model for detection, then classification but with different classes - the different people.

So Roboflow should help in keeping the directory structure intact so that I don’t have to do a lot of renaming

It sounds like what you want to do is upload with the class name being the person (instead of “forehead”). Then if you want to export generically for object detection, map all classes back to forehead with the remap classes option, and do not remap when exporting for classification.

You could also try just training an object detection model; it might surprise you and be simpler than a two-stage process plus perform just as well while being faster. Hard to know without trying.

Sounds cool. Thanks for suggesting