Update ucf_crime.py
Browse files- ucf_crime.py +17 -9
ucf_crime.py
CHANGED
@@ -69,8 +69,8 @@ _SPLIT_FILES = {
|
|
69 |
},
|
70 |
},
|
71 |
"anomaly_detection": {
|
72 |
-
"train":
|
73 |
-
"test":
|
74 |
},
|
75 |
"temporal_anomaly": {
|
76 |
"train": [_SPLIT_PATH + "Temporal_Anomaly_Annotation_for_Testing_Videos.txt"],
|
@@ -78,7 +78,12 @@ _SPLIT_FILES = {
|
|
78 |
}
|
79 |
|
80 |
|
81 |
-
raw_videos = datasets.Features(
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
|
84 |
class UCFCrimeConfig(datasets.BuilderConfig):
|
@@ -175,13 +180,16 @@ class UCFCrime(datasets.GeneratorBasedBuilder):
|
|
175 |
split_files = [line.strip().split("/")[-1] for line in f.readlines()]
|
176 |
for extracted_path in extracted.values():
|
177 |
for root, _, files in os.walk(extracted_path, topdown=False):
|
178 |
-
relative_dir_path = root.replace(
|
179 |
-
os.path.abspath(extracted_path) + os.sep, ""
|
180 |
-
)
|
181 |
for name in files:
|
182 |
-
|
183 |
-
|
184 |
if split_path and name not in split_files:
|
185 |
continue
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
idx += 1
|
|
|
69 |
},
|
70 |
},
|
71 |
"anomaly_detection": {
|
72 |
+
"train": {"anomaly": _SPLIT_PATH + "Anomaly_Detection_splits/Anomaly_Train.txt"},
|
73 |
+
"test": {"anomaly": _SPLIT_PATH + "Anomaly_Detection_splits/Anomaly_Test.txt"},
|
74 |
},
|
75 |
"temporal_anomaly": {
|
76 |
"train": [_SPLIT_PATH + "Temporal_Anomaly_Annotation_for_Testing_Videos.txt"],
|
|
|
78 |
}
|
79 |
|
80 |
|
81 |
+
raw_videos = datasets.Features(
|
82 |
+
{
|
83 |
+
"video_path": datasets.Value("string"),
|
84 |
+
"event": datasets.Value("string"),
|
85 |
+
}
|
86 |
+
)
|
87 |
|
88 |
|
89 |
class UCFCrimeConfig(datasets.BuilderConfig):
|
|
|
180 |
split_files = [line.strip().split("/")[-1] for line in f.readlines()]
|
181 |
for extracted_path in extracted.values():
|
182 |
for root, _, files in os.walk(extracted_path, topdown=False):
|
|
|
|
|
|
|
183 |
for name in files:
|
184 |
+
if name.endswith(".mp4"):
|
185 |
+
absolute_file_path = os.path.join(root, name)
|
186 |
if split_path and name not in split_files:
|
187 |
continue
|
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
|