FuxiCV / 3D-Face-GCNs

Towards High-Fidelity 3D Face Reconstruction from In-the-Wild Images Using Graph Convolutional Networks, CVPR 2020
MIT License
398 stars 80 forks source link

Preparing Dataset *a modification in readme file #19

Open HOMGH opened 3 years ago

HOMGH commented 3 years ago

Just use img_align_celebA_png.7z I think. I suggest you read this part of code carefully (containing the aligning code) https://github.com/FuxiCV/3D-Face-GCNs/blob/2c4459cfa05faaf82ef85994a696e79d2993d650/utils.py#L217

Originally posted by @deepmo24 in https://github.com/FuxiCV/3D-Face-GCNs/issues/10#issuecomment-693219359

HOMGH commented 3 years ago

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)

5) 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 commented 3 years ago

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

HOMGH commented 3 years ago

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

https://github.com/FuxiCV/3D-Face-GCNs/issues/2#issuecomment-658134688 Here is the segmentation algorithm suggested by the author.

ZechCal commented 3 years ago

Thx a lot!

ZechCal commented 3 years ago

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

HOMGH commented 3 years ago

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

Hi, Mine is 156 GB.

ZechCal commented 3 years ago

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 commented 3 years ago

@HOMGH can you share the dataset?

cyjouc commented 3 years ago

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 commented 3 years ago

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

cyjouc commented 3 years ago

Segment the aligned dataset

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

cyjouc commented 3 years ago

@HOMGH can you share the dataset?

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

cyjouc commented 3 years ago

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 commented 3 years ago

Hi, do you train with main.py? have you suffer out of memory?Could you share your train.py with me?plz reply to 3180532485@qq.com thx. @HOMGH

biga-bomb commented 3 years ago

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! 1154225766@qq.com

Rafael8830 commented 2 years ago

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?