From 07709e7ab06557cbe1637107f5683e94249e7589 Mon Sep 17 00:00:00 2001 From: ZXYFrank <49837632+ZXYFrank@users.noreply.github.com> Date: Wed, 23 Feb 2022 20:36:33 +0800 Subject: [PATCH 1/3] Add optional arguments to ImageDataManager Add **kwargs optional arguments to ImageDataManager, which will ensure flexibility of the custom and registered dataset --- torchreid/data/datamanager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/torchreid/data/datamanager.py b/torchreid/data/datamanager.py index 7ae28cbaf..ebd13c938 100644 --- a/torchreid/data/datamanager.py +++ b/torchreid/data/datamanager.py @@ -175,7 +175,8 @@ def __init__( train_sampler_t='RandomSampler', cuhk03_labeled=False, cuhk03_classic_split=False, - market1501_500k=False + market1501_500k=False, + **kwargs ): super(ImageDataManager, self).__init__( @@ -202,7 +203,8 @@ def __init__( split_id=split_id, cuhk03_labeled=cuhk03_labeled, cuhk03_classic_split=cuhk03_classic_split, - market1501_500k=market1501_500k + market1501_500k=market1501_500k, + **kwargs ) trainset.append(trainset_) trainset = sum(trainset) From a6b2f77e8a005cad2eb94d25aac05482145d0c9e Mon Sep 17 00:00:00 2001 From: ZXYFrank <49837632+ZXYFrank@users.noreply.github.com> Date: Wed, 23 Feb 2022 20:37:42 +0800 Subject: [PATCH 2/3] Add **kwargs to ImageDataManager Add **kwargs optional arguments to ImageDataManager I defined a custom ImageDataset, which takes some additional arguments for init. According to [use custom dataset](https://kaiyangzhou.github.io/deep-person-reid/user_guide.html#use-your-own-dataset), the officially recommended way to use the dataset is to use the ImageDataManager I tried to pass **kwargs(a dict) into the torchreid.data.ImageDataManager() constructor. Unfortunately, due to the **positional(fixed)** arguments of the function `init_image_dataset` (in datamanager.py), the constructor of my own custom dataset cannot receive any additional arguaments. I hope it will fix the problem! --- torchreid/data/datamanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchreid/data/datamanager.py b/torchreid/data/datamanager.py index ebd13c938..87581f6ef 100644 --- a/torchreid/data/datamanager.py +++ b/torchreid/data/datamanager.py @@ -204,7 +204,7 @@ def __init__( cuhk03_labeled=cuhk03_labeled, cuhk03_classic_split=cuhk03_classic_split, market1501_500k=market1501_500k, - **kwargs + **kwargs ) trainset.append(trainset_) trainset = sum(trainset) From 94d6b02e406b320165324a157234538bbdb0ef02 Mon Sep 17 00:00:00 2001 From: ZXYFrank <49837632+ZXYFrank@users.noreply.github.com> Date: Wed, 23 Feb 2022 21:23:47 +0800 Subject: [PATCH 3/3] Update datamanager.py add **kwargs to all occurrences of `init_image_dataset ` in `datamanager.py` --- torchreid/data/datamanager.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/torchreid/data/datamanager.py b/torchreid/data/datamanager.py index 87581f6ef..872009d8e 100644 --- a/torchreid/data/datamanager.py +++ b/torchreid/data/datamanager.py @@ -248,7 +248,8 @@ def __init__( split_id=split_id, cuhk03_labeled=cuhk03_labeled, cuhk03_classic_split=cuhk03_classic_split, - market1501_500k=market1501_500k + market1501_500k=market1501_500k, + **kwargs ) trainset_t.append(trainset_t_) trainset_t = sum(trainset_t) @@ -297,7 +298,8 @@ def __init__( split_id=split_id, cuhk03_labeled=cuhk03_labeled, cuhk03_classic_split=cuhk03_classic_split, - market1501_500k=market1501_500k + market1501_500k=market1501_500k, + **kwargs ) self.test_loader[name]['query'] = torch.utils.data.DataLoader( queryset, @@ -319,7 +321,8 @@ def __init__( split_id=split_id, cuhk03_labeled=cuhk03_labeled, cuhk03_classic_split=cuhk03_classic_split, - market1501_500k=market1501_500k + market1501_500k=market1501_500k, + **kwargs ) self.test_loader[name]['gallery'] = torch.utils.data.DataLoader( galleryset,