zhang-tao-whu / DVIS_Plus

89 stars 6 forks source link

Custom dataset #9

Closed triscl closed 5 months ago

triscl commented 6 months ago

Dear Mr. Zhang,

Could you please give me some advice on introducing custom datasets for training?

I want to segment a video with 2 fish swimming next to each other. I tried inferring instances using Ovis pretrained vitl model and it worked well. I want to further improve segmentation by training DVIS_Plus on a combination of OVIS and my custom dataset. In particular, I have labeled "fish" instances in some frames of my video (totally ~800 frames with 2 instances each) and saved annotation file in coco.json format.

But I am confused how I should register the dataset. I tried adding function to register custom dataset in builtin.py:

def register_all_coco_custom(root):
    for key, (image_root, json_file) in _PREDEFINED_SPLITS_COCO_CUSTOM.items():
        # Assume pre-defined datasets live in `./datasets`
        register_coco_instances(
            key,
            {},
            os.path.join(root, json_file) if "://" not in json_file else json_file,
            os.path.join(root, image_root),
        )

This worked well, when I just trying Detectron2 model separately before. But now I get following error : AttributeError: Attribute 'thing_dataset_id_to_contiguous_id' does not exist in the metadata of dataset 'custom_train'. Available keys are dict_keys(['name', 'json_file', 'image_root', 'evaluator_type']).

What additional information should I provide? How can I run training on both custom and ovis dataset? Also, does custom data set have to consist of consistent frames, or random frames should be also okay? Thank you very much in advance!