import datasets import pandas as pd _CITATION = """\ @InProceedings{huggingface:dataset, title = {botox-injections-before-and-after}, author = {TrainingDataPro}, year = {2023} } """ _DESCRIPTION = """\ The dataset consists of photos featuring the same individuals captured before and after botox injections procedure. The dataset contains a diverse range of individuals with various ages, ethnicities and genders. The dataset is useful for evaluation of the effectiveness of botox injections for different skin and face types, face recognition and reidentification tasks. It can be utilised for biometric tasks , in beauty sphere, for medical purposes and e-commerce. """ _NAME = "botox-injections-before-and-after" _HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}" _LICENSE = "" _DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/" class BotoxInjectionsBeforeAndAfter(datasets.GeneratorBasedBuilder): def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=datasets.Features( { "id": datasets.Value("int32"), "before": datasets.Image(), "after": datasets.Image(), } ), supervised_keys=None, homepage=_HOMEPAGE, citation=_CITATION, ) def _split_generators(self, dl_manager): before = dl_manager.download(f"{_DATA}before.tar.gz") after = dl_manager.download(f"{_DATA}after.tar.gz") annotations = dl_manager.download(f"{_DATA}{_NAME}.csv") before = dl_manager.iter_archive(before) after = dl_manager.iter_archive(after) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={ "before": before, "after": after, "annotations": annotations, }, ), ] def _generate_examples(self, before, after, annotations): for idx, ( (before_image_path, before_image), (after_image_path, after_image), ) in enumerate(zip(before, after)): yield idx, { "id": before_image_path.split("/")[-1].split(".")[0], "before": {"path": before_image_path, "bytes": before_image.read()}, "after": {"path": after_image_path, "bytes": after_image.read()}, }