Open manrj007 opened 3 years ago
Torchvision's CocoDetection
dataset expects just a single root
and annFile
, as can be seen here. In other words, even if you have multiple classes, you'll need to create the following directory structure:
path/to/coco/
├ train
│ ├ annotations
│ │ └instance_default.json
│ ├ images
│ │ └img-001.jpg
│ │ └img-002.jpg
│ │ └...
├ test
├ valid
This is the COCO format. So I'd advise you to just create a single JSON file which contains the annotations for all images, and rename the file names of the images such that they are all unique. You can for example name them class1-img-001.png
, etc. Make sure to use the right IDs in the annotation JSON file. This blog post for example is very helpful.
I'm creating a custom dataloader for DETR which use the below file directory for training.
for this I was able to create one using
huggingface
DetrFeatureExtractor using below codeMy Question Say if my image directory is like this
I tried using Glob and Path to create the dataset but it only had the final class after execution . Below is the code I'm using for it.
any help would on this would be great