add audio2mesh model support
This commit is contained in:
1 parent
5eb304186a
commit
386df9a4ab
83 files changed
+9318
-1307
No files matched your search
@@ -0,0 +1,110 @@
|
||||
import moviepy
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
from moviepy.editor import *
|
||||
|
||||
STEP_VIDEO = False
|
||||
STEP_CONCATE = True
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
video_name = "2021-P09"
|
||||
path_root = Path(f"/yrfs/lsen/DATA/LuoXData/processing2/{video_name}")
|
||||
path_frame = path_root.joinpath(f"frames")
|
||||
path_audio = path_root.joinpath("audio/audio_trim.wav")
|
||||
|
||||
# load audio
|
||||
clip_audio = AudioFileClip(str(path_audio))
|
||||
clip_audio.set_duration(120.0)
|
||||
|
||||
# load video
|
||||
clip_video = ImageSequenceClip(path_frame, fps=50, load_images=True)
|
||||
clip_video.set_duration(120.0)
|
||||
|
||||
# add audio
|
||||
clip_image.write_videofile(str(path_image_save), fps=25)
|
||||
|
||||
concate_clips = concate_clips.set_audio(clip_audio)
|
||||
|
||||
# save
|
||||
path_concate_save = path_data.joinpath("concate4.mp4")
|
||||
#concate_clips = concate_clips.resize(width=720)
|
||||
|
||||
concate_clips.write_videofile(str(path_concate_save), fps=25)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# # to video
|
||||
# if STEP_VIDEO:
|
||||
# path_image = path_data.joinpath("frames_crop")
|
||||
# path_image_save = path_data.joinpath("images.mp4")
|
||||
# clip_image = ImageSequenceClip(path_image, fps=25, load_images=True)
|
||||
# clip_image.write_videofile(str(path_image_save), fps=25)
|
||||
|
||||
# path_frame = path_data.joinpath("render")
|
||||
# path_frame_save = path_data.joinpath("render.mp4")
|
||||
# clip_render = ImageSequenceClip(path_frame, fps=25, load_images=True)
|
||||
# clip_render.write_videofile(str(path_frame_save), fps=25)
|
||||
|
||||
# path_frame = path_data.joinpath("render_pt")
|
||||
# path_frame_save = path_data.joinpath("render_pt.mp4")
|
||||
# clip_render_pt = ImageSequenceClip(path_frame, fps=25, load_images=True)
|
||||
# clip_render_pt.write_videofile(str(path_frame_save), fps=25)
|
||||
|
||||
# path_frame = path_data.joinpath("render_pt_fix_idn")
|
||||
# path_frame_save = path_data.joinpath("render_pt_fix_idn.mp4")
|
||||
# clip_render_pt2 = ImageSequenceClip(path_frame, fps=25, load_images=True)
|
||||
# clip_render_pt2.write_videofile(str(path_frame_save), fps=25)
|
||||
|
||||
|
||||
# # concate
|
||||
# if STEP_CONCATE:
|
||||
|
||||
# # image
|
||||
# clip_image = VideoFileClip(str(path_data.joinpath("images.mp4"))).margin(10)
|
||||
# clip_text = TextClip("Crop Image", fontsize = 14, color = 'white', stroke_width=3)
|
||||
# clip_text = clip_text.set_pos((0.4, 0.9), relative=True).set_duration(clip_image.duration)
|
||||
# clip_image = CompositeVideoClip([clip_image, clip_text])
|
||||
|
||||
# # render
|
||||
# clip_render = VideoFileClip(str(path_data.joinpath("render.mp4"))).margin(10)
|
||||
# clip_text = TextClip("Render GT", fontsize = 14, color = 'white', stroke_width=3)
|
||||
# clip_text = clip_text.set_pos((0.4,0.9), relative=True).set_duration(clip_render.duration)
|
||||
# clip_render = CompositeVideoClip([clip_render, clip_text])
|
||||
|
||||
# # render with specific identiy
|
||||
# clip_render2 = VideoFileClip(str(path_data.joinpath("render_pt.mp4"))).margin(10)
|
||||
# clip_text = TextClip("Render PT fix identity", fontsize = 14, color = 'white', stroke_width=3)
|
||||
# clip_text = clip_text.set_pos((0.2,0.9), relative=True).set_duration(clip_render2.duration)
|
||||
# clip_render2 = CompositeVideoClip([clip_render2, clip_text])
|
||||
|
||||
# # render with specific identiy
|
||||
# clip_render3 = VideoFileClip(str(path_data.joinpath("render_pt_fix_idn.mp4"))).margin(10)
|
||||
# # clip_text = TextClip("Render PT with fixed identity", fontsize = 14, color = 'red')
|
||||
# # clip_text = clip_text.set_pos("center", "top").set_duration(clip_render3.duration)
|
||||
# # clip_render3 = CompositeVideoClip([clip_render3, clip_text])
|
||||
|
||||
|
||||
# # audio
|
||||
# path_audio = path_data.joinpath("../audio/test_video.wav")
|
||||
# clip_audio = AudioFileClip(str(path_audio))
|
||||
|
||||
# # concate
|
||||
# # concate_clips = clips_array([[clip_image, clip_render],
|
||||
# # [clip_render2, clip_render3]])
|
||||
# concate_clips = clips_array([[clip_image, clip_render, clip_render2]])
|
||||
|
||||
# concate_clips = concate_clips.set_audio(clip_audio)
|
||||
|
||||
# # save
|
||||
# path_concate_save = path_data.joinpath("concate4.mp4")
|
||||
# #concate_clips = concate_clips.resize(width=720)
|
||||
|
||||
# concate_clips.write_videofile(str(path_concate_save), fps=25)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import os
|
||||
import numpy as np
|
||||
import moviepy.editor as mpy
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
# path_clipA = "/ssdata1/lsen/CODE/voca/data/animation_obama/video_save.mp4"
|
||||
# path_clipB = "/ssdata1/lsen/CODE/Audio2Motion/experiments/audio2mesh/infer_audio2mesh_EN_20220208/20220216-12H58M21S/obama_infer_20220215-15H12M28S_epoch_120_00.mp4"
|
||||
# path_audio = "/ssdata1/lsen/CODE/voca/data/audio/obama.wav"
|
||||
|
||||
# path_clipA = "/ssdata1/lsen/CODE/voca/data/animation_obama2/video_save.mp4"
|
||||
# path_clipB = "/ssdata1/lsen/CODE/Audio2Motion/experiments/audio2mesh/infer_audio2mesh_EN_20220208/20220216-13H01M33S/audio_trim_infer_20220215-15H12M28S_epoch_120_00.mp4"
|
||||
# path_audio = "/yrfs/lsen/DATA/Obama/processing/Bringing-Our-Workplace-Policies-into-the-21st-Century/audio/audio_trim.wav"
|
||||
|
||||
path_clipA = "/ssdata1/lsen/CODE/Audio2Motion/experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220214-18H49M33S/audio_trim_60_120s_infer_20220211-15H41M37S_epoch_120_00.mp4"
|
||||
path_clipB = "/ssdata1/lsen/CODE/Audio2Motion/experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220223-19H47M15S/audio_trim_60_120s_infer_20220217-18H29M20S_epoch_160_00.mp4"
|
||||
path_clipC = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/video/deca_render_no_idn_no_pos_60_120s.mp4"
|
||||
# path_audio = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_60_120s.wav"
|
||||
|
||||
path_clipAA = "experiments/audio2mesh/infer_audio2mesh_EN_20220208/20220223-21H45M05S/audio_trim_60_120s_infer_20220215-15H12M28S_epoch_120_00.mp4"
|
||||
path_clipBB = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220223-20H51M40S/audio_trim_60_120s_infer_20220222-10H37M51S_epoch_235_00.mp4"
|
||||
path_clipCC = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/video/deca_render_no_pos_60_120s.mp4"
|
||||
|
||||
|
||||
path_audio = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_60_120s.wav"
|
||||
|
||||
clip_A = mpy.VideoFileClip(path_clipA)
|
||||
clip_B = mpy.VideoFileClip(path_clipB)
|
||||
clip_C = mpy.VideoFileClip(path_clipC)
|
||||
|
||||
clip_AA = mpy.VideoFileClip(path_clipAA)
|
||||
clip_BB = mpy.VideoFileClip(path_clipBB)
|
||||
clip_CC = mpy.VideoFileClip(path_clipCC)
|
||||
|
||||
audio = mpy.AudioFileClip(path_audio)
|
||||
|
||||
# txtClip = mpy.TextClip('orignal',color='white', kerning = 5, fontsize=18)
|
||||
# clip_A = mpy.CompositeVideoClip( [clip_A, txtClip.set_pos('top')], size=(512,512))
|
||||
|
||||
# txtClip = mpy.TextClip('-pose',color='white', kerning = 5, fontsize=18)
|
||||
# clip_B = mpy.CompositeVideoClip( [clip_B, txtClip.set_pos('top')], size=(512,512))
|
||||
|
||||
# txtClip = mpy.TextClip('-pose-idn',color='white', kerning = 5, fontsize=18)
|
||||
# clip_C = mpy.CompositeVideoClip( [clip_C, txtClip.set_pos('top')], size=(512,512))
|
||||
|
||||
# align to clipGT
|
||||
duration = min(min(clip_A.duration, clip_B.duration), audio.duration)
|
||||
|
||||
clip_A = clip_A.set_duration(duration)
|
||||
clip_B = clip_B.set_duration(duration)
|
||||
# clip_C = clip_C.set_duration(duration)
|
||||
audio = audio.set_duration(duration)
|
||||
|
||||
# stack
|
||||
video = mpy.clips_array([[clip_A, clip_B, clip_C], [clip_AA, clip_BB, clip_CC]]) # clip_C
|
||||
video = video.set_audio(audio) # audd audio
|
||||
|
||||
# save
|
||||
path_save = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/video/predict_compare_6.mp4"
|
||||
# path_save = "/ssdata1/lsen/CODE/Audio2Motion/experiments/audio2mesh/infer_audio2mesh_EN_20220208/20220216-12H58M21S/compare_voca.mp4"
|
||||
video.write_videofile(path_save, fps=50, logger=None)
|
||||
print(f"save to > {path_save}")
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import os
|
||||
import numpy as np
|
||||
import moviepy.editor as mpy
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
path_TalkingGlow1 = Path('/mnt/data/CODE/Audio2Expression/data/paper/20210918-22H20M48S-epoch100/video_25fps')
|
||||
path_TalkingGlow2 = Path('/mnt/data/CODE/Audio2Expression/data/paper/20210918-22H20M48S-epoch100-1/video_25fps')
|
||||
path_TalkingGlow3 = Path('/mnt/data/CODE/Audio2Expression/data/paper/20210918-22H20M48S-epoch100-2/video_25fps')
|
||||
path_TalkingGlow4 = Path('/mnt/data/CODE/Audio2Expression/data/paper/20210918-22H20M48S-epoch100-3/video_25fps')
|
||||
|
||||
path_audio = Path('/mnt/data/CODE/Audio2Expression/data/paper_gt/audio_wav')
|
||||
|
||||
path_save = Path('/mnt/data/CODE/Audio2Expression/data/paper/stack_video_diverse')
|
||||
path_save.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for i in range(43):
|
||||
clip_A = mpy.VideoFileClip(str(path_TalkingGlow1.joinpath(f"clips_{i:03d}.mp4")))
|
||||
clip_B = mpy.VideoFileClip(str(path_TalkingGlow2.joinpath(f"clips_{i:03d}.mp4")))
|
||||
clip_C = mpy.VideoFileClip(str(path_TalkingGlow3.joinpath(f"clips_{i:03d}.mp4")))
|
||||
clip_D = mpy.VideoFileClip(str(path_TalkingGlow4.joinpath(f"clips_{i:03d}.mp4")))
|
||||
|
||||
audio = mpy.AudioFileClip(str(path_audio.joinpath(f"clips_{i:03d}.wav")))
|
||||
|
||||
# align to clipGT
|
||||
duration = clip_A.duration
|
||||
clip_B = clip_B.set_duration(duration)
|
||||
clip_C = clip_C.set_duration(duration)
|
||||
clip_D = clip_D.set_duration(duration)
|
||||
audio = audio.set_duration(duration)
|
||||
|
||||
# stack
|
||||
video = mpy.clips_array([[clip_A, clip_B, clip_C, clip_D]])
|
||||
video = video.set_audio(audio) # audd audio
|
||||
|
||||
# save
|
||||
ipath_save = path_save.joinpath(f"clips_{i:03d}.mp4")
|
||||
video.write_videofile(str(ipath_save), fps=25, logger=None)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user