File size: 8,222 Bytes
e86b08c 22f23a4 e86b08c 441df6b e86b08c 441df6b e86b08c |
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
import json
from pathlib import Path
import datasets
import numpy as np
import pandas as pd
import PIL.Image
import PIL.ImageOps
_CITATION = """\
@InProceedings{huggingface:dataset,
title = {body-measurements-dataset},
author = {TrainingDataPro},
year = {2023}
}
"""
_DESCRIPTION = """\
The dataset consists of a compilation of people's photos along with their
corresponding body measurements. It is designed to provide information and
insights into the physical appearances and body characteristics of individuals.
The dataset includes a diverse range of subjects representing different age
groups, genders, and ethnicities.
The photos are captured in a standardized manner, depicting individuals in a
front and side positions.
The images aim to capture the subjects' physical appearance using appropriate
lighting and angles that showcase their body proportions accurately.
The dataset serves various purposes, including:
- research projects
- body measurement analysis
- fashion or apparel industry applications
- fitness and wellness studies
- anthropometric studies for ergonomic design in various fields
"""
_NAME = 'body-measurements-dataset'
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
_LICENSE = "cc-by-nc-nd-4.0"
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
class BodyMeasurementsDataset(datasets.GeneratorBasedBuilder):
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features({
'front_img': datasets.Image(),
'selfie_img': datasets.Image(),
'side_img': datasets.Image(),
"arm_circumference_cm": datasets.Value('string'),
"arm_length_cm": datasets.Value('string'),
"back_build_cm": datasets.Value('string'),
"calf_circumference_cm": datasets.Value('string'),
"chest_circumference_cm": datasets.Value('string'),
"crotch_height_cm": datasets.Value('string'),
"front_build_cm": datasets.Value('string'),
"hips_circumference_cm": datasets.Value('string'),
"leg_length_cm": datasets.Value('string'),
"neck_circumference_cm": datasets.Value('string'),
"neck_pelvis_length_front_cm": datasets.Value('string'),
"neck_waist_length_back_cm": datasets.Value('string'),
"neck_waist_length_front_cm": datasets.Value('string'),
"pelvis_circumference_cm": datasets.Value('string'),
"shoulder_length_cm": datasets.Value('string'),
"shoulder_width_cm": datasets.Value('string'),
"thigh_circumference_cm": datasets.Value('string'),
"under_chest_circumference_cm": datasets.Value('string'),
"upper_arm_length_cm": datasets.Value('string'),
"waist_circumference_cm": datasets.Value('string'),
"height": datasets.Value('string'),
"weight": datasets.Value('string'),
"age": datasets.Value('string'),
"gender": datasets.Value('string'),
"race": datasets.Value('string'),
"profession": datasets.Value('string'),
"arm_circumference": datasets.Image(),
"arm_length": datasets.Image(),
"back_build": datasets.Image(),
"calf_circumference": datasets.Image(),
"chest_circumference": datasets.Image(),
"crotch_height": datasets.Image(),
"front_build": datasets.Image(),
"hips_circumference": datasets.Image(),
"leg_length": datasets.Image(),
"neck_circumference": datasets.Image(),
"neck_pelvis_length_front": datasets.Image(),
"neck_waist_length_back": datasets.Image(),
"neck_waist_length_front": datasets.Image(),
"pelvis_circumference": datasets.Image(),
"shoulder_length": datasets.Image(),
"shoulder_width": datasets.Image(),
"thigh_circumference": datasets.Image(),
"under_chest_circumference": datasets.Image(),
"upper_arm_length": datasets.Image(),
"waist_circumference": datasets.Image()
}),
supervised_keys=None,
homepage=_HOMEPAGE,
citation=_CITATION,
license=_LICENSE)
def _split_generators(self, dl_manager):
files = dl_manager.download_and_extract(f"{_DATA}files.zip")
proofs = dl_manager.download_and_extract(f"{_DATA}proofs.zip")
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
files = dl_manager.iter_files(files)
proofs = dl_manager.iter_files(proofs)
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN,
gen_kwargs={
"files": files,
'proofs': proofs,
'annotations': annotations
}),
]
def _generate_examples(self, files, proofs, annotations):
files = list(files)
files = [files[i:i + 4] for i in range(0, len(files), 4)]
proofs = list(proofs)
proofs = [proofs[i:i + 20] for i in range(0, len(proofs), 20)]
for idx, (files_dir, proofs_dir) in enumerate(zip(files, proofs)):
data = {}
for file in files_dir:
if 'front_img' in file:
data['front_img'] = file
elif 'selfie_img' in file:
data['selfie_img'] = file
elif 'side_img' in file:
data['side_img'] = file
elif 'measurements' in file:
with open(file) as f:
data.update(json.load(f))
for proof in proofs_dir:
if "arm_circumference" in proof:
data['arm_circumference'] = proof
elif 'upper_arm_length' in proof:
data['upper_arm_length'] = proof
elif 'arm_length' in proof:
data['arm_length'] = proof
elif 'back_build' in proof:
data['back_build'] = proof
elif 'calf_circumference' in proof:
data['calf_circumference'] = proof
elif 'under_chest_circumference' in proof:
data['under_chest_circumference'] = proof
elif 'chest_circumference' in proof:
data['chest_circumference'] = proof
elif 'crotch_height' in proof:
data['crotch_height'] = proof
elif 'front_build' in proof:
data['front_build'] = proof
elif 'hips_circumference' in proof:
data['hips_circumference'] = proof
elif 'leg_length' in proof:
data['leg_length'] = proof
elif 'neck_circumference' in proof:
data['neck_circumference'] = proof
elif 'neck_pelvis_length_front' in proof:
data['neck_pelvis_length_front'] = proof
elif 'neck_waist_length_back' in proof:
data['neck_waist_length_back'] = proof
elif 'neck_waist_length_front' in proof:
data['neck_waist_length_front'] = proof
elif 'pelvis_circumference' in proof:
data['pelvis_circumference'] = proof
elif 'shoulder_length' in proof:
data['shoulder_length'] = proof
elif 'shoulder_width' in proof:
data['shoulder_width'] = proof
elif 'thigh_circumference' in proof:
data['thigh_circumference'] = proof
elif 'waist_circumference' in proof:
data['waist_circumference'] = proof
yield idx, data
|