Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support Multi-task. #1229

Merged
merged 183 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
1c2974f
unit test for multi_task_head
piercus Jan 26, 2022
7c20f41
[Feature] MultiTaskHead (#628, #481)
piercus Jan 26, 2022
ad20f36
[Fix] lint for multi_task_head
piercus Jan 27, 2022
21b0a38
[Feature] Add `MultiTaskDataset` to support multi-task training.
mzr1996 Apr 24, 2022
787fc94
Merge remote-tracking branch 'origin/dev' into multi_task_head
mzr1996 Apr 29, 2022
2098c7e
Update MultiTaskClsHead
mzr1996 Apr 29, 2022
df68f03
Update docs
mzr1996 Apr 29, 2022
812f3d4
[CI] Add test mim CI. (#879)
mzr1996 Jun 22, 2022
11df205
[Fix] Remove duplicated wide-resnet metafile.
mzr1996 Jul 5, 2022
c03efee
[Feature] Support MPS device. (#894)
mzr1996 Jul 28, 2022
00f0e0d
[Fix] Fix Albu crash bug. (#918)
PeterH0323 Jul 28, 2022
9300cc4
Bump version to 0.23.2. (#937)
mzr1996 Jul 28, 2022
71ef7ba
Merge remote-tracking branch 'origin/dev'
mzr1996 Jul 28, 2022
90254a8
[Improve] Use `forward_dummy` to calculate FLOPS. (#953)
twmht Aug 8, 2022
982cab4
Update README
mzr1996 Sep 7, 2022
8d1bc55
[Docs] Fix typo for wrong reference. (#1036)
Crescent-Saturn Sep 16, 2022
a1b644b
[Doc] Fix typo in tutorial 2 (#1043)
Crescent-Saturn Sep 19, 2022
75ae845
[Docs] Fix a typo in ImageClassifier (#1050)
wangruohui Sep 22, 2022
6dce428
Merge branch 'mzr1996-multi-task' into multi-task
piercus Sep 22, 2022
49b91a7
Merge branch 'master' into multi-task
piercus Sep 23, 2022
4dc273a
Merge branch 'multi_task_head' into multi-task
piercus Sep 23, 2022
83df1e5
add mask to loss
marouaneamz Oct 7, 2022
2bbe5e2
add another pipeline
marouaneamz Oct 10, 2022
5ee0534
adpat the pipeline if there is no mask
marouaneamz Oct 12, 2022
b2c42fa
switch mask and task
marouaneamz Oct 17, 2022
8784684
Merge pull request #1 from marouaneamz/add_mask_loss
piercus Oct 18, 2022
7e24822
first version of multi data smaple
marouaneamz Oct 31, 2022
6c70927
fix problem with attribut by getattr
marouaneamz Oct 31, 2022
e362f22
rm img_label suffix, fix 'LabelData' object has no attribute 'gt_label'
piercus Nov 1, 2022
d274960
training without evaluation
marouaneamz Nov 2, 2022
67ff94a
first version work
marouaneamz Nov 3, 2022
b7063b2
add others metrics
marouaneamz Nov 4, 2022
b290d92
delete evaluation from dataset
marouaneamz Nov 4, 2022
cdf331d
fix linter
marouaneamz Nov 4, 2022
1cfbdf4
fix linter
marouaneamz Nov 4, 2022
b8b520f
multi metrics
marouaneamz Nov 7, 2022
4c6147c
first version of test
marouaneamz Nov 7, 2022
e46d482
change evaluate metric
marouaneamz Nov 7, 2022
9ad1b09
Merge branch 'my_multi_task_1_x' into issue2
marouaneamz Nov 7, 2022
9e8e683
Update tests/test_models/test_heads.py
marouaneamz Nov 8, 2022
ded2196
Update tests/test_models/test_heads.py
marouaneamz Nov 8, 2022
72c24e5
add tests
marouaneamz Nov 8, 2022
abeeb81
add test for multidatasample
marouaneamz Nov 8, 2022
d2d072f
create a generic test
marouaneamz Nov 8, 2022
518b6a4
create a generic test
marouaneamz Nov 8, 2022
a449690
create a generic test
marouaneamz Nov 8, 2022
2078392
change multi data sample
marouaneamz Nov 9, 2022
6264f1a
correct test
marouaneamz Nov 9, 2022
08aafd5
test
marouaneamz Nov 9, 2022
9f1396a
add new test
marouaneamz Nov 9, 2022
639d360
add test for dataset
marouaneamz Nov 9, 2022
aacd1bc
correct test
marouaneamz Nov 10, 2022
23433a4
correct test
marouaneamz Nov 10, 2022
2d13b23
correct test
marouaneamz Nov 10, 2022
b259dc3
correct test
marouaneamz Nov 10, 2022
d36ce6f
fix : #5
marouaneamz Nov 10, 2022
34df146
run yapf
marouaneamz Nov 10, 2022
1e9b836
fix linter
marouaneamz Nov 10, 2022
cb7921b
fix linter
marouaneamz Nov 10, 2022
2484669
fix linter
marouaneamz Nov 10, 2022
ad10eaf
fix isort
marouaneamz Nov 10, 2022
30b6bda
fix isort
marouaneamz Nov 10, 2022
502d9c5
fix docformmater
marouaneamz Nov 10, 2022
31e05a9
fix docformmater
marouaneamz Nov 10, 2022
9763a37
fix linter
marouaneamz Nov 10, 2022
982420a
fix linter
marouaneamz Nov 14, 2022
52901bb
fix data sample
marouaneamz Nov 14, 2022
aff44ff
Update mmcls/structures/multi_task_data_sample.py
marouaneamz Nov 14, 2022
93c9f6c
Update mmcls/structures/multi_task_data_sample.py
marouaneamz Nov 14, 2022
67aa7da
Update mmcls/structures/multi_task_data_sample.py
marouaneamz Nov 14, 2022
aacaf42
Update mmcls/structures/multi_task_data_sample.py
marouaneamz Nov 14, 2022
45f9258
Update mmcls/structures/multi_task_data_sample.py
marouaneamz Nov 14, 2022
4f07cf1
Update mmcls/structures/multi_task_data_sample.py
marouaneamz Nov 14, 2022
0b98eee
Update tests/test_structures/test_datasample.py
marouaneamz Nov 14, 2022
30683f6
Update mmcls/structures/multi_task_data_sample.py
marouaneamz Nov 14, 2022
b14f2ed
Update tests/test_structures/test_datasample.py
marouaneamz Nov 14, 2022
34f2fc6
Update tests/test_structures/test_datasample.py
marouaneamz Nov 14, 2022
1666db5
update data sample
marouaneamz Nov 14, 2022
0a9da7c
update head
marouaneamz Nov 14, 2022
8f4d930
update head
marouaneamz Nov 14, 2022
6024be6
update multi data sample
marouaneamz Nov 14, 2022
10d7841
fix linter
marouaneamz Nov 14, 2022
2c391fe
fix linter
marouaneamz Nov 14, 2022
49d399b
fix linter
marouaneamz Nov 14, 2022
d95a484
merge with my_multi
marouaneamz Nov 14, 2022
c184998
fix linter
marouaneamz Nov 14, 2022
8abe181
fix linter
marouaneamz Nov 14, 2022
f2bb527
fix linter
marouaneamz Nov 14, 2022
9956301
Merge branch 'my_multi_task_1_x' into issue5
marouaneamz Nov 14, 2022
e9dc751
Merge pull request #6 from marouaneamz/issue5
marouaneamz Nov 14, 2022
00a1f1e
merge with my_multi_task
marouaneamz Nov 14, 2022
2bdfafe
update head
marouaneamz Nov 14, 2022
e920ee2
fix problem we don't set pred or gt
marouaneamz Nov 14, 2022
cc839d3
fix problem we don't set pred or gt
marouaneamz Nov 14, 2022
583318a
fix problem we don't set pred or gt
marouaneamz Nov 14, 2022
61410b1
fix linter
marouaneamz Nov 14, 2022
8d02ac0
Merge pull request #9 from marouaneamz/setpredgt
marouaneamz Nov 14, 2022
80c23af
Merge branch 'my_multi_task_1_x' into issue2
marouaneamz Nov 14, 2022
de0428b
fix : #2
marouaneamz Nov 14, 2022
71ccf4b
fix : linter
marouaneamz Nov 14, 2022
fa275be
update multi head
marouaneamz Nov 16, 2022
1b48410
fix linter
marouaneamz Nov 16, 2022
b54199a
fix linter
marouaneamz Nov 16, 2022
5ece04f
update data sample
marouaneamz Nov 17, 2022
6b5034b
update data sample
marouaneamz Nov 17, 2022
6691901
fix ; linter
marouaneamz Nov 17, 2022
5e50e6a
Merge pull request #3 from marouaneamz/issue2
marouaneamz Nov 17, 2022
7215730
Merge branch 'my_multi_task_1_x' into issue7
marouaneamz Nov 17, 2022
8c0bbbf
update test
marouaneamz Nov 17, 2022
876fec8
test pipeline
marouaneamz Nov 17, 2022
01b480c
update pipeline
marouaneamz Nov 17, 2022
b656477
update test
marouaneamz Nov 17, 2022
0251f66
update dataset
marouaneamz Nov 18, 2022
deff8b8
update dataset
marouaneamz Nov 18, 2022
0689286
fix linter
marouaneamz Nov 18, 2022
f9d41f6
fix linter
marouaneamz Nov 18, 2022
3f13cca
Merge pull request #8 from marouaneamz/issue7
marouaneamz Nov 18, 2022
0577dd8
Merge branch 'my_multi_task_1_x' into pipeline
marouaneamz Nov 18, 2022
7cdc6a4
update formatting
marouaneamz Nov 18, 2022
1523355
add test for multi-task-eval
marouaneamz Nov 18, 2022
7eb6fe4
update formatting
marouaneamz Nov 18, 2022
9407214
fix linter
marouaneamz Nov 18, 2022
3a03842
update test
marouaneamz Nov 18, 2022
1148709
update
marouaneamz Nov 21, 2022
13a3d9c
Merge pull request #10 from marouaneamz/pipeline
marouaneamz Nov 21, 2022
2a45cad
Merge branch 'my_multi_task_1_x' into metrics
marouaneamz Nov 22, 2022
936f6d7
add test
marouaneamz Nov 23, 2022
5854322
update metrics
marouaneamz Nov 23, 2022
ce11749
update metrics
marouaneamz Nov 23, 2022
9aa6785
add doc for functions
marouaneamz Nov 23, 2022
6ad02d9
fix linter
marouaneamz Nov 23, 2022
7ee882f
training for multitask 1.x
marouaneamz Nov 23, 2022
7ea5765
fix linter
marouaneamz Nov 23, 2022
04bc7a9
run flake8
marouaneamz Nov 24, 2022
581bd82
run linter
marouaneamz Nov 24, 2022
522135d
update test
marouaneamz Nov 24, 2022
5d26026
add mask in evaluation
marouaneamz Nov 24, 2022
77e180e
update metric doc
marouaneamz Nov 24, 2022
d3d9c2f
update metric doc
marouaneamz Nov 25, 2022
b15105b
Update mmcls/evaluation/metrics/multi_task.py
marouaneamz Nov 25, 2022
59aed15
Update mmcls/evaluation/metrics/multi_task.py
marouaneamz Nov 25, 2022
3ee49df
Update mmcls/evaluation/metrics/multi_task.py
marouaneamz Nov 25, 2022
d071eab
Update mmcls/evaluation/metrics/multi_task.py
marouaneamz Nov 25, 2022
6f735e7
Update mmcls/evaluation/metrics/multi_task.py
marouaneamz Nov 25, 2022
0c90c00
Update mmcls/evaluation/metrics/multi_task.py
marouaneamz Nov 25, 2022
360b864
update metric doc
marouaneamz Nov 25, 2022
54b4108
update metric doc
marouaneamz Nov 25, 2022
d860e4a
Merge pull request #11 from marouaneamz/metrics
marouaneamz Nov 25, 2022
23a5382
Merge branch 'multi-task' into marouaneamz/my_multi_task_1_x
piercus Nov 25, 2022
f472453
Merge branch 'multi-task' of github.com:piercus/mmclassification into…
piercus Nov 25, 2022
15fb9b0
merge with 1.x
piercus Nov 25, 2022
404d15d
Fix cannot import name MultiTaskDataSample
marouaneamz Nov 28, 2022
25049e7
Merge pull request #3 from marouaneamz/my_multi_task_1_x
piercus Nov 28, 2022
e5af45f
fix test_datasets
marouaneamz Nov 28, 2022
f5014f4
fix test_datasets
marouaneamz Nov 28, 2022
fa05028
Merge pull request #4 from marouaneamz/my_multi_task_1_x
piercus Nov 28, 2022
2a80c2a
fix linter
marouaneamz Nov 29, 2022
798fc9a
add an example of multitask
marouaneamz Nov 29, 2022
c67408f
Merge branch 'my_multi_task_1_x' of github.com:marouaneamz/mmclassifi…
marouaneamz Nov 29, 2022
c6552e3
change name of configs dataset
marouaneamz Nov 29, 2022
87d78fd
Merge pull request #5 from marouaneamz/my_multi_task_1_x
piercus Nov 29, 2022
73473b0
Refactor the multi-task support
mzr1996 Dec 1, 2022
99969d1
correct test and metric
marouaneamz Dec 2, 2022
c742154
add test to multidatasample
marouaneamz Dec 5, 2022
1f7cfad
add test to multidatasample
marouaneamz Dec 5, 2022
70be3ae
correct test
marouaneamz Dec 5, 2022
ecdfb87
correct metrics and clshead
marouaneamz Dec 6, 2022
3dc8324
Update mmcls/models/heads/cls_head.py
marouaneamz Dec 6, 2022
3fe628e
Merge pull request #7 from marouaneamz/multi_task_mzr
piercus Dec 6, 2022
ad9f2ec
Merge branch '1.x' into multi-task
piercus Dec 6, 2022
81b605b
update cls_head.py documentation
piercus Dec 6, 2022
b5890d9
lint
piercus Dec 6, 2022
7c07ea2
lint
piercus Dec 6, 2022
7983caf
fix: lint
piercus Dec 6, 2022
0ac2f5c
fix linter
marouaneamz Dec 9, 2022
3d10f95
Merge branch 'multi_task_mzr' of github.com:marouaneamz/mmclassificat…
marouaneamz Dec 9, 2022
c3654d3
add eval mask
marouaneamz Dec 9, 2022
e6ad209
Merge remote-tracking branch 'pier_multi/multi-task' into multi_task_mzr
marouaneamz Dec 9, 2022
da32c23
fix documentation
marouaneamz Dec 9, 2022
deb3bf4
Merge pull request #8 from marouaneamz/multi_task_mzr
piercus Dec 9, 2022
0a655d8
fix: single_label.py back to 1.x
piercus Dec 9, 2022
172952c
Update mmcls/models/heads/multi_task_head.py
piercus Dec 16, 2022
83c8cb7
Remove multi-task configs.
mzr1996 Dec 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion mmcls/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
from .imagenet import ImageNet, ImageNet21k
from .mnist import MNIST, FashionMNIST
from .multi_label import MultiLabelDataset
from .multi_task import MultiTaskDataset
from .samplers import * # noqa: F401,F403
from .transforms import * # noqa: F401,F403
from .voc import VOC

__all__ = [
'BaseDataset', 'ImageNet', 'CIFAR10', 'CIFAR100', 'MNIST', 'FashionMNIST',
'VOC', 'build_dataset', 'ImageNet21k', 'KFoldDataset', 'CUB',
'CustomDataset', 'MultiLabelDataset'
'CustomDataset', 'MultiLabelDataset', 'MultiTaskDataset'
]
344 changes: 344 additions & 0 deletions mmcls/datasets/multi_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,344 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import os.path as osp
from os import PathLike
from typing import Optional, Sequence

import mmengine
from mmcv.transforms import Compose
from mmengine.fileio import FileClient

from .builder import DATASETS


def expanduser(path):
if isinstance(path, (str, PathLike)):
return osp.expanduser(path)
else:
return path


def isabs(uri):
return osp.isabs(uri) or ('://' in uri)


@DATASETS.register_module()
class MultiTaskDataset:
"""Custom dataset for multi-task dataset.

To use the dataset, please generate and provide an annotation file in the
below format:

.. code-block:: json

{
"metainfo": {
"tasks":
[
'gender'
'wear'
]
},
"data_list": [
{
"img_path": "a.jpg",
gt_label:{
"gender": 0,
"wear": [1, 0, 1, 0]
}
},
{
"img_path": "b.jpg",
gt_label:{
"gender": 1,
"wear": [1, 0, 1, 0]
}
}
]
}

Assume we put our dataset in the ``data/mydataset`` folder in the
repository and organize it as the below format: ::

mmclassification/
└── data
└── mydataset
├── annotation
│   ├── train.json
│   ├── test.json
│   └── val.json
├── train
│   ├── a.jpg
│   └── ...
├── test
│   ├── b.jpg
│   └── ...
└── val
├── c.jpg
└── ...

We can use the below config to build datasets:

.. code:: python

>>> from mmcls.datasets import build_dataset
>>> train_cfg = dict(
... type="MultiTaskDataset",
... ann_file="annotation/train.json",
... data_root="data/mydataset",
... # The `img_path` field in the train annotation file is relative
... # to the `train` folder.
... data_prefix='train',
... )
>>> train_dataset = build_dataset(train_cfg)

Or we can put all files in the same folder: ::

mmclassification/
└── data
└── mydataset
├── train.json
├── test.json
├── val.json
├── a.jpg
├── b.jpg
├── c.jpg
└── ...

And we can use the below config to build datasets:

.. code:: python

>>> from mmcls.datasets import build_dataset
>>> train_cfg = dict(
... type="MultiTaskDataset",
... ann_file="train.json",
... data_root="data/mydataset",
... # the `data_prefix` is not required since all paths are
... # relative to the `data_root`.
... )
>>> train_dataset = build_dataset(train_cfg)


Args:
ann_file (str): The annotation file path. It can be either absolute
path or relative path to the ``data_root``.
metainfo (dict, optional): The extra meta information. It should be
a dict with the same format as the ``"metainfo"`` field in the
annotation file. Defaults to None.
data_root (str, optional): The root path of the data directory. It's
the prefix of the ``data_prefix`` and the ``ann_file``. And it can
be a remote path like "s3://openmmlab/xxx/". Defaults to None.
data_prefix (str, optional): The base folder relative to the
``data_root`` for the ``"img_path"`` field in the annotation file.
Defaults to None.
pipeline (Sequence[dict]): A list of dict, where each element
represents a operation defined in :mod:`mmcls.datasets.pipelines`.
Defaults to an empty tuple.
test_mode (bool): in train mode or test mode. Defaults to False.
file_client_args (dict, optional): Arguments to instantiate a
FileClient. See :class:`mmengine.fileio.FileClient` for details.
If None, automatically inference from the ``data_root``.
Defaults to None.
"""
METAINFO = dict()

def __init__(self,
ann_file: str,
metainfo: Optional[dict] = None,
data_root: Optional[str] = None,
data_prefix: Optional[str] = None,
pipeline: Sequence = (),
test_mode: bool = False,
file_client_args: Optional[dict] = None):

self.data_root = expanduser(data_root)

# Inference the file client
if self.data_root is not None:
file_client = FileClient.infer_client(
file_client_args, uri=self.data_root)
else:
file_client = FileClient(file_client_args)
self.file_client: FileClient = file_client

self.ann_file = self._join_root(expanduser(ann_file))
self.data_prefix = self._join_root(data_prefix)

self.test_mode = test_mode
self.pipeline = Compose(pipeline)
self.data_list = self.load_data_list(self.ann_file, metainfo)

def _join_root(self, path):
"""Join ``self.data_root`` with the specified path.

If the path is an absolute path, just return the path. And if the
path is None, return ``self.data_root``.

Examples:
>>> self.data_root = 'a/b/c'
>>> self._join_root('d/e/')
'a/b/c/d/e'
>>> self._join_root('https://openmmlab.com')
'https://openmmlab.com'
>>> self._join_root(None)
'a/b/c'
"""
if path is None:
return self.data_root
if isabs(path):
return path

joined_path = self.file_client.join_path(self.data_root, path)
return joined_path

@classmethod
def _get_meta_info(cls, in_metainfo: dict = None) -> dict:
"""Collect meta information from the dictionary of meta.

Args:
in_metainfo (dict): Meta information dict.

Returns:
dict: Parsed meta information.
"""
# `cls.METAINFO` will be overwritten by in_meta
metainfo = copy.deepcopy(cls.METAINFO)
if in_metainfo is None:
return metainfo

metainfo.update(in_metainfo)

return metainfo

def load_data_list(self, ann_file, metainfo_override=None):
"""Load annotations from an annotation file.

Args:
ann_file (str): Absolute annotation file path if ``self.root=None``
or relative path if ``self.root=/path/to/data/``.

Returns:
list[dict]: A list of annotation.
"""
annotations = mmengine.load(ann_file)
if not isinstance(annotations, dict):
raise TypeError(f'The annotations loaded from annotation file '
f'should be a dict, but got {type(annotations)}!')
if 'data_list' not in annotations:
raise ValueError('The annotation file must have the `data_list` '
'field.')
metainfo = annotations.get('metainfo', {})
raw_data_list = annotations['data_list']

# Set meta information.
assert isinstance(metainfo, dict), 'The `metainfo` field in the '\
f'annotation file should be a dict, but got {type(metainfo)}'
if metainfo_override is not None:
assert isinstance(metainfo_override, dict), 'The `metainfo` ' \
f'argument should be a dict, but got {type(metainfo_override)}'
metainfo.update(metainfo_override)
self._metainfo = self._get_meta_info(metainfo)

data_list = []
for i, raw_data in enumerate(raw_data_list):
try:
data_list.append(self.parse_data_info(raw_data))
except AssertionError as e:
raise RuntimeError(
f'The format check fails during parse the item {i} of '
f'the annotation file with error: {e}')
return data_list

def parse_data_info(self, raw_data):
"""Parse raw annotation to target format.

This method will return a dict which contains the data information of a
sample.

Args:
raw_data (dict): Raw data information load from ``ann_file``

Returns:
dict: Parsed annotation.
"""
assert isinstance(raw_data, dict), \
f'The item should be a dict, but got {type(raw_data)}'
assert 'img_path' in raw_data, \
"The item doesn't have `img_path` field."
data = dict(
img_path=self._join_root(raw_data['img_path']),
gt_label=raw_data['gt_label'],
)
return data

@property
def metainfo(self) -> dict:
"""Get meta information of dataset.

Returns:
dict: meta information collected from ``cls.METAINFO``,
annotation file and metainfo argument during instantiation.
"""
return copy.deepcopy(self._metainfo)

def prepare_data(self, idx):
"""Get data processed by ``self.pipeline``.

Args:
idx (int): The index of ``data_info``.

Returns:
Any: Depends on ``self.pipeline``.
"""
results = copy.deepcopy(self.data_list[idx])
return self.pipeline(results)

def __len__(self):
"""Get the length of the whole dataset.

Returns:
int: The length of filtered dataset.
"""
return len(self.data_list)

def __getitem__(self, idx):
"""Get the idx-th image and data information of dataset after
``self.pipeline``.

Args:
idx (int): The index of of the data.

Returns:
dict: The idx-th image and data information after
``self.pipeline``.
"""
return self.prepare_data(idx)

def __repr__(self):
"""Print the basic information of the dataset.

Returns:
str: Formatted string.
"""
head = 'Dataset ' + self.__class__.__name__
body = [f'Number of samples: \t{self.__len__()}']
if self.data_root is not None:
body.append(f'Root location: \t{self.data_root}')
body.append(f'Annotation file: \t{self.ann_file}')
if self.data_prefix is not None:
body.append(f'Prefix of images: \t{self.data_prefix}')
# -------------------- extra repr --------------------
tasks = self.metainfo['tasks']
body.append(f'For {len(tasks)} tasks')
for task in tasks:
body.append(f' {task} ')
# ----------------------------------------------------

if len(self.pipeline.transforms) > 0:
body.append('With transforms:')
for t in self.pipeline.transforms:
body.append(f' {t}')

lines = [head] + [' ' * 4 + line for line in body]
return '\n'.join(lines)
6 changes: 4 additions & 2 deletions mmcls/datasets/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Brightness, ColorTransform, Contrast, Cutout,
Equalize, Invert, Posterize, RandAugment, Rotate,
Sharpness, Shear, Solarize, SolarizeAdd, Translate)
from .formatting import Collect, PackClsInputs, ToNumpy, ToPIL, Transpose
from .formatting import (Collect, PackClsInputs, PackMultiTaskInputs, ToNumpy,
ToPIL, Transpose)
from .processing import (Albumentations, ColorJitter, EfficientNetCenterCrop,
EfficientNetRandomCrop, Lighting, RandomCrop,
RandomErasing, RandomResizedCrop, ResizeEdge)
Expand All @@ -15,5 +16,6 @@
'Contrast', 'Brightness', 'Sharpness', 'AutoAugment', 'SolarizeAdd',
'Cutout', 'RandAugment', 'Lighting', 'ColorJitter', 'RandomErasing',
'PackClsInputs', 'Albumentations', 'EfficientNetRandomCrop',
'EfficientNetCenterCrop', 'ResizeEdge', 'BaseAugTransform'
'EfficientNetCenterCrop', 'ResizeEdge', 'BaseAugTransform',
'PackMultiTaskInputs'
]