Upload 5 files
Browse files- .gitattributes +1 -0
- README.md +18 -0
- flickr30k-images.zip +3 -0
- flickr30k.py +81 -0
- flickr_annotations_30k.csv +0 -0
- flickr_annotations_30k_bak.csv +3 -0
.gitattributes
CHANGED
|
@@ -56,3 +56,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 56 |
# Video files - compressed
|
| 57 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 58 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 56 |
# Video files - compressed
|
| 57 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 58 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
flickr_annotations_30k_bak.csv filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Flickr30k
|
| 2 |
+
|
| 3 |
+
Original paper: [From image descriptions to visual denotations: New similarity metrics for semantic inference over event descriptions](https://aclanthology.org/Q14-1006)
|
| 4 |
+
|
| 5 |
+
Homepage: https://shannon.cs.illinois.edu/DenotationGraph/
|
| 6 |
+
|
| 7 |
+
Bibtex:
|
| 8 |
+
```
|
| 9 |
+
@article{young2014image,
|
| 10 |
+
title={From image descriptions to visual denotations: New similarity metrics for semantic inference over event descriptions},
|
| 11 |
+
author={Young, Peter and Lai, Alice and Hodosh, Micah and Hockenmaier, Julia},
|
| 12 |
+
journal={Transactions of the Association for Computational Linguistics},
|
| 13 |
+
volume={2},
|
| 14 |
+
pages={67--78},
|
| 15 |
+
year={2014},
|
| 16 |
+
publisher={MIT Press}
|
| 17 |
+
}
|
| 18 |
+
```
|
flickr30k-images.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ce2420c0d17f0531deaa89ac657b4d5067ec519da16ff1ea12acbf5619c7391
|
| 3 |
+
size 4390240817
|
flickr30k.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2022 the HuggingFace Datasets Authors.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
import os
|
| 17 |
+
import pandas as pd
|
| 18 |
+
import datasets
|
| 19 |
+
import json
|
| 20 |
+
import ast
|
| 21 |
+
from huggingface_hub import hf_hub_url
|
| 22 |
+
|
| 23 |
+
_INPUT_CSV = "flickr_annotations_30k.csv"
|
| 24 |
+
_INPUT_IMAGES = "flickr30k-images"
|
| 25 |
+
_REPO_ID = "nlphuji/flickr30k"
|
| 26 |
+
_JSON_KEYS = ["raw", "sentids"]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class Dataset(datasets.GeneratorBasedBuilder):
|
| 30 |
+
VERSION = datasets.Version("1.1.0")
|
| 31 |
+
BUILDER_CONFIGS = [
|
| 32 |
+
datasets.BuilderConfig(name="TEST", version=VERSION, description="test"),
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
def _info(self):
|
| 36 |
+
return datasets.DatasetInfo(
|
| 37 |
+
features=datasets.Features(
|
| 38 |
+
{
|
| 39 |
+
"image": datasets.Image(),
|
| 40 |
+
"caption": [datasets.Value("string")],
|
| 41 |
+
"sentids": [datasets.Value("string")],
|
| 42 |
+
"split": datasets.Value("string"),
|
| 43 |
+
"img_id": datasets.Value("string"),
|
| 44 |
+
"filename": datasets.Value("string"),
|
| 45 |
+
}
|
| 46 |
+
),
|
| 47 |
+
task_templates=[],
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
def _split_generators(self, dl_manager):
|
| 51 |
+
"""Returns SplitGenerators."""
|
| 52 |
+
|
| 53 |
+
repo_id = _REPO_ID
|
| 54 |
+
data_dir = dl_manager.download_and_extract(
|
| 55 |
+
{
|
| 56 |
+
"examples_csv": hf_hub_url(
|
| 57 |
+
repo_id=repo_id, repo_type="dataset", filename=_INPUT_CSV
|
| 58 |
+
),
|
| 59 |
+
"images_dir": hf_hub_url(
|
| 60 |
+
repo_id=repo_id,
|
| 61 |
+
repo_type="dataset",
|
| 62 |
+
filename=f"{_INPUT_IMAGES}.zip",
|
| 63 |
+
),
|
| 64 |
+
}
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
return [datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs=data_dir)]
|
| 68 |
+
|
| 69 |
+
def _generate_examples(self, examples_csv, images_dir):
|
| 70 |
+
"""Yields examples."""
|
| 71 |
+
examples_csv = "/home/robinhad/Projects/flickr30k/flickr_annotations_30k.csv"
|
| 72 |
+
df = pd.read_csv(examples_csv)
|
| 73 |
+
for c in _JSON_KEYS:
|
| 74 |
+
df[c] = df[c].apply(ast.literal_eval)
|
| 75 |
+
|
| 76 |
+
for r_idx, r in df.iterrows():
|
| 77 |
+
r_dict = r.to_dict()
|
| 78 |
+
image_path = os.path.join(images_dir, _INPUT_IMAGES, r_dict["filename"])
|
| 79 |
+
r_dict["image"] = image_path
|
| 80 |
+
r_dict["caption"] = r_dict.pop("raw")
|
| 81 |
+
yield r_idx, r_dict
|
flickr_annotations_30k.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
flickr_annotations_30k_bak.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:395990db603ab8bafd5c7ab2746b22058bb1e75b78b3eb56ad755931364ac137
|
| 3 |
+
size 12896305
|