File size: 2,422 Bytes
f5f283f |
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 |
import datasets
from datasets.data_files import DataFilesDict
from datasets.packaged_modules.imagefolder.imagefolder import ImageFolder, ImageFolderConfig
logger = datasets.logging.get_logger(__name__)
class GTSRB(ImageFolder):
R"""
DTD dataset for image classification.
"""
BUILDER_CONFIG_CLASS = ImageFolderConfig
BUILDER_CONFIGS = [
ImageFolderConfig(
name="default",
features=("images", "labels"),
data_files=DataFilesDict({split: f"data/{split}.zip" for split in ["train", "test"]}),
)
]
classnames = [
"banded",
"blotchy",
"braided",
"bubbly",
"bumpy",
"chequered",
"cobwebbed",
"cracked",
"crosshatched",
"crystalline",
"dotted",
"fibrous",
"flecked",
"freckled",
"frilly",
"gauzy",
"grid",
"grooved",
"honeycombed",
"interlaced",
"knitted",
"lacelike",
"lined",
"marbled",
"matted",
"meshed",
"paisley",
"perforated",
"pitted",
"pleated",
"polka-dotted",
"porous",
"potholed",
"scaly",
"smeared",
"spiralled",
"sprinkled",
"stained",
"stratified",
"striped",
"studded",
"swirly",
"veined",
"waffled",
"woven",
"wrinkled",
"zigzagged",
]
clip_templates = [
lambda c: f"a photo of a {c} texture.",
lambda c: f"a photo of a {c} pattern.",
lambda c: f"a photo of a {c} thing.",
lambda c: f"a photo of a {c} object.",
lambda c: f"a photo of the {c} texture.",
lambda c: f"a photo of the {c} pattern.",
lambda c: f"a photo of the {c} thing.",
lambda c: f"a photo of the {c} object.",
]
def _info(self):
return datasets.DatasetInfo(
description="DTD dataset for image classification.",
features=datasets.Features(
{
"image": datasets.Image(),
"label": datasets.ClassLabel(names=self.classnames),
}
),
supervised_keys=("image", "label"),
task_templates=[datasets.ImageClassification(image_column="image", label_column="label")],
)
|