Add extract_ego4d_batch.py for efficient EgoSpeak clip extraction. This script loads the Qwen model once and processes selected manifest rows sequentially, ensuring each clip is handled independently. Update README with usage instructions and details on the extraction process, including handling of completed outputs and memory management.
This commit is contained in:
32
README.md
32
README.md
@@ -685,6 +685,38 @@ conversion can differ slightly; validate a short Decord/PyNvVideoCodec pair
|
||||
before extracting every session, and do not mix decoder backends across
|
||||
train/test splits.
|
||||
|
||||
### Persistent-model Ego4D batch extraction
|
||||
|
||||
`extract_ego4d_batch.py` loads Qwen and its processor once, then extracts the
|
||||
selected EgoSpeak manifest rows sequentially. Each clip receives a new media
|
||||
reader, Thinker KV cache, TMRoPE origin, and rolling-memory state; only the
|
||||
immutable model weights and processor are reused. Manifest indices are
|
||||
one-based data-row indices and do not count the TSV header.
|
||||
|
||||
For example, process manifest samples 81 through the end on visible GPU 0:
|
||||
|
||||
```bash
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
OMP_NUM_THREADS=4 \
|
||||
MKL_NUM_THREADS=4 \
|
||||
OPENBLAS_NUM_THREADS=4 \
|
||||
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \
|
||||
python extract_ego4d_batch.py \
|
||||
--data-root /data1/yfzx/wangx/Datasets/ego4d \
|
||||
--model-id /data1/yfzx/wangx/Models/Qwen2.5-Omni-3B \
|
||||
--start-index 81 \
|
||||
--memory-seconds 20 \
|
||||
--video-fps 2 \
|
||||
--decoder decord \
|
||||
--dtype bfloat16 \
|
||||
--flash-attention-2 \
|
||||
--device cuda:0
|
||||
```
|
||||
|
||||
Completed non-empty `.pt` files are skipped. Each new output is first written
|
||||
to a process-specific `.partial` path and atomically renamed after extraction,
|
||||
so rerunning the same range resumes safely.
|
||||
|
||||
For CPU Decord, the direct reader intentionally indexes each clip and releases
|
||||
that temporary reader, then keeps an LRU of at most two live readers during
|
||||
extraction. Each reader defaults to one decode thread. These limits avoid one
|
||||
|
||||
Reference in New Issue
Block a user