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): for data_point in data_dir: yield video_path, { "video": data_point, "label": str(data_point).split("/")[-3], } """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, }"""