update audio2mesh with write_video, remove from path_raw

This commit is contained in:
sen.liang committed 2022-04-25 22:22:55 +08:00
1 parent 0d5689979f
commit 7fb22e4750
15 files changed
+302 -245

No files matched your search

@@ -0,0 +1,51 @@
from pathlib import Path
from skimage.metrics import structural_similarity
from imageio import imread
import numpy as np
from pathlib import Path
import multiprocessing
from os import getpid
path_root = Path("/mfs/lsen/DATA/Actor4/bg")
# idx_frame = 3530
# fname = "body1"
idx_frame = 3740 #100
fname = "head"
path_frames = path_root.joinpath(fname, "frames")
# read inference images
path_frame_ref = path_frames.joinpath(f"frame-{idx_frame:06d}.jpg")
img_ref = imread(str(path_frame_ref))
def worker_ssim(i):
if i % 100 == 0: print(f"[{getpid()}] procssing the {i:06d}-th... ")
ipath_frame = path_frames.joinpath(f"frame-{i:06d}.jpg")
img = imread(str(ipath_frame))
ssim = structural_similarity(img_ref, img, multichannel = True)
return ssim
if __name__ == '__main__':
# save path
path_save = path_root.joinpath(fname, "video", f"ssim_ref_{idx_frame}.npy")
path_save.parent.mkdir(parents=True, exist_ok=True)
# check frames
nframe = len(list(path_frames.glob("*.jpg")))
# multi-processing
pool = multiprocessing.Pool(24)
results = list(pool.map(worker_ssim, range(nframe)))
# print(results)
# save to npy
np.save(path_save, np.array(results))