ncoop57 commited on
Commit
973e0e8
1 Parent(s): 99f197c

Add hierarchies to dataset

Browse files
captions_images.zip → captions_hierarchies_images.zip RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:850703b04c0723b698e8c72ee3bb8540d45f34632cd49a81014dac4aa390b4d8
3
- size 5850078360
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06be80e71cfeedcf22f20bed55a276587fc5831605fae37df9cc829ba18dba5e
3
+ size 6478261393
rico_captions.py CHANGED
@@ -50,7 +50,7 @@ _LICENSE = ""
50
  # The HuggingFace dataset library don't host the datasets but only point to the original files
51
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
52
  _DATA_URLs = {
53
- "screenshots_captions": "https://huggingface.co/datasets/ncoop57/rico_captions/resolve/main/captions_images.zip",
54
  }
55
 
56
 
@@ -86,8 +86,9 @@ class RicoDataset(datasets.GeneratorBasedBuilder):
86
  features = datasets.Features(
87
  {
88
  "screenshot_path": datasets.Value("string"),
89
- # This is a JSON obj, but will be coded as a string
90
  "caption": datasets.Value("string"),
 
 
91
  }
92
  )
93
 
@@ -131,11 +132,14 @@ class RicoDataset(datasets.GeneratorBasedBuilder):
131
  # The `key` is here for legacy reason (tfds) and is not important in itself.
132
 
133
  screen_glob = sorted(glob.glob(os.path.join(root_dir, "**/*.jpg")))
 
134
  caption_glob = sorted(glob.glob(os.path.join(root_dir, "**/*.txt")))
135
- for idx, (screen_filepath, caption_filepath) in enumerate(
136
- zip(screen_glob, caption_glob)
137
  ):
 
 
138
  with open(caption_filepath, "r", encoding="utf-8") as f:
139
  caption = f.read()
140
 
141
- yield idx, {"screenshot_path": screen_filepath, "caption": caption}
 
50
  # The HuggingFace dataset library don't host the datasets but only point to the original files
51
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
52
  _DATA_URLs = {
53
+ "screenshots_captions": "https://huggingface.co/datasets/ncoop57/rico_captions/resolve/main/captions_hierarchies_images.zip",
54
  }
55
 
56
 
 
86
  features = datasets.Features(
87
  {
88
  "screenshot_path": datasets.Value("string"),
 
89
  "caption": datasets.Value("string"),
90
+ # This is a JSON obj, but will be coded as a string
91
+ "hierarchy": datasets.Value("string"),
92
  }
93
  )
94
 
 
132
  # The `key` is here for legacy reason (tfds) and is not important in itself.
133
 
134
  screen_glob = sorted(glob.glob(os.path.join(root_dir, "**/*.jpg")))
135
+ hierarchy_glob = sorted(glob.glob(os.path.join(root_dir, "**/*.json")))
136
  caption_glob = sorted(glob.glob(os.path.join(root_dir, "**/*.txt")))
137
+ for idx, (screen_filepath, hierarchy_filepath, caption_filepath) in enumerate(
138
+ zip(screen_glob, hierarchy_glob, caption_glob)
139
  ):
140
+ with open(hierarchy_filepath, "r", encoding="utf-8") as f:
141
+ hierarchy = f.read()
142
  with open(caption_filepath, "r", encoding="utf-8") as f:
143
  caption = f.read()
144
 
145
+ yield idx, {"screenshot_path": screen_filepath, "hierarchy": hierarchy, "caption": caption}