Skip to content

Commit 4f7c35c

Browse files
author
ZHANG Zhiwei
committed
update for supporting vehicleid
1 parent 90bccb3 commit 4f7c35c

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

openunreid/apis/test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from .train import set_random_seed
1313
from openunreid.data import build_test_dataloader
14+
from openunreid.utils.logger import display
1415
from ..core.metrics.rank import evaluate_rank
1516
from ..core.utils.compute_dist import build_dist
1617
from ..models.utils.dsbn_utils import switch_target_bn
@@ -221,8 +222,11 @@ def final_test(cfg, model, cmc_topk=(1, 5, 10)):
221222
all_cmc.append(cmc)
222223
all_mAP.append(mAP)
223224

224-
225-
display(cfg, all_mAP, all_cmc, cmc_topk)
225+
if cfg.TRAIN.num_repeat != 1:
226+
print("\n ")
227+
print("Average CMC Scores:")
228+
for k in cmc_topk:
229+
print(" top-{:<4}{:12.1%}".format(k, np.mean(all_cmc, axis=0)[k - 1]))
226230

227231
end_time = time.monotonic()
228232
print("Testing time: ", timedelta(seconds=end_time - start_time))

openunreid/data/datasets/vehicleid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(
3434
):
3535
self.root = osp.abspath(osp.expanduser(root))
3636
self.dataset_dir = osp.join(self.root, self.dataset_dir)
37+
self.mode = mode
3738
self.del_labels = del_labels
3839
self.download_dataset(self.dataset_dir, self.dataset_url)
3940
assert (val_split > 0.0) and (

openunreid/utils/logger.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ def close(self):
4747

4848

4949
def display(cfg, map, cmc, cmc_topk=(1, 5, 10)):
50-
if cfg.TRAIN.num_repeat == 10:
50+
if cfg.TRAIN.num_repeat != 1:
5151
print("\n")
52-
print("Mean AP: {:4.1%}".format(np.mean(map)))
5352
print("CMC Scores:")
5453
for k in cmc_topk:
55-
print(" top-{:<4}{:12.1%}".format(k, np.mean(cmc, axis=0)[k - 1]))
54+
print(" top-{:<4}{:12.1%}".format(k, cmc[k - 1]))
5655
else:
5756
print("\n")
57+
print("Mean AP: {:4.1%}".format(np.mean(map)))
5858
print("CMC Scores:")
5959
for k in cmc_topk:
60-
print(" top-{:<4}{:12.1%}".format(k, np.mean(cmc, axis=0)[k - 1]))
60+
print(" top-{:<4}{:12.1%}".format(k, cmc[k - 1]))

tools/SpCL/config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ MODEL:
2424

2525
DATA:
2626

27-
height: 256
28-
width: 128
27+
height: 224
28+
width: 224
2929
norm_mean: [0.485, 0.456, 0.406]
3030
norm_std: [0.229, 0.224, 0.225]
3131

@@ -57,23 +57,23 @@ TRAIN:
5757
amp: False
5858

5959
# datasets
60-
datasets: {'market1501': 'trainval',}
60+
datasets: {'vehicleid': 'trainval',}
6161
# datasets: {'market1501': 'trainval', 'dukemtmcreid': 'trainval'}
6262
unsup_dataset_indexes: [0,]
6363

6464
# repeated number of evaluation
6565
num_repeat: 10 # 10 only for vehicleid dataset, otherwise 1
6666

6767
epochs: 50
68-
iters: 400
68+
iters: 800
6969

7070
LOSS:
7171
losses: {'hybrid_memory': 1.,}
7272
temp: 0.05
7373
momentum: 0.2
7474

7575
# validate
76-
val_dataset: 'market1501'
76+
val_dataset: 'vehicleid'
7777
val_freq: 5
7878

7979
# sampler
@@ -121,7 +121,7 @@ TRAIN:
121121
TEST:
122122

123123
# datasets
124-
datasets: ['market1501',]
124+
datasets: ['vehicleid',]
125125

126126
# data loader
127127
LOADER:

tools/strong_baseline/config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ MODEL:
2424

2525
DATA:
2626

27-
height: 256
28-
width: 128
27+
height: 224
28+
width: 224
2929
norm_mean: [0.485, 0.456, 0.406]
3030
norm_std: [0.229, 0.224, 0.225]
3131

@@ -57,22 +57,22 @@ TRAIN:
5757
amp: False
5858

5959
# datasets
60-
datasets: {'market1501': 'trainval',}
60+
datasets: {'vehicleid': 'trainval',}
6161
# datasets: {'market1501': 'trainval', 'dukemtmcreid': 'trainval'}
6262
unsup_dataset_indexes: [0,]
6363

6464
# repeated number of evaluation
6565
num_repeat: 10 # 10 only for vehicleid dataset, otherwise 1
6666

6767
epochs: 50
68-
iters: 400
68+
iters: 800
6969

7070
LOSS:
7171
losses: {'cross_entropy': 1., 'softmax_triplet': 1.}
7272
margin: 0.
7373

7474
# validate
75-
val_dataset: 'market1501'
75+
val_dataset: 'vehicleid'
7676
val_freq: 5
7777

7878
# sampler
@@ -118,7 +118,7 @@ TRAIN:
118118
TEST:
119119

120120
# datasets
121-
datasets: ['market1501',]
121+
datasets: ['vehicleid',]
122122

123123
# data loader
124124
LOADER:

0 commit comments

Comments
 (0)