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

Update g_partition.py #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions face_parsing/Data_preprocessing/g_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from utils import make_folder

#### source data path
s_label = 'CelebAMask-HQ-label'
s_label = 'CelebAMask-HQ-mask'
s_img = 'CelebA-HQ-img'
#### destination training data path
d_train_label = 'train_label'
Expand Down Expand Up @@ -35,21 +35,21 @@
f_val = open('val_list.txt', 'w')
f_test = open('test_list.txt', 'w')

for idx, x in enumerate(image_list.loc[:, 1]):
for idx, x in enumerate(image_list.loc[1:, 1]):
print (idx, x)
x = int(x)
if x >= 162771 and x < 182638:
copyfile(os.path.join(s_label, str(idx)+'.png'), os.path.join(d_val_label, str(val_count)+'.png'))
copyfile(os.path.join(s_img, str(idx)+'.jpg'), os.path.join(d_val_img, str(val_count)+'.jpg'))
copyfile(os.path.join(s_img, str(idx)+'.jpg'), os.path.join(d_val_img, str(val_count)+'.jpg'))
val_count += 1

elif x >= 182638:
copyfile(os.path.join(s_label, str(idx)+'.png'), os.path.join(d_test_label, str(test_count)+'.png'))
copyfile(os.path.join(s_img, str(idx)+'.jpg'), os.path.join(d_test_img, str(test_count)+'.jpg'))
test_count += 1
test_count += 1
else:
copyfile(os.path.join(s_label, str(idx)+'.png'), os.path.join(d_train_label, str(train_count)+'.png'))
copyfile(os.path.join(s_img, str(idx)+'.jpg'), os.path.join(d_train_img, str(train_count)+'.jpg'))
train_count += 1
train_count += 1

print (train_count + test_count + val_count)
#### close the file
Expand Down