ziqi-jin / finetune-anything

Fine-tune SAM (Segment Anything Model) for computer vision tasks such as semantic segmentation, matting, detection ... in specific scenarios
MIT License
766 stars 55 forks source link

what's class_names? #14

Closed davvvy closed 1 year ago

davvvy commented 1 year ago

Thanks for sharing this material first.

According to this line(https://github.com/ziqi-jin/finetune-anything/blob/main/extend_sam/runner.py#L97), class_names = self.val_loader.dataset.class_names. But I can't find class_names in config file.

Is it a list consisting of 19 semantic labels? Which labels does it have? Could you please give an example of class_names?

ziqi-jin commented 1 year ago

Now the BaseSemanticDataset and TorchVOCSegmentation is available, if you want to use BaseSemanticDataset, you should add the 'class_names' into 'metainfo' as below, and if your img and annotation folders' names are not 'img' and 'ann', you also shoult modify the 'prefix' as below

    metainfo = {'class_names': ['bicycle', 'bird', 'boat', 'bottle',
                            'bus', 'car', 'cat', 'chair', 'cow',
                            'diningtable', 'dog', 'horse', 'motorbike', 'person',
                            'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor']}
    prefix = {'img_path':'your_img_folder', 'ann_path':"your_ann_folder"}
    dataset = BaseSemanticDataset(metainfo=metainfo,dataset_dir='/data/jinziqi/DATASETS/VOCdevkit/VOC2012/',
                                  img_suffix='.png', ann_suffix='.jpg', data_prefix=prefix, transform=transform, target_transform=transform)

this example shows the VOC dataset classes, if you have DIY dataset, just add your own class names into metainfo. I will introduce the usage of these dataset later in the How_to_use_finetune_anything.md .

ziqi-jin commented 1 year ago

I close this issue, if you have other questions, open this issue.