added GamePhysics.py
Browse files- GamePhysics.py +92 -0
GamePhysics.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""GamePhysics Dataset"""
|
2 |
+
|
3 |
+
from __future__ import absolute_import, division, print_function
|
4 |
+
|
5 |
+
import csv
|
6 |
+
import json
|
7 |
+
import os
|
8 |
+
|
9 |
+
import datasets
|
10 |
+
from datasets import Dataset
|
11 |
+
|
12 |
+
_CITATION = """\
|
13 |
+
@article{taesiri2022clip,
|
14 |
+
title={CLIP meets GamePhysics: Towards bug identification in gameplay videos using zero-shot transfer learning},
|
15 |
+
author={Taesiri, Mohammad Reza and Macklon, Finlay and Bezemer, Cor-Paul},
|
16 |
+
journal={arXiv preprint arXiv:2203.11096},
|
17 |
+
year={2022}
|
18 |
+
}
|
19 |
+
"""
|
20 |
+
|
21 |
+
_DESCRIPTION = """\
|
22 |
+
GamePhysics dataset
|
23 |
+
"""
|
24 |
+
|
25 |
+
_HOMEPAGE = "https://asgaardlab.github.io/CLIPxGamePhysics/"
|
26 |
+
|
27 |
+
_LICENSE = "MIT"
|
28 |
+
|
29 |
+
with open("list_of_games.json", "r") as f:
|
30 |
+
_GAMEs = json.load(f)
|
31 |
+
|
32 |
+
|
33 |
+
_URLs = {
|
34 |
+
k: f"https://huggingface.co/datasets/taesiri/GamePhysics/resolve/main/data/{v}"
|
35 |
+
for k, v in _GAMEs.items()
|
36 |
+
}
|
37 |
+
|
38 |
+
_NAMES = [k for k, v in _GAMEs.items()]
|
39 |
+
|
40 |
+
|
41 |
+
class GamePhysics_Config(datasets.BuilderConfig):
|
42 |
+
"""BuilderConfig for GamePhysics."""
|
43 |
+
|
44 |
+
def __init__(self, **kwargs):
|
45 |
+
"""BuilderConfig for GamePhysics_Config.
|
46 |
+
Args:
|
47 |
+
**kwargs: keyword arguments forwarded to super.
|
48 |
+
"""
|
49 |
+
super(GamePhysics_Config, self).__init__(
|
50 |
+
version=datasets.Version("1.0.0", ""), **kwargs
|
51 |
+
)
|
52 |
+
|
53 |
+
|
54 |
+
class GamePhysics(datasets.GeneratorBasedBuilder):
|
55 |
+
"""GamePhysics dataset"""
|
56 |
+
|
57 |
+
BUILDER_CONFIGS = [
|
58 |
+
GamePhysics_Config(
|
59 |
+
name="GamePhysics",
|
60 |
+
description="GamePhysics dataset",
|
61 |
+
)
|
62 |
+
]
|
63 |
+
|
64 |
+
def _info(self):
|
65 |
+
return datasets.DatasetInfo(
|
66 |
+
description=_DESCRIPTION,
|
67 |
+
features=datasets.Features(
|
68 |
+
{
|
69 |
+
"video_file_path": datasets.Value("string"),
|
70 |
+
"labels": datasets.features.ClassLabel(names=_NAMES),
|
71 |
+
}
|
72 |
+
),
|
73 |
+
supervised_keys=None,
|
74 |
+
homepage=_HOMEPAGE,
|
75 |
+
citation=_CITATION,
|
76 |
+
)
|
77 |
+
|
78 |
+
def _split_generators(self, dl_manager):
|
79 |
+
data_files = dl_manager.download_and_extract(_URLS)
|
80 |
+
return [
|
81 |
+
datasets.SplitGenerator(
|
82 |
+
name=game_name,
|
83 |
+
gen_kwargs={"files": dl_manager.iter_files([data_files[game_name]])},
|
84 |
+
)
|
85 |
+
for game_name in _GAMES.keys()
|
86 |
+
]
|
87 |
+
|
88 |
+
def _generate_examples(self, files, split):
|
89 |
+
for i, path in enumerate(files):
|
90 |
+
file_name = os.path.basename(path)
|
91 |
+
if file_name.endswith(".mp4"):
|
92 |
+
yield i, {"video_file_path": path, "labels": "Grand_Theft_Auto_V"}
|