[Feature] Add MultiTaskDataset
to support multi-task training.
#808
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
To support using a single backbone to perform multiple classification tasks.
Modification
This PR is one part of the multi-task support plan, and it depends on #675 to build a network.
BC-breaking (Optional)
No
Use cases
Here is a detailed multi-task support design. First, the multi-task means using one backbone and multiple heads to do classification on an image with multiple kinds of labels.
Dataset
The current multi-task requires full labels on every image, which means you cannot use partial-labeled samples to train the multi-task model.
To create a multi-task dataset, you can use the
MultiTaskDataset
class and prepare an annotation file. Here is a brief example:The annotation json file example
The detailed usage and example of the
MultiTaskDataset
can be found hereAnd here is a script to use the CIFAR10 dataset to generate an example multi-task dataset, just run it in the
data
folder. And here is the file structure.And here is an example config to train on the multi-task dataset.
Then, we can train the dataset by
python tools/train.py configs/resnet/multi-task-demo.py
Checklist
Before PR:
After PR: