File size: 4,604 Bytes
57e7a6e | 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | ---
task_categories:
- image-feature-extraction
- image-classification
tags:
- face_recognition
pretty_name: Glint360K
size_categories:
- 10M<n<100M
---
# Dataset Card for Glint360K
Citiation by [InsightFace Repository](https://github.com/deepinsight/insightface/tree/master/recognition/partial_fc)
> We clean, merge, and release the largest and cleanest face recognition dataset Glint360K, which contains 17091657 images of 360232 individuals. By employing the Patial FC training strategy, baseline models trained on Glint360K can easily achieve state-of-the-art performance. Detailed evaluation results on the large-scale test set (e.g. IFRT, IJB-C and Megaface) are as follows:
## Dataset Details
### Dataset Description
- **Curated by:** [InsightFace](https://insightface.ai/)
- **Shared by:** [Academic Torrents](https://academictorrents.com/details/e5f46ee502b9e76da8cc3a0e4f7c17e4000c7b1e)
- **License:** The license isn't clearly stated, but InsightFace says it's for "available for non-commercial research purposes only."
### Dataset Sources
<!-- Provide the basic links for the dataset. -->
- **Repository:** [deepinsight/insightface](https://github.com/deepinsight/insightface/tree/master/recognition/partial_fc)
- **Paper:** [https://arxiv.org/abs/2010.05222](https://arxiv.org/abs/2010.05222)
## Uses
It is used for training face recognition models such as RetinaFace, FaceNet, etc.
## Dataset Structure
It adopts the WebDataset format, with images and metadata (class: cls) stored in tar files split every 16GB.
## Dataset Creation
### Source Data
Get Data from torrent and concatenate divided tar files.
Next, extract the tar file.
Finally, the directory structure is as follows:
```sh
.\glint360k\
├── agedb_30.bin
├── calfw.bin
├── cfp_ff.bin
├── cfp_fp.bin
├── cplfw.bin
├── lfw.bin
├── train.idx
├── train.rec
└── vgg2_fp.bin
```
#### Data Collection and Processing
use train.rec and train.idx.
Save the following script and run it with `uv run script.py`.
```py
# /// script
# dependencies = [
# "mxnet",
# "numpy=<1.24",
# "Pillow",
# "tqdm",
# ]
# requires-python = "==3.10.*"
# ///
import mxnet
import os
from PIL import Image
from tqdm import tqdm
glint360k_root = "/path/to/glint360k"
idx_path = os.path.join(glint360k_root, "train.idx")
rec_path = os.path.join(glint360k_root, "train.rec")
export_path = "/path/to/glint360k_export"
imgrec = mxnet.recordio.MXIndexedRecordIO(idx_path, rec_path, 'r')
print(f"Total records to process: {imgrec.keys.__len__()}")
for i in tqdm(imgrec.keys):
header, content = mxnet.recordio.unpack(imgrec.read_idx(i))
label = int(header.label if isinstance(header.label, (int, float)) else header.label[0])
label_dir = os.path.join(export_path, str(label))
if not os.path.exists(label_dir):
os.makedirs(label_dir, exist_ok=True)
img = mxnet.image.imdecode(content).asnumpy()
img = Image.fromarray(img.astype('uint8'))
img_save_path = os.path.join(label_dir, f'{i}.jpg')
img.save(img_save_path, quality=93)
print("Export complete.")
```
This converts Glint360K to PyTorch ImageFolder format. To convert it to WebDataset format, follow the steps below.
```py
# /// script
# dependencies = [
# "webdataset",
# "torchvision",
# "tqdm",
# "torch",
# ]
# requires-python = ">=3.9"
# ///
import os
import webdataset
from torchvision import datasets
from tqdm import tqdm
imagefolder_path = "/path/to/glint360k_export"
output_prefix = "/path/to/glint360k_WebDataset/glint360k_train"
dataset = datasets.ImageFolder(
root=imagefolder_path,
transform=None
)
with webdataset.ShardWriter(f"{output_prefix}-%02d.tar", maxsize=1.1e+10, maxcount=float('inf')) as writer:
for image_path, label in tqdm(dataset.imgs, desc="Converting to WebDataset"):
with open(image_path, "rb") as image_file:
image_bytes = image_file.read()
basename = os.path.splitext(os.path.basename(image_path))[0]
sample = {
"__key__": basename,
"jpg": image_bytes,
"cls": str(label)
}
writer.write(sample)
print("Conversion to WebDataset format complete.")
```
#### Personal and Sensitive Information
This dataset collects human faces and contains personally identifiable information. Please handle it with care.
## Bias, Risks, and Limitations
The dataset may not consider the diversity of race, gender, age distribution, and shooting environments in the included facial images. This may lead to biases against specific groups. |