Skip to content

lavad项目的简单复现(适配macos平台)

Notifications You must be signed in to change notification settings

emo1mo/lavad-mps

Repository files navigation

lavad-mps

项目简介 / Project Overview

lavad-mps 是在原项目 lavad 的基础上进行修改的版本,主要适配了 macOS (Apple Silicon / MPS 加速) 平台,同时保留了原始功能与结构,方便在不同硬件和操作系统上复现。

The lavad-mps project is a modified version of the original lavad repository, adapted for macOS (Apple Silicon / MPS acceleration), while retaining the original functionality and structure for easier reproduction across various hardware and OS environments.


主要改动 / Key Modifications

  • 将原始的 CUDA 专用代码 修改为 MPS(Metal Performance Shaders) 兼容版本,用于 MacBook (Apple Silicon)。
  • 调整了部分 shell 脚本,以保证在 macOS 上路径格式 (/ 而非 \) 正确。
  • 删除了 Windows 和 Linux 平台下不兼容的部分依赖。
  • 更新了 README 文档,提供了中英文复现说明。

环境要求 / Environment Requirements

macOS

  • macOS 13+
  • Apple Silicon 芯片(M1 / M2 / M3)
  • Python 3.10+
  • Anaconda 或 Miniconda

Linux / Windows

  • CUDA 11.8+ (Linux / Windows)
  • NVIDIA GPU (6GB+ VRAM 建议)
  • Python 3.10+

安装步骤 / Installation Steps

1. 克隆项目 / Clone the Repository

git clone https://github.com/emo-naxia/lavad-mps.git
cd lavad-mps

2. 创建虚拟环境 / Create a Virtual Environment

conda create -n lavad_mps python=3.10 -y
conda activate lavad_mps

3. 安装依赖 / Install Dependencies

macOS (MPS)

pip install -r requirements.txt

Linux / Windows (CUDA)

pip install -r requirements_cuda.txt

运行流程 / Running the Pipeline

  1. 提取视频帧 / Extract frames
./scripts/00_extract_frames.sh <VIDEO_NAME>
  1. 生成字幕 / Generate captions
./scripts/01_caption.sh <VIDEO_NAME>
  1. 创建索引 / Create index
./scripts/02_create_index.sh <VIDEO_NAME>
  1. 清洗字幕 / Clean captions
./scripts/03_clean_captions.sh <VIDEO_NAME>
  1. 调用 LLM 进行异常打分 / Query LLM for anomaly scores
./scripts/04_query_llm.sh <VIDEO_NAME>
  1. 生成摘要索引 / Create summary index
./scripts/05_create_summary_index.sh <VIDEO_NAME>
  1. 优化异常分数 / Refine anomaly scores
./scripts/06_refine_anomaly_scores.sh <VIDEO_NAME>
  1. 评估结果 / Evaluate results
./scripts/07_eval.sh <VIDEO_NAME>

注意事项 / Notes

  • 本项目已适配 macOS MPS,但在 CUDA 环境下依然可运行。
  • 某些路径依赖于 datasets 目录的结构,请严格按照原始数据组织方式。
  • 原项目作者的 CUDA 版 README 依然适用,只需将设备参数改为 mps 即可。

致谢 / Acknowledgements

原始项目作者:lavad by lucazanella
This repository is a modified version of the original lavad repository by lucazanella.

About

lavad项目的简单复现(适配macos平台)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published