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

Preparing Dataset *a modification in readme file #19

Open
HOMGH opened this issue Sep 23, 2020 · 16 comments
Open

Preparing Dataset *a modification in readme file #19

HOMGH opened this issue Sep 23, 2020 · 16 comments

Comments

@HOMGH
Copy link

HOMGH commented Sep 23, 2020

Just use img_align_celebA_png.7z I think.
I suggest you read this part of code carefully (containing the aligning code)

def load_images(filenames, img_size, alpha, landmark, cropper=None, gray=False):

Originally posted by @deepmo24 in #10 (comment)

@HOMGH
Copy link
Author

HOMGH commented Sep 23, 2020

Prepare dataset:
1)For training this model, you need to use "img_celeba" folder in celebA dataset.
2)This data should be aligned using 5 landmarks from "list_landmarks_align_celeba.tx using preproces function in https://github.com/microsoft/Deep3DFaceReconstruction/blob/4b27ddf4227c687b953caa7aa3f3e7acf87cc786/preprocess_img.py#L52
list_landmarks_align_celeba.txt
3) Segment the aligned dataset
4)Make RGBA using the following code:
def save_RGBA_face(im, parsing_anno, img_size, save_path='vis_results/parsing_map_on_im.jpg'):

vis_parsing_anno = parsing_anno.copy().astype(np.uint8)
face_mask = np.zeros((vis_parsing_anno.shape[0], vis_parsing_anno.shape[1]))

num_of_class = np.max(vis_parsing_anno)
for pi in range(1, num_of_class + 1):
    index = np.where(vis_parsing_anno == pi)
    if pi in [1,2,3,4,5,10,12,13]:
        face_mask[index[0], index[1]] = 255.0

im = np.array(im)
img = im.copy().astype(np.uint8)
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)

seg_img = face_mask.astype(np.uint8)

img = cv2.resize(img, (img_size, img_size))
seg_img = cv2.resize(seg_img, (img_size, img_size))
seg_img = seg_img[:,:,None]

BGRA_img = np.concatenate((img, seg_img), axis=2)

cv2.imwrite(save_path, BGRA_img)
  1. create .bin files using create_bin.py

Done!

Now the Dataset is ready to be used for training the model...

P.S, Thank @deepmo24 for her contribution.

@ZechCal
Copy link

ZechCal commented Sep 30, 2020

Great, but how to segment the dataset? Is there any good public algorithm available?

@HOMGH
Copy link
Author

HOMGH commented Sep 30, 2020

Great, but how to segment the dataset? Is there any good public algorithm available?

#2 (comment)
Here is the segmentation algorithm suggested by the author.

@ZechCal
Copy link

ZechCal commented Oct 1, 2020

Thx a lot!

@ZechCal
Copy link

ZechCal commented Oct 16, 2020

Hello, what is the size of your bin dataset? I may faced with some troubles....(152GB)

@HOMGH
Copy link
Author

HOMGH commented Oct 16, 2020

Hello, what is the size of your bin dataset? I may faced with some troubles....(152GB)

Hi, Mine is 156 GB.

@ZechCal
Copy link

ZechCal commented Oct 19, 2020

Hello, what is the size of your bin dataset? I may faced with some troubles....(152GB)

Hi, Mine is 156 GB.

Thx a lot!

@ghost
Copy link

ghost commented Dec 24, 2020

@HOMGH
can you share the dataset?

@cyjouc
Copy link

cyjouc commented Jan 13, 2021

Prepare dataset:
1)For training this model, you need to use "img_celeba" folder in celebA dataset.
2)This data should be aligned using 5 landmarks from "list_landmarks_align_celeba.tx using preproces function in https://github.com/microsoft/Deep3DFaceReconstruction/blob/4b27ddf4227c687b953caa7aa3f3e7acf87cc786/preprocess_img.py#L52
list_landmarks_align_celeba.txt
3) Segment the aligned dataset
4)Make RGBA using the following code:
def save_RGBA_face(im, parsing_anno, img_size, save_path='vis_results/parsing_map_on_im.jpg'):

