- The coco format can be found in Link. Specifically, the coco annotation file (
.json
) includes three necessary feilds, i.e., image, annotation, categories. A toy sample (namedtoy_sample.json
) is provided below:
{
"categories":
[{
"supercategory": "person",
"id": 1,
"name": "person"
}],
"images":
[{
"license": 1,
"file_name": "000000425226.jpg",
"coco_url": "http://images.cocodataset.org/val2017/000000425226.jpg",
"height": 640,
"width": 480,
"date_captured":
"2013-11-14 21:48:51",
"flickr_url":
"http://farm5.staticflickr.com/4055/4546463824_bc40e0752b_z.jpg",
"id": 1
}],
"annotations":
[{
"image_id": 1,
"category_id": 1,
"segmentation": [],
"area": 47803.279549999985,
"iscrowd": 0,
"bbox": [73.35, 206.02, 300.58, 372.5],
"id": 1
}]
}
- Then we can organize the custom dataset (including images and annotations) as follows:
├── Custom_coco
│ ├── annotations
│ │ └── toy_sample.json
│ ├── images
│ │ └── 000000425226.jpg
- Link your dataset into
datasets
.
ln -s path/to/Custom_coco datasets/toy_sample
- Add the custom dataset into
damo/config/paths_catalog.py
. Note, the added dataset should contain coco in their names to declare the dataset format, e.g., here we usesample_train_coco
andsample_test_coco
.
'sample_train_coco': {
'img_dir': 'toy_sample/images',
'ann_file': 'toy_sample/annotations/toy_sample.json'
},
'sample_test_coco': {
'img_dir': 'toy_sample/images',
'ann_file': 'toy_sample/annotations/toy_sample.json'
},
In this tutorial, we finetune on DAMO-YOLO-Tiny as example.
- Download the DAMO-YOLO-Tiny torch model from Model Zoo
- Add the following pretrained model path into
damoyolo_tinynasL20_T.py
.
self.train.finetune_path='path/to/damoyolo_tinynasL20_T.pth'
-
Modify the custom dataset in config file. Change
coco_2017_train
andcoco_2017_test
indamoyolo_tinynasL20_T.py
tosample_train_coco
andsample_test_coco
respectively.DAMO-YOLO/configs/damoyolo_tinynasL20_T.py
Lines 33 to 34 in cae1f6c
-
Modify the category number in config file. Change
'num_classes': 80
indamoyolo_tinynasL20_T.py
to'num_classes': 1
. Because in our toy sample, there is only one category, so we setnum_classes
to 1.DAMO-YOLO/configs/damoyolo_tinynasL20_T.py
Lines 64 to 66 in cae1f6c
-
Modify the list of class names.
You can run the finetuning with the following code:
python -m torch.distributed.launch --nproc_per_node=8 tools/train.py -f configs/damoyolo_tinynasL20_T.py