Upload folder using huggingface_hub
#24
by
infinitysugam - opened
- clip_cc.py +34 -0
clip_cc.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import datasets
|
| 3 |
+
|
| 4 |
+
class ClipCcDataset(datasets.GeneratorBasedBuilder):
|
| 5 |
+
VERSION = datasets.Version("1.0.0")
|
| 6 |
+
|
| 7 |
+
def _info(self):
|
| 8 |
+
return datasets.DatasetInfo(
|
| 9 |
+
description="200 video summaries with IDs and YouTube links.",
|
| 10 |
+
features=datasets.Features(
|
| 11 |
+
{
|
| 12 |
+
"id": datasets.Value("string"),
|
| 13 |
+
"file_link": datasets.Value("string"),
|
| 14 |
+
"summary": datasets.Value("string"),
|
| 15 |
+
}
|
| 16 |
+
),
|
| 17 |
+
supervised_keys=None,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
def _split_generators(self, dl_manager):
|
| 21 |
+
data_path = dl_manager.download_and_extract("metadata.jsonl")
|
| 22 |
+
return [
|
| 23 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_path})
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
def _generate_examples(self, filepath):
|
| 27 |
+
with open(filepath, encoding="utf-8") as f:
|
| 28 |
+
for idx, line in enumerate(f):
|
| 29 |
+
item = json.loads(line)
|
| 30 |
+
yield idx, {
|
| 31 |
+
"id": item.get("id", ""),
|
| 32 |
+
"file_link": item.get("file_link", ""),
|
| 33 |
+
"summary": item.get("summary", ""),
|
| 34 |
+
}
|