Pytorch Implementation of ACM MM 2024 paper "VrdONE: One-stage Video Visual Relation Detection".
Video Visual Relation Detection (VidVRD) focuses on understanding how entities interact over time and space in videos, a key step for gaining deeper insights into video scenes beyond basic visual tasks. Traditional methods for VidVRD, challenged by its complexity, typically split the task into two parts: one for identifying what relation categories are present and another for determining their temporal boundaries. This split overlooks the inherent connection between these elements. Addressing the need to recognize entity pairs' spatiotemporal interactions across a range of durations, we propose VrdONE, a streamlined yet efficacious one-stage model. VrdONE combines the features of subjects and objects, turning predicate detection into 1D instance segmentation on their combined representations. This setup allows for both relation category identification and binary mask generation in one go, eliminating the need for extra steps like proposal generation or post-processing. VrdONE facilitates the interaction of features across various frames, adeptly capturing both short-lived and enduring relations. Additionally, we introduce the Subject-Object Synergy (SOS) module, enhancing how subjects and objects perceive each other before combining. VrdONE achieves state-of-the-art performances on the VidOR benchmark and ImageNet-VidVRD, showcasing its superior capability in discerning relations across different temporal scales.
- This repository needs
python=3.10.14,pytorch=1.12.1, andtorchvision=0.13.1 - Run the following command to install the required packages.
pip install -r requirements.txt - Clone Shang's evaluation helper https://github.com/xdshang/VidVRD-helper to the root path and rename the folder as
VidVRD_helper.
Install ffmpeg using sudo apt-get install ffmpeg. The organization of datasets should be like this:
├── datasets
│ ├── coco
│ ├── mega
│ ├── vidor
│ │ ├── annotations
| | | ├── training
| | | | ├── 0000
| | | | ├── ...
| | | | └── 1203
| | | └── validation
| | | ├── 0001
| | | ├── ...
| | | └── 1203
| | ├── cache
| | | ├── MEGA_mask_clip_VidOR_training
| | | ├── MEGA_mask_clip_VidOR_validation
| | | ├── MEGA_mask_VidOR_training
| | | └── MEGA_mask_VidOR_validation
| | ├── features
| | | ├── clip_features_training
| | | ├── clip_val_proposal
| | | ├── GT_boxfeatures_training
| | | ├── MEGA_VidORval_cache
| | | | └─ MEGAv9_m60s0.3_freq1_VidORval_freq1_th_15-180-200-0.40.pkl
| | | └── vidor_per_video_val
| | ├── frames
│ │ └── videos
| | ├── 0000
| | ├── ...
| | └── 1203
| ├── VidSGG-BIG
│ ├── vidvrd
│ │ ├── annotations
| | | ├── test
| | | └── train
| | ├── cache
| | | ├── MEGA_mask_VidOR_test
| | | └── MEGA_mask_VidOR_train
| | ├── features
| | | ├── GT_boxfeatures_training
| | | ├── Proposal_boxfeatures_test
| | | ├── vidvrd_per_video_val
| | | └── VidVRD_test_every1frames
| | ├── frames
│ │ └── videos
| | ├── ILSVRC2015_train_00005003.mp4
| | ├── ...
| ├── vidor_policy.txt
| ├── vidor_video_to_frames.py
| └── vidvrd_video_to_frames.py
├── experiments
├── models
...
├── VidVRD_helper
...
- Download the VidOR dataset. Unzip all videos (training and validation) into
datasets/vidor/videos. Unzip the training and validation annotations intodatasets/vidor/annotations. - Go to the
datasetsdirectory and run the following command to decode the videos into frames.python vidor_video_to_frames.py - Extract visual features from gt bounding boxes. We follow Gao's method from https://github.com/Dawn-LX/VidVRD-tracklets. First, download the pretrained weight of MEGA and put it into
datasets/mega/ckpts. Step intodatasets/megaand run the following command to extract features.Or we can download our extracted features from Hugging Face and unzip it into the corresponding place.bash scripts/extract_vidor_gt.sh [gpu_id] - Download the extracted proposal features of validation set from Gao's method (BIG). Then, put it into
datasets/vidor/features/MEGA_VidORval_cache. We copy thedataloaderpart from BIG. Step intodatasets/VidSGG-BIGand divide the proposal features into per-video ones by the following command:python prepare_vidor_proposal.py - For the vrdone-x, we need to extract the clip features. First, install CLIP. Second, extract the features for training and evaluation respectively. We step into
datasets/mega, runandCUDA_VISIBLE_DEVICES=[gpu_id] python -W ignore extract_gt_clip_features_vidor.pyOr we can download our extracted features from Hugging Face and unzip them into the corresponding places.CUDA_VISIBLE_DEVICES=[gpu_id] python -W ignore extract_val_clip_features_vidor.py
- Download the ImageNet-VidVRD dataset. Unzip all videos into
datasets/vidvrd/videos. Unzip the annotations intodatasets/vidvrd/annotations. - Go to the
datasetsdirectory and run the following command to decode the videos into frames.python vidvrd_video_to_frames.py - Extract visual features from gt bounding boxes. We follow Gao's method from https://github.com/Dawn-LX/VidVRD-tracklets. Because Gao did not provide the trained checkpoints, we trained the model ourselves. Download COCO 2014 and put the dataset into
datasets/coco. Step intodatasets/megaand run the command to extract coco annotations.Then train the detector.python extract_coco.pyThen we finetune the detector using the ImageNet-VidVRD dataset.bash scripts/train_mega_vidvrd.sh 2 [gpu_ids]Or we can download our pretrained checkpoint from Hugging Face. Keep in mind that the model weightbash scripts/finetune_mega_vidvrd.sh 2 [gpu_ids]model_0190000.pthshould be put intodatasets/mega/experiments/vidvrd/COCO21VRDfreq5_2gpu_finetune_lr1. Then, extract the gt features of the training set with the following command:Or we can download our extracted features from Hugging Face and unzip it into the corresponding place.bash scripts/extract_vidvrd_gt.sh [gpu_id] - Download the extracted proposal features of test set from Gao's method (BIG). Then, put it into
datasets/vidvrd/features/VidVRD_test_every1frames. Step intodatasets/VidSGG-BIGand process the feature with:python prepare_vidvrd_proposal.py - For the proposal features, we further need to process them. Step into
datasets/megaand run:Or we can download our extracted features from Hugging Face and unzip it into the corresponding place.python -W ignore extract_test_features_vidvrd.py --gpu_id ${gpu_id}
- VrdONE for vidor. By default, we train the model with a single gpu.
Change the
bash scripts/train_vidor.sh 1 [gpu_id]batch_sizein the config and train the model with multiple gpus.bash scripts/train_vidor.sh [num_gpus] [gpu_ids] - VrdONE-X for vidor. By default, we train the model with a single gpu.
Change the
bash scripts/train_vidor_x.sh 1 [gpu_id]batch_sizein the config and train the model with multiple gpus.bash scripts/train_vidor_x.sh [num_gpus] [gpu_ids] - VrdONE for vidvrd.
bash scripts/train_vidvrd.sh 1 [gpu_id]
-
VrdONE for vidor. Download our vrdone checkpoint and evaluate with the following command.
bash scripts/eval_vidor_ckpt.sh [gpu_id]If we already have trained our own model, we can evaluate all trained checkpoints.
bash scripts/eval_vidor_multi.sh [gpu_id]We can change the
topkand theckpt_pathto check. -
VrdONE-X for vidor. Download our vrdone-x checkpoint and evaluate with the following command.
bash scripts/eval_vidor_x_ckpt.sh [gpu_id]If we already have trained our own model, we can evaluate all trained checkpoints.
bash scripts/eval_vidor_x_multi.sh [gpu_id]We can change the
topkand theckpt_pathto check. -
VrdONE for vidvrd. Download our vrdone checkpoint for vidvrd and Run:
bash scripts/eval_vidvrd_ckpt.sh [gpu_id]Or
bash scripts/eval_vidvrd_multi.sh [gpu_id]When using our provided model, don't forget to replace the config of
dataset_config.test_boxfeatures_dirto the path of our provided data.
Hugging Face model repository: https://huggingface.co/guacamole99/vrdone.
Hugging Face dataset repository: https://huggingface.co/datasets/guacamole99/vrdone_features.
| Model | Dataset | Extra Features | Download Path |
|---|---|---|---|
| VrdONE | VidOR | - | Hugging Face |
| VrdONE-X | VidOR | CLIP | Hugging Face |
| VrdONE | ImageNet-VidVRD | - | Hugging Face |
@inproceedings{jiang2024vrdone,
author = {Jiang, Xinjie and Zheng, Chenxi and Xu, Xuemiao and Liu, Bangzhen and Zheng, Weiying and Zhang, Huaidong and He, Shengfeng},
title = {VrdONE: One-stage Video Visual Relation Detection},
booktitle = {Proceedings of the 32nd ACM International Conference on Multimedia},
year = {2024},
}
This project is mainly based on ActionFormer, MaskFormer, and BIG. Thanks for their amazing projects!
