movingthings / movingthings.py
Rivoks's picture
Upload movingthings.py
9c0f414
raw
history blame
2.64 kB
import os
import datasets
from datasets.tasks import ImageClassification
"""MovingThings: The moving things dataset."""
_HOMEPAGE = "https://github.com/Rivoks"
_CITATION = """\
@ONLINE {beansdata,
author="Rivoks",
title="Moving things dataset",
month="August",
year="2023",
url="https://github.com/Rivoks"
}
"""
_DESCRIPTION = """\
MovingThings is a dataset of images of moving things programmaticaly generated with Stable Diffusion (v1.5).
It consists of 5 self movement class: roll, flow, zigzag, walk and linear.
Data was annoted by the script that generates the images with the prompt passed to Stable Diffusion.
"""
_URLS = {
"train": "coming soon...",
"validation": "coming soon...",
"test": "coming soon...",
}
_NAMES = ["roll", "flow", "zigzag", "walk", "linear"]
class Beans(datasets.GeneratorBasedBuilder):
"""Beans plant leaf images dataset."""
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"text": datasets.Value("string"),
"image": datasets.Image(),
"labels": datasets.features.ClassLabel(names=_NAMES),
}
),
supervised_keys=("image", "labels"),
homepage=_HOMEPAGE,
citation=_CITATION,
task_templates=[ImageClassification(image_column="image", label_column="labels")],
)
def _split_generators(self, dl_manager):
data_files = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"files": dl_manager.iter_files([data_files["train"]]),
},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={
"files": dl_manager.iter_files([data_files["validation"]]),
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"files": dl_manager.iter_files([data_files["test"]]),
},
),
]
def _generate_examples(self, files):
for i, path in enumerate(files):
file_name = os.path.basename(path)
if file_name.endswith(".jpg"):
yield i, {
"text": path,
"image": path,
"labels": os.path.basename(os.path.dirname(path)).lower(),
}