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

file examples #13

Open
ly-jy opened this issue Jun 23, 2020 · 1 comment
Open

file examples #13

ly-jy opened this issue Jun 23, 2020 · 1 comment

Comments

@ly-jy
Copy link

ly-jy commented Jun 23, 2020

Hello author, how do you get 'market1501_init_-1.0.pickle','duke_init_-1.0.pickle' in file examples? Plase help me! Please! Thank you very much!

@Yu-Wu
Copy link
Owner

Yu-Wu commented Jun 23, 2020

label_dataset = []
unlabel_dataset = []
if init_str == "one-shot":
# dataset indexed by [pid, cam]
dataset_in_pid_cam = [[[] for _ in range(dataset.num_cams)] for _ in range(dataset.num_train_ids) ]
for index, (images, pid, camid, videoid) in enumerate(dataset.train):
dataset_in_pid_cam[pid][camid].append([images, pid, camid, videoid])
# generate the labeled dataset by randomly selecting a tracklet from the first camera for each identity
for pid, cams_data in enumerate(dataset_in_pid_cam):
for camid, videos in enumerate(cams_data):
if len(videos) != 0:
selected_video = random.choice(videos)
break
label_dataset.append(selected_video)
assert len(label_dataset) == dataset.num_train_ids
labeled_videoIDs =[vid for _, (_,_,_, vid) in enumerate(label_dataset)]
else:
# dataset indexed by [pid]
dataset_in_pid = [ [] for _ in range(dataset.num_train_ids) ]
for index, (images, pid, camid, videoid) in enumerate(dataset.train):
dataset_in_pid[pid].append([images, pid, camid, videoid])
for pid, pid_data in enumerate(dataset_in_pid):
k = int(np.ceil(len(pid_data) * init)) # random sample ratio
selected_video = random.sample(pid_data, k)
label_dataset.extend(selected_video)
labeled_videoIDs =[vid for _, (_,_,_, vid) in enumerate(label_dataset)]
# generate unlabeled set
for (imgs, pid, camid, videoid) in dataset.train:
if videoid not in labeled_videoIDs:
unlabel_dataset.append([imgs, pid, camid, videoid])
with open(load_path, "wb") as fp:
pickle.dump({"label set":label_dataset, "unlabel set":unlabel_dataset}, fp)
print(" labeled | N/A | {:8d}".format(len(label_dataset)))
print(" unlabeled | N/A | {:8d}".format(len(unlabel_dataset)))
print("\nCreate new {} split and save it to {}".format(init_str, load_path))
return label_dataset, unlabel_dataset

Please see the code here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants