Update ucf_crime.py
Browse files- ucf_crime.py +23 -5
ucf_crime.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
import os
|
|
|
|
|
2 |
import datasets
|
3 |
|
4 |
|
@@ -77,11 +79,19 @@ _SPLIT_FILES = {
|
|
77 |
},
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
|
82 |
{
|
83 |
"video_path": datasets.Value("string"),
|
84 |
-
"event": datasets.
|
|
|
85 |
}
|
86 |
)
|
87 |
|
@@ -89,14 +99,16 @@ raw_videos = datasets.Features(
|
|
89 |
class UCFCrimeConfig(datasets.BuilderConfig):
|
90 |
def __init__(
|
91 |
self,
|
92 |
-
data_urls=_DATA_URLS,
|
93 |
-
split_files=_SPLIT_FILES,
|
|
|
94 |
**kwargs,
|
95 |
):
|
96 |
super().__init__(**kwargs)
|
97 |
self.data_urls = data_urls
|
98 |
self.split_files = split_files
|
99 |
-
self.features =
|
|
|
100 |
|
101 |
|
102 |
class UCFCrime(datasets.GeneratorBasedBuilder):
|
@@ -188,8 +200,14 @@ class UCFCrime(datasets.GeneratorBasedBuilder):
|
|
188 |
label = root.split(os.sep)[-1].lower()
|
189 |
if "normal" in label:
|
190 |
label = "normal"
|
|
|
|
|
|
|
|
|
|
|
191 |
yield idx, {
|
192 |
"video_path": absolute_file_path,
|
193 |
"event": label,
|
|
|
194 |
}
|
195 |
idx += 1
|
|
|
1 |
import os
|
2 |
+
import subprocess
|
3 |
+
|
4 |
import datasets
|
5 |
|
6 |
|
|
|
79 |
},
|
80 |
}
|
81 |
|
82 |
+
_NAMES = [
|
83 |
+
"Abuse", "Arrest", "Arson", "Assault",
|
84 |
+
"Burglary", "Explosion", "Fighting",
|
85 |
+
"RoadAccidents", "Robbery", "Shooting"
|
86 |
+
"Shoplifting", "Stealing", "Vandalism",
|
87 |
+
"Normal",
|
88 |
+
]
|
89 |
|
90 |
+
video_frames = datasets.Features(
|
91 |
{
|
92 |
"video_path": datasets.Value("string"),
|
93 |
+
"event": datasets.features.ClassLabel(names=_NAMES),
|
94 |
+
"images": [datasets.Image()],
|
95 |
}
|
96 |
)
|
97 |
|
|
|
99 |
class UCFCrimeConfig(datasets.BuilderConfig):
|
100 |
def __init__(
|
101 |
self,
|
102 |
+
data_urls: str = _DATA_URLS,
|
103 |
+
split_files: str = _SPLIT_FILES,
|
104 |
+
to_images: bool = True,
|
105 |
**kwargs,
|
106 |
):
|
107 |
super().__init__(**kwargs)
|
108 |
self.data_urls = data_urls
|
109 |
self.split_files = split_files
|
110 |
+
self.features = video_frames
|
111 |
+
self.to_images = to_images
|
112 |
|
113 |
|
114 |
class UCFCrime(datasets.GeneratorBasedBuilder):
|
|
|
200 |
label = root.split(os.sep)[-1].lower()
|
201 |
if "normal" in label:
|
202 |
label = "normal"
|
203 |
+
|
204 |
+
images = [None]
|
205 |
+
if self.config.to_images == True:
|
206 |
+
pass
|
207 |
+
|
208 |
yield idx, {
|
209 |
"video_path": absolute_file_path,
|
210 |
"event": label,
|
211 |
+
"images": images,
|
212 |
}
|
213 |
idx += 1
|