vis_parsing_anno = parsing_anno.copy().astype(np.uint8)
face_mask = np.zeros((vis_parsing_anno.shape[0], vis_parsing_anno.shape[1]))

num_of_class = np.max(vis_parsing_anno)
for pi in range(1, num_of_class + 1):
    index = np.where(vis_parsing_anno == pi)
    if pi in [1,2,3,4,5,10,12,13]:
        face_mask[index[0], index[1]] = 255.0

im = np.array(im)
img = im.copy().astype(np.uint8)
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)

seg_img = face_mask.astype(np.uint8)

img = cv2.resize(img, (img_size, img_size))
seg_img = cv2.resize(seg_img, (img_size, img_size))
seg_img = seg_img[:,:,None]

BGRA_img = np.concatenate((img, seg_img), axis=2)

cv2.imwrite(save_path, BGRA_img)
  1. create .bin files using create_bin.py

Done!

Now the Dataset is ready to be used for training the model...

P.S, Thank @deepmo24 for her contribution.

hi,Can you success to the train?Could you ask me some questions?(hicaicaihi for my wetchat)

@cyjouc
Copy link

cyjouc commented Jan 14, 2021

how do you obtain the the fllowing three data?
train_txt = '{}_train.txt'.format(prefix)
val_txt = '{}_val.txt'.format(prefix)
test_txt = '{}

@cyjouc
Copy link

cyjouc commented Jan 18, 2021

Segment the aligned dataset

Segment the aligned dataset?link only speak decode process,how split face and no_face data?

@cyjouc
Copy link

cyjouc commented Jan 19, 2021

@HOMGH
can you share the dataset?

Hi,do you prepare the dataset for training?would you like share with me?

@cyjouc
Copy link

cyjouc commented Jan 19, 2021

Hello, what is the size of your bin dataset? I may faced with some troubles....(152GB)

Hi, Mine is 156 GB.

Thx a lot!

can you share the dataset?

@Msj5
Copy link

Msj5 commented Mar 19, 2021

Hi, do you train with main.py? have you suffer out of memory?Could you share your train.py with me?plz reply to [email protected]
thx. @HOMGH

@biga-bomb
Copy link

Prepare dataset:
1)For training this model, you need to use "img_celeba" folder in celebA dataset.
2)This data should be aligned using 5 landmarks from "list_landmarks_align_celeba.tx using preproces function in https://github.com/microsoft/Deep3DFaceReconstruction/blob/4b27ddf4227c687b953caa7aa3f3e7acf87cc786/preprocess_img.py#L52
list_landmarks_align_celeba.txt
3) Segment the aligned dataset
4)Make RGBA using the following code:
def save_RGBA_face(im, parsing_anno, img_size, save_path='vis_results/parsing_map_on_im.jpg'):

vis_parsing_anno = parsing_anno.copy().astype(np.uint8)
face_mask = np.zeros((vis_parsing_anno.shape[0], vis_parsing_anno.shape[1]))

num_of_class = np.max(vis_parsing_anno)
for pi in range(1, num_of_class + 1):
    index = np.where(vis_parsing_anno == pi)
    if pi in [1,2,3,4,5,10,12,13]:
        face_mask[index[0], index[1]] = 255.0

im = np.array(im)
img = im.copy().astype(np.uint8)
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)

seg_img = face_mask.astype(np.uint8)

img = cv2.resize(img, (img_size, img_size))
seg_img = cv2.resize(seg_img, (img_size, img_size))
seg_img = seg_img[:,:,None]

BGRA_img = np.concatenate((img, seg_img), axis=2)

cv2.imwrite(save_path, BGRA_img)
1. create .bin files using create_bin.py

Done!

Now the Dataset is ready to be used for training the model...

P.S, Thank @deepmo24 for her contribution.

Hi, can you train the model correctly? If you can do that, could you please share your pre-model? Thank you very much! [email protected]

@Rafael8830
Copy link

you obtain the the fllowing three data?

how do you obtain the the fllowing three data? train_txt = '{}_train.txt'.format(prefix) val_txt = '{}_val.txt'.format(prefix) test_txt = '{}

I have the same problem, 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

6 participants