-
Unzip the Data File
- Navigate to the directory
./ganimation_replicate/datasets/celebA
. - Unzip the file
aus_openface.pkl.zip
.
- Navigate to the directory
-
Download the Model
- Download the model from the provided Google Drive link : (https://drive.google.com/drive/folders/1bQb8Nun2ijjknIdYemaHwa7qJVnjFpQQ?usp=sharing)
- Add the downloaded model to the
./ganimation_replicate
folder.
-
Prepare the Images
- Place the two images you want to modify in the
./ganimation_replicate/datasets/celebA/imgs
folder. - Update the file
./ganimation_replicate/datasets/celebA/test_ids.csv
with the names of these image files.
- Place the two images you want to modify in the
-
Run the Codebase
- Use the following command to run the model:
For model flag, you can also use ganimation, but stargan gives better results
python main.py --mode test --data_root ganimation_replicate/datasets/celebA --ckpt_dir [path_to_model] --load_epoch [epoch_num] --model stargan
- Use the following command to run the model:
-
Check the Output
- Find the modified images in the
results
folder.
- Find the modified images in the
-
Reference
- The implementation is based on the GitHub repository: donydchen/ganimation_replicate
-
Ensure that the
path to group image
andpath to clusters
for each face which you plan to edit are available. -
Following the usage of
driver.py
, run. Usage fordriver.py
:
usage: driver.py [-h] group_photo_path
Edit group photo with multiple faces using clusters.
positional arguments:
group_photo_path Path to the group photo
options:
-h, --help show this help message and exit
-
Each face present in the group is shown, and user is given option to choose whether to edit or not. If choosen to edit, provide the
path to cluster
of the corresponding face. And theupper limit
of for the eye blink upto which you want to consider eyes. Rest are filtered out. -
Loop through each face and edit accordingly.
-
Final edited group photo in
edited_group_photo.jpg
.
- Run
patch_blend.py
according to the below usage:
usage: patch_blend.py [-h] base_path eyes_target_path mouth_target_path eyes_landmarks_path mouth_landmarks_path
Patching and Blending
positional arguments:
base_path Path to the base image.
eyes_target_path Path to the eyes target image
mouth_target_path Path to the mouth target image
eyes_landmarks_path Path to the text file containing landmarks of eye
mouth_landmarks_path Path to the text file containing landmarks of mouth
options:
-h, --help show this help message and exit
driver.py
: Usage:
usage: driver.py [-h] group_photo_path
Edit group photo with multiple faces using clusters.
positional arguments:
group_photo_path Path to the group photo
options:
-h, --help show this help message and exit
edit_face.py
: Usage:
usage: edit_face.py [-h] base_image_path cluster_folder_path
Edit base image with single face using cluster corresponding to it.
positional arguments:
base_image_path Path to the base image
cluster_folder_path Path to the folder containing cluster images
options:
-h, --help show this help message and exit
patch_blend.py
: Usage:
usage: patch_blend.py [-h] base_path eyes_target_path mouth_target_path eyes_landmarks_path mouth_landmarks_path
Patching and Blending
positional arguments:
base_path Path to the base image.
eyes_target_path Path to the eyes target image
mouth_target_path Path to the mouth target image
eyes_landmarks_path Path to the text file containing landmarks of eye
mouth_landmarks_path Path to the text file containing landmarks of mouth
options:
-h, --help show this help message and exit
pick_best_filter_eye.py
: Usage:
usage: pick_best_filter_eye.py [-h] [--threshold THRESHOLD] base_image_path cluster_folder_path
Sort the best and filter out the eyes
positional arguments:
base_image_path Path to the base image
cluster_folder_path Path to the folder containing cluster images
options:
-h, --help show this help message and exit
--threshold THRESHOLD
Threshold for eyeBlinkLeft and eyeBlinkRight sum
pick_best_filter_mouth.py
: Usage:
usage: pick_best_filter_mouth.py [-h] [--topK TOPK] base_image_path cluster_folder_path
Sort the best and filter out the eyes
positional arguments:
base_image_path Path to the base image
cluster_folder_path Path to the folder containing cluster images
options:
-h, --help show this help message and exit
--topK TOPK Number of entries in sorted order to sort according to smile scores.
-
eyes.txt
: Contains the manually selected coordinates for extracting the patch of eyes. Coordinates are selected so as to give the best patch for realistic patch and blend later. -
mouth2.txt
: Contains manually selected coordinates for extracting the patch of mouth. Coordinates are selected so as to give the best patch for realistic patch and blend later. -
requirements.txt
: Contains the requirements for running the codes. -
models
: Folder containing the pretrained models for RetinaFace face detection and Mediapipe landmark detector. -
Datasets
: Contains datasets corresponding to different use cases. Each use case contains agroup photo
andclusters of faces
corresponding to faces which we want to edit. -
file_structure.txt
: contains the file structure of current folder for reference. -
models.txt
: contains the link for pretrained models. Make sure -
Datasets.txt
: contains the link for Datasets folder link in caseDatasets
folder is not present.