【1】COGVIDEO生成视频
1. 背景
cogvideoX是清华和清影同源的开源视频生成大模型,详情可以查看:CogvideoX
其中模型差异如下:
![[09 大模型专区/ob_photo/Pasted image 20241102155335.png]]
2. 搭建
2.1 搭建comfy-ui
下载和使用comfy-ui,配置可以查看:FLUX安装与使用
2.2 下载ComfyUI-CogVideoXWrapper
进入comfyUI,下载CogVideoXWrapper,这是一个cogvideo的中转器
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-CogVideoXWrapper.git
git clone https://github.com/MinusZoneAI/ComfyUI-CogVideoX-MZ
2.3 启动comfyui
启动即可,--listen是监听IP,一般是你自己服务器的IP,如果没有设置listen,则是默认的locatehost
python3 main.py --listen 10.229.41.60
然后访问对应的8188端口即可。
http://10.229.41.60:8188
⚠️ 注意:
- ==操作前请备份重要文件。注意直接启动可能会报错,因为他运行会安装Python的依赖,其实就是需要安装ComfyUI-CogVideoXWrapper的依赖,这个使用需要仔细看原因,或者手动安装依赖.==
- ==一定要安装python 3.12以上的版本,不然会跑不起来==
安装ComfyUI-CogVideoXWrapper的依赖
cd custom_nodes/ComfyUI-CogVideoXWrapper
pip install -r requirements.txt
安装comfyui的依赖
cd ComfyUI
pip install -r requirements.txt
## 2.4 下载模型
直接启动有可能不成功,默认配置是从huggingface中下载模型,如果无法连接,就手动从魔塔社区手动下载。
进入models
cd ComfyUI/models
新建CogVideo文件夹
mkdir CogVideo
下载对应的模型
### 2.4.1 下载clip模型
国外huggingface: https://huggingface.co/comfyanonymous/flux_text_encoders/tree/main
国内用魔塔社区: https://modelscope.cn/models/AI-ModelScope/flux_text_encoders/files
需下载 t5xxl_fp16.safetensors 或 t5xxl_fp8_e4m3fn.safetensors (建议选择fp8 版本,如果你显存超过 32G 可选择 fp16 版本),用于文本对齐
需下载 clip_l.safetensors,用于文本对齐
```bash
cd ComfyUI/models/clip
# 下载clip_l.safetensors
wget https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/clip_l.safetensors
wget https://modelscope.cn/models/AI-ModelScope/flux_text_encoders/resolve/master/clip_l.safetensors
# 下载t5xxl_fp16.safetensors
wget https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/t5xxl_fp16.safetensors
wget https://modelscope.cn/models/AI-ModelScope/flux_text_encoders/resolve/master/t5xxl_fp16.safetensors
# 下载t5xxl_fp8_e4m3fn.safetensors
wget https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/t5xxl_fp8_e4m3fn.safetensors
wget https://modelscope.cn/models/AI-ModelScope/flux_text_encoders/resolve/master/t5xxl_fp8_e4m3fn.safetensors
从魔塔社区直接下载的是多个safetensors,需要合并到一起
2.4.2 魔塔社区下载
pip install modelscope
# 指定下载到dir位置
modelscope download --model ZhipuAI/CogVideoX-5b-I2V --local_dir ./dir
3. 多个safetensors合并
有些时候魔塔社区没有对应的safetensors的模型,需要手动将huggingface里的模型进行合并,可以通过如下Python脚本进行合并。
from safetensors import safe_open, safe_save
import torch
# 定义分块文件的路径
files = [
"diffusion_pytorch_model-00001-of-00002.safetensors",
"diffusion_pytorch_model-00002-of-00002.safetensors"
]
# 合并后的文件保存路径
merged_file_path = "merged_diffusion_model.safetensors"
# 初始化一个空的字典来存储所有参数
state_dict = {}
# 遍历每个分块文件并加载其内容
for file in files:
with safe_open(file, framework="pt") as f:
for key in f.keys():
state_dict[key] = f.get_tensor(key)
# 将合并的状态字典保存到一个新的safetensors文件
safe_save(state_dict, merged_file_path)
print("合并完成,保存路径:", merged_file_path)
下载其他模型:
# 下载到unet文件夹
wget https://modelscope.cn/models/wailovet/CogVideoX-5b/resolve/master/CogVideoX_5b_fp8_4em.safetensors
# 下载到vae文件夹(记得重命名文件名方便辨认)
wget https://modelscope.cn/models/zhipuai/cogvideox-5b/resolve/master/vae/diffusion_pytorch_model.safetensors
# 下载到clip文件夹(和sd3/flux通用,不需要重复下载
https://modelscope.cn/models/ai-modelscope/flux_text_encoders/resolve/master/t5xxl_fp8_e4m3fn.safetensors
4. 使用效果
通过img2video,使用效果如下:

使用cogvidex_fun_i2v_example_01.json
图生视频效果不好,clip很难理解图片中的各种关系,从而展示我希望的图片,提示词如下:
睁开眼睛慢慢的看着镜头
Open your eyes and slowly look at the camera.

幽暗的古堡,广阔的星空,月光下人形在缓慢的靠近,让人恐惧和未知
Dark and ancient castle, vast starry sky, a figure slowly approaching under the moonlight, instilling feelings of fear and the unknown.

The spacecraft begins to fly from the left side of the scene.

cogvideox_5b_example_01.json
文生视频效果还不错
在深邃的太空中,背景有小星球,一架宇宙飞船在画面正中心
In the depths of space, with small planets in the background, a spacecraft is at the center of the scene.The spacecraft begins to fly from the left side of the scene
本文发布于2024年11月19日20:23,已经过了404天,若内容或图片失效,请留言反馈 -
github大模型软件评测
1. 背景 互联网上有许多开源的大模型软件,每种软件都有其独特的功能和优缺点。我曾试用过许多大模型软件,但最终效果和具体内容都未能完全记住。因此,本文将主要记录我所了解和使用过的大模型软件。此外,文中...
2025/02/19
-
whisper.cpp安装
1. 背景 whisper是OpenAI官方发布的一款开源语音识别大模型,使用python实现。可以将语音信息转化为文本信息。其实也叫做ASR"自动语音识别”(Automatic Speech Rec...
2025/03/02
-
【1】COGVIDEO生成视频
1. 背景 cogvideoX是清华和清影同源的开源视频生成大模型,详情可以查看:CogvideoXhttps://modelscope.cn/models/ZhipuAI/CogVideoX-5b-...
2024/11/19
-
whisper.cpp测试与使用
whipser.cpp安装完毕后,加载了多个大模型,分别进行测试。 测试项目 下载模型命令: bash sh ./models/download-ggml-model.sh base 测试命令: 转化...
2025/04/21
求索空间
apostle9891
360视觉云
360智慧生活
gitea
导航
hoppscotch
暂无评论