refactor: data and script
Browse files- FaceSegmentation.py +76 -0
- Face_Segmentation.pdf +0 -0
- Face_Segmentation_20.csv +0 -21
- data/FaceSegmentation.csv +21 -0
- img/0.jpg → data/images.tar.gz +2 -2
- img/11.jpg → data/masks.tar.gz +2 -2
- img/1.jpg +0 -3
- img/10.jpg +0 -3
- img/12.jpg +0 -3
- img/13.jpg +0 -3
- img/14.jpg +0 -3
- img/15.jpg +0 -3
- img/16.jpg +0 -3
- img/17.jpg +0 -3
- img/18.jpg +0 -3
- img/19.jpg +0 -3
- img/2.jpg +0 -3
- img/3.jpg +0 -3
- img/4.jpg +0 -3
- img/5.jpg +0 -3
- img/6.jpg +0 -3
- img/7.jpg +0 -3
- img/8.jpg +0 -3
- img/9.jpg +0 -3
- masks/0.jpg +0 -3
- masks/1.jpg +0 -3
- masks/10.jpg +0 -3
- masks/11.jpg +0 -3
- masks/12.jpg +0 -3
- masks/13.jpg +0 -3
- masks/14.jpg +0 -3
- masks/15.jpg +0 -3
- masks/16.jpg +0 -3
- masks/17.jpg +0 -3
- masks/18.jpg +0 -3
- masks/19.jpg +0 -3
- masks/2.jpg +0 -3
- masks/3.jpg +0 -3
- masks/4.jpg +0 -3
- masks/5.jpg +0 -3
- masks/6.jpg +0 -3
- masks/7.jpg +0 -3
- masks/8.jpg +0 -3
- masks/9.jpg +0 -3
FaceSegmentation.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
_CITATION = """\
|
5 |
+
@InProceedings{huggingface:dataset,
|
6 |
+
title = {FaceSegmentation},
|
7 |
+
author = {TrainingDataPro},
|
8 |
+
year = {2023}
|
9 |
+
}
|
10 |
+
"""
|
11 |
+
|
12 |
+
_DESCRIPTION = """\
|
13 |
+
An example of a dataset that we've collected for a photo edit App.
|
14 |
+
The dataset includes 20 selfies of people (man and women)
|
15 |
+
in segmentation masks and their visualisations.
|
16 |
+
"""
|
17 |
+
_NAME = 'FaceSegmentation'
|
18 |
+
|
19 |
+
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
|
20 |
+
|
21 |
+
_LICENSE = ""
|
22 |
+
|
23 |
+
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
|
24 |
+
|
25 |
+
|
26 |
+
class FaceSegmentation(datasets.GeneratorBasedBuilder):
|
27 |
+
"""Small sample of image-text pairs"""
|
28 |
+
|
29 |
+
def _info(self):
|
30 |
+
return datasets.DatasetInfo(
|
31 |
+
description=_DESCRIPTION,
|
32 |
+
features=datasets.Features({
|
33 |
+
'image': datasets.Image(),
|
34 |
+
'mask': datasets.Image(),
|
35 |
+
'id': datasets.Value('string'),
|
36 |
+
'gender': datasets.Value('string'),
|
37 |
+
'age': datasets.Value('int8')
|
38 |
+
}),
|
39 |
+
supervised_keys=None,
|
40 |
+
homepage=_HOMEPAGE,
|
41 |
+
citation=_CITATION,
|
42 |
+
)
|
43 |
+
|
44 |
+
def _split_generators(self, dl_manager):
|
45 |
+
images = dl_manager.download(f"{_DATA}images.tar.gz")
|
46 |
+
masks = dl_manager.download(f"{_DATA}masks.tar.gz")
|
47 |
+
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
|
48 |
+
images = dl_manager.iter_archive(images)
|
49 |
+
masks = dl_manager.iter_archive(masks)
|
50 |
+
return [
|
51 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
52 |
+
gen_kwargs={
|
53 |
+
"images": images,
|
54 |
+
'masks': masks,
|
55 |
+
'annotations': annotations
|
56 |
+
}),
|
57 |
+
]
|
58 |
+
|
59 |
+
def _generate_examples(self, images, masks, annotations):
|
60 |
+
annotations_df = pd.read_csv(annotations, sep=';')
|
61 |
+
|
62 |
+
for idx, ((image_path, image),
|
63 |
+
(mask_path, mask)) in enumerate(zip(images, masks)):
|
64 |
+
yield idx, {
|
65 |
+
"image": {
|
66 |
+
"path": image_path,
|
67 |
+
"bytes": image.read()
|
68 |
+
},
|
69 |
+
"mask": {
|
70 |
+
"path": mask_path,
|
71 |
+
"bytes": mask.read()
|
72 |
+
},
|
73 |
+
'id': annotations_df['id'].iloc[idx],
|
74 |
+
'gender': annotations_df['gender'].iloc[idx],
|
75 |
+
'age': annotations_df['age'].iloc[idx]
|
76 |
+
}
|
Face_Segmentation.pdf
ADDED
Binary file (124 kB). View file
|
|
Face_Segmentation_20.csv
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
img_name,masks_name
|
2 |
-
img/0.jpg,masks/0.jpg
|
3 |
-
img/1.jpg,masks/1.jpg
|
4 |
-
img/2.jpg,masks/2.jpg
|
5 |
-
img/3.jpg,masks/3.jpg
|
6 |
-
img/4.jpg,masks/4.jpg
|
7 |
-
img/5.jpg,masks/5.jpg
|
8 |
-
img/6.jpg,masks/6.jpg
|
9 |
-
img/7.jpg,masks/7.jpg
|
10 |
-
img/8.jpg,masks/8.jpg
|
11 |
-
img/9.jpg,masks/9.jpg
|
12 |
-
img/10.jpg,masks/10.jpg
|
13 |
-
img/11.jpg,masks/11.jpg
|
14 |
-
img/12.jpg,masks/12.jpg
|
15 |
-
img/13.jpg,masks/13.jpg
|
16 |
-
img/14.jpg,masks/14.jpg
|
17 |
-
img/15.jpg,masks/15.jpg
|
18 |
-
img/16.jpg,masks/16.jpg
|
19 |
-
img/17.jpg,masks/17.jpg
|
20 |
-
img/18.jpg,masks/18.jpg
|
21 |
-
img/19.jpg,masks/19.jpg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/FaceSegmentation.csv
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
id;gender;age;images;masks
|
2 |
+
060002_4_028450;FEMALE;30;0.jpg;0.jpg
|
3 |
+
060003_4_028451;FEMALE;65;1.jpg;1.jpg
|
4 |
+
060004_4_028452;MALE;31;2.jpg;2.jpg
|
5 |
+
060005_4_023834;FEMALE;33;3.jpg;3.jpg
|
6 |
+
060006_4_015021;FEMALE;39;4.jpg;4.jpg
|
7 |
+
060009_4_019350;FEMALE;21;5.jpg;5.jpg
|
8 |
+
060012_4_020004;MALE;27;6.jpg;6.jpg
|
9 |
+
060013_4_014380;MALE;34;7.jpg;7.jpg
|
10 |
+
060014_4_016695;MALE;43;8.jpg;8.jpg
|
11 |
+
060019_4_028457;MALE;33;9.jpg;9.jpg
|
12 |
+
060020_3_024801;NONE;28;10.jpg;10.jpg
|
13 |
+
060027_4_025986;FEMALE;36;11.jpg;11.jpg
|
14 |
+
060028_4_022580;NONE;25;12.jpg;12.jpg
|
15 |
+
060032_4_027166;MALE;28;13.jpg;13.jpg
|
16 |
+
060033_4_028462;MALE;19;14.jpg;14.jpg
|
17 |
+
060037_4_028465;FEMALE;23;15.jpg;15.jpg
|
18 |
+
060038_4_028466;MALE;19;16.jpg;16.jpg
|
19 |
+
060040_4_015000;FEMALE;39;17.jpg;17.jpg
|
20 |
+
060043_4_028470;FEMALE;19;18.jpg;18.jpg
|
21 |
+
060047_4_027403;MALE;25;19.jpg;19.jpg
|
img/0.jpg → data/images.tar.gz
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:459515c556e6d0ab1f1cf0f3f03d593e5c61905877abd9997076e51e44b05152
|
3 |
+
size 43055161
|
img/11.jpg → data/masks.tar.gz
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f355f1f7e3ac9807c6adc99b2eddde8e76bf06b2f0f4e851c4f494986cd9ffd9
|
3 |
+
size 1038283
|
img/1.jpg
DELETED
Git LFS Details
|
img/10.jpg
DELETED
Git LFS Details
|
img/12.jpg
DELETED
Git LFS Details
|
img/13.jpg
DELETED
Git LFS Details
|
img/14.jpg
DELETED
Git LFS Details
|
img/15.jpg
DELETED
Git LFS Details
|
img/16.jpg
DELETED
Git LFS Details
|
img/17.jpg
DELETED
Git LFS Details
|
img/18.jpg
DELETED
Git LFS Details
|
img/19.jpg
DELETED
Git LFS Details
|
img/2.jpg
DELETED
Git LFS Details
|
img/3.jpg
DELETED
Git LFS Details
|
img/4.jpg
DELETED
Git LFS Details
|
img/5.jpg
DELETED
Git LFS Details
|
img/6.jpg
DELETED
Git LFS Details
|
img/7.jpg
DELETED
Git LFS Details
|
img/8.jpg
DELETED
Git LFS Details
|
img/9.jpg
DELETED
Git LFS Details
|
masks/0.jpg
DELETED
Git LFS Details
|
masks/1.jpg
DELETED
Git LFS Details
|
masks/10.jpg
DELETED
Git LFS Details
|
masks/11.jpg
DELETED
Git LFS Details
|
masks/12.jpg
DELETED
Git LFS Details
|
masks/13.jpg
DELETED
Git LFS Details
|
masks/14.jpg
DELETED
Git LFS Details
|
masks/15.jpg
DELETED
Git LFS Details
|
masks/16.jpg
DELETED
Git LFS Details
|
masks/17.jpg
DELETED
Git LFS Details
|
masks/18.jpg
DELETED
Git LFS Details
|
masks/19.jpg
DELETED
Git LFS Details
|
masks/2.jpg
DELETED
Git LFS Details
|
masks/3.jpg
DELETED
Git LFS Details
|
masks/4.jpg
DELETED
Git LFS Details
|
masks/5.jpg
DELETED
Git LFS Details
|
masks/6.jpg
DELETED
Git LFS Details
|
masks/7.jpg
DELETED
Git LFS Details
|
masks/8.jpg
DELETED
Git LFS Details
|
masks/9.jpg
DELETED
Git LFS Details
|