Datasets:

ArXiv:
License:
File size: 2,614 Bytes
e643a7e
 
 
 
a6e70a3
e643a7e
 
 
a6e70a3
e643a7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a6e70a3
 
 
 
e643a7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f729411
e643a7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85f16d2
e643a7e
 
 
 
 
21e402c
e643a7e
 
 
 
 
 
 
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
"""GamePhysics Dataset"""

from __future__ import absolute_import, division, print_function

import os
import csv
import json
import datasets
import urllib.request
from datasets import Dataset

_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}
}
"""

_DESCRIPTION = """\
GamePhysics dataset
"""

_HOMEPAGE = "https://asgaardlab.github.io/CLIPxGamePhysics/"

_LICENSE = "MIT"

with urllib.request.urlopen(
    "https://huggingface.co/datasets/taesiri/GamePhysics/raw/main/list_of_games.json"
) as url:
    _GAMEs = json.loads(url.read().decode())

_URLs = {
    k: f"https://huggingface.co/datasets/taesiri/GamePhysics/resolve/main/data/{v}"
    for k, v in _GAMEs.items()
}

_NAMES = [k for k, v in _GAMEs.items()]


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

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


class GamePhysics(datasets.GeneratorBasedBuilder):
    """GamePhysics dataset"""

    BUILDER_CONFIGS = [
        GamePhysics_Config(
            name="GamePhysics",
            description="GamePhysics dataset",
        )
    ]

    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=game_name,
                gen_kwargs={"files": dl_manager.iter_files([data_files[game_name]])},
            )
            for game_name in _GAMEs.keys()
        ]

    def _generate_examples(self, files, split):
        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"}