Example #1
0
num_cam = 6
###########   DATASET   ###########
img_dir = dataset_path + 'Market-1501/bounding_box_train_camstyle_merge/'
train_dataset = imgdataset_camtrans(dataset_dir=img_dir,
                                    txt_path=ann_file_train,
                                    transformer='test',
                                    K=num_cam,
                                    num_cam=num_cam)
train_loader = DataLoader(dataset=train_dataset,
                          batch_size=1,
                          shuffle=False,
                          num_workers=4)

img_dir = dataset_path + 'Market-1501/'
test_dataset = imgdataset(dataset_dir=img_dir,
                          txt_path=ann_file_test,
                          transformer='test')
test_loader = DataLoader(dataset=test_dataset,
                         batch_size=1,
                         shuffle=False,
                         num_workers=4)

###########   TEST   ###########
model, _ = resnet50(pretrained=snapshot, num_classes=702)
model.cuda()
model.eval()

print('extract feature for training set')
train_feas = extract_fea_camtrans(model, train_loader)
_, cam_ids, frames = get_info(ann_file_train)
Example #2
0
num_cam = 6
##########   DATASET   ###########
dataset_path = 'data/dataset/'
src_dir = dataset_path + 'DukeMTMC-reID/bounding_box_train/'
tar_dir = dataset_path + 'Market-1501/bounding_box_train_camstyle_merge/'
tar_dir_test = dataset_path + 'Market-1501/'

src_annfile = 'list_duke/list_duke_train.txt'
tar_annfile = 'list_market/list_market_train.txt'
tar_annfile_test = 'list_market/list_market_test.txt'

#resnet50: https://download.pytorch.org/models/resnet50-19c8e357.pth
imageNet_pretrain = 'resnet50-19c8e357.pth'

train_dataset = imgdataset(dataset_dir=src_dir,
                           txt_path=src_annfile,
                           transformer='train')
train_loader = DataLoader(dataset=train_dataset,
                          batch_size=batch_size,
                          shuffle=True,
                          num_workers=4,
                          drop_last=True)

train_dataset_t = imgdataset_camtrans(dataset_dir=tar_dir,
                                      txt_path=tar_annfile,
                                      transformer='train',
                                      num_cam=num_cam,
                                      K=K)
train_loader_t = DataLoader(dataset=train_dataset_t,
                            batch_size=int(batch_size / K),
                            shuffle=True,
Example #3
0
base_lr = 0.01
num_epoches = 100
batch_size = 128
num_instances = 4
K = 4
num_cam = opt.num_cam
sys.stdout = Logger(os.path.join('./snapshot', opt.name, 'log_train.txt'))
##########   DATASET   ###########
dataset_path = 'data/'
if opt.src == 'unreal':
    src_dir = dataset_path
else:
    src_dir = dataset_path + opt.src + '/bounding_box_train_camstyle_merge/'
src_annfile = 'list_{}/list_{}_train.txt'.format(opt.src, opt.src)
train_dataset = imgdataset(dataset_dir=src_dir,
                           txt_path=src_annfile,
                           transformer='train')

dataset_path = 'data/'
if opt.src2 == 'unreal':
    src_dir2 = dataset_path
else:
    src_dir2 = dataset_path + opt.src2 + '/bounding_box_train_camstyle_merge/'
src2_annfile = 'list_{}/list_{}_train.txt'.format(opt.src2, opt.src2)
train_dataset2 = imgdataset(dataset_dir=src_dir2,
                            txt_path=src2_annfile,
                            transformer='train')

train_datasource = train_dataset.data_source
numpids = len(train_dataset.pids)
numcams = len(train_dataset.cams)