Datasets:
fix yield
Browse files
TGIF.py
CHANGED
|
@@ -61,7 +61,7 @@ class TGIF(datasets.GeneratorBasedBuilder):
|
|
| 61 |
archive_path = dl_manager.download_and_extract(_DL_URL)
|
| 62 |
archive_data_path = archive_path + "data/splits/"
|
| 63 |
infos_file = archive_path + "data/tgif-v1.0.tsv"
|
| 64 |
-
|
| 65 |
train_splits = [
|
| 66 |
datasets.SplitGenerator(
|
| 67 |
name=datasets.Split.TRAIN,
|
|
@@ -96,19 +96,20 @@ class TGIF(datasets.GeneratorBasedBuilder):
|
|
| 96 |
|
| 97 |
dict = {}
|
| 98 |
split_links_file = "/content/TGIF-Release-master/data/splits/test.txt"
|
| 99 |
-
with open(split_links_file,encoding
|
| 100 |
for line in txt_file:
|
| 101 |
-
|
| 102 |
-
|
| 103 |
infos_file = "/content/TGIF-Release-master/data/tgif-v1.0.tsv"
|
| 104 |
with open(infos_file, encoding="utf-8") as tsv_file:
|
| 105 |
-
tsv_reader = csv.reader(tsv_file, delimiter="\t", quotechar='"'
|
| 106 |
for idx, (video_link, text) in enumerate(tsv_reader):
|
| 107 |
-
try:
|
| 108 |
dict[video_link].append(text)
|
| 109 |
except Exception:
|
| 110 |
pass
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
| 61 |
archive_path = dl_manager.download_and_extract(_DL_URL)
|
| 62 |
archive_data_path = archive_path + "data/splits/"
|
| 63 |
infos_file = archive_path + "data/tgif-v1.0.tsv"
|
| 64 |
+
|
| 65 |
train_splits = [
|
| 66 |
datasets.SplitGenerator(
|
| 67 |
name=datasets.Split.TRAIN,
|
|
|
|
| 96 |
|
| 97 |
dict = {}
|
| 98 |
split_links_file = "/content/TGIF-Release-master/data/splits/test.txt"
|
| 99 |
+
with open(split_links_file, encoding="utf-8") as txt_file:
|
| 100 |
for line in txt_file:
|
| 101 |
+
line = line[0:-1]
|
| 102 |
+
dict[line] = []
|
| 103 |
infos_file = "/content/TGIF-Release-master/data/tgif-v1.0.tsv"
|
| 104 |
with open(infos_file, encoding="utf-8") as tsv_file:
|
| 105 |
+
tsv_reader = csv.reader(tsv_file, delimiter="\t", quotechar='"')
|
| 106 |
for idx, (video_link, text) in enumerate(tsv_reader):
|
| 107 |
+
try:
|
| 108 |
dict[video_link].append(text)
|
| 109 |
except Exception:
|
| 110 |
pass
|
| 111 |
+
for idx, video_link in enumerate(dict):
|
| 112 |
+
yield idx, {
|
| 113 |
+
"path": video_link,
|
| 114 |
+
"captions": dict[video_link],
|
| 115 |
+
}
|