Filtered-Laion-Face / README.md
csyxwei's picture
upload data
a8c1b6c
|
raw
history blame
2.65 kB
# Filtered Laion Face
---
This repository provides the pipeline to construt the face augmneted dataset used in [MasterWeaver](https://arxiv.org/abs/2405.05806). The dataset contains ~160k text-image pairs from the [LAION-Face dataset](https://github.com/FacePerceiver/LAION-Face/). We have generated the corresponding captions using BLIP2 and created several attribute-augmented faces.
## Steps to Construct the Dataset
### 1. Clone the Repository
```bash
git clone https://huggingface.co/datasets/csyxwei/Filtered-Laion-Face
cd Filtered-Laion-Face
```
### 2. Download images
We have provided links of filerted laion face images in `filtered_laion_faces.parquet`. You can download the original image using [img2dataset tool](https://github.com/rom1504/img2dataset/blob/main/dataset_examples/laion-face.md):
```bash
pip install img2dataset
img2dataset --url_list ./filtered_laion_faces.parquet --input_format "parquet" \
--url_col "URL" --caption_col "TEXT" --output_format files \
--output_folder ./filtered_laion_faces/images --processes_count 16 --thread_count 128 --resize_mode no \
--save_additional_columns '["NSFW","similarity","LICENSE","SAMPLE_ID"]'
```
The downloaded images will be saved in the `./filtered_laion_faces/images` directory.
### 3. Process Laion Face Images
Next, use dlib and a face parsing model to crop and align the downloaded images:
```bash
cd data_scripts
CUDA_VISIBLE_DEVICES=4 python process_images.py
```
### 4. Augment the Face Images
After processing, construct the augmented faces using [DeltaEdit](https://github.com/Yueming6568/DeltaEdit). Refer to its [official repository](https://github.com/Yueming6568/DeltaEdit) for configuration details.
Then, run the following command::
```bash
cd ../delta_edit
CUDA_VISIBLE_DEVICES=7 python scripts/inference_laion.py \
--image_dir "../filtered_laion_faces/images_cropped_face" \
--save_dir "../filtered_laion_faces/images_cropped_face_aug/" \
--target ""
```
The final directory structure will be as follows:
```
filtered_laion_faces
└─ images
└─ images_cropped
└─ images_cropped_face
└─ images_cropped_face_mask
└─ images_cropped_face_aug
└─ captions
```
## Acknowledgements
This dataset is built upon the [Laion Face dataset](https://github.com/FacePerceiver/LAION-Face/) with tools from [FFHQ](https://github.com/NVlabs/ffhq-dataset), [face-parsing.PyTorch](https://github.com/zllrunning/face-parsing.PyTorch), and [DeltaEdit](https://github.com/Yueming6568/DeltaEdit/). We thank the authors for sharing the datasets and code.