File size: 3,136 Bytes
94cdf44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""mini-GamePhysics test Dataset """

from __future__ import absolute_import, division, print_function

import csv
import json
import os

import datasets
from datasets import Dataset


# TODO: Add BibTeX citation
# Find for instance the citation on arxiv or on the dataset repo/website
_CITATION = """\
@article{taesiri2022clip,
  title={CLIP meets GamePhysics: Towards bug identification in gameplay videos using zero-shot transfer learning},
  author={Taesiri, Mohammad Reza and Macklon, Finlay and Bezemer, Cor-Paul},
  journal={arXiv preprint arXiv:2203.11096},
  year={2022}
}
"""


# TODO: Add description of the dataset here
# You can copy an official description
_DESCRIPTION = """\
A test dataset for GamePhysics
"""

# TODO: Add a link to an official homepage for the dataset here
_HOMEPAGE = "https://asgaardlab.github.io/CLIPxGamePhysics/"

# TODO: Add the licence for the dataset here if you can find it
_LICENSE = ""

# TODO: Add link to the official dataset URLs here
# The HuggingFace dataset library don't host the datasets but only point to the original files
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)

_URLS = {
    "Grand_Theft_Auto_V": "https://huggingface.co/datasets/taesiri/GamePhysics_Grand_Theft_Auto_V/resolve/main/gta-v.tar.gz"
}

_NAMES = ["Grand_Theft_Auto_V"]


class GamePhysics_Grand_Theft_Auto_VConfig(datasets.BuilderConfig):
    """BuilderConfig for GamePhysics."""

    def __init__(self, **kwargs):
        """BuilderConfig for GamePhysics_Grand_Theft_Auto_V.
        Args:
          **kwargs: keyword arguments forwarded to super.
        """
        super(GamePhysics_Grand_Theft_Auto_VConfig, self).__init__(
            version=datasets.Version("0.0.1", ""), **kwargs
        )


class GamePhysics_Grand_Theft_Auto_V(datasets.GeneratorBasedBuilder):
    """Test dataset for GamePhysics"""

    BUILDER_CONFIGS = [
        GamePhysics_Grand_Theft_Auto_VConfig(
            name="GamePhysics_Grand_Theft_Auto_V",
            description="GamePhysics - Grand Theft Auto V",
        )
    ]

    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "video_file_path": datasets.Value("string"),
                    "labels": datasets.features.ClassLabel(names=_NAMES),
                }
            ),
            supervised_keys=None,
            homepage=_HOMEPAGE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        data_files = dl_manager.download_and_extract(_URLS)
        return [
            datasets.SplitGenerator(
                name="Grand_Theft_Auto_V",
                gen_kwargs={
                    "files": dl_manager.iter_files([data_files["Grand_Theft_Auto_V"]]),
                },
            ),
        ]

    def _generate_examples(self, files):
        for i, path in enumerate(files):
            file_name = os.path.basename(path)
            if file_name.endswith(".mp4"):
                yield i, {"video_file_path": path, "labels": "Grand_Theft_Auto_V"}