中文网站模板大全,个体户千万不能去注销,温州市住房和城乡建设局,颜金华深圳广告公司文章目录 一、项目介绍二、项目部署模型的权重下载提取目标图像的关节点图像#xff08;这个可以先不看先用官方提供的数据集进行生成#xff09;提取人脸#xff08;这个也可以先不看#xff09;进行图片的生成 三、模型部署报错 一、项目介绍
由复旦、微软、虎牙、CMU的… 文章目录 一、项目介绍二、项目部署模型的权重下载提取目标图像的关节点图像这个可以先不看先用官方提供的数据集进行生成提取人脸这个也可以先不看进行图片的生成 三、模型部署报错 一、项目介绍
由复旦、微软、虎牙、CMU的研究团队提出的StableAnimator框架实现了高质量和高保真的ID一致性人类视频生成。 当前的人类图像动画扩散模型很难确保身份 (ID) 的一致性。本文介绍了 StableAnimator这是第一个端到端保留 ID 的视频扩散框架它无需任何后处理即可合成高质量视频以参考图像和一系列姿势为条件。 StableAnimator 以视频扩散模型为基础包含精心设计的模块用于训练和推理力求身份一致性。特别是StableAnimator 首先分别使用现成的提取器计算图像和面部嵌入并通过使用全局内容感知面部编码器与图像嵌入交互来进一步细化面部嵌入。然后StableAnimator 引入了一种新颖的分布感知 ID 适配器可防止时间层造成的干扰同时通过对齐保留 ID。在推理过程中我们提出了一种新颖的基于 Hamilton-Jacobi-Bellman (HJB) 方程的优化以进一步提高人脸质量。我们证明求解 HJB 方程可以集成到扩散去噪过程中所得解约束去噪路径从而有利于 ID 保留。多个基准测试的实验在定性和定量上都证明了 StableAnimator 的有效性。
github项目地址
二、项目部署
浏览器下载pytorch、torchvision、torchaudio 下载pytorch相关的网页 下载后用命令安装
pip install torchaudio-2.5.1cu124-cp310-cp310-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple模型的权重下载
将huggingface下的模型权重下的权重文件按照如下的文件目录进行下载 StableAnimator/ ├── DWPose ├── animation ├── checkpoints │ ├── DWPose │ │ ├── dw-ll_ucoco_384.onnx │ │ └── yolox_l.onnx │ ├── Animation │ │ ├── pose_net.pth │ │ ├── face_encoder.pth │ │ └── unet.pth │ ├── SVD │ │ ├── feature_extractor │ │ ├── image_encoder │ │ ├── scheduler │ │ ├── unet │ │ ├── vae │ │ ├── model_index.json │ │ ├── svd_xt.safetensors │ │ └── svd_xt_image_decoder.safetensors │ └── inference.zip ├── models │ │ └── antelopev2 │ │ ├── 1k3d68.onnx │ │ ├── 2d106det.onnx │ │ ├── genderage.onnx │ │ ├── glintr100.onnx │ │ └── scrfd_10g_bnkps.onnx ├── app.py ├── command_basic_infer.sh ├── inference_basic.py ├── requirement.txt
提取目标图像的关节点图像这个可以先不看先用官方提供的数据集进行生成
将参考图像需要提取关节点的图像放在target_images里命名为frame_i 运行如代码从target_images中提取关节点的信息
python DWPose/skeleton_extraction.py --target_image_folder_path/media/dell/DATA/RK/StableAnimator-main/inference/test/target_images --ref_image_path/media/dell/DATA/RK/StableAnimator-main/inference/case-1/reference.png --poses_folder_path/media/dell/DATA/RK/StableAnimator-main/inference/test/pose提取结果报错在pose文件夹里
提取人脸这个也可以先不看
需要将以下模型权重下载到指定文件夹里 Downloading: “https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth” to /home/dell/anaconda3/envs/stableanimator/lib/python3.10/site-packages/facexlib/weights/detection_Resnet50_Final.pth Downloading: “https://github.com/xinntao/facexlib/releases/download/v0.2.2/parsing_parsenet.pth” to /home/dell/anaconda3/envs/stableanimator/lib/python3.10/site-packages/facexlib/weights/parsing_parsenet.pth Downloading: “https://github.com/xinntao/facexlib/releases/download/v0.2.0/parsing_bisenet.pth” to /home/dell/anaconda3/envs/stableanimator/lib/python3.10/site-packages/facexlib/weights/parsing_bisenet.pth
运行一下带代码从一个包含图片的文件夹中提取每张图片的人脸掩码存储到当前同级文件夹的face文件夹里
python face_mask_extraction.py --image_folder/media/dell/DATA/RK/StableAnimator-main/inference/case-1进行图片的生成
bash command_basic_infer.sh将以下文件夹的一些参数修改为你自己的参数
CUDA_VISIBLE_DEVICES0 python inference_basic.py \--pretrained_model_name_or_pathpath/checkpoints/SVD/stable-video-diffusion-img2vid-xt \--output_dir/media/dell/DATA/RK/StableAnimator-main/inference/output \--validation_control_folder/media/dell/DATA/RK/StableAnimator-main/inference/test/pose \--validation_imagepath/inference/case-1/reference.png \--width576 \--height1024 \--guidance_scale3.0 \--num_inference_steps25 \--posenet_model_name_or_pathpath/checkpoints/Animation/pose_net.pth \--face_encoder_model_name_or_pathpath/checkpoints/Animation/face_encoder.pth \--unet_model_name_or_pathpath/checkpoints/Animation/unet.pth \--tile_size16 \--overlap4 \--noise_aug_strength0.02 \--frames_overlap4 \--decode_chunk_size4 \--gradient_checkpointing三、模型部署报错
①OSError: Can’t load image processor for ‘/media/dell/DATA/RK/StableAnimator-main/checkpoints/SVD/stable-video-diffusion-img2vid-xt’. If you were trying to load it from ‘https://huggingface.co/models’, make sure you don’t have a local directory with the same name. Otherwise, make sure ‘/media/dell/DATA/RK/StableAnimator-main/checkpoints/SVD/stable-video-diffusion-img2vid-xt’ is the correct path to a directory containing a preprocessor_config.json file 模型的路径写错了/media/dell/DATA/RK/StableAnimator-main/checkpoints/SVD 应该写这个刚刚的路径最后一个文件夹根本不存在
② Error no file named model.fpl6.safetensors found in directory /media/dell/DATA/RK/StableAnimator-main/checkpoints/SVD. 读取不了图像编码器的权重 OSError: Error no file named pytorch_model.bin, tf_model.h5, model.ckpt.index or flax_model.msgpack found in directory /media/dell/DATA/RK/StableAnimator-main/checkpoints/SVD/image_encoder.
将inference_basic.py文件中的第226行左右的模型加载代码进行修改 这里是原来的 image_encoder CLIPVisionModelWithProjection.from_pretrained(args.pretrained_model_name_or_path, subfolderimage_encoder, revisionargs.revision)将其修改为以下 image_encoder CLIPVisionModelWithProjection.from_pretrained(/media/dell/DATA/RK/StableAnimator-main/checkpoints/SVD/image_encoder, revisionfp16,variantfp16)注意这两个要一起加才能识别模型的权重
revisionfp16,variantfp16revision“fp16” 会告诉系统加载 FP16 精度的模型而 variant“fp16” 则指定推理或训练过程中的精度 两者协同作用确保你在运行时使用的是 FP16 精度的模型避免错误或不一致的精度设置 其他的vae和unet 的加载也要改成类似的
③模型运行后直接被杀死了
可能是内容爆掉了 我把unet的加载放到了 cuda里就正常运行了但是爆别的错误④ ④IndexError: list index out of range 我选择将输入的数据换成官方的数据试试 官方下载权重的文件夹里面的有一个inference的zip的压缩包
可以跑起来了显存占用15个G
⑤RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 30 but got size 29 for tensor number 1 in the list.
注意这个问题是由于我自己输出的图像的长宽不是32的整数宽为904倍导致的。
四、模型的生成结果 生成的流程 用官方提供的姿势文件夹pose 用自己的参考图像一张png 然后进行生成
用官方提供的第一个case的pose包含15张图片如果pose的帧数太多很容易被杀死 这是官方的512 * 512 的像素的 推理需要一分钟的时间生成图片的大小改为768*1024 官方的代码里给的是576 * 1024 生成的结果① ②参考图像用的自己的 生成图片的大小改为512 * 512的 官方的代码里给的是576 * 1024感觉生成的图像有些扭曲 注意参考图像需要和pose的比例一致比如pose是全身的参考图像是半身的话生成的内容会不一致。 参考图像用的这张 生成的结果 可以看到角色的一致性还是有些问题需要调整一些参数
③我用动漫的角色作为参考图像的话生成的效果并不保真
④将输入图像裁剪为和实力图像一样的大小512 * 512 或者 512 * 904 pose 的帧数选择20以内不然会爆内存被杀死
参考的图像
生成的结果 文章转载自: http://www.morning.fmswb.cn.gov.cn.fmswb.cn http://www.morning.hgsmz.cn.gov.cn.hgsmz.cn http://www.morning.byrlg.cn.gov.cn.byrlg.cn http://www.morning.pltbd.cn.gov.cn.pltbd.cn http://www.morning.pmysp.cn.gov.cn.pmysp.cn http://www.morning.dhckp.cn.gov.cn.dhckp.cn http://www.morning.scrnt.cn.gov.cn.scrnt.cn http://www.morning.sxlrg.cn.gov.cn.sxlrg.cn http://www.morning.mqbsm.cn.gov.cn.mqbsm.cn http://www.morning.wfwqr.cn.gov.cn.wfwqr.cn http://www.morning.tfkqc.cn.gov.cn.tfkqc.cn http://www.morning.qscsy.cn.gov.cn.qscsy.cn http://www.morning.rmlz.cn.gov.cn.rmlz.cn http://www.morning.qgbfx.cn.gov.cn.qgbfx.cn http://www.morning.lpqgq.cn.gov.cn.lpqgq.cn http://www.morning.fglzk.cn.gov.cn.fglzk.cn http://www.morning.rnfn.cn.gov.cn.rnfn.cn http://www.morning.qcsbs.cn.gov.cn.qcsbs.cn http://www.morning.skmpj.cn.gov.cn.skmpj.cn http://www.morning.tmzlt.cn.gov.cn.tmzlt.cn http://www.morning.nfbxgtj.com.gov.cn.nfbxgtj.com http://www.morning.rwcw.cn.gov.cn.rwcw.cn http://www.morning.nzmw.cn.gov.cn.nzmw.cn http://www.morning.bqpg.cn.gov.cn.bqpg.cn http://www.morning.fcftj.cn.gov.cn.fcftj.cn http://www.morning.wbxrl.cn.gov.cn.wbxrl.cn http://www.morning.bqppr.cn.gov.cn.bqppr.cn http://www.morning.bnrnb.cn.gov.cn.bnrnb.cn http://www.morning.qcwrm.cn.gov.cn.qcwrm.cn http://www.morning.qxgmp.cn.gov.cn.qxgmp.cn http://www.morning.skdrp.cn.gov.cn.skdrp.cn http://www.morning.fqyxb.cn.gov.cn.fqyxb.cn http://www.morning.fsrtm.cn.gov.cn.fsrtm.cn http://www.morning.lfqnk.cn.gov.cn.lfqnk.cn http://www.morning.xsfg.cn.gov.cn.xsfg.cn http://www.morning.bpmnz.cn.gov.cn.bpmnz.cn http://www.morning.nrjr.cn.gov.cn.nrjr.cn http://www.morning.lpnpn.cn.gov.cn.lpnpn.cn http://www.morning.trzzm.cn.gov.cn.trzzm.cn http://www.morning.cpctr.cn.gov.cn.cpctr.cn http://www.morning.cfccp.cn.gov.cn.cfccp.cn http://www.morning.pbknh.cn.gov.cn.pbknh.cn http://www.morning.wjhnx.cn.gov.cn.wjhnx.cn http://www.morning.piekr.com.gov.cn.piekr.com http://www.morning.gychx.cn.gov.cn.gychx.cn http://www.morning.c7507.cn.gov.cn.c7507.cn http://www.morning.mehrim.com.gov.cn.mehrim.com http://www.morning.mtsck.cn.gov.cn.mtsck.cn http://www.morning.rbjth.cn.gov.cn.rbjth.cn http://www.morning.wfdlz.cn.gov.cn.wfdlz.cn http://www.morning.qfplp.cn.gov.cn.qfplp.cn http://www.morning.080203.cn.gov.cn.080203.cn http://www.morning.tzkrh.cn.gov.cn.tzkrh.cn http://www.morning.rnlx.cn.gov.cn.rnlx.cn http://www.morning.ntffl.cn.gov.cn.ntffl.cn http://www.morning.mbrbg.cn.gov.cn.mbrbg.cn http://www.morning.jfjfk.cn.gov.cn.jfjfk.cn http://www.morning.ailvturv.com.gov.cn.ailvturv.com http://www.morning.dzzjq.cn.gov.cn.dzzjq.cn http://www.morning.srbfp.cn.gov.cn.srbfp.cn http://www.morning.gglhj.cn.gov.cn.gglhj.cn http://www.morning.cttgj.cn.gov.cn.cttgj.cn http://www.morning.dbcw.cn.gov.cn.dbcw.cn http://www.morning.rpkl.cn.gov.cn.rpkl.cn http://www.morning.ngcbd.cn.gov.cn.ngcbd.cn http://www.morning.xysxj.com.gov.cn.xysxj.com http://www.morning.pthmn.cn.gov.cn.pthmn.cn http://www.morning.nknt.cn.gov.cn.nknt.cn http://www.morning.pkdng.cn.gov.cn.pkdng.cn http://www.morning.lrmts.cn.gov.cn.lrmts.cn http://www.morning.drfrm.cn.gov.cn.drfrm.cn http://www.morning.ylsxk.cn.gov.cn.ylsxk.cn http://www.morning.fdrch.cn.gov.cn.fdrch.cn http://www.morning.sqhtg.cn.gov.cn.sqhtg.cn http://www.morning.qxmys.cn.gov.cn.qxmys.cn http://www.morning.nnttr.cn.gov.cn.nnttr.cn http://www.morning.kpcky.cn.gov.cn.kpcky.cn http://www.morning.gmysq.cn.gov.cn.gmysq.cn http://www.morning.gcqs.cn.gov.cn.gcqs.cn http://www.morning.jntcr.cn.gov.cn.jntcr.cn