EventActivityNet / docs /DATASET_FORMAT.md
IIS-CVL's picture
Add annotations, timing metadata, and final shard checksums
d6582a4 verified
|
Raw
History Blame Contribute Delete
5.83 kB
# EventActivityNet Dataset Format
## Overview
EventActivityNet v1.0 stores one HDF5 file per video. Scale membership and train/validation splits are defined by manifests, so files do not need to be physically moved to use a particular split or scale.
File size varies substantially with video duration and spatial resolution.
Every production HDF5 file has exactly these root datasets:
```text
events
voxel_event_start
voxel_event_count
```
Every production HDF5 file has these required root attributes:
```text
fps
height
width
num_bins
interpolate_bins
```
## HDF5 Schema
### `events`
| Property | Value |
|---|---|
| Shape | `(T, 5, H, W)` |
| Dtype | `int16` |
| Compression | gzip |
| Shuffle | enabled |
| Chunking | `(1, 5, min(H, 256), min(W, 256))` |
`T`, `H`, and `W` vary by video. Spatial resolution is preserved from the source video.
### `voxel_event_start`
| Property | Value |
|---|---|
| Shape | `(T,)` |
| Dtype | `int64` |
| Compression | LZF |
| Shuffle | enabled |
| Chunking | `(1024,)` |
### `voxel_event_count`
| Property | Value |
|---|---|
| Shape | `(T,)` |
| Dtype | `int32` |
| Compression | LZF |
| Shuffle | enabled |
| Chunking | `(1024,)` |
## Root Attributes
| Attribute | Meaning |
|---|---|
| `fps` | Source video FPS metadata |
| `height` | Source video height |
| `width` | Source video width |
| `num_bins` | Number of voxel bins; always `5` in v1.0 |
| `interpolate_bins` | Whether temporal bin interpolation was used |
## Semantics
The generator emits event slices from adjacent grayscale video frames and accumulates them into 5-bin voxel samples.
- `events[t]` is the 5-bin voxel tensor for timestep `t`.
- `voxel_event_start[t]` is the zero-based generated-slice start index for voxel sample `t`.
- `voxel_event_count[t]` is the number of generated slices accumulated into voxel sample `t`.
For normal full samples with `frames_per_bin=1`, `voxel_event_count[t]` is typically `5`. Final partial samples may be smaller.
## Manifest Fields
Release scale manifests include one record per video. Typical fields:
| Field | Meaning |
|---|---|
| `video_id` | Canonical ActivityNet video ID, including `v_` prefix |
| `split` | `train` or `validation` |
| `class_label` | ActivityNet action class label |
| `duration_seconds` | Verified duration used for scale construction |
| `duration_source` | Duration field source, `src_fmt_dur` |
| `duration_bucket` | `short`, `medium`, or `long` |
| `event_friendly` | Boolean event-friendly flag |
| `event_keyword_hits` | Matched event-friendly caption keywords |
| `first_frame_mean` | Normalized first-frame brightness used for the darkness rule |
| `dark_first_frame` | Whether first-frame mean is below `0.4` |
## Memory-Safe Loading Example
```python
import h5py
path = "path/to/video.h5"
with h5py.File(path, "r") as f:
events = f["events"]
starts = f["voxel_event_start"]
counts = f["voxel_event_count"]
print(events.shape) # (T, 5, H, W)
print(events.dtype) # int16
print(starts.shape) # (T,)
print(counts.shape) # (T,)
print(f.attrs["num_bins"]) # 5
first_voxel = events[0] # loads one timestep, not the whole file
```
Avoid loading entire HDF5 arrays into memory unless your system has sufficient RAM.
## Payload Shards
The HDF5 payload is distributed as deterministic uncompressed tar shards:
- 157 train tar shards under `data/train/`;
- 62 validation tar shards under `data/validation/`;
- 219 tar shards total;
- 3,263 HDF5 members total;
- one HDF5 member per released ActivityNet video.
Large, Medium, and Small share the same physical HDF5 payload. Medium and Small are selected using `scales/medium_ids.txt` and `scales/small_ids.txt`; they do not duplicate payload files.
## Timing Metadata
EventActivityNet v1.0 uses original-rate, variable-FPS ActivityNet videos. The released HDF5 files were not generated from `anet_240fps_v2` or `anet_240fps_old`.
Implementation-derived timing:
- one event slice is generated for each adjacent decoded source-frame transition `(e, e + 1)`;
- one full `events[t]` tensor groups five adjacent-frame transitions and has shape `(5, H, W)`;
- for source frame count `N`, `events_T = ceil((N - 1) / 5)`;
- voxel `t` covers event-slice range `[5*t, 5*t + 5)`, clipped to available transitions `[0, N - 1)`;
- the corresponding source-frame interval is `[5*t, min(5*t + 5, N - 1)]`;
- with rational FPS `fps_num / fps_den`, the approximate seconds interval is `[5*t * fps_den / fps_num, min(5*t + 5, N - 1) * fps_den / fps_num]`;
- the final voxel may be partial, with `voxel_event_count[t]` smaller than 5;
- HDF5 root `fps` is the original source-frame FPS captured by OpenCV, not a 240 fps derivative;
- `voxel_event_start[t]` is the generated event-slice start index for voxel `t`;
- `voxel_event_count[t]` is the number of generated adjacent-frame slices in voxel `t`;
- `voxel_event_start` and `voxel_event_count` are not timestamps and not pixel-event counts.
For caption/action interval `[start_seconds, end_seconds]`, use original FPS to compute:
```text
start_frame = floor(start_seconds * fps_num / fps_den)
end_frame = ceil(end_seconds * fps_num / fps_den)
t_start = max(0, floor(start_frame / 5))
t_end_exclusive = min(events_T, ceil(end_frame / 5))
```
Use `[t_start, t_end_exclusive)` for Python slicing, or `[t_start, t_end_exclusive - 1]` as an inclusive range when non-empty. Do not use `time_seconds = t / fps` for voxel starts; voxel start time is approximately `5 * t / fps`.
## Checksums
Tar shard checksums are published in `metadata/shard_checksums.sha256`. To verify downloaded shards from the repository root:
```bash
sha256sum -c metadata/shard_checksums.sha256
```
The checksum file contains one repository-relative entry for each of the 219 tar shards.