File size: 2,785 Bytes
2c67d52 9c5cfbd 8ec2959 2c67d52 8ec2959 2c67d52 8ec2959 e6ded7c 8ec2959 66dc51d 8ec2959 95ce4ea 8ec2959 fc72f5d 8ec2959 5c61cbf 06c5237 9fe6a2e 2c67d52 64d83ea af4536e 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
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"
SUPPORTED = ["VideoPoet", "BDAnimateDiffLightning", "CogVideoX5B", "Pexels", "RunwayML", "StableDiffusion", "Veo"]
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=SUPPORTED), # Add all category names
}),
supervised_keys=("video", "label"),
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
urls = []
base_url = "https://huggingface.co/datasets/faridlab/deepaction_v1/resolve/main/"
for engine in SUPPORTED:
for i in list(range(95)) + list(range(99, 104)):
if engine in ["Pexels", "Veo"]:
urls.append(os.path.join(base_url, engine, "{}".format(i), "a.mp4"))
elif engine in ["VideoPoet"]:
for vid_file in ["a.mp4", "b.mp4", "c.mp4", "d.mp4"]:
urls.append(os.path.join(base_url, engine, "{}".format(i), vid_file))
else:
for vid_file in ["a.mp4", "b.mp4", "c.mp4", "d.mp4", "e.mp4"]:
urls.append(os.path.join(base_url, engine, "{}".format(i), vid_file))
data_dir = dl_manager.download_and_extract(urls)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"data_dir": data_dir},
),
]
def _generate_examples(self, data_dir):
print(data_dir)
for label in os.listdir(data_dir):
label_path = os.path.join(data_dir, label)
if os.path.isdir(label_path):
for subfolder in os.listdir(label_path):
subfolder_path = os.path.join(label_path, 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,
} |