| import os |
| import fsspec |
| import datasets |
| import random |
|
|
|
|
| _CITATION = """\ |
| @InProceedings{Nguyen_2024_WACV, |
| author = {Nguyen, Tai D. and Fang, Shengbang and Stamm, Matthew C.}, |
| title = {VideoFACT: Detecting Video Forgeries Using Attention, Scene Context, and Forensic Traces}, |
| booktitle = {Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)}, |
| month = {January}, |
| year = {2024}, |
| pages = {8563-8573} |
| } |
| """ |
|
|
| _DESCRIPTION = """\ |
| This dataset is a collection of simple and traditional localized video manipulations, such as: splicing, color correction, contrast enhancement, bluring, and noise addition. The dataset is designed to be used for training and evaluating video manipulation detection models. We used this dataset to train the VideoFACT model, which is a deep learning model that uses attention, scene context, and forensic traces to detect a wide variety of video forgery types, i.e. splicing, editing, deepfake, inpainting. The dataset is divided into three parts: Video Camera Model Splicing (VCMS), Video Perceptually Visible Manipulation (VPVM), and Video Perceptually Invisible Manipulation (VPIM). Each part has a total of 4000 videos, each video is 1 second, or 30 frames, has a resolution of 1920 x 1080, and encoded using FFmpeg with the H.264 codec at CRF 23. Additionally, each part is splited into training, validation, and testing sets that consists of 3200, 200, 600 videos, respectively. More details about the dataset can be found in the paper. |
| """ |
|
|
| _HOMEPAGE = "https://github.com/ductai199x/videofact-wacv-2024" |
|
|
| _LICENSE = "Licensed under a Creative Commons Attribution-NonCommercial 4.0 International for Non-commercial use only. Any commercial use should get formal permission first." |
|
|
| _URLS = { |
| "vcms": "https://huggingface.co/datasets/ductai199x/video_std_manip/resolve/main/vcms.zip", |
| "vpvm": "https://huggingface.co/datasets/ductai199x/video_std_manip/resolve/main/vpvm.zip", |
| "vpim": "https://huggingface.co/datasets/ductai199x/video_std_manip/resolve/main/vpim.zip", |
| } |
|
|
| fsspec_open_file = lambda path, mode: fsspec.open(path, mode).open() |
|
|
|
|
| class VideoStdManip(datasets.GeneratorBasedBuilder): |
| """This dataset is a collection of simple and traditional localized video manipulations, such as: splicing, color correction, contrast enhancement, bluring, and noise addition. The dataset is divided into three parts: Video Camera Model Splicing (VCMS), Video Perceptually Visible Manipulation (VPVM), and Video Perceptually Invisible Manipulation (VPIM).""" |
|
|
| VERSION = datasets.Version("1.0.0") |
|
|
| |
| |
| |
|
|
| |
| |
| |
|
|
| |
| |
| |
| BUILDER_CONFIGS = [ |
| datasets.BuilderConfig(name="vcms", version=VERSION, description="This is the VCMS part of the dataset"), |
| datasets.BuilderConfig(name="vpvm", version=VERSION, description="This is the VPVM part of the dataset"), |
| datasets.BuilderConfig(name="vpim", version=VERSION, description="This is the VPIM part of the dataset"), |
| ] |
|
|
| |
|
|
| def _info(self): |
| features = datasets.Features( |
| { |
| "vid_path": datasets.Value("string"), |
| "mask_path": datasets.Value("string"), |
| "label": datasets.ClassLabel(num_classes=2), |
| |
| } |
| ) |
| return datasets.DatasetInfo( |
| |
| description=_DESCRIPTION, |
| |
| features=features, |
| |
| |
| |
| |
| homepage=_HOMEPAGE, |
| |
| license=_LICENSE, |
| |
| citation=_CITATION, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| |
|
|
| |
| |
| |
| part_name = self.config.name |
| urls = _URLS[part_name] |
| data_dir = dl_manager.download_and_extract(urls) |
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| |
| gen_kwargs={ |
| "filepath": os.path.join(data_dir, part_name, "train_ids.txt"), |
| }, |
| ), |
| datasets.SplitGenerator( |
| name=datasets.Split.VALIDATION, |
| |
| gen_kwargs={ |
| "filepath": os.path.join(data_dir, part_name, "val_ids.txt"), |
| }, |
| ), |
| datasets.SplitGenerator( |
| name=datasets.Split.TEST, |
| |
| gen_kwargs={ |
| "filepath": os.path.join(data_dir, part_name, "test_ids.txt"), |
| }, |
| ), |
| ] |
|
|
| |
| def _generate_examples(self, filepath): |
| |
| with open(filepath, "r") as f: |
| vid_ids = f.read().splitlines() |
|
|
| manip_vid_ids = [("manip", id_) for id_ in vid_ids] |
| real_vid_ids = [("real", id_) for id_ in vid_ids] |
| all_vid_ids = manip_vid_ids + real_vid_ids |
| random.seed(2024) |
| random.shuffle(all_vid_ids) |
|
|
| part_dir = os.path.dirname(filepath) |
|
|
| for key, (label, vid_id) in enumerate(all_vid_ids): |
| label = 0 if label == "real" else 1 |
| if label == 1: |
| vid_path = os.path.join(part_dir, "manipulated", vid_id + ".mp4") |
| mask_path = os.path.join(part_dir, "mask", vid_id + ".mp4") |
| else: |
| vid_path = os.path.join(part_dir, "original", vid_id + ".mp4") |
| mask_path = "" |
|
|
| yield key, { |
| "vid_path": vid_path, |
| "mask_path": mask_path, |
| "label": label, |
| } |
|
|