Rivoks commited on
Commit
d98639a
·
1 Parent(s): 408631f

Upload movingthings.py

Browse files
Files changed (1) hide show
  1. movingthings.py +85 -0
movingthings.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import datasets
3
+ from datasets.tasks import ImageClassification
4
+
5
+ """MovingThings: The moving things dataset."""
6
+
7
+
8
+ _HOMEPAGE = "https://github.com/Rivoks"
9
+
10
+ _CITATION = """\
11
+ @ONLINE {beansdata,
12
+ author="Rivoks",
13
+ title="Moving things dataset",
14
+ month="August",
15
+ year="2023",
16
+ url="https://github.com/Rivoks"
17
+ }
18
+ """
19
+
20
+ _DESCRIPTION = """\
21
+ MovingThings is a dataset of images of moving things programmaticaly generated with Stable Diffusion (v1.5).
22
+ It consists of 5 self movement class: roll, flow, zigzag, walk and linear.
23
+ Data was annoted by the script that generates the images with the prompt passed to Stable Diffusion.
24
+ """
25
+
26
+ _URLS = {
27
+ "train": "coming soon...",
28
+ "validation": "coming soon...",
29
+ "test": "coming soon...",
30
+ }
31
+
32
+ _NAMES = ["roll", "flow", "zigzag", "walk", "linear"]
33
+
34
+
35
+ class Beans(datasets.GeneratorBasedBuilder):
36
+ """Beans plant leaf images dataset."""
37
+
38
+ def _info(self):
39
+ return datasets.DatasetInfo(
40
+ description=_DESCRIPTION,
41
+ features=datasets.Features(
42
+ {
43
+ "image_file_path": datasets.Value("string"),
44
+ "image": datasets.Image(),
45
+ "labels": datasets.features.ClassLabel(names=_NAMES),
46
+ }
47
+ ),
48
+ supervised_keys=("image", "labels"),
49
+ homepage=_HOMEPAGE,
50
+ citation=_CITATION,
51
+ task_templates=[ImageClassification(image_column="image", label_column="labels")],
52
+ )
53
+
54
+ def _split_generators(self, dl_manager):
55
+ data_files = dl_manager.download_and_extract(_URLS)
56
+ return [
57
+ datasets.SplitGenerator(
58
+ name=datasets.Split.TRAIN,
59
+ gen_kwargs={
60
+ "files": dl_manager.iter_files([data_files["train"]]),
61
+ },
62
+ ),
63
+ datasets.SplitGenerator(
64
+ name=datasets.Split.VALIDATION,
65
+ gen_kwargs={
66
+ "files": dl_manager.iter_files([data_files["validation"]]),
67
+ },
68
+ ),
69
+ datasets.SplitGenerator(
70
+ name=datasets.Split.TEST,
71
+ gen_kwargs={
72
+ "files": dl_manager.iter_files([data_files["test"]]),
73
+ },
74
+ ),
75
+ ]
76
+
77
+ def _generate_examples(self, files):
78
+ for i, path in enumerate(files):
79
+ file_name = os.path.basename(path)
80
+ if file_name.endswith(".jpg"):
81
+ yield i, {
82
+ "image_file_path": path,
83
+ "image": path,
84
+ "labels": os.path.basename(os.path.dirname(path)).lower(),
85
+ }