Skip to content

forXuyx/Cinego

Repository files navigation

Cinego(Cine means 🎬, ego means 🤖)

📌 简介

此项目继承自开源项目MiniMind-V,旨在扩展MiniMind-V实现视频理解功能,同时作为一个入门视频理解的入门教程😊。相比于MiniMind-V,我们仅增加了2M左右的参数。Let's go!

Note

请确保你已经熟悉了MiniMind-V的基本使用和训练流程。

项目功能清单(含待做)

  • 清洗出更轻量用于训练的数据集
  • 为了更好的适配,我们决定训练一个英文tokenizer
  • 完善UI界面,实现UI界面多轮对话逻辑
  • 实现多轮对话训练逻辑
  • 使用统一语言的数据集(首要需要解决的,感觉目前生成的全是胡言乱语......)
  • 进行多Stage的SFT(图片SFT -> 多轮对话图片SFT -> 视频SFT)
  • 复现GPT4Video中的VideoSummary结构
  • 实现数据特征的预提取(相当于少了clip获取embedding那一块的计算量,训练稍微能快一点)
  • 修改dataset结构兼容图片、视频、抽取特征

📌 推理结果

对于验证集,我们挑选了来自sora的一些合成视频

Video Title Description
Man on the cloud.mp4 A man is seen kneeling on the ground, looking directly at the camera, then showing the viewer with his hands and the camera.
Vlogger corgi.mp4 A dog looks down at the seashore and on the sand, with the video ending with credits.
Italian pup.mp4 A black and white dog sits on a window sill, with a camera panning around a house. The dog is seen walking down a sidewalk and running into a house.
Cat on the bed.mp4 A black and white cat is sitting on a bed.
Tokyo walk.mp4 A woman walks into the room, takes a few sips of her drink, and leaves. She then proceeds to pull a broom down the sidewalk while continuing to talk.
Photorealistic train.mp4 A small, blue and black train rushes past the track, with the yellow rail cement visible on the platform and a green track shown.
Dogs downtown.mp4 A white dog on a leash is groomed by a symphony, while a black dog runs into a standing dog. The dogs are seen running around.
SUV in dust.mp4 A yellow helicopter drives on a dirt road near a mountain, with a truck parked on the side of the road near the end.

📌 快速开始

开始前注意事项

  • 请确保具有完善的训练环境(请参照Minimind-V的README.md)
  • 请参照Minimind-V准备Minimind基座模型
  • 请根据自己需求下载数据集以及checkpoint和tokenizer

下载文件存放结构

Cinego
├── out
│   ├── lm_512.pth
│   ├── lm_768.pth
│   ├── pretrain_videolm_512.pth
│   ├── pretrain_videolm_768.pth
│   ├── sft_videolm_512.pth
│   └── sft_videolm_768.pth
├── dataset
│   ├── pretrain_vlm_data.jsonl
│   ├── pretrain_images
│   ├── sft_vlm_data_video.jsonl
│   ├── sft_video_features
│   └── eval_videos
├── model
│   ├── text_tokenizer
│   └── vision_model

第0步

git clone https://github.com/forXuyx/Cinego.git

Ⅰ 测试已有模型效果

1.命令行问答

python eval.py

2.或启动WebUI (待做)

python run webui.py

Ⅱ 从0开始自己训练

1.开始训练

1.1 预训练

bash scripts/train/train_pretrain_512_8.sh

执行预训练,得到 pretrain_videolm_*.pth 作为预训练的输出权重(其中*为模型的dimension,默认为512)

1.2 监督微调

python scripts/train/train_sft_512_8.sh

执行监督微调,得到 sft_videolm_*.pth 作为指令微调的输出权重

2.测试模型效果

确保需要测试的模型*.pth文件位于./out/目录下。

bash scripts/eval/eval_512_8.sh

Note

以上运行脚本均可根据自身情况自行修改,详情请见scripts目录下的脚本文件。

📌 数据介绍

在先前的项目中我选取了LLaVA-Video-178K数据集中的一个子集作为Pretrain以及SFT数据集,这是不合规的,但当初只是作为一个toy项目来做的,所以没有考虑那么多,这也导致训练出来的模型存在很大的幻视,但我发现有部分朋友在关注我这个项目,所以我现在想尝试将他做的好一点哈哈哈(大家都可以参与进来!)

目前所选数据集:

  • Pretrain数据集:与Minimind中所选用的Pretrain数据集保持一致(LLaVA-Video-178K)
  • SFT数据集:使用了来自VideoChatGPT大概180G的视频数据集

📌 数据以及checkpoint下载

  • SFT文本对:百度网盘
  • SFT视频数据:百度网盘
  • SFT视频特征数据(建议使用):上传中......
  • 验证数据集:百度网盘
  • tokenizer:百度网盘 (其实就是用Minimind的hq数据重新训了一遍哈哈哈)
  • 全部文件:上传中......

Note

我的所以数据均位于百度网盘,对于Linux用户,我建议使用bypy + aria2加速下载。

📌 Model Structure

与MiniMind-V的整体结构一致,只是新增了一个VideoSummary块。 其结构如下(还没画):

📌 A Suggestion

其实洞察整个项目,相比于Minimind-V不同就在于我新增了一个VideoSummary的结构,所以在这里其实我们最需要主要到的就是如何得到良好的视频特征表示,其他的是图像理解模型其实大同小异,这里我列举一些结构来获得视频特征表示:

  • 利用Clip得到每一帧的特征表示,然后汇聚每一帧的特征表示到一个CLS中去(本项目的方法)
  • 利用Blip得到每一帧的特征表示,然后在token维度拼接起来(不太建议这种方法,因为Blip预训练模型太大了)
  • 直接每一帧做平均(最简单的方法)

📌 Acknowledge

Note

如果觉得Cinego对你学习视频理解大模型有所帮助,可以在 GitHub 上加一个⭐
水平有限,欢迎任何形式的修改意见,请随时提issue或pr,我会尽快查看😊

😊鸣谢

参考链接 & 感谢以下优秀的论文或项目

License

This repository is licensed under the Apache-2.0 License.

About

🚀 轻量视频🎥 大模型🤖

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages