Giter Club home page Giter Club logo

Comments (4)

hellock avatar hellock commented on May 17, 2024

Currently it is not possible to train on multiple datasets by only modifying the config file, and I think your solution is simple and feasible.
If you find it working, welcome to submit a PR. Thanks!

from mmdetection.

wangg12 avatar wangg12 commented on May 17, 2024

I am using torch.utils.data.dataset.ConcatDataset to concat a dataset with multiple ann_files.

def get_train_dataset(cfg):
    if isinstance(cfg.data.train['ann_file'], list) or isinstance(cfg.data.train['ann_file'], tuple):
        ann_files = cfg.data.train['ann_file']
        train_datasets = []
        for ann_file in ann_files:
            data_info = copy.deepcopy(cfg.data.train)
            data_info['ann_file'] = ann_file
            train_dset = obj_from_dict(data_info, datasets)
            train_datasets.append(train_dset)
        if len(train_datasets) > 1:
            train_dataset = ConcatDataset(train_datasets)
        else:
            train_dataset = train_datasets[0]
    else:
        train_dataset = obj_from_dict(cfg.data.train, datasets)
    return train_dataset

I got this error when I run the training script:

Traceback (most recent call last):
  File "tools/train.py", line 104, in <module>
    main()
  File "tools/train.py", line 100, in main
    logger=logger)
  File "/data/wanggu/mmdetection/mmdet/apis/train.py", line 59, in train_detector
    _non_dist_train(model, dataset, cfg, validate=validate)
  File "/data/wanggu/mmdetection/mmdet/apis/train.py", line 103, in _non_dist_train
    dist=False)
  File "/data/wanggu/mmdetection/mmdet/datasets/loader/build_loader.py", line 31, in build_dataloader
    sampler = GroupSampler(dataset, imgs_per_gpu)
  File "/data/wanggu/mmdetection/mmdet/datasets/loader/sampler.py", line 14, in __init__
    assert hasattr(dataset, 'flag')
AssertionError

@hellock Do you have any idea about this?

from mmdetection.

hellock avatar hellock commented on May 17, 2024

We use a field flag to identify different groups for the GroupSampler, but the ConcatDataset only implements __len__ and __getitem__. You may need to inherit the official ConcatDataset and add the flag filed, which simply concatenates flags of all datasets.

from mmdetection.

wangg12 avatar wangg12 commented on May 17, 2024

@hellock Yeah. I've noticed that. Now it works.

from mmdetection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.