|
import datasets |
|
from description import description |
|
|
|
_DESCRIPTION ="""Fetus Brain Abnormalities Images dataset""" |
|
|
|
_CITATION = """ |
|
@misc{ |
|
fetal-brain-abnormalities-ultrasound_dataset, |
|
title = { Fetal Brain Abnormalities Ultrasound Dataset }, |
|
type = { Open Source Dataset }, |
|
author = { Hritwik Trivedi }, |
|
howpublished = { \url{ https://universe.roboflow.com/hritwik-trivedi-gkgrv/fetal-brain-abnormalities-ultrasound } }, |
|
url = { https://universe.roboflow.com/hritwik-trivedi-gkgrv/fetal-brain-abnormalities-ultrasound }, |
|
journal = { Roboflow Universe }, |
|
publisher = { Roboflow }, |
|
year = { 2023 }, |
|
month = { oct }, |
|
note = { visited on 2024-03-12 }, |
|
} |
|
""" |
|
|
|
_URL = "https://huggingface.co/datasets/KBayoud/roboflow-fetus-head-abnormalities/resolve/main/images.tar.gz" |
|
|
|
class FetusBrain(datasets.GeneratorBasedBuilder): |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
'text': datasets.Value('string'), |
|
'image': datasets.Image(), |
|
} |
|
), |
|
|
|
supervised_keys=None, |
|
homepage='https://huggingface.co/datasets/KBayoud/roboflow-fetus-head-abnormalities', |
|
citation=_CITATION, |
|
) |
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
path = dl_manager.download_and_extract(_URL) |
|
image_iters = dl_manager.iter_archive(path) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"images": image_iters |
|
} |
|
), |
|
] |
|
|
|
def _generate_examples(self, images): |
|
idx = 0 |
|
|
|
for filepath, image in images: |
|
yield idx, { |
|
'image': {'path': filepath, 'bytes': image.read()}, |
|
'text': description[idx] |
|
} |
|
idx += 1 |