Datasets:
michelecafagna26
commited on
Commit
·
8ff22c4
1
Parent(s):
024c320
removed loading script
Browse files- data/annotations/test.jsonl +0 -0
- data/{annotations/train.jsonl → test.zip} +2 -2
- data/{images.tar.gz → train.zip} +2 -2
- hl.py +0 -131
data/annotations/test.jsonl
DELETED
The diff for this file is too large to render.
See raw diff
|
|
data/{annotations/train.jsonl → test.zip}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:59407de4abc93a1c5a1d2f39dd298a21e46c05af627a14c6b0e905c223b301d3
|
3 |
+
size 245399580
|
data/{images.tar.gz → train.zip}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:172a3be2ecc747577ab76dc77986cf4f1c520d07ed984ce591be81224e496c57
|
3 |
+
size 2200080694
|
hl.py
DELETED
@@ -1,131 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
3 |
-
# you may not use this file except in compliance with the License.
|
4 |
-
# You may obtain a copy of the License at
|
5 |
-
#
|
6 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
7 |
-
#
|
8 |
-
# Unless required by applicable law or agreed to in writing, software
|
9 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
10 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11 |
-
# See the License for the specific language governing permissions and
|
12 |
-
# limitations under the License.
|
13 |
-
"""High-Level dataset."""
|
14 |
-
|
15 |
-
|
16 |
-
import json
|
17 |
-
from pathlib import Path
|
18 |
-
|
19 |
-
import datasets
|
20 |
-
|
21 |
-
|
22 |
-
_CITATION = """\
|
23 |
-
@inproceedings{Cafagna2023HLDG,
|
24 |
-
title={HL Dataset: Grounding High-Level Linguistic Concepts in Vision},
|
25 |
-
author={Michele Cafagna and Kees van Deemter and Albert Gatt},
|
26 |
-
year={2023}
|
27 |
-
}
|
28 |
-
"""
|
29 |
-
|
30 |
-
_DESCRIPTION = """\
|
31 |
-
High-level Dataset
|
32 |
-
"""
|
33 |
-
|
34 |
-
# github link
|
35 |
-
_HOMEPAGE = "https://github.com/michelecafagna26/HL-dataset"
|
36 |
-
|
37 |
-
_LICENSE = "Apache 2.0"
|
38 |
-
|
39 |
-
_IMG = "https://huggingface.co/datasets/michelecafagna26/hl/resolve/main/data/images.tar.gz"
|
40 |
-
_TRAIN = "https://huggingface.co/datasets/michelecafagna26/hl/resolve/main/data/annotations/train.jsonl"
|
41 |
-
_TEST = "https://huggingface.co/datasets/michelecafagna26/hl/resolve/main/data/annotations/test.jsonl"
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
class HL(datasets.GeneratorBasedBuilder):
|
46 |
-
"""High Level Dataset."""
|
47 |
-
|
48 |
-
VERSION = datasets.Version("1.0.0")
|
49 |
-
|
50 |
-
def _info(self):
|
51 |
-
features = datasets.Features(
|
52 |
-
{
|
53 |
-
"file_name": datasets.Value("string"),
|
54 |
-
"image": datasets.Image(),
|
55 |
-
"scene": datasets.Sequence(datasets.Value("string")),
|
56 |
-
"action": datasets.Sequence(datasets.Value("string")),
|
57 |
-
"rationale": datasets.Sequence(datasets.Value("string")),
|
58 |
-
"object": datasets.Sequence(datasets.Value("string")),
|
59 |
-
"confidence": {
|
60 |
-
"scene": datasets.Sequence(datasets.Value("float32")),
|
61 |
-
"action": datasets.Sequence(datasets.Value("float32")),
|
62 |
-
"rationale": datasets.Sequence(datasets.Value("float32")),
|
63 |
-
},
|
64 |
-
"purity": {
|
65 |
-
"scene": datasets.Sequence(datasets.Value("float32")),
|
66 |
-
"action": datasets.Sequence(datasets.Value("float32")),
|
67 |
-
"rationale": datasets.Sequence(datasets.Value("float32")),
|
68 |
-
},
|
69 |
-
"diversity": {
|
70 |
-
"scene": datasets.Value("float32"),
|
71 |
-
"action": datasets.Value("float32"),
|
72 |
-
"rationale": datasets.Value("float32"),
|
73 |
-
},
|
74 |
-
}
|
75 |
-
)
|
76 |
-
return datasets.DatasetInfo(
|
77 |
-
description=_DESCRIPTION,
|
78 |
-
features=features,
|
79 |
-
homepage=_HOMEPAGE,
|
80 |
-
license=_LICENSE,
|
81 |
-
citation=_CITATION,
|
82 |
-
)
|
83 |
-
|
84 |
-
def _split_generators(self, dl_manager):
|
85 |
-
image_files = dl_manager.download(_IMG)
|
86 |
-
annotation_files = dl_manager.download_and_extract([_TRAIN, _TEST])
|
87 |
-
return [
|
88 |
-
datasets.SplitGenerator(
|
89 |
-
name=datasets.Split.TRAIN,
|
90 |
-
gen_kwargs={
|
91 |
-
"annotation_file_path": annotation_files[0],
|
92 |
-
"images": dl_manager.iter_archive(image_files),
|
93 |
-
},
|
94 |
-
),
|
95 |
-
datasets.SplitGenerator(
|
96 |
-
name=datasets.Split.TEST,
|
97 |
-
gen_kwargs={
|
98 |
-
"annotation_file_path": annotation_files[1],
|
99 |
-
"images": dl_manager.iter_archive(image_files),
|
100 |
-
},
|
101 |
-
),
|
102 |
-
]
|
103 |
-
|
104 |
-
def _generate_examples(self, annotation_file_path, images):
|
105 |
-
|
106 |
-
idx = 0
|
107 |
-
|
108 |
-
#assert Path(annotation_file_path).suffix == ".jsonl"
|
109 |
-
|
110 |
-
with open(annotation_file_path, "r") as fp:
|
111 |
-
metadata = {json.loads(item)['file_name']: json.loads(item) for item in fp}
|
112 |
-
|
113 |
-
# This loop relies on the ordering of the files in the archive:
|
114 |
-
# Annotation files come first, then the images.
|
115 |
-
for img_file_path, img_obj in images:
|
116 |
-
|
117 |
-
file_name = Path(img_file_path).name
|
118 |
-
|
119 |
-
if file_name in metadata:
|
120 |
-
yield idx, {
|
121 |
-
"file_name": file_name,
|
122 |
-
"image": {"path": img_file_path, "bytes": img_obj.read()},
|
123 |
-
"scene": metadata[file_name]['captions']['scene'],
|
124 |
-
"action": metadata[file_name]['captions']['action'],
|
125 |
-
"rationale": metadata[file_name]['captions']['rationale'],
|
126 |
-
"object": metadata[file_name]['captions']['object'],
|
127 |
-
"confidence": metadata[file_name]['confidence'],
|
128 |
-
"purity": metadata[file_name]['purity'],
|
129 |
-
"diversity": metadata[file_name]['diversity'],
|
130 |
-
}
|
131 |
-
idx += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|