当前位置:   article > 正文

wave2lip训练_wav2lip 训练

wav2lip 训练

论文:https://arxiv.org/pdf/2008.10010.pdf

训练源码:https://github.com/Rudrabha/Wav2Lip

经过调整过的代码:https://gitee.com/sparkle__code__guy/wave2lip 

ffmpeg的安装:https://blog.csdn.net/sslfk/article/details/123050218 ,可以window,也可以linux

训练配置:首先必须依赖GPU

下载源码,下载专家判别系统:Sign in to your account

并将模型放到 checkpoints文件目录下

第一步:准备视频数据,爬取可以通过硕鼠爬取想要的人物说话风格数据

第二步:执行preprocess.py,执行命令如下:

python preprocess.py --ngpu 1 --data_root data/original_data2 --preprocessed_root data/preprocessed_root2

其中,data_root为原始视频地址,preprocessed_root为处理完的视频存放的位置;准备的视频数量至少为3个才可以。

第三步骤:获取对应的文件列表并更新到filelists/train.txt和filelists/eval.txt。只保存对应的视频名称即可。代码可以参考,对视频样本重命名并生成对应的命名列表,此处视频文件数量过少<2,会报错:

  1. import time
  2. from glob import glob
  3. import shutil,os
  4. from sklearn.model_selection import train_test_split
  5. #去除名字的特殊符号,统一序号视频文件命名
  6. def original_video_name_format():
  7. base_path = "data/original_data"
  8. result = list(glob("{}/*".format(base_path),recursive=False))
  9. file_num = 0
  10. result_list = []
  11. for each in result:
  12. file_num +=1
  13. new_position ="{0}{1}".format( int(time.time()),file_num)
  14. result_list.append(new_position)
  15. shutil.move(each, os.path.join(base_path,new_position+".mp4"))
  16. pass
  17. def trained_data_name_format():
  18. base_path = "data/preprocessed_root/original_data"
  19. result = list(glob("{}/*".format(base_path)))
  20. print(result)
  21. result_list = []
  22. for i,dirpath in enumerate(result):
  23. shutil.move(dirpath,"{0}/{1}".format(base_path,i))
  24. result_list.append(str(i))
  25. if len(result_list)<14:
  26. test_result=val_result=train_result=result_list
  27. else:
  28. train_result,test_result = train_test_split(result_list,test_size=0.15, random_state=42)
  29. test_result, val_result = train_test_split(test_result, test_size=0.5, random_state=42)
  30. for file_name,dataset in zip(("train.txt","test.txt","val.txt"),(train_result,test_result,val_result)):
  31. with open(os.path.join("filelists",file_name),'w',encoding='utf-8') as fi:
  32. fi.write("\n".join(dataset))
  33. print("\n".join(result_list))

第四步骤:

执行如下命令,开始训练:

python wav2lip_train.py --data_root ./data/preprocessed_root/original_data --checkpoint_dir ./savedmodel --syncnet_checkpoint_path ./checkpoints/lipsync_expert.pth --checkpoint_path ./checkpoints/wav2lip.pth

训练过程如下图:

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Lya5Y-RcGFwZXLnmoTlrabmuKM=,size_20,color_FFFFFF,t_70,g_se,x_16

 其他环境配置参考:README.md · 仓库11360838 - Gitee.com

模型预测

python inference.py --checkpoint_path Wav2Lip/savedmodel/checkpoint_step000000001.pth --face Wav2Lip/data/original_data/test.mp4 --audio Wav2Lip/data/preprocessed_root/original_data/1/audio.wav 

调整后的代码路径为: https://gitee.com/sparkle__code__guy/wave2lip

有需要联系请邮箱:1115349889@qq.com

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/323430
推荐阅读
相关标签
  

闽ICP备14008679号