NathanGavenski commited on
Commit
aaff9cc
1 Parent(s): fc8e329

Upload imagetest.py

Browse files
Files changed (1) hide show
  1. imagetest.py +49 -0
imagetest.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+
4
+ _CITATION = ""
5
+
6
+ _DESCRIPTION = "Dataset for training agents with Maze-v0 environment."
7
+
8
+ _HOMEPAGE = "https://huggingface.co/datasets/NathanGavenski/imagetest"
9
+
10
+ _LICENSE = ""
11
+
12
+ _REPO = "https://huggingface.co/datasets/NathanGavenski/imagetest"
13
+
14
+
15
+ class ImageSet(datasets.GeneratorBasedBuilder):
16
+
17
+ def _info(self):
18
+ return datasets.DatasetInfo(
19
+ description=_DESCRIPTION,
20
+ features=datasets.Features({
21
+ "obs": datasets.Value("string"),
22
+ "actions": datasets.Value("int32"),
23
+ "rewards": datasets.Value("float32"),
24
+ "episode_starts": datasets.Value("bool"),
25
+ "maze": datasets.Value("string"),
26
+ "image": datasets.Image()
27
+ }),
28
+ supervised_keys=None,
29
+ homepage=_HOMEPAGE,
30
+ citation=_CITATION,
31
+ )
32
+
33
+ def _make_split_generators(self, dl_manager):
34
+ image_archive = dl_manager.download(f"{_REPO}/resolve/main/images.tar.gz")
35
+ image_iter = dl_manager.iter_archive(image_archive)
36
+ return [
37
+ datasets.SplitGenerator(
38
+ name=datasets.Split.TRAIN,
39
+ gen_kwargs={
40
+ "images": image_iter
41
+ }
42
+ ),
43
+ ]
44
+
45
+ def _generate_examples(self, images):
46
+ for idx, (filepath, image) in enumerate(images):
47
+ yield idx, {
48
+ "image": {"path": filepath, "bytes": image.read()},
49
+ }