Update xd-violence.py
Browse files- xd-violence.py +13 -12
xd-violence.py
CHANGED
@@ -74,8 +74,8 @@ class XDViolence(datasets.GeneratorBasedBuilder):
|
|
74 |
{
|
75 |
"id": datasets.Value("string"),
|
76 |
"feature": datasets.Array3D(
|
77 |
-
shape=(None,
|
78 |
-
dtype="float32", # (num_frames,
|
79 |
),
|
80 |
"binary_target": datasets.ClassLabel(
|
81 |
names=["Non-violence", "Violence"]
|
@@ -246,16 +246,17 @@ class XDViolence(datasets.GeneratorBasedBuilder):
|
|
246 |
frame_annotations = frame_annots_mapper.get(f_id, [])
|
247 |
feature = np.load(f_path)
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
259 |
|
260 |
else:
|
261 |
for key, (f_id, f_path, f_label) in enumerate(zip(ids, paths, labels)):
|
|
|
74 |
{
|
75 |
"id": datasets.Value("string"),
|
76 |
"feature": datasets.Array3D(
|
77 |
+
shape=(None, 2048),
|
78 |
+
dtype="float32", # (num_frames, feature_dim)
|
79 |
),
|
80 |
"binary_target": datasets.ClassLabel(
|
81 |
names=["Non-violence", "Violence"]
|
|
|
246 |
frame_annotations = frame_annots_mapper.get(f_id, [])
|
247 |
feature = np.load(f_path)
|
248 |
|
249 |
+
for crop_idx in range(feature.shape[1]): # Loop over crops (5 crops)
|
250 |
+
yield (
|
251 |
+
f"{key}-{crop_idx}",
|
252 |
+
{
|
253 |
+
"id": f"{f_id}__{crop_idx}",
|
254 |
+
"feature": feature[:, crop_idx, :],
|
255 |
+
"binary_target": binary,
|
256 |
+
"multilabel_target": multilabel,
|
257 |
+
"frame_annotations": frame_annotations,
|
258 |
+
},
|
259 |
+
)
|
260 |
|
261 |
else:
|
262 |
for key, (f_id, f_path, f_label) in enumerate(zip(ids, paths, labels)):
|