File size: 2,654 Bytes
a8c1b6c
 
a578cda
a8c1b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348d1a9
a8c1b6c
 
 
 
 
 
 
 
 
 
 
348d1a9
a8c1b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# 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=0 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=0 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.