Datasets:
Tasks:
Image Classification
Modalities:
Image
Formats:
parquet
Languages:
English
Size:
1K - 10K
Tags:
veterinary
cell classification
animal
endangered species
microscopy
microscopic biological image
License:
File size: 2,235 Bytes
29fe721 |
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 |
from pathlib import Path
import datasets
_VERSION = "0.1.0"
_CITATION = ""
_DESCRIPTION = ""
_HOMEPAGE = ""
_LICENSE = ""
_FEATURES = datasets.Features(
{
"image": datasets.Image(mode="RGB"),
"label": datasets.ClassLabel(
names=[
"Basophil",
"Eosinophil",
"Lymphocyte",
"Monocyte",
"Neutrophil",
]
),
}
)
Cropped = datasets.Split("cropped")
Augmented = datasets.Split("augmented")
Original = datasets.Split("original")
class WartyPig(datasets.GeneratorBasedBuilder):
DEFAULT_WRITER_BATCH_SIZE = 1000
def _info(self):
return datasets.DatasetInfo(
features=_FEATURES,
supervised_keys=None,
description=_DESCRIPTION,
homepage=_HOMEPAGE,
license=_LICENSE,
version=_VERSION,
citation=_CITATION,
)
def _split_generators(self, dl_manager: datasets.DownloadManager):
original_images = sorted(list(Path("Original").rglob("*.jpg")))
augmented_images = sorted(list(Path("Augmented images").rglob("*.jpg")))
cropped_images = sorted(list(Path("Cropped Classified").rglob("*.jpg")))
return [
datasets.SplitGenerator(
name=Original,
gen_kwargs={"images": original_images, "no_label": True},
),
datasets.SplitGenerator(
name=Cropped,
gen_kwargs={"images": cropped_images},
),
datasets.SplitGenerator(
name=Augmented,
gen_kwargs={"images": augmented_images},
),
]
def _generate_examples(self, images: list[Path], no_label=False):
for i, image in enumerate(images):
if no_label:
yield (
i,
{
"image": str(image),
},
)
else:
yield (
i,
{
"image": str(image),
"label": image.parent.name,
},
)
|