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

CelebAHQ dataset incompatibility #2

Closed
Jaep0805 opened this issue Apr 24, 2023 · 4 comments
Closed

CelebAHQ dataset incompatibility #2

Jaep0805 opened this issue Apr 24, 2023 · 4 comments

Comments

@Jaep0805
Copy link

Jaep0805 commented Apr 24, 2023

The dataloader you've provided seem to be incompatible with the CelebAHQ dataset.
CelebAHQ dataset does not provide the segmentation mask as a whole, but rather in categories.
It is also divided into subfolders depending on the numbers of the image, from 0~14

화면 캡처 2023-04-24 142410

@Jaep0805
Copy link
Author

solved

@hanpiness
Copy link

I have encountered the same problem. May I ask how you resolved it? Thank you!

@Sanoojan
Copy link

Sanoojan commented Aug 1, 2023

import os
from PIL import Image
import numpy as np

celelbAHQ_label_list = ['skin', 'nose', 'eye_g', 'l_eye', 'r_eye','l_brow', 'r_brow', 'l_ear', 'r_ear', 'mouth','u_lip', 'l_lip', 'hair', 'hat', `'ear_r','neck_l',` 'neck', 'cloth']

faceParser_label_list_detailed = ['background', 'lip', 'eyebrows', 'eyes', 'hair', 'nose', 'skin', 'ears', 'belowface', 'mouth', 'eye_glass', 'ear_rings']

Dataset_maskPath='e4s/data/CelebAMask-HQ/CelebA-HQ-mask'
save_path='e4s/data/CelebAMask-HQ/CelebA-HQ-mask/Overall_mask'
if not os.path.exists(save_path):
    os.mkdir(save_path)
for i in range(30000):
    mask=np.zeros((512,512))
    for ind,cate in enumerate(celelbAHQ_label_list):
        
        if os.path.exists(os.path.join(Dataset_maskPath,"%d"%int(i/2000) ,'{0:0=5d}'.format(i)+'_'+cate+'.png')):
            im= Image.open(os.path.join(Dataset_maskPath,"%d"%int(i/2000) ,'{0:0=5d}'.format(i)+'_'+cate+'.png')).convert('L')
            im = np.equal(im, 255)
            mask[im]=ind+1

    cv2.imwrite(os.path.join(save_path,'%d'%i+'.png'),mask)

@hanpiness I created the mask like this to solve the problem. Hope it may help you.

@Jeriousman
Copy link

solved

How did you solve it?

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

4 participants