lighthouse

lineApache-2.0活跃维护

面向视频/音频片段检索与高光检测的可复现 Python 库,统一多模态流程,方便研究者快速复现和对比实验结果。

[EMNLP2024 Demo], [ICASSP 2025], [ICASSP 2026] A user-friendly library for reproducible video moment retrieval and highlight detection. It also supports audio moment retrieval.

v1.2发布于 2025-11-20 06:48 UTC272star22fork同步于 2026-11-10 12:03 UTC

怎么上手

由 README 提炼,执行前请确认
apt install ffmpeg
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
pip install 'git+https://github.com/line/lighthouse.git'
硬件要求按 README 说明

推理 API 支持 CPU 与 GPU;CPU 环境建议用 feature_name='clip',因为 CLIP+Slowfast 或加 PANNs 特征在无 GPU 时很慢。README 未说明具体显存要求。

纯 CPU 可运行支持 Apple Silicon需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

可复现的视频时刻检索与高光检测库,支持音频时刻检索,开箱即用

面向视频/音频片段检索与高光检测的可复现 Python 库,统一多模态流程,方便研究者快速复现和对比实验结果。

核心能力

  • 集成七种 MR-HD 模型,含 CG-DETR、QD-DETR、TaskWeave
  • 支持视频与音频四类特征,含 CLIP+Slowfast+PANNs
  • 覆盖六个数据集,含 QVHighlights、TVSum、Clotho
  • 提供推理 API 与 Gradio 演示,可直接上传视频查询
  • 支持音频时刻检索任务与 CASTELLA 数据集

容易踩的坑

需先安装 ffmpeg,否则视频特征编码会失败;使用 clip_slowfast 特征需额外下载 SLOWFAST_8x8_R50.pkl,用 clip_slowfast_pann 还需下载 PANNs 权重;受基准数据集限制,视频最长仅支持 150 秒。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

