This commit is contained in:
sen.liang committed 2022-03-17 15:22:48 +08:00
commit a3529ab815
14 files changed
+175 -60

No files matched your search

+2
View File
@@ -6,3 +6,5 @@
*.mp3
*.pt
data/
@@ -0,0 +1,33 @@
GPUS: '9'
WORKERS: 4
OUTPUT_DIR: 'experiments/audio2mesh'
DEBUG: False
verbose: False
isTrain: False
MODEL:
# name: 'audio2mesh'
name: 'audio2mesh_ar'
name_netG: "audio2mesh_ar"
dim_motion: 53 # 68*2
dim_speech: 1024
num_vertices: 5023
pretrain: True
path_checkpoint: "experiments/audio2mesh/train_audio2meshAR_CN_20220314/20220316-23H56M06S"
load_epoch: 50
DATASET:
fps: 50
sr: 16000
path_mean_dict: './data/Actor2/DECA_Actor2_mean.npy'
TRAIN:
apply_testing: True
apply_validation: True
@@ -17,33 +17,17 @@ MODEL:
num_vertices: 5023
pretrain: True
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220312/20220313-13H26M47S"
load_epoch: 100
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220312/20220315-16H55M15S"
load_epoch: 35
DATASET:
fps: 50
sr: 16000
name: "motion_live"
root: './data/Actor2/Actor2-raw-2h' # obama-deca-3-5-08-mini
root_raw: '/yrfs/lsen/DATA/Actor2/processing'
path_mean_dict: './data/Actor2/DECA_Actor2_mean.npy'
filter: 'savgol'
speech_extractor: 'wav2vec'
nwind_second_train: 3
nwind_second_valid: 3
nwind_second_test: 15
TEST:
batch_size: 2
TRAIN:
lr: 0.00001
batch_size: 64
shuffle: True
apply_testing: True
apply_validation: True
@@ -39,7 +39,7 @@ DATASET:
flip: False
shifting_speed: True
root: './data/Actor2/Actor2-raw-2h' # obama-deca-3-5-08-mini
root: './data/Actor2/Actor2-raw-5h' # obama-deca-3-5-08-mini
root_raw: '/yrfs/lsen/DATA/Actor2/processing'
path_mean_dict: './data/Actor2/DECA_Actor2_mean.npy'
filter: 'savgol'
@@ -1,4 +1,4 @@
GPUS: '9'
GPUS: '5'
WORKERS: 4
OUTPUT_DIR: 'experiments/audio2mesh'
@@ -10,7 +10,8 @@ VISUAL:
use_visdom: True
vsdm_port: 9930
vsdm_ncol: 4
vsdm_env: "audio2mesh-actor2-1100"
vsdm_env: "audio2mesh-actor2-4h-1100-pretrain"
FREQ:
epoch_save: 5
@@ -27,9 +28,9 @@ MODEL:
dim_speech: 1024
num_vertices: 5023
pretrain: False
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220220/20220225-19H08M53S"
load_epoch: 0
pretrain: True
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220312/20220315-16H55M15S"
load_epoch: 35
DATASET:
@@ -39,7 +40,7 @@ DATASET:
flip: False
shifting_speed: True
root: './data/Actor2/Actor2-raw-2h' # obama-deca-3-5-08-mini
root: './data/Actor2/Actor2-raw-4h' # obama-deca-3-5-08-mini
root_raw: '/yrfs/lsen/DATA/Actor2/processing'
path_mean_dict: './data/Actor2/DECA_Actor2_mean.npy'
filter: 'savgol'
@@ -53,7 +54,7 @@ TEST:
batch_size: 2
TRAIN:
lr: 0.0001
lr: 0.00005
batch_size: 128
shuffle: True
@@ -67,9 +68,9 @@ TRAIN:
weight_decay: 0.0001
nesterov: True
grad_clip_norm: False
# lr_policy: 'multistep'
# lr_milestones: [50, 100]
lr_policy: 'plateau'
lr_policy: 'multistep'
lr_milestones: [10, 50]
# lr_policy: 'plateau'
resume: False
reset_lr: False
+7 -2
View File
@@ -94,13 +94,18 @@ if __name__ == "__main__":
processor = Wav2Vec2FeatureExtractor.from_pretrained(MODEL_ID)
extractor = Wav2Vec2Model.from_pretrained(MODEL_ID).to(device)
path_folder = Path("/mfs/dylan/tts/wav")
# path_folder = Path("/mfs/dylan/tts/wav")
path_folder = Path("/mfs/dylan/tts/wav_john/")
# path_folder = Path("/ssdata1/lsen/CODE/Audio2Motion/data/test-20220315")
vpath_wav = sorted(path_folder.glob("*.wav"))
for ipath_audio in vpath_wav:
print(f"procesing ... {ipath_audio}")
try:
infer_one(ipath_audio, model, processor, extractor)
except:
print("\n continue ! > ipath_audio",ipath_audio)
# path_audio = Path("/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_60_120s.wav")
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+8 -2
View File
@@ -13,14 +13,16 @@ if __name__ == '__main__':
vpath_videos = sorted(path_root.glob("raw/*.MP4"), reverse=False)
print(f"Have {len(vpath_videos)} dir files")
IDs = ["1-29min", "2-23min", "3-27min"]
# IDs = ["1-29min", "2-23min", "3-27min"]
# IDs = ["1-29min", "2-23min", "3-27min"]
durations = 0
# for each video
for i, ipath_item in enumerate(vpath_videos):
iname = ipath_item.stem
print(f"processing {i}/{len(vpath_videos)} -> {ipath_item} ... ")
# if i < 40: continue
if iname in IDs: continue
# if iname in IDs: continue
# data path
ipath_data = path_root.joinpath("processing", ipath_item.stem)
@@ -43,6 +45,10 @@ if __name__ == '__main__':
video = VideoFileClip(str(ipath_item))
print(f"video duration = {video.duration}, fps = {video.fps}, (start, end)=({video.start},{video.end}), nframes={int(video.duration * video.fps)}")
# durations += video.duration
# print(f"\t -> Total durations = ({durations / 60 } min) ({durations / 3600 } h))")
# continue
if video.audio is None:
print("\nERROR: audio info is None")
continue
@@ -18,7 +18,7 @@ def main(args):
# device = args.device
device = "cuda:3"
device = "cuda:8"
# run DECA
deca_cfg.model.use_tex = args.useTex
@@ -33,12 +33,15 @@ def main(args):
# IDs = ["actor-2HD", "actor-3HD"]
# IDs = ["clip_full"]
# for each video
for ipath_data in v_dir_videos:
for i, ipath_data in enumerate(v_dir_videos):
ivideo_name = ipath_data.stem
print("\nprocessing ...", ivideo_name)
print(f"\n processing {i}/{len(v_dir_videos)} ...", ivideo_name)
# if ivideo_name not in IDs: continue
# if i > 30: break
ipath_infor = ipath_data.joinpath("video/info.json")
ipath_frame = ipath_data.joinpath("frames")
+11 -8
View File
@@ -15,9 +15,9 @@ if __name__ == '__main__':
print(f"Have {len(vpath_videos)} dir files")
# IDs = ["clip_full"]
durations = 0
# for each video
for i, ipath_item in enumerate(vpath_videos[2:]):
for i, ipath_item in enumerate(vpath_videos):
iname = ipath_item.stem
print(f"processing {i}/{len(vpath_videos)} -> {ipath_item} ... ")
@@ -36,12 +36,12 @@ if __name__ == '__main__':
ipath_video.mkdir(parents=True, exist_ok=True)
ipath_audio.mkdir(parents=True, exist_ok=True)
# # load video info
if ipath_infor.exists():
continue
# with open(str(ipath_infor), "r") as f:
# info = json.load(f)
# nframe_info = info['nframes']
# # # load video info
# if ipath_infor.exists():
# continue
# # with open(str(ipath_infor), "r") as f:
# # info = json.load(f)
# # nframe_info = info['nframes']
# load video
video = VideoFileClip(str(ipath_item))
@@ -51,6 +51,9 @@ if __name__ == '__main__':
print("\nERROR: audio info is None")
continue
durations += video.duration
print(f"\t -> Total durations = ({durations / 60 } min) ({durations / 3600 } h))")
continue
# Trim
# video = video.subclip(t_start=5.0, t_end=int(video.duration)-5.0) before 03.14
@@ -32,7 +32,7 @@ if __name__ == "__main__":
path_data = Path("/yrfs/lsen/DATA/Actor2/processing")
path_save = Path('data/Actor2/Actor2-raw-2h') # processing
path_save = Path('data/Actor2/Actor2-raw-6h') # processing
path_save.mkdir(parents=True, exist_ok=True)
v_dir_videos = sorted(path_data.glob("*/audio/feat_DECA_exp_trim.npy"))
@@ -42,8 +42,8 @@ if __name__ == "__main__":
vids = set([ipath.stem for ipath in v_dir_videos])
# print(f"vids total= {vids}")
vid_test = set(["AA7A9568"])
vid_valid = set(["AA7A9569"])
vid_test = set(["AA7A9568", "AA7A9577"])
vid_valid = set(["AA7A9569", "AA7A9578"])
vid_train = vids - vid_test - vid_valid
# vids = set(["2021-P09", "2021-P14", "2021-P22"])
@@ -63,7 +63,7 @@ if __name__ == "__main__":
# if vid not in vids: continue
# if vid in vid_test: continue
# if vid in vid_valid:continue
if durations_train / 3600 > 2: break
if durations_train / 3600 > 6: break
print(f"\n processing the {i}-th video {vid} ... ")
+74
View File
@@ -35,3 +35,77 @@ flame_mouth_idx = [
3806, 3914, 3915, 3916, 3917, 3918, 3919, 3920, 3921, 3922,
3923, 3924, 3925, 3926, 3927, 3928
]
flame_eye_idx = [
337, 338, 807, 808, 809, 814, 815, 816, 821, 822,
823, 824, 825, 826, 827, 828, 829, 841, 842, 848,
864, 865, 877, 878, 879, 880, 881, 882, 883, 884,
885, 896, 897, 898, 899, 902, 903, 904, 905, 906,
907, 908, 909, 918, 919, 922, 923, 924, 926, 927,
928, 929, 939, 943, 944, 945, 946, 947, 948, 949,
950, 951, 952, 953, 954, 955, 958, 959, 960, 961,
962, 963, 964, 965, 966, 967, 968, 969, 970, 971,
972, 977, 978, 979, 980, 985, 986, 991, 992, 993,
994, 995, 999, 1000, 1003, 1006, 1008, 1011, 1012, 1013,
1014, 1015, 1019, 1020, 1021, 1022, 1023, 1033, 1034, 1043,
1044, 1045, 1046, 1059, 1060, 1061, 1062, 1093, 1096, 1101,
1108, 1113, 1114, 1115, 1125, 1126, 1132, 1134, 1135, 1142,
1143, 1144, 1146, 1147, 1150, 1151, 1152, 1153, 1154, 1155,
1161, 1162, 1163, 1164, 1168, 1169, 1170, 1175, 1176, 1181,
1182, 1183, 1184, 1189, 1190, 1193, 1194, 1195, 1200, 1201,
1202, 1216, 1217, 1218, 1224, 1225, 1226, 1227, 1230, 1232,
1233, 1243, 1244, 1283, 1289, 1292, 1293, 1294, 1320, 1329,
1331, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344,
1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354,
1355, 1356, 1357, 1358, 1361, 1362, 1363, 1364, 1365, 1366,
1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376,
1377, 1378, 1383, 1384, 1385, 1387, 1388, 1389, 1390, 1391,
1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405,
1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419,
1420, 1421, 1422, 1425, 1426, 1427, 1428, 1431, 1432, 1433,
1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443,
1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453,
1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467,
1468, 1469, 1474, 1475, 1476, 1477, 1478, 1752, 1755, 2043,
2044, 2046, 2085, 2086, 2103, 2104, 2105, 2108, 2109, 2110,
2111, 2112, 2113, 2114, 2118, 2119, 2122, 2123, 2125, 2126,
2127, 2207, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271,
2272, 2273, 2274, 2275, 2276, 2277, 2278, 2282, 2283, 2286,
2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296,
2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306,
2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316,
2317, 2318, 2319, 2321, 2322, 2323, 2324, 2325, 2326, 2327,
2328, 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337,
2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, 2346, 2347,
2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357,
2358, 2359, 2360, 2361, 2364, 2365, 2367, 2369, 2370, 2371,
2372, 2373, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384,
2385, 2386, 2388, 2389, 2390, 2391, 2402, 2403, 2404, 2405,
2406, 2407, 2408, 2411, 2412, 2416, 2417, 2418, 2419, 2420,
2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430,
2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, 2439, 2440,
2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450,
2451, 2453, 2454, 2455, 2456, 2461, 2465, 2466, 2471, 2473,
2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494,
2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504,
2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514,
2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524,
2525, 2526, 2527, 2528, 2529, 2530, 2532, 2533, 2534, 2535,
2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545,
2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555,
2556, 2557, 2558, 2559, 2562, 2563, 2564, 2565, 2566, 2567,
2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577,
2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587,
2588, 2589, 2590, 2595, 2596, 2597, 2598, 2599, 2600, 2601,
2602, 2603, 2604, 2605, 2606, 2611, 2612, 2613, 2614, 2615,
3078, 3079, 3081, 3130, 3131, 3132, 3134, 3135, 3136, 3137,
3138, 3139, 3140, 3141, 3145, 3146, 3148, 3149, 3150, 3151,
3152, 3154, 3589, 3592, 3615, 3619, 3620, 3631, 3632, 3638,
3645, 3674, 3675, 3682, 3686, 3687, 3688, 3689, 3690, 3692,
3694, 3696, 3699, 3743, 3744, 3749, 3750, 3759, 3766, 3774,
3775, 3776, 3777, 3779, 3780, 3781, 3784, 3787, 3809, 3812,
3823, 3827, 3828, 3832, 3833, 3835, 3840, 3847, 3848, 3852,
3853, 3854, 3855, 3856, 3857, 3858, 3859, 3860, 3861, 3881,
3882, 3891, 3895, 3900, 3902, 3903, 3907, 3910,
]
+2
View File
@@ -417,6 +417,8 @@ class Audio2MeshModel(Base):
loss_vel_geo2 = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo, weight=self.vertices_weight)
loss_dict["loss_vel_geo_w"] = loss_vel_geo2.mean().detach()
# loss += loss_vel_geo.mean() * self.opt.LOSS.lambda_vel_geo
if self.opt.LOSS.lambda_vel_geo:
loss += loss_vel_geo2.mean() * self.opt.LOSS.lambda_vel_geo
# total loss
loss_dict['loss_all'] = loss.detach()
+14 -12
View File
@@ -46,9 +46,15 @@ class Audio2MeshARModel(Base):
self.netR, self.flame = define_netR(device=self.device)
# self.netG.init_reconstruct_model(self.netR)
path_deca_mean = Path("./data/DECA_obama_mean.npy")
path_deca_mean = self.opt.DATASET.path_mean_dict
self.mean_dict = np.load(path_deca_mean, allow_pickle=True).item()
print(f"mean_dict keys = {self.mean_dict.keys()}")
if self.isTrain:
self.template_verts = self.get_template_vertices()
else:
self.template_verts = self.get_template_vertices(self.mean_dict)
debug(opt, f"template_verts shape = {self.template_verts.shape}")
debug(opt, f"mean_dict keys = {self.mean_dict.keys()}", verbose=True)
@@ -198,7 +204,6 @@ class Audio2MeshARModel(Base):
batch_y_pdf = torch.zeros(B, nsteps, self.template_verts.shape[-2], 3) # B x nsteps x 5023 x 3
ibatch_y_pre = self.template_verts.expand(B, -1, -1, -1) # B x 1 x 5023 x 3
for istep in range(nsteps):
ibatch_x = x[:, istep:istep+1] # B x 1 x nwind x nc_condit
@@ -251,14 +256,15 @@ class Audio2MeshARModel(Base):
def get_template_vertices(self, mean_dict=None):
if mean_dict is not None:
pass
else:
batch_shape = torch.zeros(1, 100).to(self.device)
batch_exp = torch.zeros(1, 50).to(self.device)
batch_pos = torch.zeros(1, 6).to(self.device)
if mean_dict is not None:
batch_shape = self.mean_dict["shape"].reshape(1, 100)
batch_shape = torch.from_numpy(batch_shape).float().to(self.device)
else:
batch_shape = torch.zeros(1, 100).to(self.device)
verts, _, _ = self.netR.get_vertices(batch_shape, batch_exp, batch_pos) # 1 x 5023 x 3
verts = verts.unsqueeze(dim=0) # 1 x 1 x 5023 x 3
print(f"template verts reshape = {verts.shape}")
@@ -509,14 +515,10 @@ class Audio2MeshARModel(Base):
# print(f"jstart_time={jstart_time}, jend_time={jend_time}")
# save animation
# print(f"testing v_render_pt = {len(v_render_pt)}, gt shape = {len(v_render_gt)}")
# save_animation_with_gt2(v_render_pt, v_render_gt, ipath_save, fps=self.opt.DATASET.fps, path_audio=jpath_audio, start_time=jstart_time, end_time=jend_time)
# save animation
print(f"testing v_render_pt = {len(v_render_pt)}, gt shape = {len(v_render_gt)}, fps={self.opt.DATASET.fps}")
save_animation_with_gt2(v_render_pt, v_render_gt, ipath_save, fps=self.opt.DATASET.fps, path_audio=jpath_audio, start_time=jstart_time, end_time=jend_time)
# save_animation_with_gt2(v_render_pt, v_render_gt, ipath_save, fps=self.opt.DATASET.fps, path_audio=jpath_audio, start_time=jstart_time, end_time=jend_time)
#########################################
def tensor2image(tensor):