Skip to content

Commit b9465f1

Browse files
authored
Fix a bug for DukeMTMC without multi-query
1 parent b00f136 commit b9465f1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,15 @@
7878

7979

8080
data_dir = test_dir
81-
image_datasets = {x: datasets.ImageFolder( os.path.join(data_dir,x) ,data_transforms) for x in ['gallery','query','multi-query']}
82-
dataloaders = {x: torch.utils.data.DataLoader(image_datasets[x], batch_size=opt.batchsize,
83-
shuffle=False, num_workers=16) for x in ['gallery','query','multi-query']}
8481

82+
if opt.multi:
83+
image_datasets = {x: datasets.ImageFolder( os.path.join(data_dir,x) ,data_transforms) for x in ['gallery','query','multi-query']}
84+
dataloaders = {x: torch.utils.data.DataLoader(image_datasets[x], batch_size=opt.batchsize,
85+
shuffle=False, num_workers=16) for x in ['gallery','query','multi-query']}
86+
else:
87+
image_datasets = {x: datasets.ImageFolder( os.path.join(data_dir,x) ,data_transforms) for x in ['gallery','query']}
88+
dataloaders = {x: torch.utils.data.DataLoader(image_datasets[x], batch_size=opt.batchsize,
89+
shuffle=False, num_workers=16) for x in ['gallery','query']}
8590
class_names = image_datasets['query'].classes
8691
use_gpu = torch.cuda.is_available()
8792

@@ -159,11 +164,13 @@ def get_id(img_path):
159164

160165
gallery_path = image_datasets['gallery'].imgs
161166
query_path = image_datasets['query'].imgs
162-
mquery_path = image_datasets['multi-query'].imgs
163167

164168
gallery_cam,gallery_label = get_id(gallery_path)
165169
query_cam,query_label = get_id(query_path)
166-
mquery_cam,mquery_label = get_id(mquery_path)
170+
171+
if opt.multi:
172+
mquery_path = image_datasets['multi-query'].imgs
173+
mquery_cam,mquery_label = get_id(mquery_path)
167174

168175
######################################################################
169176
# Load Collected data Trained model

0 commit comments

Comments
 (0)