3 个版本v1.2
  1. v1.2version 1.2最新正式版2025-11-20 · 2025-11-20 06:48 UTC

    This version supports for a new AMR dataset called CASTELLA.

  2. v1.1version 1.12025-06-03 · 2025-06-03 22:48 UTC
    查看更新说明

    This version contains some minor modifications.

    • Fix interface of API and update demo
    • Fix dependency of library
    • Support some models on HuggingFace
  3. v1.0version 1.02024-10-22 · 2024-10-22 09:19 UTC
    查看更新说明

    This version is the first stable version of lighthouse. It has the following features:

    • Supports recent 7 methods, 6 datasets, and 3 features for moment retrieval and highlight detection
    • Releases all of the pre-trained weights and features on Google drive. Several models are available on Zenodo.
    • Supports audio moment retrieval
    • Inference API and web demo
    • Supports audio features (PANNs) for QVHighlight
    • Supports pre-training based on YouTube captions

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Lighthouse

    Contributions welcome License Video moment retrieval demo Audio moment retrieval demo Run pytest Run mypy and ruff

    Lighthouse is a user-friendly library for reproducible video moment retrieval and highlight detection (MR-HD). It supports seven models, four features (video and audio features), and six datasets for reproducible MR-HD, MR, and HD. In addition, we prepare an inference API and Gradio demo for developers to use state-of-the-art MR-HD approaches easily. Furthermore, Lighthouse supports audio moment retrieval, a task to identify relevant moments from an audio input based on a given text query.

    News

    Installation

    Install ffmpeg first. If you are an Ubuntu user, run:

    apt install ffmpeg
    

    Then, install pytorch, torchvision, and torchaudio based on your GPU environments. Note that the inference API is available for CPU environments. We tested the codes on Python 3.9 and CUDA 11.8:

    pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
    

    Finally, run to install dependency libraries:

    pip install 'git+https://github.com/line/lighthouse.git'
    

    Inference API (Available for both CPU/GPU mode)

    Lighthouse supports the following inference API:

    import torch
    from lighthouse.models import CGDETRPredictor
    
    # use GPU if available
    device = "cuda" if torch.cuda.is_available() else "cpu"
    
    # slowfast_path is necesary if you use clip_slowfast features
    query = 'A man is speaking in front of the camera'
    model = CGDETRPredictor('/path/to/weight.ckpt', device=device,
                            feature_name='clip_slowfast', slowfast_path='SLOWFAST_8x8_R50.pkl')
    
    # encode video features
    video = model.encode_video('api_example/RoripwjYFp8_60.0_210.0.mp4')
    
    # moment retrieval & highlight detection
    prediction = model.predict(query, video)
    print(prediction)
    """
    pred_relevant_windows: [[start, end, score], ...,]
    pred_saliency_scores: [score, ...]
    
    {'query': 'A man is speaking in front of the camera',
     'pred_relevant_windows': [[117.1296, 149.4698, 0.9993],
                               [-0.1683, 5.4323, 0.9631],
                               [13.3151, 23.42, 0.8129],
                               ...],
     'pred_saliency_scores': [-10.868017196655273,
                              -12.097496032714844,
                              -12.483806610107422,
                              ...]}
    """
    

    Lighthouse also supports the AMR inference API:

    import torch
    from lighthouse.models import QDDETRPredictor
    
    device = "cuda" if torch.cuda.is_available() else "cpu"
    model = QDDETRPredictor('/path/to/weight.ckpt', device=device, feature_name='clap')
    
    audio = model.encode_audio('api_example/1a-ODBWMUAE.wav')
    query = 'Water cascades down from a waterfall.'
    prediction = model.predict(query, audio)
    print(prediction)
    

    Run python api_example/demo.py (MR-HD) or python api_example/amr_demo.py (AMR) to reproduce the results. It automatically downloads pre-trained weights. If you want to use other models, download pre-trained weights. When using clip_slowfast features, it is necessary to download slowfast pre-trained weights. When using clip_slowfast_pann features, in addition to the slowfast weight, download panns weights. Run python api_example/amr_demo.py to reproduce the AMR results.

    Limitation: The maximum video duration is 150s due to the current benchmark datasets. For CPU users, set feature_name='clip' because CLIP+Slowfast or CLIP+Slowfast+PANNs features are very slow without GPUs.

    Gradio demo

    Run python gradio_demo/demo.py. Upload the video and input text query, and click the blue button. For AMR demo, run python gradio_demo/amr_demo.py.

    MR-HD demo Gradio demo image

    AMR demo Amr demo image

    Supported models, datasets, and features

    Models

    Moment retrieval & highlight detection

    Datasets

    Moment retrieval & highlight detection

    Moment retrieval

    Highlight detection

    Audio moment retrieval

    Features

    • : ResNet+GloVe
    • : CLIP
    • : CLIP+Slowfast
    • : CLIP+Slowfast+PANNs (Audio) for QVHighlights
    • : I3D+CLIP (Text) for TVSum

    Reproduce the experiments

    Pre-trained weights

    Pre-trained weights can be downloaded from here. Download and unzip on the home directory. AMR models trained on CASTELLA and Clotho-Moment is available in here

    Datasets

    Due to the copyright issue, we here distribute only feature files. Download and place them under ./features directory. To extract features from videos, we use HERO_Video_Feature_Extractor.

    For AMR, download features from here.

    The whole directory should be look like this:

    lighthouse/
    ├── api_example
    ├── configs
    ├── data
    ├── features # Download the features and place them here
    │   ├── ActivityNet
    │   │   ├── clip
    │   │   ├── clip_text
    │   │   ├── resnet
    │   │   └── slowfast
    │   ├── Charades
    │   │   ├── clip
    │   │   ├── clip_text
    │   │   ├── resnet
    │   │   ├── slowfast
    │   ├── QVHighlight
    │   │   ├── clip
    │   │   ├── clip_text
    │   │   ├── pann
    │   │   ├── resnet
    │   │   └── slowfast
    │   ├── tacos
    │   │   ├── clip
    │   │   ├── clip_text
    │   │   ├── resnet
    │   │   └── slowfast
    │   ├── tvsum
    │   │   ├── clip
    │   │   ├── clip_text
    │   │   ├── i3d
    │   │   ├── resnet
    │   │   ├── slowfast
    │   ├── youtube_highlight
    │   │   ├── clip
    │   │   ├── clip_text
    │   │   └── slowfast
    │   └── clotho-moments
    │       ├── clap
    │       └── clap_text
    ├── gradio_demo
    ├── images
    ├── lighthouse
    ├── results # The pre-trained weights are saved in this directory
    └── training
    

    Training and evaluation

    Training

    The training command is:

    python training/train.py --model MODEL --dataset DATASET --feature FEATURE [--resume RESUME] [--domain DOMAIN]
    
    Options
    Modelmoment_detr, qd_detr, eatr, cg_detr, uvcom, tr_detr, taskweave_mr2hd, taskweave_hd2mr
    Featureresnet_glove, clip, clip_slowfast, clip_slowfast_pann, i3d_clip, clap
    Datasetqvhighlight, qvhighlight_pretrain, activitynet, charades, tacos, tvsum, youtube_highlight, clotho-moment

    (Example 1) Moment DETR w/ CLIP+Slowfast on QVHighlights:

    python training/train.py --model moment_detr --dataset qvhighlight --feature clip_slowfast
    

    (Example 2) Moment DETR w/ CLIP+Slowfast+PANNs (Audio) on QVHighlights:

    python training/train.py --model moment_detr --dataset qvhighlight --feature clip_slowfast_pann
    

    (Pre-train & Fine-tuning, QVHighlights only) Lighthouse supports pre-training. Run:

    python training/train.py --model moment_detr --dataset qvhighlight_pretrain --feature clip_slowfast
    

    Then fine-tune the model with --resume option:

    python training/train.py --model moment_detr --dataset qvhighlight --feature clip_slowfast --resume results/moment_detr/qvhighlight_pretrain/clip_slowfast/best.ckpt
    

    (TVSum and YouTube Highlight) To train models on these two datasets, you need to specify domain:

    python training/train.py --model moment_detr --dataset tvsum --feature clip_slowfast --domain BK
    
    Evaluation

    The evaluation command is:

    python training/evaluate.py --model MODEL --dataset DATASET --feature FEATURE --split {val,test} --model_path MODEL_PATH --eval_path EVAL_PATH [--domain DOMAIN]
    

    (Example 1) Evaluating Moment DETR w/ CLIP+Slowfast on the QVHighlights val set:

    python training/evaluate.py --model moment_detr --dataset qvhighlight --feature clip_slowfast --split val --model_path results/moment_detr/qvhighlight/clip_slowfast/best.ckpt --eval_path data/qvhighlight/highlight_val_release.jsonl
    

    To generate submission files for QVHighlight test sets, change split into test (QVHighlights only):

    python training/evaluate.py --model moment_detr --dataset qvhighlight --feature clip_slowfast --split test --model_path results/moment_detr/qvhighlight/clip_slowfast/best.ckpt --eval_path data/qvhighlight/highlight_test_release.jsonl
    

    Then zip hl_val_submission.jsonl and hl_test_submission.jsonl, and submit it to the Codalab (QVHighlights only):

    zip -r submission.zip val_submission.jsonl test_submission.jsonl
    

    HuggingFace Wrapper

    We support wrappers for HuggingFace. You can easily use models and dataset via AutoModel and huggingface_hub.

    The following models and datasets are provided by the wrapper for HuggingFace.

    Models

    Datasets

    Citation

    Lighthouse

    @InProceedings{taichi2024emnlp,
      author    = {Taichi Nishimura and Shota Nakada and Hokuto Munakata and Tatsuya Komatsu},
      title     = {Lighthouse: A User-Friendly Library for Reproducible Video Moment Retrieval and Highlight Detection},
      booktitle = {Proceedings of The 2024 Conference on Empirical Methods in Natural Language Processing: System Demonstrations},
      year      = {2024},
    }
    

    Audio moment retrieval

    @InProceedings{hokuto2025icassp,
      author    = {Hokuto Munakata and Taichi Nishimura and Shota Nakada and Tatsuya Komatsu},
      title     = {Language-based Audio Moment Retrieval},
      booktitle = {IEEE International Conference on Acoustic, Speech, and Signal Processing},
      year      = {2025},
    }
    

    Contributing

    Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

    LICENSE

    Apache License 2.0

    Contact

    Taichi Nishimura ([email protected])