yonatanbitton commited on
Commit
09a1f13
1 Parent(s): be436fb

Create flickr_1k_test_image_text_retrieval.py

Browse files
flickr_1k_test_image_text_retrieval.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+ import datasets
19
+ import json
20
+
21
+ class Dataset(datasets.GeneratorBasedBuilder):
22
+ BUILDER_CONFIGS = [
23
+ datasets.BuilderConfig(name="TEST", version=VERSION, description="test"),
24
+ ]
25
+
26
+ def _info(self):
27
+ return datasets.DatasetInfo(
28
+ description=_DESCRIPTION,
29
+ features=datasets.Features(
30
+ {
31
+ "split": datasets.Value("string"),
32
+ }
33
+ ),
34
+ task_templates=[],
35
+ )
36
+
37
+ def _split_generators(self, dl_manager):
38
+ """Returns SplitGenerators."""
39
+
40
+ hf_auth_token = dl_manager.download_config.use_auth_token
41
+ if hf_auth_token is None:
42
+ raise ConnectionError(
43
+ "Please set use_auth_token=True or use_auth_token='<TOKEN>' to download this dataset"
44
+ )
45
+
46
+ downloaded_files = dl_manager.download_and_extract({
47
+ "examples": "test_1k_flickr.csv",
48
+ })
49
+
50
+ # return [datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs=downloaded_files)]
51
+ return [datasets.SplitGenerator(name=datasets.Split.TEST)]
52
+
53
+
54
+ def _generate_examples(self, examples):
55
+ """Yields examples."""
56
+ df = pd.read_csv(examples)
57
+ print("HERE!?")
58
+ raise Exception("E")
59
+ for r_idx, r in df.iterrows():
60
+ r_dict = r.to_dict()
61
+ yield r_idx, r_dict