File size: 2,098 Bytes
2c67d52 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import os
import datasets
_CITATION = """\
@inproceedings{tbd,
title={tbd},
author={tbd},
year={2024},
url={https://huggingface.co/datasets/faridlab/deepaction_v1}
}
"""
_DESCRIPTION = """\
TBD
"""
_HOMEPAGE = "https://huggingface.co/datasets/faridlab/deepaction_v1"
_LICENSE = "TBD"
class DeepActionV1(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features({
"video": datasets.Video(),
"label": datasets.ClassLabel(names=["VideoPoet", "BDAnimateDiffLightning", "CogVideoX5B", "Pexels", "RunwayML", "StableDiffusion", "Veo"]), # Add all category names
}),
supervised_keys=("video", "label"),
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
url = "https://huggingface.co/datasets/faridlab/deepaction_v1/resolve/main/data.zip"
data_dir = dl_manager.download_and_extract(url)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"data_dir": data_dir},
),
]
def _generate_examples(self, data_dir):
label_names = os.listdir(data_dir)
for label in label_names:
label_dir = os.path.join(data_dir, label)
if os.path.isdir(label_dir):
for subfolder in os.listdir(label_dir):
subfolder_path = os.path.join(label_dir, subfolder)
if os.path.isdir(subfolder_path):
for video_file in os.listdir(subfolder_path):
if video_file.endswith(".mp4"):
video_path = os.path.join(subfolder_path, video_file)
yield video_path, {
"video": video_path,
"label": label,
} |