jherng commited on
Commit
aacff4b
1 Parent(s): f27e353

Update xd-violence.py

Browse files
Files changed (1) hide show
  1. 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, 5, 2048),
78
- dtype="float32", # (num_frames, num_crops, feature_dim) use 5 crops by default as of now
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
- yield (
250
- key,
251
- {
252
- "id": f_id,
253
- "feature": feature,
254
- "binary_target": binary,
255
- "multilabel_target": multilabel,
256
- "frame_annotations": frame_annotations,
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)):