Datasets:
specify dtypes
Browse files- ActivityNet_Captions.py +7 -5
ActivityNet_Captions.py
CHANGED
|
@@ -95,19 +95,21 @@ class ActivityNet(datasets.GeneratorBasedBuilder):
|
|
| 95 |
|
| 96 |
def _generate_examples(self, infos_file):
|
| 97 |
"""This function returns the examples."""
|
| 98 |
-
|
| 99 |
with open(infos_file, encoding="utf-8") as json_file:
|
| 100 |
infos = json.load(json_file)
|
| 101 |
for idx, id in enumerate(infos):
|
| 102 |
path = "https://www.youtube.com/watch?v=" + id[2:]
|
| 103 |
-
starts = [timestamp[0]
|
| 104 |
for timestamp in infos[id]["timestamps"]]
|
| 105 |
-
ends = [timestamp[1]
|
|
|
|
|
|
|
| 106 |
yield idx, {
|
| 107 |
"video_id": id,
|
| 108 |
"path": path,
|
| 109 |
-
"duration": infos[id]["duration"],
|
| 110 |
"starts": starts,
|
| 111 |
"ends": ends,
|
| 112 |
-
"captions":
|
| 113 |
}
|
|
|
|
| 95 |
|
| 96 |
def _generate_examples(self, infos_file):
|
| 97 |
"""This function returns the examples."""
|
| 98 |
+
|
| 99 |
with open(infos_file, encoding="utf-8") as json_file:
|
| 100 |
infos = json.load(json_file)
|
| 101 |
for idx, id in enumerate(infos):
|
| 102 |
path = "https://www.youtube.com/watch?v=" + id[2:]
|
| 103 |
+
starts = [float(timestamp[0])
|
| 104 |
for timestamp in infos[id]["timestamps"]]
|
| 105 |
+
ends = [float(timestamp[1])
|
| 106 |
+
for timestamp in infos[id]["timestamps"]]
|
| 107 |
+
captions = [str(caption) for caption in infos[id]["sentences"]]
|
| 108 |
yield idx, {
|
| 109 |
"video_id": id,
|
| 110 |
"path": path,
|
| 111 |
+
"duration": float(infos[id]["duration"]),
|
| 112 |
"starts": starts,
|
| 113 |
"ends": ends,
|
| 114 |
+
"captions": captions,
|
| 115 |
}
|