renjianzhexuejia commited on
Commit
d41ef2c
·
verified ·
1 Parent(s): cd72b4b

Standardize event sample identifiers and document dataset usage

Browse files

Align event sample_id, category, and subclass values with the existing full annotations and video directories. Preserve video numbers and all other event fields. Document the annotation files, timing fields, sample-to-video matching, and a Python loading example in README.md.

Files changed (2) hide show
  1. README.md +141 -7
  2. data/event_annotations_300_samples.csv +2 -2
README.md CHANGED
@@ -1,13 +1,147 @@
1
  # Moment-Video
2
 
3
- This repository contains the Moment-Video dataset.
4
 
5
- ## Contents
6
 
7
- - `data/videos/`: video files organized by category and subclass.
8
- - `data/annotation_all.json`: annotations in JSON format.
9
- - `data/annotation_all.csv`: annotations in CSV format.
 
 
 
10
 
11
- ## Annotation Fields
12
 
13
- The annotation files include category, subclass, index, question type, answer type, question, and answer information for each video sample.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Moment-Video
2
 
3
+ This repository contains 1,000 video samples with question-answer annotations. It also provides event-level temporal annotations for a subset of 300 samples, covering 609 events.
4
 
5
+ ## Files and usage
6
 
7
+ | File or directory | Contents | How to use it |
8
+ | --- | --- | --- |
9
+ | [`data/videos/`](https://huggingface.co/datasets/VisionXLab/Moment-Video/tree/main/data/videos) | 1,000 videos organized by category and subclass. | Load the video corresponding to an annotation record. |
10
+ | [`data/annotation_all.csv`](https://huggingface.co/datasets/VisionXLab/Moment-Video/blob/main/data/annotation_all.csv) | 1,000 sample-level annotation rows. | Use for spreadsheet inspection, filtering, or tabular analysis. |
11
+ | [`data/annotation_all.json`](https://huggingface.co/datasets/VisionXLab/Moment-Video/blob/main/data/annotation_all.json) | The same 1,000 sample-level records as a JSON list of objects. | Use for loading the full question-answer annotations in code. |
12
+ | [`data/event_annotations_300_samples.csv`](https://huggingface.co/datasets/VisionXLab/Moment-Video/blob/main/data/event_annotations_300_samples.csv) | 609 event-level rows for 300 distinct samples, with 30 columns. | Use to locate annotated events in time and analyze their duration or position within a video. |
13
 
14
+ The full CSV and JSON contain the same records and field names; choose either format. The event CSV supplements the full annotations for 300 samples. Each row in the event CSV represents one event, so a sample with multiple events appears on multiple rows.
15
 
16
+ ## Full sample-level annotations
17
+
18
+ Both `annotation_all.csv` and `annotation_all.json` use the following fields:
19
+
20
+ | Field | Meaning |
21
+ | --- | --- |
22
+ | `Category` | Video category, matching the category directory under `data/videos/`. |
23
+ | `Subclass` | Subclass within the category, matching the next directory level. |
24
+ | `Index` | Video identifier within the category and subclass. |
25
+ | `QuestionType` | Question-type code as recorded in the annotations. |
26
+ | `AnswerType` | Answer-type label as recorded in the annotations. |
27
+ | `Question` | Question about the video. |
28
+ | `Answer` | Corresponding answer. |
29
+
30
+ Identify a sample using the combination of `Category`, `Subclass`, and `Index`. The video is stored under `data/videos/<Category>/<Subclass>/<Index>.mp4`. Preserve the actual filename case when opening or downloading files; one video uses the extension `.MP4`.
31
+
32
+ ## Event-level temporal annotations
33
+
34
+ `event_annotations_300_samples.csv` contains 300 distinct `sample_id` values and 609 event rows. Group rows by `sample_id` to collect all events for a sample. Use `(sample_id, event_id)` to identify an individual event.
35
+
36
+ The main fields are:
37
+
38
+ | Field | Meaning |
39
+ | --- | --- |
40
+ | `sample_id` | Sample identifier in the form `Category/Subclass/Index`, using the same names and video number as the full annotations and video directories. |
41
+ | `event_id` | Event identifier within a sample. |
42
+ | `start_sec` | Event start time in seconds from the beginning of the video. |
43
+ | `end_sec` | Event end time in seconds from the beginning of the video. |
44
+ | `event_duration_sec` | Event duration in seconds: `end_sec - start_sec`. |
45
+ | `video_duration_sec` | Total video duration in seconds. |
46
+ | `question`, `answer` | Question and answer associated with the sample, repeated across its event rows. |
47
+ | `event_count_in_sample` | Total number of annotated events for the sample. |
48
+ | `event_role` | Event role: `single evidence`, `repeated occurrence`, `prerequisite event`, or `outcome event`. |
49
+
50
+ Additional fields provide annotation metadata and derived timing values:
51
+
52
+ | Fields | Meaning |
53
+ | --- | --- |
54
+ | `sample_order` | Sample order in the event annotation table. |
55
+ | `category`, `subclass` | Category and subclass names, matching `Category` and `Subclass` in the full annotations. |
56
+ | `question_type`, `answer_type` | Question-type and answer-type metadata. |
57
+ | `duration_bucket` | Video-duration group. |
58
+ | `annotator_id`, `annotation_status`, `annotation_revision` | Annotator identifier, annotation status, and revision metadata. |
59
+ | `is_required`, `confidence` | Recorded event requirement flag and confidence label. |
60
+ | `start_sec_raw`, `end_sec_raw` | Raw event boundary values retained alongside `start_sec` and `end_sec`. |
61
+ | `event_center_sec` | Event midpoint in seconds: `(start_sec + end_sec) / 2`. |
62
+ | `relative_event_start`, `relative_event_center`, `relative_event_end` | Start, midpoint, and end times divided by `video_duration_sec`, expressed as fractions of the video duration. |
63
+ | `description`, `event_notes`, `general_notes` | Optional text fields; these are empty in the current release. |
64
+
65
+ Use `start_sec` and `end_sec` to seek to or extract an annotated interval. Absolute times and durations are in seconds; relative positions are fractions, not percentages.
66
+
67
+ ### Matching event samples to videos
68
+
69
+ Category and subclass names are consistent across the event table, the full annotations, and the video directories. The categories are `AIGC`, `GUI`, `animal`, `games`, `human`, `industrial`, and `nature`.
70
+
71
+ Split `sample_id` into its three parts and join them to `Category`, `Subclass`, and `Index` in the full annotations. For example, `AIGC/artifacts/4` corresponds to `data/videos/AIGC/artifacts/4.mp4`, and `games/combat/11` corresponds to `data/videos/games/combat/11.mp4`.
72
+
73
+ All 300 event samples resolve to an existing video and a record in the full annotations. Use these identifiers to join the files; question and answer text can be shared by different samples. The Python example below looks up the actual video filename to preserve its extension's case.
74
+
75
+ ## Python example
76
+
77
+ Install the download helper:
78
+
79
+ ```bash
80
+ pip install huggingface_hub
81
+ ```
82
+
83
+ This example downloads the two annotation files, groups events by sample, and finds the video and full annotation for the first event sample. Listing video filenames does not download the videos.
84
+
85
+ ```python
86
+ import csv
87
+ import json
88
+ from collections import defaultdict
89
+ from pathlib import Path, PurePosixPath
90
+
91
+ from huggingface_hub import hf_hub_download, list_repo_files
92
+
93
+ repo_id = "VisionXLab/Moment-Video"
94
+
95
+ full_path = hf_hub_download(
96
+ repo_id=repo_id,
97
+ repo_type="dataset",
98
+ filename="data/annotation_all.json",
99
+ )
100
+ samples = json.loads(Path(full_path).read_text(encoding="utf-8"))
101
+ sample_lookup = {
102
+ (row["Category"], row["Subclass"], str(row["Index"])): row
103
+ for row in samples
104
+ }
105
+
106
+ event_path = hf_hub_download(
107
+ repo_id=repo_id,
108
+ repo_type="dataset",
109
+ filename="data/event_annotations_300_samples.csv",
110
+ )
111
+ with open(event_path, encoding="utf-8-sig", newline="") as file:
112
+ events = list(csv.DictReader(file))
113
+
114
+ events_by_sample = defaultdict(list)
115
+ for event in events:
116
+ events_by_sample[event["sample_id"]].append(event)
117
+
118
+ # Keep the exact filename, including the extension's case.
119
+ video_files = {
120
+ str(PurePosixPath(filename).with_suffix("")): filename
121
+ for filename in list_repo_files(repo_id, repo_type="dataset")
122
+ if filename.startswith("data/videos/")
123
+ and PurePosixPath(filename).suffix.lower() == ".mp4"
124
+ }
125
+
126
+ sample_id = events[0]["sample_id"]
127
+ key = tuple(sample_id.split("/"))
128
+ annotation = sample_lookup[key]
129
+ video_filename = video_files["data/videos/" + "/".join(key)]
130
+
131
+ print(len(samples)) # 1000 sample-level records
132
+ print(len(events_by_sample)) # 300 samples with event annotations
133
+ print(len(events)) # 609 annotated events
134
+ print(sample_id, video_filename)
135
+ print(annotation["Question"], annotation["Answer"])
136
+ for event in events_by_sample[sample_id]:
137
+ start = float(event["start_sec"])
138
+ end = float(event["end_sec"])
139
+ print(event["event_id"], start, end)
140
+
141
+ # To download this video, uncomment:
142
+ # local_video = hf_hub_download(
143
+ # repo_id=repo_id, repo_type="dataset", filename=video_filename
144
+ # )
145
+ ```
146
+
147
+ CSV readers return strings, so convert timing values to numbers before calculating durations, comparing timestamps, or seeking within a video. To analyze events across the subset, use the 609 event rows; to analyze samples, first group them by the 300 distinct `sample_id` values.
data/event_annotations_300_samples.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6c862a1cbf9ae200f34d4e8da9ce947271ff2240fa7f7c3196929b1c3f195eea
3
- size 213144
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c75be80c07f7101b854640a01fabc669c80845f86b4172419c92cf50e71d8cf9
3
+ size 216366