add infer loss for LuoXData with long data by clip & alignment data
This commit is contained in:
1 parent
386df9a4ab
commit
ded9b27f71
42 files changed
+1230
-1358
No files matched your search
@@ -53,6 +53,7 @@ def weight_reduce_loss(loss, weight=None, reduction='mean', avg_factor=None):
|
||||
# if reduction is 'none', then do nothing, otherwise raise an error
|
||||
elif reduction != 'none':
|
||||
raise ValueError('avg_factor can not be used with reduction="sum"')
|
||||
|
||||
return loss
|
||||
|
||||
|
||||
|
||||
@@ -47,17 +47,15 @@ class WingLoss(nn.Module):
|
||||
avg_factor(int, optional): The average of the reduction loss
|
||||
"""
|
||||
|
||||
loss = wing_loss(pred, target, w=self.w, epsilon=self.epsilon, weight=weight, avg_factor=avg_factor)
|
||||
loss = wing_loss(pred, target, w=self.w, epsilon=self.epsilon, weight=weight, reduction=self.reduction, avg_factor=avg_factor)
|
||||
loss = self.loss_weight * loss
|
||||
|
||||
|
||||
|
||||
return loss
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
crieation = WingLoss()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
GPUS: '2'
|
||||
GPUS: '0'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
@@ -8,8 +8,9 @@ isTrain: False
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2mesh_specific'
|
||||
name_netG: "audio2mesh"
|
||||
name: 'audio2mesh'
|
||||
name_netG: "audio2mesh_resnet"
|
||||
# name_netG: "audio2mesh"
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 1024
|
||||
@@ -17,8 +18,9 @@ MODEL:
|
||||
|
||||
|
||||
pretrain: True
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220220/20220222-10H37M51S"
|
||||
load_epoch: 235
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220208/20220228-18H41M46S"
|
||||
load_epoch: 175
|
||||
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
GPUS: '2'
|
||||
GPUS: '9'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
@@ -7,18 +7,19 @@ verbose: False
|
||||
isTrain: False
|
||||
|
||||
MODEL:
|
||||
name: 'audio2mesh'
|
||||
# name: 'audio2mesh_specific'
|
||||
name_netG: "audio2mesh"
|
||||
# name: 'audio2mesh'
|
||||
name: 'audio2mesh_specific'
|
||||
name_netG: "audio2mesh_resnet"
|
||||
# name_netG: "audio2mesh"
|
||||
name_header: "resnet50" # "resnet50", "resnet34",
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 1024
|
||||
num_vertices: 5023
|
||||
|
||||
pretrain: True
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_EN_20220208/20220217-17H36M22S"
|
||||
load_epoch: 115
|
||||
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_EN_20220220/20220225-18H53M05S"
|
||||
load_epoch: 285
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
@@ -26,7 +27,8 @@ DATASET:
|
||||
name: "motion_live"
|
||||
root: './data/obama-raw-deca-9h-50fps' # obama-deca-3-5-08-mini
|
||||
root_raw: '/yrfs/lsen/DATA/Obama/processing'
|
||||
path_mean_dict: './data/DECA_obama_mean.npy'
|
||||
# path_mean_dict: './data/DECA_obama_mean.npy'
|
||||
path_mean_dict: './data/DECA_obama_mean_wf.npy'
|
||||
filter: 'savgol'
|
||||
speech_extractor: 'wav2vec'
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
GPUS: '9'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9900
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2meshF-cn"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 1
|
||||
epoch_valid: 1
|
||||
batch_print: 20
|
||||
epoch_test: 5
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2meshF'
|
||||
name_netG: "MotionWaveFlow"
|
||||
|
||||
dim_motion: 5023*3 # 68*2
|
||||
dim_speech: 1024
|
||||
num_vertices: 5023
|
||||
|
||||
dim_hidden: 128
|
||||
n_flowstep: 12 # 12 # 24
|
||||
n_early_every: 3 # 3 # 6
|
||||
n_layer_wave: 4
|
||||
kernel_size: 3
|
||||
lambda_std: [1, 1, 1, 1] #[1, 0.75, 0.5, 0.25] # [1, 1, 1, 1]
|
||||
fix_dims: [0, 0, -1, -1]
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_EN_20220208/20220216-19H57M17S"
|
||||
load_epoch: 155
|
||||
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
sr: 16000
|
||||
name: "motion_live"
|
||||
root: './data/LuoXData-raw-deca-10h' # obama-deca-3-5-08-mini
|
||||
root_raw: '/yrfs/lsen/DATA/LuoXData/processing2'
|
||||
filter: 'savgol'
|
||||
speech_extractor: 'wav2vec'
|
||||
|
||||
nwind_second_train: 3
|
||||
nwind_second_valid: 3
|
||||
nwind_second_test: 15
|
||||
|
||||
TEST:
|
||||
batch_size: 2
|
||||
|
||||
TRAIN:
|
||||
lr: 0.0001
|
||||
batch_size: 16
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'Adam'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: False
|
||||
grad_clip_norm: True
|
||||
max_grad_clip: 5
|
||||
max_grad_norm: 100
|
||||
lr_policy: 'plateau' # multistep, plateau, consine
|
||||
# lr_milestones: [20, 80]
|
||||
|
||||
resume: False
|
||||
reset_lr: False
|
||||
resume_suffix: "20220211-16H54M11S"
|
||||
epoch_begin: 0 # 5000 # 2300 # 2600
|
||||
epoch_end: 200
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "logp", "logdet"]
|
||||
lambda_logp: 1
|
||||
lambda_logdet: 1
|
||||
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
# lambda_rec_geo: 1
|
||||
# lambda_vol_geo: 10
|
||||
@@ -1,94 +0,0 @@
|
||||
GPUS: '6'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9900
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2meshF-en"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 1
|
||||
epoch_valid: 1
|
||||
batch_print: 20
|
||||
epoch_test: 5
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2meshF'
|
||||
name_netG: "MotionWaveFlow"
|
||||
|
||||
dim_motion: 5023*3 # 68*2
|
||||
dim_speech: 1024
|
||||
num_vertices: 5023
|
||||
|
||||
dim_hidden: 128
|
||||
n_flowstep: 12 # 12 # 24
|
||||
n_early_every: 3 # 3 # 6
|
||||
n_layer_wave: 4
|
||||
kernel_size: 3
|
||||
lambda_std: [1, 1, 1, 1.0] #[1, 0.75, 0.5, 0.25] # [1, 1, 1, 1]
|
||||
fix_dims: [0, 0, -1, -1]
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_EN_20220208/20220216-19H57M17S"
|
||||
load_epoch: 155
|
||||
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
sr: 16000
|
||||
name: "motion_live"
|
||||
root: './data/obama-raw-deca-9h-50fps' # obama-deca-3-5-08-mini
|
||||
root_raw: '/yrfs/lsen/DATA/Obama/processing'
|
||||
filter: 'savgol'
|
||||
speech_extractor: 'wav2vec'
|
||||
|
||||
nwind_second_train: 3
|
||||
nwind_second_valid: 3
|
||||
nwind_second_test: 15
|
||||
|
||||
TEST:
|
||||
batch_size: 2
|
||||
|
||||
TRAIN:
|
||||
lr: 0.0001
|
||||
batch_size: 16
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'Adam'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: False
|
||||
grad_clip_norm: True
|
||||
max_grad_clip: 5
|
||||
max_grad_norm: 100
|
||||
lr_policy: 'plateau' # multistep, plateau, consine
|
||||
# lr_milestones: [20, 80]
|
||||
|
||||
resume: False
|
||||
reset_lr: False
|
||||
resume_suffix: "20220211-16H54M11S"
|
||||
epoch_begin: 0 # 5000 # 2300 # 2600
|
||||
epoch_end: 200
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "logp", "logdet"]
|
||||
lambda_logp: 1
|
||||
lambda_logdet: 1
|
||||
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
# lambda_rec_geo: 1
|
||||
# lambda_vol_geo: 10
|
||||
@@ -1,4 +1,4 @@
|
||||
GPUS: '3'
|
||||
GPUS: '6'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
@@ -11,7 +11,7 @@ VISUAL:
|
||||
use_visdom: True
|
||||
vsdm_port: 9900
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2mesh-resnet-cn-weight-50-2"
|
||||
vsdm_env: "audio2mesh-resnet-cn-50-outliar"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
@@ -29,10 +29,9 @@ MODEL:
|
||||
num_vertices: 5023
|
||||
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_EN_20220208/20220216-19H57M17S"
|
||||
load_epoch: 0
|
||||
|
||||
pretrain: True
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220208/20220225-16H33M13S"
|
||||
load_epoch: 200
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
@@ -79,6 +78,6 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
names: ["all", "rec_geo", "rec_geo_w", "rec_geo_l1", "vel_geo", "vel_geo_w", "vel_geo_l1"]
|
||||
lambda_rec_geo: 1
|
||||
lambda_vol_geo: 10
|
||||
lambda_vel_geo: 10
|
||||
@@ -1,82 +0,0 @@
|
||||
GPUS: '6'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9000
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2mesh-voca"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
epoch_valid: 1
|
||||
batch_print: 20
|
||||
|
||||
epoch_test: 5
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2mesh'
|
||||
name_netG: "audio2mesh_voca"
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 1024
|
||||
num_vertices: 5023
|
||||
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/audio2motion/train_audio2motionV_CN_20220207_2/20220207-12H47M47S"
|
||||
load_epoch: 0
|
||||
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
sr: 16000
|
||||
name: "motion_live"
|
||||
root: './data/LuoXData-raw-deca-10h' # obama-deca-3-5-08-mini
|
||||
filter: 'savgol'
|
||||
speech_extractor: 'wav2vec'
|
||||
|
||||
nwind_second_train: 3
|
||||
nwind_second_valid: 3
|
||||
nwind_second_test: 10
|
||||
|
||||
TEST:
|
||||
batch_size: 2
|
||||
|
||||
TRAIN:
|
||||
lr: 0.00001
|
||||
batch_size: 64
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'Adam'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: True
|
||||
grad_clip_norm: False
|
||||
lr_policy: 'multistep'
|
||||
lr_milestones: [50, 100]
|
||||
# lr_policy: 'plateau'
|
||||
|
||||
resume: False
|
||||
reset_lr: False
|
||||
resume_suffix: "20220128-10H10M10S"
|
||||
epoch_begin: 0 # 5000 # 2300 # 2600
|
||||
epoch_end: 1000
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_geo", "vol_geo"]
|
||||
lambda_rec_geo: 1
|
||||
lambda_vol_geo: 10
|
||||
@@ -1,4 +1,4 @@
|
||||
GPUS: '8'
|
||||
GPUS: '5'
|
||||
WORKERS: 4
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
@@ -11,16 +11,14 @@ VISUAL:
|
||||
use_visdom: True
|
||||
vsdm_port: 9900
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2mesh-specific-resnet-50"
|
||||
vsdm_env: "audio2mesh-specific-cn-resnet50-outliar-pretrain"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
epoch_valid: 1
|
||||
batch_print: 20
|
||||
|
||||
epoch_test: 5
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2mesh_specific'
|
||||
name_netG: "audio2mesh_resnet"
|
||||
@@ -29,7 +27,6 @@ MODEL:
|
||||
dim_speech: 1024
|
||||
num_vertices: 5023
|
||||
|
||||
|
||||
pretrain: True
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220220/20220225-19H08M53S"
|
||||
load_epoch: 295
|
||||
@@ -53,7 +50,7 @@ TEST:
|
||||
|
||||
TRAIN:
|
||||
lr: 0.00001
|
||||
batch_size: 48
|
||||
batch_size: 64
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
@@ -78,6 +75,6 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
names: ["all", "rec_geo", "rec_geo_w", "rec_geo_l1", "vel_geo", "vel_geo_w", "vel_geo_l1"]
|
||||
lambda_rec_geo: 1
|
||||
lambda_vol_geo: 10
|
||||
lambda_vel_geo: 10
|
||||
@@ -76,6 +76,6 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
|
||||
lambda_rec_geo: 1
|
||||
lambda_vol_geo: 10
|
||||
lambda_vel_geo: 10
|
||||
@@ -1,4 +1,4 @@
|
||||
GPUS: '9'
|
||||
GPUS: '6'
|
||||
WORKERS: 4
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
@@ -10,7 +10,7 @@ VISUAL:
|
||||
use_visdom: True
|
||||
vsdm_port: 9900
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2mesh-specific-en-resnet-50"
|
||||
vsdm_env: "audio2mesh-specific-en-resnet50-outliar2"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
@@ -18,7 +18,6 @@ FREQ:
|
||||
batch_print: 20
|
||||
epoch_test: 5
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2mesh_specific'
|
||||
name_netG: "audio2mesh_resnet"
|
||||
@@ -27,9 +26,8 @@ MODEL:
|
||||
dim_speech: 1024
|
||||
num_vertices: 5023
|
||||
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220220/20220221-18H39M50S"
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_EN_20220220/20220225-18H53M05S"
|
||||
load_epoch: 0
|
||||
|
||||
|
||||
@@ -39,7 +37,7 @@ DATASET:
|
||||
name: "motion_live2"
|
||||
root: './data/obama-raw-deca-9h-50fps' # obama-deca-3-5-08-mini
|
||||
root_raw: '/yrfs/lsen/DATA/Obama/processing'
|
||||
path_mean_dict: './data/DECA_obama_mean.npy'
|
||||
path_mean_dict: './data/DECA_obama_mean_wf.npy'
|
||||
filter: 'savgol'
|
||||
speech_extractor: 'wav2vec'
|
||||
|
||||
@@ -51,8 +49,8 @@ TEST:
|
||||
batch_size: 2
|
||||
|
||||
TRAIN:
|
||||
lr: 0.00005
|
||||
batch_size: 48
|
||||
lr: 0.0001
|
||||
batch_size: 64
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
@@ -77,6 +75,6 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
|
||||
lambda_rec_geo: 1
|
||||
lambda_vol_geo: 10
|
||||
lambda_vel_geo: 10
|
||||
@@ -1,94 +0,0 @@
|
||||
GPUS: '5'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2mesh'
|
||||
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9000
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "waveflow-en"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
epoch_valid: 1
|
||||
batch_print: 20
|
||||
epoch_test: 1
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'MotionWave'
|
||||
name_netG: "MotionWaveFlow"
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 1024
|
||||
num_vertices: 5023
|
||||
|
||||
dim_hidden: 256
|
||||
n_flowstep: 12 # 12 # 24
|
||||
n_early_every: 3 # 3 # 6
|
||||
n_layer_wave: 4
|
||||
kernel_size: 3
|
||||
lambda_std: [0.25, 0.5, 0.75, 1.0] #[1, 0.75, 0.5, 0.25] # [1, 1, 1, 1]
|
||||
fix_dims: [0, 0, -1, -1]
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_EN_20220208/20220216-19H57M17S"
|
||||
load_epoch: 155
|
||||
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
sr: 16000
|
||||
name: "motion_live"
|
||||
root: './data/obama-raw-deca-9h-50fps' # obama-deca-3-5-08-mini
|
||||
root_raw: '/yrfs/lsen/DATA/Obama/processing'
|
||||
filter: 'savgol'
|
||||
speech_extractor: 'wav2vec'
|
||||
|
||||
nwind_second_train: 3
|
||||
nwind_second_valid: 3
|
||||
nwind_second_test: 15
|
||||
|
||||
TEST:
|
||||
batch_size: 2
|
||||
|
||||
TRAIN:
|
||||
lr: 0.001
|
||||
batch_size: 64
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'Adam'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: False
|
||||
grad_clip_norm: True
|
||||
max_grad_clip: 5
|
||||
max_grad_norm: 100
|
||||
lr_policy: 'plateau' # multistep, plateau, consine
|
||||
# lr_milestones: [20, 80]
|
||||
|
||||
resume: False
|
||||
reset_lr: False
|
||||
resume_suffix: "20220211-16H54M11S"
|
||||
epoch_begin: 0 # 5000 # 2300 # 2600
|
||||
epoch_end: 200
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "logp", "logdet"]
|
||||
lambda_logp: 1
|
||||
lambda_logdet: 1
|
||||
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
# lambda_rec_geo: 1
|
||||
# lambda_vol_geo: 10
|
||||
@@ -1,81 +0,0 @@
|
||||
GPUS: '4'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2motion'
|
||||
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9000
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2motion-VOCA-big-sgd"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
epoch_valid: 1
|
||||
batch_print: 20
|
||||
|
||||
epoch_test: 5
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2motion_live2'
|
||||
name_netG: "audio2motion_voca3"
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 1024
|
||||
dim_hidden: 256
|
||||
|
||||
pretrain: True
|
||||
path_checkpoint: "experiments/audio2motion/train_audio2motionV_CN_20220127/20220127-20H48M25S"
|
||||
load_epoch: 125
|
||||
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
sr: 16000
|
||||
name: "motion_live"
|
||||
root: './data/LuoXData-raw-deca-6h' # obama-deca-3-5-08-mini
|
||||
filter: 'savgol'
|
||||
speech_extractor: 'wav2vec'
|
||||
|
||||
nwind_second_train: 3
|
||||
nwind_second_valid: 3
|
||||
nwind_second_test: 10
|
||||
|
||||
TEST:
|
||||
batch_size: 2
|
||||
|
||||
TRAIN:
|
||||
lr: 0.001
|
||||
batch_size: 32
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'SGD'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: False
|
||||
grad_clip_norm: False
|
||||
lr_policy: 'multistep'
|
||||
lr_milestones: [10, 100, 500]
|
||||
# lr_policy: 'plateau'
|
||||
|
||||
resume: False
|
||||
reset_lr: False
|
||||
resume_suffix: "20220120-11H42M19S"
|
||||
epoch_begin: 0 # 5000 # 2300 # 2600
|
||||
epoch_end: 1000
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "vol_exp", "vol_pos"]
|
||||
lambda_rec: 1
|
||||
lambda_rec_smooth: 1
|
||||
@@ -76,10 +76,10 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "rec_geo", "vol_exp", "vol_pos", "vol_geo"]
|
||||
names: ["all", "rec_exp", "rec_pos", "rec_geo", "vel_exp", "vel_pos", "vel_geo"]
|
||||
lambda_rec_exp: 10
|
||||
lambda_rec_pos: 1
|
||||
lambda_rec_geo: 10
|
||||
lambda_vol_exp: 1
|
||||
lambda_vol_pos: 10
|
||||
lambda_vol_geo: 10
|
||||
lambda_vel_exp: 1
|
||||
lambda_vel_pos: 10
|
||||
lambda_vel_geo: 10
|
||||
@@ -77,8 +77,8 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "vol_exp", "vol_pos"]
|
||||
names: ["all", "rec_exp", "rec_pos", "vel_exp", "vel_pos"]
|
||||
lambda_rec_exp: 10
|
||||
lambda_rec_pos: 1
|
||||
lambda_vol_exp: 1
|
||||
lambda_vol_pos: 10
|
||||
lambda_vel_exp: 1
|
||||
lambda_vel_pos: 10
|
||||
@@ -1,77 +0,0 @@
|
||||
GPUS: '1'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2motion'
|
||||
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9000
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2motion-obama"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
|
||||
batch_print: 5
|
||||
epoch_print: 1
|
||||
|
||||
epoch_test: 5
|
||||
epoch_valid: 5
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2motion'
|
||||
name_netG: "audio2motion_conv_lstm"
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 29
|
||||
dim_hidden: 256
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/MotionVAE/train-MoCVAE3-Obama/20210726-19H09M17S"
|
||||
load_epoch: 0
|
||||
|
||||
|
||||
DATASET:
|
||||
name: "motion"
|
||||
root: './data/obama-ds-deca-5-10-08-mini' # obama-deca-3-5-08-mini
|
||||
filter: 'savgol'
|
||||
|
||||
TEST:
|
||||
batch_size: 3
|
||||
|
||||
TRAIN:
|
||||
lr: 0.0005
|
||||
batch_size: 16
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'Adam'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: False
|
||||
grad_clip_norm: False
|
||||
# lr_policy: 'multistep'
|
||||
# lr_milestones: [10, 100, 200]
|
||||
lr_policy: 'plateau'
|
||||
|
||||
|
||||
resume: False
|
||||
reset_lr: False
|
||||
resume_suffix: "20220119-20H26M39S"
|
||||
epoch_begin: 0 # 5000 # 2300 # 2600
|
||||
epoch_end: 500
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec", "rec_l1", "rec_smooth", "rec_smooth_l1"]
|
||||
lambda_rec: 1
|
||||
lambda_rec_smooth: 0.1
|
||||
@@ -1,77 +0,0 @@
|
||||
GPUS: '0'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2motion'
|
||||
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9000
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2motion-obama"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
|
||||
batch_print: 5
|
||||
epoch_print: 1
|
||||
|
||||
epoch_test: 5
|
||||
epoch_valid: 5
|
||||
|
||||
|
||||
MODEL:
|
||||
name: 'audio2motion'
|
||||
name_netG: "audio2motion_conv"
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 29
|
||||
dim_hidden: 256
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/MotionVAE/train-MoCVAE3-Obama/20210726-19H09M17S"
|
||||
load_epoch: 0
|
||||
|
||||
|
||||
DATASET:
|
||||
name: "motion"
|
||||
root: './data/obama-ds-deca-5-10-08' # obama-deca-3-5-08-mini
|
||||
filter: 'savgol'
|
||||
|
||||
TEST:
|
||||
batch_size: 3
|
||||
|
||||
TRAIN:
|
||||
lr: 0.0005
|
||||
batch_size: 16
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'Adam'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: False
|
||||
grad_clip_norm: False
|
||||
# lr_policy: 'multistep'
|
||||
# lr_milestones: [10, 100, 200]
|
||||
lr_policy: 'plateau'
|
||||
|
||||
|
||||
resume: True
|
||||
reset_lr: True
|
||||
resume_suffix: "20220119-20H26M39S"
|
||||
epoch_begin: 100 # 5000 # 2300 # 2600
|
||||
epoch_end: 500
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec", "rec_l1", "rec_smooth", "rec_smooth_l1"]
|
||||
lambda_rec: 1
|
||||
lambda_rec_smooth: 1
|
||||
@@ -89,6 +89,6 @@ LOSS:
|
||||
lambda_logp: 1
|
||||
lambda_logdet: 1
|
||||
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
|
||||
# lambda_rec_geo: 1
|
||||
# lambda_vol_geo: 10
|
||||
# lambda_vel_geo: 10
|
||||
@@ -89,6 +89,6 @@ LOSS:
|
||||
lambda_logp: 1
|
||||
lambda_logdet: 1
|
||||
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
|
||||
# lambda_rec_geo: 1
|
||||
# lambda_vol_geo: 10
|
||||
# lambda_vel_geo: 10
|
||||
@@ -89,6 +89,6 @@ LOSS:
|
||||
lambda_logp: 1
|
||||
lambda_logdet: 1
|
||||
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
|
||||
# lambda_rec_geo: 1
|
||||
# lambda_vol_geo: 10
|
||||
# lambda_vel_geo: 10
|
||||
@@ -88,6 +88,6 @@ LOSS:
|
||||
lambda_logp: 1
|
||||
lambda_logdet: 1
|
||||
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vol_geo", "vol_geo_w"]
|
||||
# names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
|
||||
# lambda_rec_geo: 1
|
||||
# lambda_vol_geo: 10
|
||||
# lambda_vel_geo: 10
|
||||
@@ -78,6 +78,6 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "vol_exp", "vol_pos"]
|
||||
names: ["all", "rec_exp", "rec_pos", "vel_exp", "vel_pos"]
|
||||
lambda_rec: 1
|
||||
lambda_rec_smooth: 1
|
||||
@@ -76,6 +76,6 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "vol_exp", "vol_pos"]
|
||||
names: ["all", "rec_exp", "rec_pos", "vel_exp", "vel_pos"]
|
||||
lambda_rec: 1
|
||||
lambda_rec_smooth: 1
|
||||
@@ -76,8 +76,8 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "vol_exp", "vol_pos"]
|
||||
names: ["all", "rec_exp", "rec_pos", "vel_exp", "vel_pos"]
|
||||
lambda_rec_exp: 10
|
||||
lambda_rec_pos: 1
|
||||
lambda_vol_exp: 1
|
||||
lambda_vol_pos: 10
|
||||
lambda_vel_exp: 1
|
||||
lambda_vel_pos: 10
|
||||
@@ -77,8 +77,8 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "vol_exp", "vol_pos"]
|
||||
names: ["all", "rec_exp", "rec_pos", "vel_exp", "vel_pos"]
|
||||
lambda_rec_exp: 1
|
||||
lambda_rec_pos: 1
|
||||
lambda_vol_exp: 1
|
||||
lambda_vol_pos: 1
|
||||
lambda_vel_exp: 1
|
||||
lambda_vel_pos: 1
|
||||
@@ -77,10 +77,10 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "rec_geo", "vol_exp", "vol_pos", "vol_geo"]
|
||||
names: ["all", "rec_exp", "rec_pos", "rec_geo", "vel_exp", "vel_pos", "vel_geo"]
|
||||
lambda_rec_exp: 10
|
||||
lambda_rec_pos: 1
|
||||
lambda_rec_geo: 10
|
||||
lambda_vol_exp: 1
|
||||
lambda_vol_pos: 10
|
||||
lambda_vol_geo: 10
|
||||
lambda_vel_exp: 1
|
||||
lambda_vel_pos: 10
|
||||
lambda_vel_geo: 10
|
||||
@@ -77,8 +77,8 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "vol_exp", "vol_pos"]
|
||||
names: ["all", "rec_exp", "rec_pos", "vel_exp", "vel_pos"]
|
||||
lambda_rec_exp: 10
|
||||
lambda_rec_pos: 1
|
||||
lambda_vol_exp: 1
|
||||
lambda_vol_pos: 10
|
||||
lambda_vel_exp: 1
|
||||
lambda_vel_pos: 10
|
||||
@@ -78,10 +78,10 @@ TRAIN:
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec_exp", "rec_pos", "rec_geo", "vol_exp", "vol_pos", "vol_geo"]
|
||||
names: ["all", "rec_exp", "rec_pos", "rec_geo", "vel_exp", "vel_pos", "vel_geo"]
|
||||
lambda_rec_exp: 1
|
||||
lambda_rec_pos: 1
|
||||
lambda_rec_geo: 10
|
||||
lambda_vol_exp: 10
|
||||
lambda_vol_pos: 10
|
||||
lambda_vol_geo: 10
|
||||
lambda_vel_exp: 10
|
||||
lambda_vel_pos: 10
|
||||
lambda_vel_geo: 10
|
||||
@@ -1,76 +0,0 @@
|
||||
GPUS: '0'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2motion'
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9000
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2motion-obama"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
epoch_valid: 5
|
||||
batch_print: 20
|
||||
epoch_test: 10
|
||||
|
||||
MODEL:
|
||||
name: 'audio2motion'
|
||||
name_netG: "audio2motion"
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 256
|
||||
dim_hidden: 256
|
||||
|
||||
n_lookprevs_speech: 3
|
||||
n_lookahead_speech: 3
|
||||
|
||||
n_layer_lstm: 2
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/MotionVAE/train-MoCVAE3-Obama/20210726-19H09M17S"
|
||||
load_epoch: 0
|
||||
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
name: "motion_window"
|
||||
root: './data/LuoXData-ds093-deca-3-10-07-mini10' # obama-deca-3-5-08-mini
|
||||
filter: 'savgol'
|
||||
|
||||
TEST:
|
||||
batch_size: 1
|
||||
|
||||
TRAIN:
|
||||
lr: 0.0001
|
||||
batch_size: 64
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'Adam'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: False
|
||||
grad_clip_norm: False
|
||||
lr_policy: 'multistep'
|
||||
lr_milestones: [10, 100, 200]
|
||||
# lr_policy: 'plateau'
|
||||
|
||||
resume: False
|
||||
reset_lr: False
|
||||
resume_suffix: "20220124-12H17M28S"
|
||||
epoch_begin: 0 # 5000 # 2300 # 2600
|
||||
epoch_end: 500
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec", "rec_l1", "rec_smooth", "rec_smooth_l1"]
|
||||
lambda_rec: 1
|
||||
lambda_rec_smooth: 0.1
|
||||
@@ -1,76 +0,0 @@
|
||||
GPUS: '0'
|
||||
WORKERS: 8
|
||||
OUTPUT_DIR: 'experiments/audio2motion'
|
||||
DEBUG: False
|
||||
verbose: False
|
||||
|
||||
VISUAL:
|
||||
use_HTML: False
|
||||
use_visdom: True
|
||||
vsdm_port: 9000
|
||||
vsdm_ncol: 4
|
||||
vsdm_env: "audio2motion-obama"
|
||||
|
||||
FREQ:
|
||||
epoch_save: 5
|
||||
epoch_valid: 5
|
||||
batch_print: 20
|
||||
epoch_test: 10
|
||||
|
||||
MODEL:
|
||||
name: 'audio2motion'
|
||||
name_netG: "audio2motion"
|
||||
|
||||
dim_motion: 53 # 68*2
|
||||
dim_speech: 27
|
||||
dim_hidden: 256
|
||||
|
||||
n_lookprevs_speech: 7
|
||||
n_lookahead_speech: 7
|
||||
|
||||
n_layer_lstm: 3
|
||||
|
||||
pretrain: False
|
||||
path_checkpoint: "experiments/MotionVAE/train-MoCVAE3-Obama/20210726-19H09M17S"
|
||||
load_epoch: 0
|
||||
|
||||
|
||||
DATASET:
|
||||
fps: 50
|
||||
name: "motion_window"
|
||||
root: './data/LuoXData-deca-5-10-07-mini' # obama-deca-3-5-08-mini
|
||||
filter: 'savgol'
|
||||
|
||||
TEST:
|
||||
batch_size: 2
|
||||
|
||||
TRAIN:
|
||||
lr: 0.0001
|
||||
batch_size: 64
|
||||
shuffle: True
|
||||
|
||||
apply_testing: True
|
||||
apply_validation: True
|
||||
|
||||
optimizer: 'Adam'
|
||||
momentum: 0.9
|
||||
beta1: 0.5
|
||||
beta2: 0.999
|
||||
weight_decay: 0.0001
|
||||
nesterov: False
|
||||
grad_clip_norm: False
|
||||
lr_policy: 'multistep'
|
||||
lr_milestones: [10, 100, 200]
|
||||
# lr_policy: 'plateau'
|
||||
|
||||
resume: True
|
||||
reset_lr: True
|
||||
resume_suffix: "20220125-12H02M01S"
|
||||
epoch_begin: 160 # 5000 # 2300 # 2600
|
||||
epoch_end: 500
|
||||
|
||||
|
||||
LOSS:
|
||||
names: ["all", "rec", "rec_l1", "rec_smooth", "rec_smooth_l1"]
|
||||
lambda_rec: 1
|
||||
lambda_rec_smooth: 0.1
|
||||
+2
-2
@@ -44,8 +44,8 @@ if __name__ == "__main__":
|
||||
|
||||
# path_audio = Path("/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_60_120s.wav")
|
||||
|
||||
# path_audio = Path("/yrfs/lsen/DATA/Obama/processing/Bringing-Our-Workplace-Policies-into-the-21st-Century/audio/audio_trim_120s.wav")
|
||||
path_audio = Path("/yrfs/lsen/DATA/Obama/processing/Celebrating-Independence-Day/audio/audio_trim_60_120s.wav")
|
||||
path_audio = Path("/yrfs/lsen/DATA/Obama/processing/Bringing-Our-Workplace-Policies-into-the-21st-Century/audio/audio_trim_120s.wav")
|
||||
# path_audio = Path("/yrfs/lsen/DATA/Obama/processing/Celebrating-Independence-Day/audio/audio_trim_60_120s.wav")
|
||||
# path_audio = Path("/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_120s.wav")
|
||||
# path_audio = Path("/yrfs/lsen/DATA/LuoXData/processing2/2021-P22/audio/audio_trim.wav")
|
||||
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
import sys
|
||||
import pprint
|
||||
import argparse
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
import torch.nn.functional as F
|
||||
import json
|
||||
|
||||
import torch
|
||||
import torchaudio
|
||||
|
||||
from src.models import create_model
|
||||
from src.config import config as opt
|
||||
from src.config import update_config
|
||||
|
||||
from common.logger import Logger
|
||||
from transformers import Wav2Vec2FeatureExtractor, Wav2Vec2Model
|
||||
|
||||
torch.autograd.set_detect_anomaly(True)
|
||||
|
||||
|
||||
def parese_args():
|
||||
pareser = argparse.ArgumentParser(description='Audio2Expression Network')
|
||||
|
||||
# general
|
||||
pareser.add_argument("--opt", type=str, default="experiments/xxx.yaml", help="experiment configure file name")
|
||||
args, _ = pareser.parse_known_args()
|
||||
update_config(args.opt)
|
||||
|
||||
pareser.add_argument("--gpus", type=str, default="0", help="gpus")
|
||||
args = pareser.parse_args()
|
||||
|
||||
return args
|
||||
|
||||
|
||||
def load_speech_data(path_audio):
|
||||
"""
|
||||
return sr=16000 raw audio data
|
||||
"""
|
||||
if not path_audio.exists():
|
||||
raise(f"NOT existing {path_audio}")
|
||||
|
||||
# Load data_audio
|
||||
data_speech, sample_rate = torchaudio.load(path_audio)
|
||||
# print(f"data_speech shape = {data_speech.shape}, sr = {sample_rate}, duration = {(len(data_speech[0])/sample_rate)}")
|
||||
|
||||
if len(data_speech.shape) == 2:
|
||||
data_speech = data_speech[0]
|
||||
|
||||
if sample_rate != 16000:
|
||||
resampler = torchaudio.transforms.Resample(sample_rate, 16_000)
|
||||
data_speech = resampler(data_speech).squeeze().numpy()
|
||||
# print(f"data_speech shape = {data_speech.shape}, sr = {16000}, duration = {(len(data_speech)/16000)}")
|
||||
|
||||
return data_speech
|
||||
|
||||
|
||||
def load_motion_data(path_info, path_feat_exp, path_feat_pos):
|
||||
if not path_feat_exp.exists() or not path_feat_pos.exists() :
|
||||
raise(f"NOT existing {path_feat_exp} | {path_feat_pos}")
|
||||
|
||||
# load video info
|
||||
with open(str(path_info), "r") as f:
|
||||
info = json.load(f)
|
||||
fps = info["fps"]
|
||||
nframes = info['nframes']
|
||||
# print(f"info={info}, duration = {nframes/fps}")
|
||||
assert fps == 50, "fps should be 50"
|
||||
|
||||
# laod motion
|
||||
data_exp = np.load(path_feat_exp) # (nframe, 50)
|
||||
data_pos = np.load(path_feat_pos) # (nframe, 6)
|
||||
# data_idn = np.load(ipath_feat_idn) # (nframe, 100)
|
||||
|
||||
assert data_exp.shape[0] == data_pos.shape[0], f"data_exp shape={data_exp.shape}, data_pos shape={data_pos.shape}"
|
||||
# assert data_exp.shape[0] == data_idn.shape[0], f"data_exp shape={data_exp.shape}, data_idn shape={data_idn.shape}"
|
||||
|
||||
data_pos_lips = data_pos[:, 3:] # (nframe, 3)
|
||||
data_motion = np.concatenate([data_exp, data_pos_lips], axis=1) # (nframe, 53) --> fps=30
|
||||
|
||||
return data_motion
|
||||
|
||||
|
||||
|
||||
def processing_one_file(path_data, processor, extractor, model):
|
||||
|
||||
# base path of this data
|
||||
path_info = path_data.joinpath("video/info.json")
|
||||
path_feat_exp = path_data.joinpath("audio/feat_DECA_exp_trim.npy")
|
||||
path_feat_pos = path_data.joinpath("audio/feat_DECA_pos_trim.npy")
|
||||
path_speech = path_data.joinpath("audio/audio_trim.wav")
|
||||
path_loss_save = path_data.joinpath("audio/loss_20220228-18H41M46S_175.npy")
|
||||
|
||||
# load data
|
||||
data_speech = load_speech_data(path_speech)
|
||||
data_motion = load_motion_data(path_info, path_feat_exp, path_feat_pos)
|
||||
total_segmt = data_speech.shape[0]
|
||||
print(f"\t load: data_speech = {data_speech.shape}, data_motion={data_motion.shape}")
|
||||
|
||||
# clip speech & motion data
|
||||
fps = opt.DATASET.fps # 50
|
||||
sr = opt.DATASET.sr # 16000
|
||||
nwind = opt.DATASET.nwind_second_test
|
||||
nsteps_frame = nwind * fps
|
||||
nsteps_segmt = nwind * sr
|
||||
print(f"\t setting: fps = {fps}, sr = {sr}, nwind={nwind}, nsteps_frame={nsteps_frame}, nsteps_segmt={nsteps_segmt}")
|
||||
|
||||
|
||||
beg_segmt, beg_frame = 0, 0
|
||||
nframe_total_real = 0
|
||||
batch_loss, batch_frame = [], []
|
||||
while beg_segmt < len(data_speech):
|
||||
end_segmt = beg_segmt + nsteps_segmt # update
|
||||
end_frame = beg_frame + nsteps_frame # update
|
||||
print(f"\n\t\t while loop ... beg_frame:end_frame = {beg_frame}:{end_frame}")
|
||||
###### get clip data_motion
|
||||
idata_motion = data_motion[beg_frame:end_frame] # (nframe_steps?, nc_motion)
|
||||
if idata_motion.shape[0] < nsteps_frame:
|
||||
inpad_motion = nsteps_frame - idata_motion.shape[0]
|
||||
print(f"\t idata_motion = {idata_motion.shape}, need padding inpad_motion = {inpad_motion}")
|
||||
idata_motion = np.pad(idata_motion, pad_width=((0, inpad_motion),(0,0)), mode="edge") # (nframe_steps, nc_motion)
|
||||
print(f"\t after padding idata_motion = {idata_motion.shape}")
|
||||
|
||||
idata_motion = torch.from_numpy(idata_motion).reshape(1, nsteps_frame, -1) # 1 x nframe_steps x nc_motion
|
||||
|
||||
###### get clip data_speech
|
||||
# padding data for wave2vect alignment
|
||||
npad_wv = int(0.5 * sr * ( 1 / fps) + 0.5)
|
||||
npad_wd1, npad_wd2 = 7, 8 # nwind_size = 16, need_pad 15 frame for each clips
|
||||
nframe_real = nsteps_frame
|
||||
|
||||
ibeg_segmt = int(beg_segmt - sr * (npad_wd1/fps) - npad_wv - 0.5)
|
||||
iend_segmt = int(end_segmt + sr * (npad_wd2/fps) + npad_wv + 0.5)
|
||||
idata_speech = data_speech[max(ibeg_segmt, 0): min(iend_segmt, total_segmt)] # (nsegmt_steps + npad_wv, )
|
||||
|
||||
inpad_l = - ibeg_segmt if ibeg_segmt < 0 else 0
|
||||
inpad_r = iend_segmt - total_segmt if iend_segmt > total_segmt else 0
|
||||
if inpad_l + inpad_r > 0:
|
||||
print(f"\t idata_speech = {idata_speech.shape}, inpad_l = {inpad_l}, inpad_r={inpad_r} ")
|
||||
idata_speech = np.pad(idata_speech, pad_width=((inpad_l, inpad_r)), mode="edge") # (nsegmt_steps + 2npad_wv, )
|
||||
print(f"\t after padding idata_speech = {idata_speech.shape}")
|
||||
|
||||
if end_segmt > total_segmt:
|
||||
nframe_real = int(((total_segmt - beg_segmt) / sr ) * fps)
|
||||
else:
|
||||
nframe_real = nsteps_frame
|
||||
|
||||
# do audio extraction
|
||||
# print(f"\t before extraction idata_speech = {idata_speech.shape}, nframe_real={nframe_real}")
|
||||
|
||||
inputs = processor(idata_speech, sampling_rate=16000, return_tensors="pt").to(device)
|
||||
with torch.no_grad():
|
||||
output = extractor(**inputs)
|
||||
cond = output.last_hidden_state
|
||||
# print(f"\t cond shape = {cond.shape}")
|
||||
cond = cond.unfold(dimension=1, size=16, step=1) # (1, nseqs, nc_motion, 16)
|
||||
cond = cond.permute(0, 1, 3, 2) # (1, nseqs, 16, 53)
|
||||
nseq = cond.size(1)
|
||||
# print(f"\t after convert window cond shape = {cond.shape}")
|
||||
assert nseq == nsteps_frame, f"\t cond = {cond.shape}, nsteps_frame={nsteps_frame}"
|
||||
|
||||
idata_speech = cond # 1 x nsteps_frames x 16 x nc_speech
|
||||
|
||||
|
||||
########### infer loss
|
||||
print(f"\t idata_motion={idata_motion.shape} idata_speech = {idata_speech.shape}")
|
||||
loss = model.infer_loss(idata_speech, idata_motion) # 1 x nsteps_frames x 3
|
||||
print(f"\t predict loss shape = {loss.shape}")
|
||||
|
||||
########### update
|
||||
batch_loss.append(loss)
|
||||
batch_frame.append(nframe_real)
|
||||
beg_segmt, beg_frame = end_segmt, end_frame
|
||||
nframe_total_real += nframe_real
|
||||
|
||||
#
|
||||
batch_loss = torch.concat(batch_loss, dim=0) # B x nsteps x 16 x nc_speech
|
||||
batch_frame = torch.from_numpy(np.array(batch_frame)) # B
|
||||
assert data_motion.shape[0] == nframe_total_real, \
|
||||
f"nframe_total_real/{nframe_total_real} of infrence should = data_motion.shape[0]/{data_motion.shape[0]}"
|
||||
|
||||
print(f"\t nframe toatl = {nframe_total_real}")
|
||||
print(f"\t data_speech = {data_speech.shape}, duration = {total_segmt/sr}, nframe_infer={(total_segmt/sr) * fps} \n")
|
||||
print(f"\t batch_loss = {batch_loss.shape}, batch_frame={batch_frame.shape}")
|
||||
|
||||
batch_loss = batch_loss.cpu().numpy().reshape(-1, 3)
|
||||
batch_loss = batch_loss[:nframe_total_real, :] # B x nframe_real
|
||||
|
||||
# save batch loss
|
||||
np.save(path_loss_save, batch_loss)
|
||||
print(f"\t save loss > {path_loss_save}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parese_args()
|
||||
path_config = Path(args.opt)
|
||||
postfix = opt.TRAIN.resume_suffix if opt.TRAIN.resume else None # if resume, resume to resume_suffix folder
|
||||
logger = Logger(opt.OUTPUT_DIR, path_config=path_config, postfix=postfix)
|
||||
device = torch.device(f'cuda:{opt.GPUS[0]}') # get device name: CPU or GPU
|
||||
|
||||
logger.info(pprint.pformat(opt))
|
||||
opt.OUTPUT_DIR = logger.path_output
|
||||
|
||||
# load wav2Vec model
|
||||
print("load Wav2Vec2Model ...")
|
||||
MODEL_ID = "jonatasgrosman/wav2vec2-large-xlsr-53-chinese-zh-cn"
|
||||
processor = Wav2Vec2FeatureExtractor.from_pretrained(MODEL_ID)
|
||||
extractor = Wav2Vec2Model.from_pretrained(MODEL_ID).to(device)
|
||||
|
||||
# load audio-driven model
|
||||
model = create_model(opt, logger)
|
||||
model.setup(opt)
|
||||
|
||||
# iterater folders
|
||||
path_data = Path('/yrfs/lsen/DATA/LuoXData/processing2') # '../data/trinity/source'
|
||||
v_dir_videos = sorted(path_data.glob("*/audio/feat_DECA_exp_trim.npy"))
|
||||
v_dir_videos = [ipath.parent.parent for ipath in v_dir_videos]
|
||||
vids = set([ipath.stem for ipath in v_dir_videos])
|
||||
print(f"Have {len(v_dir_videos)} dir files > {v_dir_videos[:3]}")
|
||||
|
||||
for i, ipath_data in enumerate(v_dir_videos):
|
||||
vid = ipath_data.stem
|
||||
|
||||
if vid not in vids: continue
|
||||
print(f"\n processing the {i}-th video {vid} ... ")
|
||||
processing_one_file(ipath_data, processor, extractor, model)
|
||||
|
||||
# break
|
||||
|
||||
|
||||
@@ -0,0 +1,609 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 86,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"from pathlib import Path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 77,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(233050, 3)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 89,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Have 40 dir files\n",
|
||||
"(2859750, 3)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"path_data = Path('/yrfs/lsen/idata/LuoXData/processing2') # '../data/trinity/source'\n",
|
||||
"v_dir_videos = sorted(path_data.glob(\"*/audio/loss_20220228-18H41M46S_175.npy\"))\n",
|
||||
"print(f\"Have {len(v_dir_videos)} dir files\")\n",
|
||||
"\n",
|
||||
"data = []\n",
|
||||
"for ipath_data in v_dir_videos:\n",
|
||||
" idata = np.load(ipath_data)\n",
|
||||
" data.append(idata)\n",
|
||||
"\n",
|
||||
"data = np.concatenate(data, axis=0)\n",
|
||||
"print(data.shape)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 107,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"rec_prec 75% = 0.010481649544090033, vel_perc 75% = 0.006076762365410104\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"rec_perc = np.percentile(data[:, 0], q=75) * 2\n",
|
||||
"vel_perc = np.percentile(data[:, 1], q=75) * 5\n",
|
||||
"print(f\"rec_prec 75% = {rec_perc}, vel_perc 75% = {vel_perc}\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 109,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"processing... > 2021-P01\n",
|
||||
"(129700, 3)\n",
|
||||
"idx_rec len=1208/ total len=129700, percents = 0.9313801079414032 %\n",
|
||||
"idx_vel len=210/ total len=129700, percents = 0.16191210485736315 %\n",
|
||||
"idx_filter len=1407/ total len=129700, percents = 1.084811102544333 %\n",
|
||||
"idx_filter len=35159/ total len=129700, percents = 27.107941403238243 %\n",
|
||||
"remain idx len=94541/ total len=129700, percents = 72.89205859676176 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P01/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P02\n",
|
||||
"(148750, 3)\n",
|
||||
"idx_rec len=1990/ total len=148750, percents = 1.33781512605042 %\n",
|
||||
"idx_vel len=225/ total len=148750, percents = 0.15126050420168066 %\n",
|
||||
"idx_filter len=2201/ total len=148750, percents = 1.4796638655462184 %\n",
|
||||
"idx_filter len=38100/ total len=148750, percents = 25.613445378151262 %\n",
|
||||
"remain idx len=110650/ total len=148750, percents = 74.38655462184875 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P02/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P03\n",
|
||||
"(233050, 3)\n",
|
||||
"idx_rec len=3271/ total len=233050, percents = 1.4035614674962456 %\n",
|
||||
"idx_vel len=536/ total len=233050, percents = 0.22999356361295858 %\n",
|
||||
"idx_filter len=3772/ total len=233050, percents = 1.6185367946792535 %\n",
|
||||
"idx_filter len=78697/ total len=233050, percents = 33.76829006650933 %\n",
|
||||
"remain idx len=154353/ total len=233050, percents = 66.23170993349066 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P03/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P04\n",
|
||||
"(57350, 3)\n",
|
||||
"idx_rec len=307/ total len=57350, percents = 0.5353095030514385 %\n",
|
||||
"idx_vel len=112/ total len=57350, percents = 0.1952920662598082 %\n",
|
||||
"idx_filter len=418/ total len=57350, percents = 0.7288578901482128 %\n",
|
||||
"idx_filter len=15716/ total len=57350, percents = 27.403661726242373 %\n",
|
||||
"remain idx len=41634/ total len=57350, percents = 72.59633827375762 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P04/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P05\n",
|
||||
"(38850, 3)\n",
|
||||
"idx_rec len=309/ total len=38850, percents = 0.7953667953667953 %\n",
|
||||
"idx_vel len=81/ total len=38850, percents = 0.2084942084942085 %\n",
|
||||
"idx_filter len=388/ total len=38850, percents = 0.9987129987129987 %\n",
|
||||
"idx_filter len=12412/ total len=38850, percents = 31.948519948519948 %\n",
|
||||
"remain idx len=26438/ total len=38850, percents = 68.05148005148006 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P05/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P06\n",
|
||||
"(103900, 3)\n",
|
||||
"idx_rec len=777/ total len=103900, percents = 0.7478344562078922 %\n",
|
||||
"idx_vel len=303/ total len=103900, percents = 0.29162656400384984 %\n",
|
||||
"idx_filter len=1044/ total len=103900, percents = 1.0048123195380174 %\n",
|
||||
"idx_filter len=34870/ total len=103900, percents = 33.56111645813282 %\n",
|
||||
"remain idx len=69030/ total len=103900, percents = 66.43888354186718 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P06/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P07\n",
|
||||
"(27950, 3)\n",
|
||||
"idx_rec len=9/ total len=27950, percents = 0.03220035778175313 %\n",
|
||||
"idx_vel len=42/ total len=27950, percents = 0.15026833631484796 %\n",
|
||||
"idx_filter len=51/ total len=27950, percents = 0.18246869409660108 %\n",
|
||||
"idx_filter len=5839/ total len=27950, percents = 20.89087656529517 %\n",
|
||||
"remain idx len=22111/ total len=27950, percents = 79.10912343470483 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P07/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P08\n",
|
||||
"(184000, 3)\n",
|
||||
"idx_rec len=2284/ total len=184000, percents = 1.241304347826087 %\n",
|
||||
"idx_vel len=457/ total len=184000, percents = 0.2483695652173913 %\n",
|
||||
"idx_filter len=2720/ total len=184000, percents = 1.4782608695652173 %\n",
|
||||
"idx_filter len=62221/ total len=184000, percents = 33.81576086956522 %\n",
|
||||
"remain idx len=121779/ total len=184000, percents = 66.18423913043478 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P08/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P09\n",
|
||||
"(21500, 3)\n",
|
||||
"idx_rec len=306/ total len=21500, percents = 1.4232558139534883 %\n",
|
||||
"idx_vel len=222/ total len=21500, percents = 1.0325581395348837 %\n",
|
||||
"idx_filter len=487/ total len=21500, percents = 2.2651162790697676 %\n",
|
||||
"idx_filter len=13897/ total len=21500, percents = 64.63720930232559 %\n",
|
||||
"remain idx len=7603/ total len=21500, percents = 35.36279069767442 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P10\n",
|
||||
"(178750, 3)\n",
|
||||
"idx_rec len=1126/ total len=178750, percents = 0.62993006993007 %\n",
|
||||
"idx_vel len=375/ total len=178750, percents = 0.2097902097902098 %\n",
|
||||
"idx_filter len=1497/ total len=178750, percents = 0.8374825174825175 %\n",
|
||||
"idx_filter len=56091/ total len=178750, percents = 31.37958041958042 %\n",
|
||||
"remain idx len=122659/ total len=178750, percents = 68.62041958041958 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P10/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P11\n",
|
||||
"(73500, 3)\n",
|
||||
"idx_rec len=304/ total len=73500, percents = 0.41360544217687073 %\n",
|
||||
"idx_vel len=162/ total len=73500, percents = 0.22040816326530613 %\n",
|
||||
"idx_filter len=448/ total len=73500, percents = 0.6095238095238096 %\n",
|
||||
"idx_filter len=20965/ total len=73500, percents = 28.523809523809526 %\n",
|
||||
"remain idx len=52535/ total len=73500, percents = 71.47619047619048 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P11/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P12\n",
|
||||
"(51300, 3)\n",
|
||||
"idx_rec len=94/ total len=51300, percents = 0.18323586744639375 %\n",
|
||||
"idx_vel len=86/ total len=51300, percents = 0.16764132553606237 %\n",
|
||||
"idx_filter len=180/ total len=51300, percents = 0.3508771929824561 %\n",
|
||||
"idx_filter len=12907/ total len=51300, percents = 25.159844054580898 %\n",
|
||||
"remain idx len=38396/ total len=51300, percents = 74.84600389863547 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P12/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P14\n",
|
||||
"(18400, 3)\n",
|
||||
"idx_rec len=98/ total len=18400, percents = 0.532608695652174 %\n",
|
||||
"idx_vel len=123/ total len=18400, percents = 0.6684782608695652 %\n",
|
||||
"idx_filter len=202/ total len=18400, percents = 1.0978260869565217 %\n",
|
||||
"idx_filter len=7873/ total len=18400, percents = 42.78804347826087 %\n",
|
||||
"remain idx len=10530/ total len=18400, percents = 57.22826086956522 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P14/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P16\n",
|
||||
"(66400, 3)\n",
|
||||
"idx_rec len=173/ total len=66400, percents = 0.2605421686746988 %\n",
|
||||
"idx_vel len=111/ total len=66400, percents = 0.16716867469879518 %\n",
|
||||
"idx_filter len=279/ total len=66400, percents = 0.42018072289156627 %\n",
|
||||
"idx_filter len=16739/ total len=66400, percents = 25.20933734939759 %\n",
|
||||
"remain idx len=49661/ total len=66400, percents = 74.79066265060241 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P16/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P19\n",
|
||||
"(33350, 3)\n",
|
||||
"idx_rec len=140/ total len=33350, percents = 0.4197901049475262 %\n",
|
||||
"idx_vel len=48/ total len=33350, percents = 0.14392803598200898 %\n",
|
||||
"idx_filter len=186/ total len=33350, percents = 0.5577211394302849 %\n",
|
||||
"idx_filter len=7486/ total len=33350, percents = 22.44677661169415 %\n",
|
||||
"remain idx len=25864/ total len=33350, percents = 77.55322338830585 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P19/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P20\n",
|
||||
"(21300, 3)\n",
|
||||
"idx_rec len=68/ total len=21300, percents = 0.3192488262910798 %\n",
|
||||
"idx_vel len=13/ total len=21300, percents = 0.06103286384976526 %\n",
|
||||
"idx_filter len=81/ total len=21300, percents = 0.38028169014084506 %\n",
|
||||
"idx_filter len=2774/ total len=21300, percents = 13.023474178403756 %\n",
|
||||
"remain idx len=18529/ total len=21300, percents = 86.9906103286385 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P20/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P21\n",
|
||||
"(21300, 3)\n",
|
||||
"idx_rec len=4/ total len=21300, percents = 0.018779342723004695 %\n",
|
||||
"idx_vel len=17/ total len=21300, percents = 0.07981220657276995 %\n",
|
||||
"idx_filter len=21/ total len=21300, percents = 0.09859154929577464 %\n",
|
||||
"idx_filter len=2543/ total len=21300, percents = 11.938967136150234 %\n",
|
||||
"remain idx len=18757/ total len=21300, percents = 88.06103286384976 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P21/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P22\n",
|
||||
"(15700, 3)\n",
|
||||
"idx_rec len=76/ total len=15700, percents = 0.4840764331210191 %\n",
|
||||
"idx_vel len=45/ total len=15700, percents = 0.28662420382165604 %\n",
|
||||
"idx_filter len=118/ total len=15700, percents = 0.7515923566878981 %\n",
|
||||
"idx_filter len=6824/ total len=15700, percents = 43.46496815286624 %\n",
|
||||
"remain idx len=8876/ total len=15700, percents = 56.53503184713376 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P22/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P24\n",
|
||||
"(171900, 3)\n",
|
||||
"idx_rec len=983/ total len=171900, percents = 0.5718440954043048 %\n",
|
||||
"idx_vel len=399/ total len=171900, percents = 0.23211169284467714 %\n",
|
||||
"idx_filter len=1347/ total len=171900, percents = 0.7835951134380453 %\n",
|
||||
"idx_filter len=48662/ total len=171900, percents = 28.308318789994182 %\n",
|
||||
"remain idx len=123238/ total len=171900, percents = 71.69168121000581 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P24/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P25\n",
|
||||
"(74300, 3)\n",
|
||||
"idx_rec len=188/ total len=74300, percents = 0.253028263795424 %\n",
|
||||
"idx_vel len=158/ total len=74300, percents = 0.2126514131897712 %\n",
|
||||
"idx_filter len=323/ total len=74300, percents = 0.4347240915208614 %\n",
|
||||
"idx_filter len=12738/ total len=74300, percents = 17.14401076716016 %\n",
|
||||
"remain idx len=61562/ total len=74300, percents = 82.85598923283983 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P25/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P26\n",
|
||||
"(15250, 3)\n",
|
||||
"idx_rec len=11/ total len=15250, percents = 0.07213114754098361 %\n",
|
||||
"idx_vel len=17/ total len=15250, percents = 0.11147540983606558 %\n",
|
||||
"idx_filter len=26/ total len=15250, percents = 0.17049180327868851 %\n",
|
||||
"idx_filter len=1873/ total len=15250, percents = 12.281967213114754 %\n",
|
||||
"remain idx len=13377/ total len=15250, percents = 87.71803278688525 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P26/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P27\n",
|
||||
"(55700, 3)\n",
|
||||
"idx_rec len=194/ total len=55700, percents = 0.348294434470377 %\n",
|
||||
"idx_vel len=45/ total len=55700, percents = 0.0807899461400359 %\n",
|
||||
"idx_filter len=239/ total len=55700, percents = 0.42908438061041293 %\n",
|
||||
"idx_filter len=8551/ total len=55700, percents = 15.351885098743267 %\n",
|
||||
"remain idx len=47149/ total len=55700, percents = 84.64811490125673 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P27/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P29\n",
|
||||
"(35700, 3)\n",
|
||||
"idx_rec len=91/ total len=35700, percents = 0.2549019607843137 %\n",
|
||||
"idx_vel len=48/ total len=35700, percents = 0.13445378151260504 %\n",
|
||||
"idx_filter len=128/ total len=35700, percents = 0.3585434173669468 %\n",
|
||||
"idx_filter len=4113/ total len=35700, percents = 11.521008403361344 %\n",
|
||||
"remain idx len=31587/ total len=35700, percents = 88.47899159663865 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P29/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P30\n",
|
||||
"(163500, 3)\n",
|
||||
"idx_rec len=901/ total len=163500, percents = 0.5510703363914373 %\n",
|
||||
"idx_vel len=237/ total len=163500, percents = 0.14495412844036698 %\n",
|
||||
"idx_filter len=1115/ total len=163500, percents = 0.6819571865443425 %\n",
|
||||
"idx_filter len=34727/ total len=163500, percents = 21.239755351681957 %\n",
|
||||
"remain idx len=128773/ total len=163500, percents = 78.76024464831804 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P30/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P31\n",
|
||||
"(162650, 3)\n",
|
||||
"idx_rec len=433/ total len=162650, percents = 0.2662158007992622 %\n",
|
||||
"idx_vel len=147/ total len=162650, percents = 0.09037811251152782 %\n",
|
||||
"idx_filter len=580/ total len=162650, percents = 0.35659391331079004 %\n",
|
||||
"idx_filter len=24896/ total len=162650, percents = 15.306486320319705 %\n",
|
||||
"remain idx len=137754/ total len=162650, percents = 84.6935136796803 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P31/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P32\n",
|
||||
"(9000, 3)\n",
|
||||
"idx_rec len=40/ total len=9000, percents = 0.4444444444444444 %\n",
|
||||
"idx_vel len=7/ total len=9000, percents = 0.07777777777777778 %\n",
|
||||
"idx_filter len=47/ total len=9000, percents = 0.5222222222222223 %\n",
|
||||
"idx_filter len=1334/ total len=9000, percents = 14.822222222222223 %\n",
|
||||
"remain idx len=7666/ total len=9000, percents = 85.17777777777778 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P32/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P33\n",
|
||||
"(66850, 3)\n",
|
||||
"idx_rec len=984/ total len=66850, percents = 1.4719521316379955 %\n",
|
||||
"idx_vel len=195/ total len=66850, percents = 0.2916978309648467 %\n",
|
||||
"idx_filter len=1130/ total len=66850, percents = 1.6903515332834704 %\n",
|
||||
"idx_filter len=18149/ total len=66850, percents = 27.148840688107704 %\n",
|
||||
"remain idx len=48701/ total len=66850, percents = 72.8511593118923 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P33/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P34\n",
|
||||
"(11700, 3)\n",
|
||||
"idx_rec len=17/ total len=11700, percents = 0.1452991452991453 %\n",
|
||||
"idx_vel len=10/ total len=11700, percents = 0.08547008547008547 %\n",
|
||||
"idx_filter len=27/ total len=11700, percents = 0.23076923076923078 %\n",
|
||||
"idx_filter len=1916/ total len=11700, percents = 16.376068376068375 %\n",
|
||||
"remain idx len=9784/ total len=11700, percents = 83.62393162393163 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P34/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P35\n",
|
||||
"(31950, 3)\n",
|
||||
"idx_rec len=65/ total len=31950, percents = 0.20344287949921752 %\n",
|
||||
"idx_vel len=73/ total len=31950, percents = 0.22848200312989045 %\n",
|
||||
"idx_filter len=133/ total len=31950, percents = 0.4162754303599374 %\n",
|
||||
"idx_filter len=7522/ total len=31950, percents = 23.54303599374022 %\n",
|
||||
"remain idx len=24428/ total len=31950, percents = 76.45696400625978 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P35/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P36\n",
|
||||
"(15100, 3)\n",
|
||||
"idx_rec len=478/ total len=15100, percents = 3.165562913907285 %\n",
|
||||
"idx_vel len=26/ total len=15100, percents = 0.17218543046357615 %\n",
|
||||
"idx_filter len=502/ total len=15100, percents = 3.3245033112582782 %\n",
|
||||
"idx_filter len=4708/ total len=15100, percents = 31.178807947019866 %\n",
|
||||
"remain idx len=10392/ total len=15100, percents = 68.82119205298014 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P36/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P37\n",
|
||||
"(164200, 3)\n",
|
||||
"idx_rec len=705/ total len=164200, percents = 0.42935444579780757 %\n",
|
||||
"idx_vel len=138/ total len=164200, percents = 0.08404384896467722 %\n",
|
||||
"idx_filter len=840/ total len=164200, percents = 0.5115712545676004 %\n",
|
||||
"idx_filter len=23842/ total len=164200, percents = 14.520097442143728 %\n",
|
||||
"remain idx len=140358/ total len=164200, percents = 85.47990255785628 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P37/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P38\n",
|
||||
"(69050, 3)\n",
|
||||
"idx_rec len=250/ total len=69050, percents = 0.3620564808110065 %\n",
|
||||
"idx_vel len=58/ total len=69050, percents = 0.08399710354815351 %\n",
|
||||
"idx_filter len=308/ total len=69050, percents = 0.44605358435916004 %\n",
|
||||
"idx_filter len=8673/ total len=69050, percents = 12.560463432295439 %\n",
|
||||
"remain idx len=60377/ total len=69050, percents = 87.43953656770456 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P38/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P39\n",
|
||||
"(22400, 3)\n",
|
||||
"idx_rec len=164/ total len=22400, percents = 0.7321428571428571 %\n",
|
||||
"idx_vel len=33/ total len=22400, percents = 0.14732142857142858 %\n",
|
||||
"idx_filter len=189/ total len=22400, percents = 0.84375 %\n",
|
||||
"idx_filter len=4261/ total len=22400, percents = 19.022321428571427 %\n",
|
||||
"remain idx len=18139/ total len=22400, percents = 80.97767857142857 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P39/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P40\n",
|
||||
"(15700, 3)\n",
|
||||
"idx_rec len=0/ total len=15700, percents = 0.0 %\n",
|
||||
"idx_vel len=1/ total len=15700, percents = 0.006369426751592357 %\n",
|
||||
"idx_filter len=1/ total len=15700, percents = 0.006369426751592357 %\n",
|
||||
"idx_filter len=153/ total len=15700, percents = 0.9745222929936306 %\n",
|
||||
"remain idx len=15547/ total len=15700, percents = 99.02547770700637 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P40/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P41\n",
|
||||
"(50450, 3)\n",
|
||||
"idx_rec len=344/ total len=50450, percents = 0.6818632309217046 %\n",
|
||||
"idx_vel len=137/ total len=50450, percents = 0.27155599603567887 %\n",
|
||||
"idx_filter len=470/ total len=50450, percents = 0.931615460852329 %\n",
|
||||
"idx_filter len=15452/ total len=50450, percents = 30.62834489593657 %\n",
|
||||
"remain idx len=35001/ total len=50450, percents = 69.37760158572844 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P41/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P42\n",
|
||||
"(15100, 3)\n",
|
||||
"idx_rec len=12/ total len=15100, percents = 0.07947019867549669 %\n",
|
||||
"idx_vel len=27/ total len=15100, percents = 0.17880794701986755 %\n",
|
||||
"idx_filter len=36/ total len=15100, percents = 0.23841059602649006 %\n",
|
||||
"idx_filter len=3237/ total len=15100, percents = 21.43708609271523 %\n",
|
||||
"remain idx len=11863/ total len=15100, percents = 78.56291390728477 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P42/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P43\n",
|
||||
"(173900, 3)\n",
|
||||
"idx_rec len=745/ total len=173900, percents = 0.4284071305347901 %\n",
|
||||
"idx_vel len=291/ total len=173900, percents = 0.16733755031627373 %\n",
|
||||
"idx_filter len=1020/ total len=173900, percents = 0.58654399079931 %\n",
|
||||
"idx_filter len=39644/ total len=173900, percents = 22.79700977573318 %\n",
|
||||
"remain idx len=134259/ total len=173900, percents = 77.20471535365152 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P43/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P44\n",
|
||||
"(52750, 3)\n",
|
||||
"idx_rec len=308/ total len=52750, percents = 0.5838862559241706 %\n",
|
||||
"idx_vel len=70/ total len=52750, percents = 0.13270142180094788 %\n",
|
||||
"idx_filter len=373/ total len=52750, percents = 0.7071090047393365 %\n",
|
||||
"idx_filter len=8045/ total len=52750, percents = 15.251184834123222 %\n",
|
||||
"remain idx len=44705/ total len=52750, percents = 84.74881516587678 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P44/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P45\n",
|
||||
"(21450, 3)\n",
|
||||
"idx_rec len=23/ total len=21450, percents = 0.10722610722610723 %\n",
|
||||
"idx_vel len=6/ total len=21450, percents = 0.027972027972027972 %\n",
|
||||
"idx_filter len=29/ total len=21450, percents = 0.1351981351981352 %\n",
|
||||
"idx_filter len=1112/ total len=21450, percents = 5.1841491841491845 %\n",
|
||||
"remain idx len=20338/ total len=21450, percents = 94.81585081585082 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P45/audio/idx_w150_20220228-18H41M46S_175.npy\n",
|
||||
"\n",
|
||||
"processing... > 2021-P46\n",
|
||||
"(36100, 3)\n",
|
||||
"idx_rec len=234/ total len=36100, percents = 0.6481994459833795 %\n",
|
||||
"idx_vel len=38/ total len=36100, percents = 0.10526315789473684 %\n",
|
||||
"idx_filter len=272/ total len=36100, percents = 0.7534626038781164 %\n",
|
||||
"idx_filter len=7231/ total len=36100, percents = 20.030470914127424 %\n",
|
||||
"remain idx len=28869/ total len=36100, percents = 79.96952908587258 %\n",
|
||||
"save to > /yrfs/lsen/DATA/LuoXData/processing2/2021-P46/audio/idx_w150_20220228-18H41M46S_175.npy\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# processing \n",
|
||||
"for ipath_data in v_dir_videos:\n",
|
||||
" print(f\"\\nprocessing... > {ipath_data.parent.parent.stem}\")\n",
|
||||
"\n",
|
||||
" idata = np.load(ipath_data)\n",
|
||||
" idx = np.array(np.arange(idata.shape[0]))\n",
|
||||
" print(idata.shape)\n",
|
||||
"\n",
|
||||
" idx_rec = set(idx[idata[:, 0] > rec_perc])\n",
|
||||
" idx_vel = set(idx[idata[:, 1] > vel_perc])\n",
|
||||
" print(f\"idx_rec len={len(idx_rec)}/ total len={len(idx)}, percents = {100* len(idx_rec) / len(idx)} %\")\n",
|
||||
" print(f\"idx_vel len={len(idx_vel)}/ total len={len(idx)}, percents = {100* len(idx_vel) / len(idx)} %\")\n",
|
||||
"\n",
|
||||
" idx_rec.update(idx_vel)\n",
|
||||
" print(f\"idx_filter len={len(idx_rec)}/ total len={len(idx)}, percents = {100* len(idx_rec) / len(idx)} %\")\n",
|
||||
"\n",
|
||||
" # windows 3s * 50fps = 150 frame\n",
|
||||
" mask_idx = idx_rec.copy()\n",
|
||||
" for i in idx_rec:\n",
|
||||
"\n",
|
||||
" temp_set = set()\n",
|
||||
" for j in range(-3, 150, 1):\n",
|
||||
" if i-j >= 0: temp_set.add(i-j)\n",
|
||||
"\n",
|
||||
" # update idx_rec:\n",
|
||||
" mask_idx.update(temp_set)\n",
|
||||
"\n",
|
||||
" # print(mask_idx)\n",
|
||||
" print(f\"idx_filter len={len(mask_idx)}/ total len={len(idx)}, percents = {100* len(mask_idx) / len(idx)} %\")\n",
|
||||
" idx_remain = set(idx) - mask_idx\n",
|
||||
" print(f\"remain idx len={len(idx_remain)}/ total len={len(idx)}, percents = {100* len(idx_remain) / len(idx)} %\")\n",
|
||||
"\n",
|
||||
" # save idx_remain \n",
|
||||
" idx_remain = np.array(idx_remain)\n",
|
||||
" ipath_save_idx = ipath_data.parent.joinpath(\"idx_w150_20220228-18H41M46S_175.npy\")\n",
|
||||
" np.save(ipath_save_idx, idx_remain)\n",
|
||||
" print(f\"save to > {ipath_save_idx}\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 97,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 65794, 65795, 65805, 65797, 65798, 65799, 65800, 65801, 65802, 65803, 65804, 65806, 65807, 65808, 65809, 65810, 65811, 65812, 65813, 65814, 65815, 65816, 65817, 65818, 65819, 65820, 65821, 65822, 65823, 65824, 65825, 65826, 65827, 65828, 65829, 65830, 65831, 65832, 65833, 65834, 65835, 65836, 65837, 65838, 65839, 65840, 65841, 65842, 65843, 65844, 65845, 65846, 65847, 65848, 65849, 65850, 65851, 65852, 65853, 65854, 65855, 65856, 65857, 65858, 65859, 65860, 65861, 65862, 65863, 65864, 65865, 65866, 65867, 65868, 65869, 65870, 65871, 65872, 65873, 65874, 65875, 65876, 65877, 65878, 65879, 65880, 65881, 65882, 65883, 65884, 65885, 65886, 65887, 65888, 65889, 65890, 65891, 65892, 65893, 65894, 65895, 65896, 65897, 65898, 65899, 65900, 65901, 65902, 65903, 65904, 65905, 65906, 65907, 65908, 65909, 65910, 65911, 65912, 65913, 65914, 65915, 65916, 65917, 65918, 65919, 65920, 65921, 65922, 65923, 65924, 65925, 65926, 65927, 65928, 65929, 65930, 65931, 65932, 65933, 65934, 65935, 65936, 65937, 65938, 65939, 65940, 65941, 65942, 65943, 65944, 65945, 65946, 65947, 65948, 65957, 65949, 65950, 65951, 65952, 65953, 65954, 65955, 65956, 65958, 65959, 65960, 66248, 66249, 66250, 66251, 66252, 66253, 66254, 66255, 66256, 66257, 66258, 66259, 66260, 66261, 66262, 66263, 66264, 66265, 66266, 66267, 66268, 66269, 66270, 66271, 66272, 66273, 66274, 66275, 66276, 66277, 66278, 66279, 66280, 66281, 66282, 66283, 66284, 66285, 66286, 66287, 66288, 66289, 66290, 66291, 66292, 66293, 66294, 66295, 66296, 66297, 66298, 66299, 66300, 66301, 66302, 66303, 66304, 66305, 66306, 66307, 66308, 66309, 66310, 66311, 66312, 66313, 66314, 66315, 66316, 66317, 66318, 66319, 66320, 66321, 66322, 66323, 66324, 66325, 66326, 66327, 66328, 66329, 66330, 66331, 66332, 66333, 66334, 66335, 66336, 66337, 66338, 66339, 66340, 66341, 66342, 66343, 66344, 66345, 66346, 66347, 66348, 66349, 66350, 66351, 66352, 66353, 66354, 66355, 66356, 66357, 66358, 66359, 66360, 66361, 66362, 66363, 66364, 66365, 66366, 66367, 66368, 66369, 66370, 66371, 66372, 66373, 66374, 66375, 66376, 66377, 66378, 66379, 66380, 66381, 66382, 66383, 66384, 66385, 66386, 66387, 66388, 66389, 66390, 66391, 66392, 66393, 66394, 66395, 66396, 66397, 66398, 66399, 66400, 26250, 26251, 26252, 26253, 26254, 26255, 26256, 26257, 26258, 26259, 26260, 26261, 26262, 26263, 26264, 26265, 26266, 26267, 26268, 66630, 66631, 66632, 66633, 66634, 66635, 66636, 66637, 66638, 66639, 66640, 66641, 66642, 66643, 66644, 66645, 66646, 66647, 66648, 66649, 66650, 66651, 66652, 66653, 66654, 66655, 66656, 66657, 66658, 66659, 66660, 66661, 66662, 66663, 66664, 66665, 66666, 66667, 66668, 66669, 66670, 66671, 66672, 66673, 66674, 66675, 66676, 66677, 66678, 66679, 66680, 66681, 66682, 66683, 66684, 66685, 66686, 66687, 66688, 66689, 66690, 66691, 66692, 66693, 66694, 66695, 66696, 66697, 66698, 66699, 66700, 66701, 66702, 66703, 66704, 66705, 66706, 66707, 66708, 66709, 66710, 66711, 66712, 66713, 66714, 66715, 66716, 66717, 66718, 66719, 66720, 66721, 66722, 66723, 66724, 66725, 66726, 66727, 66728, 66729, 66730, 66731, 66732, 66733, 66734, 66735, 66736, 66737, 66738, 66739, 66740, 66741, 66742, 66743, 66744, 66745, 66746, 66747, 66748, 66749, 66750, 66751, 66752, 66753, 66754, 66755, 66756, 66757, 66758, 66759, 66760, 66761, 66762, 66763, 66764, 66765, 66766, 66767, 66768, 66769, 66770, 66771, 66772, 66773, 66774, 66775, 66776, 66777, 66778, 66779, 66780, 66781, 66782, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 138Line truncated
|
||||
"idx_filter len=24171/ total len=129700, percents = 18.636083269082498 %\n",
|
||||
"remain idx len=105529/ total len=129700, percents = 81.3639167309175 %\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 45,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([0.00266631, 0.00262837, 0.00337514, ..., 0.00482252, 0.00508082,\n",
|
||||
" 0.00521696], dtype=float32)"
|
||||
]
|
||||
},
|
||||
"execution_count": 45,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"data[:, 0] "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAABrsAAAJDCAYAAAC7e690AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9eZxkdX0v/r/OVnvvPfswGzAzzDADg4AgCgoKuERNrskXReM1m8bkBuMvXuB6RU2i96rJTeKa5BpXTMRwk6teiSIKIii7wDAw+75Pr7WeqrP9/jhLV3dXdZ2qOtVVder1fDx8OFNd3X26qOlzzuf9eb/egmVZICIiIiIiIiIiIiIiIupGYrsPgIiIiIiIiIiIiIiIiKhRLHYRERERERERERERERFR12Kxi4iIiIiIiIiIiIiIiLoWi11ERERERERERERERETUtVjsIiIiIiIiIiIiIiIioq7FYhcRERERERERERERERF1LV/FLkEQbhYEYY8gCPsFQbijwsejgiDc43z8cUEQ1jmPjwiC8KAgCFlBED4/53NeJgjCTudzPisIghDIT0REREREREREREREREQ9o2axSxAECcAXALwewBYAbxcEYcucp/0ugEnLsi4A8DcAPuU8rgL4CIA/q/ClvwTgDwBc6Pzv5kZ+ACIiIiIiIiIiIiIiIupdfjq7rgSw37Ksg5ZllQB8G8Bb5jznLQC+7vz5XgA3CIIgWJaVsyzrEdhFL48gCCsA9FuW9UvLsiwA3wDw1iZ+DiIiIiIiIiIiIiIiIupBfopdqwAcK/v7ceexis+xLEsHMA1gpMbXPF7jaxIREREREREREREREREtSPbxnEqztKwGntPQ8wVB+APYcYdIJpMv27x58wJfloiIiIiIiNrh0FgO2aIORRKxeXlfuw+HQmYsW8SpaTs0ZuOyPkRlXyPIiYiIiChknn766THLspbMfdxPses4gPPK/r4awMkqzzkuCIIMYADARI2vubrG1wQAWJb1jwD+EQAuv/xy66mnnvJxyERERERERLSY3vKFR/HcsSmMpqJ46r+/tt2HQyHzmR/txhcePAAA+NcPvAqbl/e3+YiIiIiIqB0EQThS6XE/W6GeBHChIAjrBUGIALgFwPfmPOd7AN7t/PltAH7qzOKqyLKsUwAygiBcJQiCAOC3AXzXx7EQERERERFRB8oUNABAUTPafCQURmOZkvdn3VgoSIaIiIiIelHNzi7LsnRBEP4YwI8ASAC+YlnWLkEQ/hzAU5ZlfQ/APwH4piAI+2F3dN3ifr4gCIcB9AOICILwVgA3Wpb1IoA/BPA1AHEA/+H8j4iIiIiIiLpQWnWKXbrZ5iOhMBrPFb0/6yaLXUREREQ0m58YQ1iWdR+A++Y8dlfZn1UAv1nlc9dVefwpABf7PVAiIiIiIiLqTJZlIV3QAQAlw4RhWpDESqOaiRpzLluCJAowTAu6wYIqEREREc3mq9hFREREREREVE1RN1EyTAzEFUwXNJR0E/GI1O7DohAZyxSxJBXF6bTKzi4iIiLqeJqm4fjx41BVtd2H0rVisRhWr14NRVF8PZ/FLiIiIiIiImpK2pnXtaQviumCBlUzWOyiwFiWhfFcEZuW99vFLs7sIiIiog53/Phx9PX1Yd26dRAEJh7Uy7IsjI+P4/jx41i/fr2vzxFbfExEREREREQUcu68riWpKADO7aJg5UoGVM3E8n77/aWbfH8RERFRZ1NVFSMjIyx0NUgQBIyMjNTVGcdiFxERERERETVl2pnXtbTfLXYZ7TwcCpmxTBEAsGIgDgAwGGNIREREXYCFrubU+/qx2EVERERERERNmdvZpWrsvKHgjGXtYtey/hgAQGOMIRERERHNwWIXERERERERNcWd2cXOLmqFsWwJALB8wH5/sbOLiIiIaPF97GMfw1/91V+1+zCqYrGLiIiIiIiImpJW7RjDJX3s7KLgze3s4swuIiIiovpYlgUz5NdQLHYRERERERFRU7zOrj67GMHOLgqSW+xy3186YwyJiIiIajp8+DAuuugivP/978dll12Gv/iLv8AVV1yB7du346Mf/aj3vG984xvYvn07LrnkErzrXe/y9bWfffZZXHXVVdi+fTt+/dd/HZOTkwCAz372s9iyZQu2b9+OW265BQDws5/9DJdeeikuvfRS7NixA5lMJvgfFoDckq9KREREREREPSOtaojIIvpjCgB2dlGwxrMlDCUUxBR7vy47u4iIiKibfPz7u/DiyXSgX3PLyn589Ne21nzenj178NWvfhVvfetbce+99+KJJ56AZVl485vfjIcffhgjIyP4xCc+gUcffRSjo6OYmJjw9f1/+7d/G5/73Odw3XXX4a677sLHP/5x/O3f/i3+5//8nzh06BCi0SimpqYAAH/1V3+FL3zhC7jmmmuQzWYRi8Wa+dGrYmcXERERERERNSVd0NEfmylGsLOLgjSWLWIkFYUiucUudnYRERER+bF27VpcddVVuP/++3H//fdjx44duOyyy7B7927s27cPP/3pT/G2t70No6OjAIDh4eGaX3N6ehpTU1O47rrrAADvfve78fDDDwMAtm/fjltvvRV33303ZNnutbrmmmvwwQ9+EJ/97GcxNTXlPR40dnYRERERERFRU9Kqhv64jKgsAWBnFwVrLFvEaCoCSRQAAAaLXURERNRF/HRgtUoymQRgz+y688478d73vnfWxz/72c9CEITAvt8PfvADPPzww/je976Hv/iLv8CuXbtwxx134I1vfCPuu+8+XHXVVXjggQewefPmwL6ni51dRERERERE1JR0QUN/TEGUnV3UAmPZEkZTUSii/f7SOLOLiIiIqC433XQTvvKVryCbzQIATpw4gbNnz+KGG27Ad77zHYyPjwOArxjDgYEBDA0N4ec//zkA4Jvf/Cauu+46mKaJY8eO4TWveQ0+/elPY2pqCtlsFgcOHMC2bdtw++234/LLL8fu3btb8jOys4uIiIiIiIiaklZ1DMQVxJzOriI7uyhAdmdXFJLkdnbx/UVERERUjxtvvBEvvfQSrr76agBAKpXC3Xffja1bt+LDH/4wrrvuOkiShB07duBrX/taza/39a9/He973/uQz+exYcMGfPWrX4VhGHjnO9+J6elpWJaFP/3TP8Xg4CA+8pGP4MEHH4QkSdiyZQte//rXt+RnZLGLiIiIiIiImpIpaDhvKO51dqns7KKAqJqBjKpjNBWB7MQYsrOLiIiIqLZ169bhhRde8P5+22234bbbbpv3vHe/+91497vfXfPrfexjH/P+fOmll+Kxxx6b95xHHnlk3mOf+9znfB5xcxhjSERERERERE2xZ3YpiMpOjCE7uygg47kSAGA0FfWKXZzZRURERERzsbOLiIiIiIiIGmZZFtIFHf0xBYIgICKL7OyiwIxniwDsYpfkFLt0g8VUIiIiolb5xCc+gX/913+d9dhv/uZv4sMf/nCbjsgfFruIiIiIiIioYUXdRMkw0R+3by9jssjOLgrMmFvs6otCEATIogCdnV1ERERELfPhD3+44wtblTDGkIiIiIiIiBqWLmgAgP6YAgCIKhKK7OyigIxl7BjDkWQEACCJAmMMiYiIiGgeFruIiIiIiIioYWlVBwD0x+1iV0xhZxcFZyxnd3Yt6YsCABRJhGaw2EVEREREs7HYRURERERERA1Lq25nlx1jGJUlzuyiwIxnS0hGJMQUCYDb2cViKhERERHNxmIXERERERERNcyLMXQ6u6Kc2UUBmsprGExEvL8rkgCNMYZERERENAeLXURERERERNQwL8Yw5sYYSijqLHZRMNKq5hVSAaezizGGRERERIFKpVJVP3b48GFcfPHFgX2vz3/+87jgggsgCALGxsYC+7osdhEREREREVHDZjq73BhDEarGGEMKRrqgeRGZACCLIjTGGBIRERF1rWuuuQYPPPAA1q5dG+jXZbGLiIiIiIiIGjYzs4udXRS86cLszi5ZEmAwxpCIiIhoQbfffju++MUven//2Mc+hr/+67/GZz7zGVxxxRXYvn07PvrRj9b9dVVVxXve8x5s27YNO3bswIMPPggA2LVrF6688kpceuml2L59O/bt24dcLoc3vvGNuOSSS3DxxRfjnnvuAQDs2LED69atC+TnLCfXfgoRERERERFRZemCjogsIqZIANjZRcHKqDoG5sQY6owxJCIiom7yH3cAp3cG+zWXbwNe/z+rfviWW27BBz7wAbz//e8HAHznO9/BHXfcgUceeQRPPPEELMvCm9/8Zjz88MO49tprfX/bL3zhCwCAnTt3Yvfu3bjxxhuxd+9e/P3f/z1uu+023HrrrSiVSjAMA/fddx9WrlyJH/zgBwCA6enpJn7g2tjZRURERERERA1Lq5rX1QWws4uCZccYzry/FFGEzhhDIiIiogXt2LEDZ8+excmTJ/Hcc89haGgIzz//PO6//37s2LEDl112GXbv3o19+/bV9XUfeeQRvOtd7wIAbN68GWvXrsXevXtx9dVX45Of/CQ+9alP4ciRI4jH49i2bRseeOAB3H777fj5z3+OgYGBVvyoHnZ2ERERERERUcPSBc2b1wWws4uCY5gWMkV91vtLEhljSERERF1mgQ6sVnrb296Ge++9F6dPn8Ytt9yCw4cP484778R73/vehr+mZVW+DnvHO96Bl7/85fjBD36Am266CV/+8pdx/fXX4+mnn8Z9992HO++8EzfeeCPuuuuuhr93LezsIiIiIiIiooalVZ2dXdQSmTnz4ABAkQRojDEkIiIiqumWW27Bt7/9bdx7771429vehptuuglf+cpXkM1mAQAnTpzA2bNn6/qa1157Lb71rW8BAPbu3YujR49i06ZNOHjwIDZs2IA/+ZM/wZvf/GY8//zzOHnyJBKJBN75znfiz/7sz/DMM88E/jOWY2cXERERERERNczu7JopRkRlEUWdnV3UvHRBB4B5M7vLine truncated
|
||||
"text/plain": [
|
||||
"<Figure size 2160x720 with 1 Axes>"
|
||||
]
|
||||
},
|
||||
"metadata": {
|
||||
"needs_background": "light"
|
||||
},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Importing packages\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"%matplotlib inline\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"beg = 32000\n",
|
||||
"nsteps = 10 * 50 # nseconds * fps, 3000\n",
|
||||
"data_loss = data[beg:beg+nsteps]\n",
|
||||
"\n",
|
||||
"# Define x and y values\n",
|
||||
"x = range(data_loss.shape[0])\n",
|
||||
"\n",
|
||||
"# Plot a simple line chart without any feature\n",
|
||||
"plt.figure(figsize=(30,10))\n",
|
||||
"plt.plot(x, data_loss[:,0], )\n",
|
||||
"plt.plot(x, data_loss[:,1])\n",
|
||||
"plt.plot(x, data_loss[:,2])\n",
|
||||
"plt.ylim(0, 0.01)\n",
|
||||
"plt.legend([\"rec_loss\", \"vel_loss1\", \"vel_loss2\"])\n",
|
||||
"# plt.plot(x, data_loss[:,2])\n",
|
||||
"plt.show()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"interpreter": {
|
||||
"hash": "7631c3454b293d59f44fb25da873c3d73daf8a0a859dfd3174f920d540a4d0d0"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.8 ('base')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.8"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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 = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220223-19H47M15S/audio_trim_60_120s_infer_20220217-18H29M20S_epoch_160_00.mp4"
|
||||
path_clipB = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220302-10H48M39S/audio_trim_60_120s_infer_20220228-18H41M46S_epoch_175_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_CN_20220208/20220223-20H51M40S/audio_trim_60_120s_infer_20220222-10H37M51S_epoch_235_00.mp4"
|
||||
path_clipBB = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220302-10H38M39S/audio_trim_60_120s_infer_20220225-19H08M53S_epoch_280_00.mp4"
|
||||
path_clipCC = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/video/deca_render_no_pos_60_120s.mp4"
|
||||
|
||||
# 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_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 = mpy.clips_array([[clip_A, clip_B, clip_C]]) # clip_C
|
||||
video = video.set_audio(audio) # audd audio
|
||||
|
||||
# save
|
||||
path_save = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/video/predict_compare_20220302.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}")
|
||||
|
||||
|
||||
|
||||
@@ -16,15 +16,18 @@ if __name__ == "__main__":
|
||||
# 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_clipA = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220223-19H47M15S/audio_trim_60_120s_infer_20220217-18H29M20S_epoch_160_00.mp4"
|
||||
path_clipB = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220302-10H48M39S/audio_trim_60_120s_infer_20220228-18H41M46S_epoch_175_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_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_clipAA = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220223-20H51M40S/audio_trim_60_120s_infer_20220222-10H37M51S_epoch_235_00.mp4"
|
||||
path_clipBB = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220302-10H38M39S/audio_trim_60_120s_infer_20220225-19H08M53S_epoch_280_00.mp4"
|
||||
path_clipCC = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/video/deca_render_no_pos_60_120s.mp4"
|
||||
|
||||
# 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_audio = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_60_120s.wav"
|
||||
|
||||
@@ -56,11 +59,12 @@ if __name__ == "__main__":
|
||||
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 = mpy.clips_array([[clip_A, clip_B, clip_C], [clip_AA, clip_BB, clip_CC]]) # clip_C
|
||||
video = mpy.clips_array([[clip_A, clip_B, clip_C]]) # 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 = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/video/predict_compare_20220302—1.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}")
|
||||
|
||||
+4
-4
@@ -207,10 +207,10 @@ config.LOSS.lambda_rec_pos = 0
|
||||
config.LOSS.lambda_rec_geo = 0
|
||||
config.LOSS.lambda_rec_syn = 0
|
||||
|
||||
config.LOSS.lambda_vol_exp = 0
|
||||
config.LOSS.lambda_vol_pos = 0
|
||||
config.LOSS.lambda_vol_geo = 0
|
||||
config.LOSS.lambda_vol_syn = 0
|
||||
config.LOSS.lambda_vel_exp = 0
|
||||
config.LOSS.lambda_vel_pos = 0
|
||||
config.LOSS.lambda_vel_geo = 0
|
||||
config.LOSS.lambda_vel_syn = 0
|
||||
|
||||
# for Flow
|
||||
config.LOSS.lambda_logp = 0
|
||||
|
||||
@@ -52,8 +52,10 @@ class Audio2MeshModel(Base):
|
||||
debug(opt, f"template_verts shape = {self.template_verts.shape}")
|
||||
debug(opt, f"mean_dict keys = {self.mean_dict.keys()}", verbose=True)
|
||||
|
||||
self.loss_func_l1 = nn.L1Loss(reduction="mean")
|
||||
self.loss_func_wing = WingLoss(reduction="mean")
|
||||
# if filter outlier
|
||||
# if self.opt.LOSS.filter_outlier:
|
||||
self.loss_func_wing = WingLoss(reduction="none") # return (B, )
|
||||
self.loss_func_l1 = nn.L1Loss(reduction="none")
|
||||
|
||||
if self.isTrain:
|
||||
self.names_loss = opt.LOSS.names
|
||||
@@ -78,8 +80,6 @@ class Audio2MeshModel(Base):
|
||||
self.extractor = Wav2Vec2Model.from_pretrained(MODEL_ID).to(self.device)
|
||||
|
||||
|
||||
|
||||
|
||||
def set_input(self, batch_input):
|
||||
|
||||
# motion data
|
||||
@@ -174,6 +174,28 @@ class Audio2MeshModel(Base):
|
||||
return loss
|
||||
|
||||
|
||||
def infer_loss(self, batch_cond, batch_data):
|
||||
"""
|
||||
input parameters:
|
||||
batch_cond: B x nsteps x 16 x nfeat_speech
|
||||
batch_data: B x nsteps x nfeat_motion
|
||||
return:
|
||||
loss: B x nsteps x 3
|
||||
"""
|
||||
self.eval()
|
||||
cond = batch_cond.float().to(self.device) # (B x nsteps x 16 x nc_condit)
|
||||
data = batch_data.float().to(self.device) # (B x nsteps x nc_motion)
|
||||
|
||||
with torch.no_grad():
|
||||
samples_pt = self.netG(cond) # B x N x 16 x nc_condit
|
||||
samples_pt += self.template_verts # B x N x 5023 x 3
|
||||
|
||||
loss = self.eval_losses_for_infer_loss(samples_pt, data)
|
||||
|
||||
return loss
|
||||
|
||||
|
||||
|
||||
def infer(self, batch_cond, path_audio, suffix=""):
|
||||
self.eval()
|
||||
self.cond = batch_cond.float().to(self.device) # (nsteps, dim_cond)
|
||||
@@ -252,6 +274,39 @@ class Audio2MeshModel(Base):
|
||||
return verts
|
||||
|
||||
|
||||
def eval_losses_for_infer_loss(self, batch_pdt_geo, batch_tgt):
|
||||
""" Computes the VAE loss function.
|
||||
pramas:
|
||||
batch_tgt, (nbatch, seqlen, dim_motion)
|
||||
batch_pdt_geo, (nbatch, seqlen, num_vertices, 3)
|
||||
"""
|
||||
|
||||
# get mesh geometry
|
||||
batch_tgt_geo = self.get_vertices(batch_tgt) # B x nseq x num_vertices x 3
|
||||
|
||||
# synthesis geo rec
|
||||
loss_rec_geo = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo) # B x nsteps x num_vertices x 3
|
||||
loss_rec_geo = loss_rec_geo.sum(dim=(2, 3)) / (3 * self.opt.MODEL.num_vertices) # B x nsteps
|
||||
loss_rec_geo = loss_rec_geo.detach()
|
||||
|
||||
# synthesis geo volocity
|
||||
diff_pdt_geo = batch_pdt_geo[:, 1:, :] - batch_pdt_geo[:, :-1, :]
|
||||
diff_tgt_geo = batch_tgt_geo[:, 1:, :] - batch_tgt_geo[:, :-1, :]
|
||||
loss_vel_geo1 = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo) # B x nsteps-1
|
||||
loss_vel_geo1 = loss_vel_geo1.sum(dim=(2, 3)) / (3 * self.opt.MODEL.num_vertices) # B x nsteps-1
|
||||
loss_vel_geo1 = F.pad(loss_vel_geo1, pad=(0, 1), mode="replicate").detach() # B x nsteps
|
||||
|
||||
diff_pdt_geo = batch_pdt_geo[:, 2:, :] - batch_pdt_geo[:, :-2, :]
|
||||
diff_tgt_geo = batch_tgt_geo[:, 2:, :] - batch_tgt_geo[:, :-2, :]
|
||||
loss_vel_geo2 = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo) # B x nsteps-2
|
||||
loss_vel_geo2 = loss_vel_geo2.sum(dim=(2, 3)) / (3 * self.opt.MODEL.num_vertices) # B x nsteps-2
|
||||
loss_vel_geo2 = F.pad(loss_vel_geo2, pad=(0, 2), mode="replicate").detach() # B x nsteps
|
||||
|
||||
# stack among these losses
|
||||
loss_stack = torch.stack([loss_rec_geo, loss_vel_geo1, loss_vel_geo2], dim=2) # B x nsteps x 3
|
||||
|
||||
return loss_stack
|
||||
|
||||
def eval_losses(self, batch_pdt_geo, batch_tgt):
|
||||
""" Computes the VAE loss function.
|
||||
pramas:
|
||||
@@ -261,6 +316,78 @@ class Audio2MeshModel(Base):
|
||||
loss = 0
|
||||
loss_dict = {}
|
||||
|
||||
# get mesh geometry
|
||||
batch_tgt_geo = self.get_vertices(batch_tgt) # B x nseq x num_vertices x 3
|
||||
# B = batch_pdt_geo.size(0)
|
||||
# print(f"batch_pdt_geo = {batch_pdt_geo.shape}, batch_tgt_geo = {batch_tgt_geo.shape}, B = {B}")
|
||||
|
||||
# synthesis geo rec
|
||||
loss = 0
|
||||
loss_rec_geo = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo) # B
|
||||
loss_dict["loss_rec_geo"] = loss_rec_geo.mean().detach()
|
||||
loss_rec_geo = self.loss_func_l1(batch_pdt_geo, batch_tgt_geo) # B
|
||||
loss_dict["loss_rec_geo_l1"] = loss_rec_geo.mean().detach()
|
||||
|
||||
|
||||
loss_rec_geo2 = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo, weight=self.vertices_weight) # B x nsteps x num_vertices x 3
|
||||
loss_rec_geo2 = loss_rec_geo2.sum(dim=(2, 3)) / (3 * self.opt.MODEL.num_vertices) # B x nsteps
|
||||
|
||||
# filter outliar
|
||||
threshold_rec, mean_rec = torch.quantile(loss_rec_geo2, q=0.75) * 1.5, torch.quantile(loss_rec_geo2, q=0.5)
|
||||
b_outlier_rec = loss_rec_geo2 > threshold_rec # B x nsteps
|
||||
# print(f"threshold_rec = {threshold_rec.shape}")
|
||||
|
||||
# synthesis geo volocity
|
||||
diff_pdt_geo = batch_pdt_geo[:, 1:, :] - batch_pdt_geo[:, :-1, :]
|
||||
diff_tgt_geo = batch_tgt_geo[:, 1:, :] - batch_tgt_geo[:, :-1, :]
|
||||
|
||||
loss_vel_geo = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo) # 1,
|
||||
loss_dict["loss_vel_geo"] = loss_vel_geo.mean().detach()
|
||||
loss_vel_geo = self.loss_func_l1(diff_pdt_geo, diff_tgt_geo) # 1,
|
||||
loss_dict["loss_vel_geo_l1"] = loss_vel_geo.mean().detach()
|
||||
|
||||
loss_vel_geo2 = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo, weight=self.vertices_weight) # B x nsteps x num_vertices x 3
|
||||
loss_vel_geo2 = loss_vel_geo2.sum(dim=(2, 3)) / (3 * self.opt.MODEL.num_vertices) # B x nsteps
|
||||
|
||||
# filter outliar
|
||||
threshold_vel, mean_vel = torch.quantile(loss_vel_geo2, q=0.75) * 1.5, torch.quantile(loss_vel_geo2, q=0.5)
|
||||
b_outlier_vel = loss_vel_geo2 > threshold_vel # B x (nsteps-1)
|
||||
# print(f"threshold_vel = {threshold_vel.shape}")
|
||||
|
||||
|
||||
# find outliar in both loss data
|
||||
b_outlier_rec[:, :-1] = b_outlier_rec[:, :-1] & b_outlier_vel[:, :]
|
||||
if torch.any(b_outlier_rec):
|
||||
# print(f"b_outlier_rec = {b_outlier_rec}")
|
||||
# print(f"outerliar size= {loss_rec_geo2[b_outlier_rec].shape} / {loss_rec_geo2.numel()} ")
|
||||
loss_rec_geo2[b_outlier_rec] = mean_rec
|
||||
loss_vel_geo2[b_outlier_rec[:, :-1]] = mean_vel
|
||||
|
||||
|
||||
# calculate again
|
||||
loss_rec_geo2 = loss_rec_geo2.mean()
|
||||
loss_dict["loss_rec_geo_w"] = loss_rec_geo2.detach()
|
||||
loss += loss_rec_geo2 * self.opt.LOSS.lambda_rec_geo
|
||||
|
||||
loss_vel_geo2 = loss_vel_geo2.mean()
|
||||
loss_dict["loss_vel_geo_w"] = loss_vel_geo2.detach()
|
||||
loss += loss_vel_geo2 * self.opt.LOSS.lambda_vel_geo
|
||||
|
||||
# total loss
|
||||
loss_dict['loss_all'] = loss.detach()
|
||||
|
||||
return loss, loss_dict
|
||||
|
||||
|
||||
def eval_losses_old(self, batch_pdt_geo, batch_tgt):
|
||||
""" Computes the VAE loss function.
|
||||
pramas:
|
||||
batch_tgt, (nbatch, seqlen, dim_motion)
|
||||
batch_pdt_geo, (nbatch, seqlen, num_vertices, 3)
|
||||
"""
|
||||
loss = 0
|
||||
loss_dict = {}
|
||||
|
||||
# get mesh geometry
|
||||
batch_tgt_geo = self.get_vertices(batch_tgt) # B x nseq x num_vertices x 3
|
||||
|
||||
@@ -277,12 +404,12 @@ class Audio2MeshModel(Base):
|
||||
diff_pdt_geo = batch_pdt_geo[:, 1:, :] - batch_pdt_geo[:, :-1, :]
|
||||
diff_tgt_geo = batch_tgt_geo[:, 1:, :] - batch_tgt_geo[:, :-1, :]
|
||||
|
||||
loss_vol_geo = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo)
|
||||
loss_dict["loss_vol_geo"] = loss_vol_geo.detach()
|
||||
loss_vel_geo = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo)
|
||||
loss_dict["loss_vel_geo"] = loss_vel_geo.detach()
|
||||
|
||||
loss_vol_geo2 = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo, weight=self.vertices_weight)
|
||||
loss_dict["loss_vol_geo_w"] = loss_vol_geo2.detach()
|
||||
loss += loss_vol_geo2 * self.opt.LOSS.lambda_vol_geo
|
||||
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.detach()
|
||||
loss += loss_vel_geo2 * self.opt.LOSS.lambda_vel_geo
|
||||
|
||||
# total loss
|
||||
loss_dict['loss_all'] = loss.detach()
|
||||
|
||||
@@ -1,472 +0,0 @@
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
from pathlib import Path
|
||||
|
||||
from src.models import init_net
|
||||
from src.models.base import Base
|
||||
from src.optims import get_optimizer, get_scheduler
|
||||
|
||||
# common
|
||||
from common.animation import save_animation_with_gt2, save_images_with_audio
|
||||
from common.debug import debug
|
||||
from common.losses import WingLoss
|
||||
|
||||
# disentangle model
|
||||
class Audio2MeshModel(Base):
|
||||
|
||||
def __init__(self, opt, logger):
|
||||
Base.__init__(self, opt, logger)
|
||||
|
||||
self.opt = opt
|
||||
self.logger = logger
|
||||
self.names_model = ["G"] # G
|
||||
|
||||
|
||||
# define networks
|
||||
self.netG = define_netG(opt)
|
||||
self.netG.to()
|
||||
self.netG = torch.nn.DataParallel(self.netG, opt.GPUS) # multi-GPUs
|
||||
init_net(self.netG, init_type='kaiming', gpu_ids=opt.GPUS)
|
||||
|
||||
self.loss_func_l1 = nn.L1Loss(reduction="mean")
|
||||
self.loss_func_wing = WingLoss(reduction="mean")
|
||||
|
||||
if self.isTrain:
|
||||
self.names_loss = opt.LOSS.names
|
||||
|
||||
# define optimizers
|
||||
self.optimizer_G = get_optimizer(self.netG, opt)
|
||||
self.optimizers.append(self.optimizer_G)
|
||||
|
||||
self.scheduler_G = get_scheduler(self.optimizer_G, opt)
|
||||
self.schedulers.append(self.scheduler_G)
|
||||
|
||||
if self.opt.TRAIN.apply_testing or not self.isTrain:
|
||||
# load mean lighting & shape
|
||||
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")
|
||||
self.mean_dict = np.load(path_deca_mean, allow_pickle=True).item()
|
||||
print(self.mean_dict.keys())
|
||||
|
||||
if self.opt.DATASET.speech_extractor == "wav2vec":
|
||||
from transformers import Wav2Vec2FeatureExtractor, Wav2Vec2Model
|
||||
print("load Wav2Vec2Model ...")
|
||||
MODEL_ID = "jonatasgrosman/wav2vec2-large-xlsr-53-chinese-zh-cn"
|
||||
self.processor = Wav2Vec2FeatureExtractor.from_pretrained(MODEL_ID)
|
||||
self.extractor = Wav2Vec2Model.from_pretrained(MODEL_ID).to(self.device)
|
||||
|
||||
|
||||
|
||||
def set_input(self, batch_input):
|
||||
|
||||
# motion data
|
||||
self.data = batch_input["data"].float().to(self.device) # (B, nsteps, nc_motion)
|
||||
|
||||
self.batch_vid = batch_input['vid']
|
||||
self.batch_nframe = batch_input['nframe']
|
||||
self.batch_interv = batch_input['frame_interval']
|
||||
|
||||
debug(self.opt, f"data = {self.data.shape}, dtype={self.data.dtype}", verbose=False)
|
||||
debug(self.opt, f"batch_vid = {self.batch_vid[:2]}", verbose=False)
|
||||
debug(self.opt, f"batch_nframe = {self.batch_nframe[:2]}", verbose=False)
|
||||
debug(self.opt, f"batch_interv len={len(self.batch_interv)} len([0])={len(self.batch_interv[0])}, \
|
||||
beg={self.batch_interv[0][:4]}, end={self.batch_interv[1][:4]}", verbose=False)
|
||||
|
||||
self.B, self.nsteps = self.data.size(0), self.data.size(1)
|
||||
|
||||
# speech data
|
||||
raw_speech = batch_input["cond"].numpy() # (B, nsegments)
|
||||
debug(self.opt, f"raw_speech = {raw_speech.shape}, dtype={raw_speech.dtype}", verbose=False)
|
||||
|
||||
if self.opt.DATASET.speech_extractor == "wav2vec":
|
||||
# raw_speech = raw_speech.reshape(self.B * self.nsteps, -1) # (B*nsteps, nsegments)
|
||||
# debug(self.opt, f"raw_speech = {raw_speech.shape}, dtype={raw_speech.dtype}", verbose=False)
|
||||
|
||||
# padding half frame length for bed and end
|
||||
npad = int(0.5 * self.opt.DATASET.sr * ( 1 / self.opt.DATASET.fps) + 0.5)
|
||||
raw_speech = np.pad(raw_speech, pad_width=((0,0), (npad, npad)), mode="edge")
|
||||
debug(self.opt, f"after padding raw_speech = {raw_speech.shape}, dtype={raw_speech.dtype}", verbose=False)
|
||||
|
||||
raw_speech = list(raw_speech)
|
||||
inputs = self.processor(raw_speech, sampling_rate=16000, return_tensors="pt")
|
||||
inputs = inputs.to(self.device)
|
||||
|
||||
with torch.no_grad():
|
||||
output = self.extractor(**inputs)
|
||||
self.cond = output.last_hidden_state
|
||||
# self.cond = output.extract_features
|
||||
|
||||
# B x nsteps x nc_feat
|
||||
debug(self.opt, f"data = {self.data.shape}, dtype={self.data.dtype}, device={self.data.device}", verbose=False)
|
||||
debug(self.opt, f"cond = {self.cond.shape}, dtype={self.cond.dtype}, device={self.cond.device}", verbose=False)
|
||||
|
||||
# unfold
|
||||
# self.data = self.data.unfold(dimension=1, size=16, step=1) # (B, nseqs, nc_motion, 16)
|
||||
# self.data = self.data.permute(0, 1, 3, 2) # (B, nseqs, 16, 53)
|
||||
|
||||
self.cond = self.cond.unfold(dimension=1, size=16, step=1) # (nseqs, nc_motion, 16)
|
||||
self.cond = self.cond.permute(0, 1, 3, 2) # (nseqs, 16, 53)
|
||||
|
||||
self.nseq = self.cond.size(1)
|
||||
self.data = self.data[:, 7:7+self.nseq, :]
|
||||
|
||||
debug(self.opt, f"\n a data = {self.data.shape}, dtype={self.data.dtype}, device={self.data.device}", verbose=False)
|
||||
debug(self.opt, f"a cond = {self.cond.shape}, dtype={self.cond.dtype}, device={self.cond.device}", verbose=False)
|
||||
|
||||
def training(self, batch_input):
|
||||
self.train() # set train model
|
||||
self.set_input(batch_input)
|
||||
|
||||
# forward
|
||||
self.pred_coef, self.pred_vert = self.netG(self.cond)
|
||||
|
||||
# loss
|
||||
loss, self.loss_dict = self.eval_losses(self.pred_coef, self.pred_vert, self.data)
|
||||
|
||||
# backward
|
||||
self.optimizer_G.zero_grad()
|
||||
loss.backward()
|
||||
|
||||
if self.opt.TRAIN.grad_clip_norm: # operate grad
|
||||
torch.nn.utils.clip_grad_value_(self.netG.parameters(), self.opt.TRAIN.max_grad_clip)
|
||||
torch.nn.utils.clip_grad_norm_(self.netG.parameters(), self.opt.TRAIN.max_grad_norm)
|
||||
|
||||
self.optimizer_G.step()
|
||||
|
||||
return loss
|
||||
|
||||
|
||||
def validation(self, batch_input):
|
||||
self.eval() # set eval model
|
||||
self.set_input(batch_input)
|
||||
|
||||
with torch.no_grad():
|
||||
self.pred_coef = self.netG(self.cond)
|
||||
loss, self.loss_dict = self.eval_losses(self.pred_coef, self.data)
|
||||
|
||||
return loss
|
||||
|
||||
|
||||
def infer(self, batch_cond, path_audio, suffix=""):
|
||||
self.eval()
|
||||
self.cond = batch_cond.float().to(self.device) # (nsteps, dim_cond)
|
||||
|
||||
with torch.no_grad():
|
||||
samples_pt = self.netG(self.cond).cpu().numpy() # B x N x dim_motion
|
||||
print(f"testing pt shape = {samples_pt.shape}")
|
||||
|
||||
self.save_reconstruct(samples_pt, path_audio,
|
||||
path_save=Path(self.opt.OUTPUT_DIR),
|
||||
suffix=suffix)
|
||||
|
||||
|
||||
def testing(self, batch_input, cur_epoch=0, cur_batch=0):
|
||||
self.eval() # set eval model
|
||||
self.set_input(batch_input)
|
||||
|
||||
with torch.no_grad():
|
||||
samples_pt = self.netG(self.cond).cpu().numpy() # B x N x dim_motion
|
||||
samples_gt = self.data.cpu().numpy() # B x N x dim_motion
|
||||
|
||||
print(f"testing pt shape = {samples_pt.shape}, gt shape = {samples_gt.shape}")
|
||||
|
||||
self.save_reconstruct_with_gt(samples_pt, samples_gt,
|
||||
path_save=Path(self.opt.OUTPUT_DIR),
|
||||
suffix=f'sampled_{cur_epoch:05d}_{cur_batch:03d}')
|
||||
|
||||
|
||||
def get_vertices(self, batch_exp, batch_pos):
|
||||
"""
|
||||
batch_exp, (nbatch, seqlen, 50)
|
||||
batch_pos, (nbatch, seqlen, 3)
|
||||
"""
|
||||
nbatch, seqlen = batch_exp.size(0), batch_exp.size(1)
|
||||
batch_exp = batch_exp.reshape(nbatch * seqlen, -1) # nbatch * seqlen x 50
|
||||
batch_pos = batch_pos.reshape(nbatch * seqlen, -1) # nbatch * seqlen x 3
|
||||
|
||||
batch_shape = np.repeat([self.mean_dict["shape"]], nbatch * seqlen, axis=0) # (nbatch * seqlen, 100)
|
||||
batch_shape= torch.from_numpy(batch_shape).to(self.device)
|
||||
|
||||
batch_pose = np.repeat([self.mean_dict["pose"]], nbatch * seqlen, axis=0) # (nbatch * seqlen, 6)
|
||||
batch_pose = torch.from_numpy(batch_pose).to(self.device)
|
||||
batch_pose[:, 3:6] = batch_pos
|
||||
|
||||
|
||||
verts, _, _ = self.netR.get_vertices(batch_shape, batch_exp, batch_pose) # nbatch * seqlen x 5023 x 3
|
||||
verts = verts.reshape(nbatch, seqlen, -1, 3) # nbatch x seqlen x 5023 x 3
|
||||
# print(f"verts reshape = {verts.shape}")
|
||||
|
||||
return verts
|
||||
|
||||
def eval_losses(self, batch_pdt_coef, batch_pdt_geo, batch_tgt):
|
||||
""" Computes the VAE loss function.
|
||||
pramas:
|
||||
batch_tgt, (nbatch, seqlen, dim_motion)
|
||||
batch_pdt_coef, (nbatch, seqlen, dim_motion)
|
||||
batch_pdt_geo, (nbatch, seqlen, num_vertices, 3)
|
||||
"""
|
||||
loss = 0
|
||||
loss_dict = {}
|
||||
|
||||
batch_pdt_exp = batch_pdt_coef[..., :50]
|
||||
batch_pdt_pos = batch_pdt_coef[..., 50:]
|
||||
|
||||
batch_tgt_exp = batch_tgt[..., :50]
|
||||
batch_tgt_pos = batch_tgt[..., 50:]
|
||||
|
||||
|
||||
# get mesh geometry
|
||||
batch_syn_geo = self.get_vertices(batch_pdt_exp, batch_pdt_pos) # B x nseq x num_vertices x 3
|
||||
batch_tgt_geo = self.get_vertices(batch_tgt_exp, batch_tgt_pos) # B x nseq x num_vertices x 3
|
||||
|
||||
|
||||
# rec loss
|
||||
loss = 0
|
||||
loss_rec_exp = self.loss_func_wing(batch_pdt_exp, batch_tgt_exp) / 50
|
||||
loss_dict["loss_rec_exp"] = loss_rec_exp.detach()
|
||||
|
||||
loss_rec_pos = self.loss_func_wing(batch_pdt_pos, batch_tgt_pos) / 3
|
||||
loss_dict["loss_rec_pos"] = loss_rec_pos.detach()
|
||||
|
||||
loss += loss_rec_exp * self.opt.LOSS.lambda_rec_exp
|
||||
loss += loss_rec_pos * self.opt.LOSS.lambda_rec_pos
|
||||
|
||||
|
||||
# rec smooth
|
||||
diff_pdt_exp = batch_pdt_exp[:, 1:, :] - batch_pdt_exp[:, :-1, :]
|
||||
diff_tgt_exp = batch_tgt_exp[:, 1:, :] - batch_tgt_exp[:, :-1, :]
|
||||
loss_vol_exp = self.loss_func_wing(diff_pdt_exp, diff_tgt_exp) / 50
|
||||
loss_dict["loss_vol_exp"] = loss_vol_exp.detach()
|
||||
|
||||
diff_pdt_pos = batch_pdt_pos[:, 1:, :] - batch_pdt_pos[:, :-1, :]
|
||||
diff_tgt_pos = batch_tgt_pos[:, 1:, :] - batch_tgt_pos[:, :-1, :]
|
||||
loss_vol_pos = self.loss_func_wing(diff_pdt_pos, diff_tgt_pos) / 3
|
||||
loss_dict["loss_vol_pos"] = loss_vol_pos.detach()
|
||||
|
||||
loss += loss_vol_exp * self.opt.LOSS.lambda_vol_exp
|
||||
loss += loss_vol_pos * self.opt.LOSS.lambda_vol_pos
|
||||
|
||||
# synthesis geo rec
|
||||
loss_rec_geo = self.loss_func_wing(batch_syn_geo, batch_tgt_geo)
|
||||
loss_dict["loss_rec_syn"] = loss_rec_geo.detach()
|
||||
loss += loss_rec_geo * self.opt.LOSS.lambda_rec_syn
|
||||
|
||||
|
||||
# synthesis geo volocity
|
||||
diff_syn_geo = batch_syn_geo[:, 1:, :] - batch_syn_geo[:, :-1, :]
|
||||
diff_tgt_geo = batch_tgt_geo[:, 1:, :] - batch_tgt_geo[:, :-1, :]
|
||||
loss_vol_geo = self.loss_func_wing(diff_syn_geo, diff_tgt_geo)
|
||||
loss_dict["loss_vol_syn"] = loss_vol_geo.detach()
|
||||
loss += loss_vol_geo * self.opt.LOSS.lambda_vol_syn
|
||||
|
||||
# synthesis geo rec
|
||||
loss_rec_geo = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo)
|
||||
loss_dict["loss_rec_geo"] = loss_rec_geo.detach()
|
||||
loss += loss_rec_geo * self.opt.LOSS.lambda_rec_geo
|
||||
|
||||
# synthesis geo volocity
|
||||
diff_pdt_geo = batch_pdt_geo[:, 1:, :] - batch_pdt_geo[:, :-1, :]
|
||||
diff_tgt_geo = batch_tgt_geo[:, 1:, :] - batch_tgt_geo[:, :-1, :]
|
||||
loss_vol_geo = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo)
|
||||
loss_dict["loss_vol_geo"] = loss_vol_geo.detach()
|
||||
loss += loss_vol_geo * self.opt.LOSS.lambda_vol_geo
|
||||
|
||||
# total loss
|
||||
loss_dict['loss_all'] = loss.detach()
|
||||
|
||||
return loss, loss_dict
|
||||
|
||||
|
||||
def save_reconstruct(self, samples_pt, path_audio, path_save, suffix=""):
|
||||
# samples_pt, [B x N x dim_motion]
|
||||
|
||||
B, N, _ = samples_pt.shape
|
||||
nbatch_render = 10
|
||||
|
||||
# for each batch
|
||||
for j in range(B):
|
||||
jcoeff_pt = samples_pt[j, :, :]
|
||||
jpath_save = path_save.joinpath(f"{suffix}_{j:02d}.mp4")
|
||||
|
||||
v_render_pt = []
|
||||
for k in range(0, N, nbatch_render):
|
||||
jcodedict_pt = {}
|
||||
|
||||
jcodedict_pt["exp"] = jcoeff_pt[k:k+nbatch_render, :50] # (nbatch_render, 50)
|
||||
nbatch_real = jcodedict_pt["exp"].shape[0]
|
||||
|
||||
# pose
|
||||
jcodedict_pt["pose"] = np.repeat([self.mean_dict["pose"]], nbatch_real, axis=0) # (nbatch_render, 6)
|
||||
jcodedict_pt["pose"][:, 3:6] = jcoeff_pt[k:k+nbatch_render, 50:53]
|
||||
|
||||
# others ==> to mean
|
||||
mean_cam = [[5,0,0]] # or [self.mean_dict["cam"]]
|
||||
jcodedict_pt["cam"] = np.repeat(mean_cam, nbatch_real, axis=0) # (nbatch_render, 3)
|
||||
jcodedict_pt["light"] = np.repeat([self.mean_dict["light"]], nbatch_real, axis=0) # (nbatch_render, 9, 3)
|
||||
jcodedict_pt["shape"] = np.repeat([self.mean_dict["shape"]], nbatch_real, axis=0) # (nbatch_render, 100)
|
||||
jcodedict_pt["detail"] = np.repeat([self.mean_dict["detail"]], nbatch_real, axis=0) # (nbatch_render, 128)
|
||||
|
||||
_, visdict_pt = self.netR.decode_one(jcodedict_pt, nbatch_real, self.device)
|
||||
|
||||
render_pt = visdict_pt["shape_images"] # (nbatch_render, 3, 224, 224)
|
||||
# print(f"render pt shape = {render_pt.shape}")
|
||||
|
||||
for m in range(nbatch_real):
|
||||
# cv2.imwrite(str(kpath_image), util.tensor2image(render_image[m, ...]))
|
||||
v_render_pt.append(tensor2image(render_pt[m, ...]))
|
||||
|
||||
# save animation
|
||||
# print(f"testing v_render_pt = {len(v_render_pt)}")
|
||||
save_images_with_audio(v_render_pt, path_audio, jpath_save)
|
||||
|
||||
|
||||
def save_reconstruct_with_gt(self, samples_pt, samples_gt, path_save, suffix=""):
|
||||
# samples_pt, [B x N x dim_motion]
|
||||
# samples_gt, [B x N x dim_motion]
|
||||
B, N, _ = samples_pt.shape
|
||||
nbatch_render = 10
|
||||
|
||||
# for each batch
|
||||
for j in range(B):
|
||||
jcoeff_pt = samples_pt[j, :, :]
|
||||
jcoeff_gt = samples_gt[j, :, :]
|
||||
jpath_save = path_save.joinpath(f"{suffix}_{j:02d}.mp4")
|
||||
|
||||
v_render_pt = []
|
||||
v_render_gt = []
|
||||
|
||||
for k in range(0, N, nbatch_render):
|
||||
jcodedict_pt = {}
|
||||
jcodedict_gt = {}
|
||||
|
||||
# exp
|
||||
jcodedict_pt["exp"] = jcoeff_pt[k:k+nbatch_render, :50] # (nbatch_render, 50)
|
||||
jcodedict_gt["exp"] = jcoeff_gt[k:k+nbatch_render, :50] # (nbatch_render, 50)
|
||||
nbatch_real = jcodedict_pt["exp"].shape[0]
|
||||
|
||||
# pose
|
||||
jcodedict_pt["pose"] = np.repeat([self.mean_dict["pose"]], nbatch_real, axis=0) # (nbatch_render, 6)
|
||||
jcodedict_gt["pose"] = np.repeat([self.mean_dict["pose"]], nbatch_real, axis=0) # (nbatch_render, 6)
|
||||
jcodedict_pt["pose"][:, 3:6] = jcoeff_pt[k:k+nbatch_render, 50:53]
|
||||
jcodedict_gt["pose"][:, 3:6] = jcoeff_gt[k:k+nbatch_render, 50:53]
|
||||
|
||||
# others ==> to mean
|
||||
mean_cam = [[5,0,0]] # or [self.mean_dict["cam"]]
|
||||
jcodedict_pt["cam"] = np.repeat(mean_cam, nbatch_real, axis=0) # (nbatch_render, 3)
|
||||
jcodedict_pt["light"] = np.repeat([self.mean_dict["light"]], nbatch_real, axis=0) # (nbatch_render, 9, 3)
|
||||
jcodedict_pt["shape"] = np.repeat([self.mean_dict["shape"]], nbatch_real, axis=0) # (nbatch_render, 100)
|
||||
jcodedict_pt["detail"] = np.repeat([self.mean_dict["detail"]], nbatch_real, axis=0) # (nbatch_render, 128)
|
||||
|
||||
jcodedict_gt["cam"] = np.repeat(mean_cam, nbatch_real, axis=0) # (nbatch_render, 3)
|
||||
jcodedict_gt["light"] = np.repeat([self.mean_dict["light"]], nbatch_real, axis=0) # (nbatch_render, 9, 3)
|
||||
jcodedict_gt["shape"] = np.repeat([self.mean_dict["shape"]], nbatch_real, axis=0) # (nbatch_render, 100)
|
||||
jcodedict_gt["detail"] = np.repeat([self.mean_dict["detail"]], nbatch_real, axis=0) # (nbatch_render, 128)
|
||||
|
||||
_, visdict_pt = self.netR.decode_one(jcodedict_pt, nbatch_real, self.device)
|
||||
_, visdict_gt = self.netR.decode_one(jcodedict_gt, nbatch_real, self.device)
|
||||
|
||||
render_pt = visdict_pt["shape_images"] # (nbatch_render, 3, 224, 224)
|
||||
render_gt = visdict_gt["shape_images"] # (nbatch_render, 3, 224, 224)
|
||||
# print(f"render pt shape = {render_pt.shape}, gt {render_gt.shape}")
|
||||
|
||||
for m in range(nbatch_real):
|
||||
# cv2.imwrite(str(kpath_image), util.tensor2image(render_image[m, ...]))
|
||||
v_render_pt.append(tensor2image(render_pt[m, ...]))
|
||||
v_render_gt.append(tensor2image(render_gt[m, ...]))
|
||||
|
||||
# get audio
|
||||
jvid = self.batch_vid[j]
|
||||
jnframe = self.batch_nframe[j].numpy()
|
||||
jstart_frame = self.batch_interv[0][j].numpy()
|
||||
|
||||
jpath_audio = f"/yrfs/lsen/DATA/LuoXData/processing2/{jvid}/audio/audio_trim.wav"
|
||||
jstart_time = (jstart_frame + 7) / self.opt.DATASET.fps # xxx.yyy min
|
||||
jend_time = (jstart_frame + 7 + self.nseq) / self.opt.DATASET.fps # xxx.yyy min
|
||||
|
||||
|
||||
|
||||
print(f"jvid={jvid}, jnfram={jnframe}, jstart_frame={jstart_frame}, jpath_audio={jpath_audio}")
|
||||
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, jpath_save, fps=self.opt.DATASET.fps,\
|
||||
path_audio=jpath_audio, start_time=jstart_time, end_time=jend_time)
|
||||
|
||||
|
||||
#########################################
|
||||
def tensor2image(tensor):
|
||||
image = tensor.detach().cpu().numpy()
|
||||
image = image*255.
|
||||
image = np.maximum(np.minimum(image, 255), 0)
|
||||
image = image.transpose(1,2,0)[:,:,[2,1,0]]
|
||||
return image.astype(np.uint8).copy()
|
||||
|
||||
|
||||
def define_netG(opt):
|
||||
netG = None
|
||||
|
||||
if opt.MODEL.name_netG == "audio2motion_voca4":
|
||||
from src.nn.audio2motion_voca4 import Audio2MotionVOCA
|
||||
netG = Audio2MotionVOCA(opt)
|
||||
|
||||
elif opt.MODEL.name_netG == "audio2motion_voca":
|
||||
from src.nn.audio2motion_voca import Audio2MotionVOCA
|
||||
netG = Audio2MotionVOCA(opt)
|
||||
|
||||
elif opt.MODEL.name_netG == "audio2motion_voca3":
|
||||
from src.nn.audio2motion_voca3 import Audio2MotionVOCA3
|
||||
netG = Audio2MotionVOCA3(opt)
|
||||
|
||||
elif opt.MODEL.name_netG == "audio2motion_voca33":
|
||||
from src.nn.audio2motion_voca33 import Audio2MotionVOCA
|
||||
netG = Audio2MotionVOCA(opt)
|
||||
|
||||
elif opt.MODEL.name_netG == "audio2motion":
|
||||
from src.nn.audio2motion import Audio2Motion
|
||||
netG = Audio2Motion(opt)
|
||||
|
||||
elif opt.MODEL.name_netG == "audio2motion2":
|
||||
from src.nn.audio2motion2 import Audio2Motion2
|
||||
netG = Audio2Motion2(opt)
|
||||
else:
|
||||
raise NameError(f"The model of opt.MODEL.name_netAE(={opt.MODEL.name_netG}) not existing!")
|
||||
|
||||
|
||||
return netG
|
||||
|
||||
|
||||
def define_netR(device):
|
||||
# import
|
||||
|
||||
from src.nn.FLAME import FLAME
|
||||
|
||||
sys.path.insert(0, "/ssdata1/lsen/CODE/DECA_old")
|
||||
from decalib.deca import DECA
|
||||
from decalib.utils import util
|
||||
from decalib.utils.config import cfg as deca_cfg
|
||||
|
||||
# use device
|
||||
# device = "cuda:2"
|
||||
# whether to use FLAME texture model to generate uv texture map
|
||||
deca_cfg.model.use_tex = False
|
||||
deca_cfg.dataset.image_size = 512
|
||||
|
||||
# reconstruction model
|
||||
netR = DECA(config = deca_cfg, device=device)
|
||||
|
||||
# flame model
|
||||
flame = FLAME(deca_cfg.model).to(device)
|
||||
|
||||
|
||||
return netR, flame
|
||||
|
||||
|
||||
|
||||
@@ -55,8 +55,12 @@ class Audio2MeshSpecificModel(Base):
|
||||
debug(opt, f"template_verts shape = {self.template_verts.shape}")
|
||||
debug(opt, f"mean_dict keys = {self.mean_dict.keys()}", verbose=True)
|
||||
|
||||
self.loss_func_l1 = nn.L1Loss(reduction="mean")
|
||||
self.loss_func_wing = WingLoss(reduction="mean")
|
||||
# self.loss_func_l1 = nn.L1Loss(reduction="mean")
|
||||
# self.loss_func_wing = WingLoss(reduction="mean")
|
||||
|
||||
self.loss_func_wing = WingLoss(reduction="none") # return (B, )
|
||||
self.loss_func_l1 = nn.L1Loss(reduction="none")
|
||||
|
||||
|
||||
if self.isTrain:
|
||||
self.names_loss = opt.LOSS.names
|
||||
@@ -198,6 +202,27 @@ class Audio2MeshSpecificModel(Base):
|
||||
print(f"save infer_result shape = {samples_pt.shape} -> {path_save_npy}")
|
||||
|
||||
|
||||
# def infer_loss(self, batch_cond, batch_data):
|
||||
# """
|
||||
# input parameters:
|
||||
# batch_cond: B x nsteps x 16 x nfeat_speech
|
||||
# batch_data: B x nsteps x nfeat_motion
|
||||
# return:
|
||||
# loss: B x nsteps x 3
|
||||
# """
|
||||
# self.eval()
|
||||
# self.cond = batch_cond.float().to(self.device) # (B x nsteps x 16 x nc_condit)
|
||||
# self.data = batch_data.float().to(self.device) # (B x nsteps x nc_motion)
|
||||
|
||||
# with torch.no_grad():
|
||||
# samples_pt = self.netG(self.cond) # B x N x 16 x nc_condit
|
||||
# samples_pt += self.template_verts # B x N x 5023 x 3
|
||||
|
||||
# loss = self.eval_losses_for_infer_loss(self.pred, self.data)
|
||||
|
||||
# return loss
|
||||
|
||||
|
||||
def testing(self, batch_input, cur_epoch=0, cur_batch=0):
|
||||
self.eval() # set eval model
|
||||
self.set_input(batch_input)
|
||||
@@ -258,6 +283,8 @@ class Audio2MeshSpecificModel(Base):
|
||||
return verts
|
||||
|
||||
|
||||
|
||||
|
||||
def eval_losses(self, batch_pdt_geo, batch_tgt):
|
||||
""" Computes the VAE loss function.
|
||||
pramas:
|
||||
@@ -272,23 +299,51 @@ class Audio2MeshSpecificModel(Base):
|
||||
|
||||
# synthesis geo rec
|
||||
loss = 0
|
||||
loss_rec_geo = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo)
|
||||
loss_dict["loss_rec_geo"] = loss_rec_geo.detach()
|
||||
loss_rec_geo = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo) # B
|
||||
loss_dict["loss_rec_geo"] = loss_rec_geo.mean().detach()
|
||||
loss_rec_geo = self.loss_func_l1(batch_pdt_geo, batch_tgt_geo) # B
|
||||
loss_dict["loss_rec_geo_l1"] = loss_rec_geo.mean().detach()
|
||||
|
||||
loss_rec_geo2 = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo, weight=self.vertices_weight)
|
||||
loss_dict["loss_rec_geo_w"] = loss_rec_geo2.detach()
|
||||
loss += loss_rec_geo2 * self.opt.LOSS.lambda_rec_geo
|
||||
|
||||
loss_rec_geo2 = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo, weight=self.vertices_weight) # B x nsteps x num_vertices x 3
|
||||
loss_rec_geo2 = loss_rec_geo2.sum(dim=(2, 3)) / (3 * self.opt.MODEL.num_vertices) # B x nsteps
|
||||
|
||||
# filter outliar
|
||||
threshold_rec, mean_rec = torch.quantile(loss_rec_geo2, q=0.75) * 1.5, torch.quantile(loss_rec_geo2, q=0.5)
|
||||
b_outlier_rec = loss_rec_geo2 > threshold_rec # B x nsteps
|
||||
|
||||
# synthesis geo volocity
|
||||
diff_pdt_geo = batch_pdt_geo[:, 1:, :] - batch_pdt_geo[:, :-1, :]
|
||||
diff_tgt_geo = batch_tgt_geo[:, 1:, :] - batch_tgt_geo[:, :-1, :]
|
||||
|
||||
loss_vol_geo = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo)
|
||||
loss_dict["loss_vol_geo"] = loss_vol_geo.detach()
|
||||
loss_vel_geo = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo)
|
||||
loss_dict["loss_vel_geo"] = loss_vel_geo.mean().detach()
|
||||
loss_vel_geo = self.loss_func_l1(diff_pdt_geo, diff_tgt_geo) # 1,
|
||||
loss_dict["loss_vel_geo_l1"] = loss_vel_geo.mean().detach()
|
||||
|
||||
loss_vol_geo2 = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo, weight=self.vertices_weight)
|
||||
loss_dict["loss_vol_geo_w"] = loss_vol_geo2.detach()
|
||||
loss += loss_vol_geo2 * self.opt.LOSS.lambda_vol_geo
|
||||
loss_vel_geo2 = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo, weight=self.vertices_weight) # B x nsteps x num_vertices x 3
|
||||
loss_vel_geo2 = loss_vel_geo2.sum(dim=(2, 3)) / (3 * self.opt.MODEL.num_vertices) # B x nsteps
|
||||
|
||||
# filter outliar
|
||||
threshold_vol, mean_vol = torch.quantile(loss_vel_geo2, q=0.75) * 1.5, torch.quantile(loss_vel_geo2, q=0.5)
|
||||
b_outlier_vol = loss_vel_geo2 > threshold_vol # B x (nsteps-1)
|
||||
|
||||
# find outliar in both loss data
|
||||
b_outlier_rec[:, :-1] = b_outlier_rec[:, :-1] & b_outlier_vol[:, :]
|
||||
if torch.any(b_outlier_rec):
|
||||
# print(f"b_outlier_rec = {b_outlier_rec}")
|
||||
# print(f"outerliar size= {loss_rec_geo2[b_outlier_rec].shape} / {loss_rec_geo2.numel()} ")
|
||||
loss_rec_geo2[b_outlier_rec] = mean_rec
|
||||
loss_vel_geo2[b_outlier_rec[:, :-1]] = mean_vol
|
||||
|
||||
# calculate again
|
||||
loss_rec_geo2 = loss_rec_geo2.mean()
|
||||
loss_dict["loss_rec_geo_w"] = loss_rec_geo2.detach()
|
||||
loss += loss_rec_geo2 * self.opt.LOSS.lambda_rec_geo
|
||||
|
||||
loss_vel_geo2 = loss_vel_geo2.mean()
|
||||
loss_dict["loss_vel_geo_w"] = loss_vel_geo2.detach()
|
||||
loss += loss_vel_geo2 * self.opt.LOSS.lambda_vel_geo
|
||||
|
||||
# total loss
|
||||
loss_dict['loss_all'] = loss.detach()
|
||||
|
||||
@@ -190,16 +190,16 @@ class Audio2motionLiveModel(Base):
|
||||
# rec smooth
|
||||
diff_pdt_exp = batch_pdt_exp[:, 1:, :] - batch_pdt_exp[:, :-1, :]
|
||||
diff_tgt_exp = batch_tgt_exp[:, 1:, :] - batch_tgt_exp[:, :-1, :]
|
||||
loss_vol_exp = self.loss_func_wing(diff_pdt_exp, diff_tgt_exp) / 50
|
||||
loss_dict["loss_vol_exp"] = loss_vol_exp.detach()
|
||||
loss_vel_exp = self.loss_func_wing(diff_pdt_exp, diff_tgt_exp) / 50
|
||||
loss_dict["loss_vel_exp"] = loss_vel_exp.detach()
|
||||
|
||||
diff_pdt_pos = batch_pdt_pos[:, 1:, :] - batch_pdt_pos[:, :-1, :]
|
||||
diff_tgt_pos = batch_tgt_pos[:, 1:, :] - batch_tgt_pos[:, :-1, :]
|
||||
loss_vol_pos = self.loss_func_wing(diff_pdt_pos, diff_tgt_pos) / 3
|
||||
loss_dict["loss_vol_pos"] = loss_vol_pos.detach()
|
||||
loss_vel_pos = self.loss_func_wing(diff_pdt_pos, diff_tgt_pos) / 3
|
||||
loss_dict["loss_vel_pos"] = loss_vel_pos.detach()
|
||||
|
||||
loss += loss_vol_exp * self.opt.LOSS.lambda_rec_smooth
|
||||
loss += loss_vol_pos * self.opt.LOSS.lambda_rec_smooth * 10
|
||||
loss += loss_vel_exp * self.opt.LOSS.lambda_rec_smooth
|
||||
loss += loss_vel_pos * self.opt.LOSS.lambda_rec_smooth * 10
|
||||
|
||||
# total loss
|
||||
loss_dict['loss_all'] = loss.detach()
|
||||
|
||||
@@ -212,16 +212,16 @@ class Audio2motionLive2Model(Base):
|
||||
# rec smooth
|
||||
diff_pdt_exp = batch_pdt_exp[:, 1:, :] - batch_pdt_exp[:, :-1, :]
|
||||
diff_tgt_exp = batch_tgt_exp[:, 1:, :] - batch_tgt_exp[:, :-1, :]
|
||||
loss_vol_exp = self.loss_func_wing(diff_pdt_exp, diff_tgt_exp) / 50
|
||||
loss_dict["loss_vol_exp"] = loss_vol_exp.detach()
|
||||
loss_vel_exp = self.loss_func_wing(diff_pdt_exp, diff_tgt_exp) / 50
|
||||
loss_dict["loss_vel_exp"] = loss_vel_exp.detach()
|
||||
|
||||
diff_pdt_pos = batch_pdt_pos[:, 1:, :] - batch_pdt_pos[:, :-1, :]
|
||||
diff_tgt_pos = batch_tgt_pos[:, 1:, :] - batch_tgt_pos[:, :-1, :]
|
||||
loss_vol_pos = self.loss_func_wing(diff_pdt_pos, diff_tgt_pos) / 3
|
||||
loss_dict["loss_vol_pos"] = loss_vol_pos.detach()
|
||||
loss_vel_pos = self.loss_func_wing(diff_pdt_pos, diff_tgt_pos) / 3
|
||||
loss_dict["loss_vel_pos"] = loss_vel_pos.detach()
|
||||
|
||||
loss += loss_vol_exp * self.opt.LOSS.lambda_vol_exp
|
||||
loss += loss_vol_pos * self.opt.LOSS.lambda_vol_pos
|
||||
loss += loss_vel_exp * self.opt.LOSS.lambda_vel_exp
|
||||
loss += loss_vel_pos * self.opt.LOSS.lambda_vel_pos
|
||||
|
||||
# total loss
|
||||
loss_dict['loss_all'] = loss.detach()
|
||||
|
||||
@@ -242,16 +242,16 @@ class Audio2motionLive3Model(Base):
|
||||
# rec smooth
|
||||
diff_pdt_exp = batch_pdt_exp[:, 1:, :] - batch_pdt_exp[:, :-1, :]
|
||||
diff_tgt_exp = batch_tgt_exp[:, 1:, :] - batch_tgt_exp[:, :-1, :]
|
||||
loss_vol_exp = self.loss_func_wing(diff_pdt_exp, diff_tgt_exp) / 50
|
||||
loss_dict["loss_vol_exp"] = loss_vol_exp.detach()
|
||||
loss_vel_exp = self.loss_func_wing(diff_pdt_exp, diff_tgt_exp) / 50
|
||||
loss_dict["loss_vel_exp"] = loss_vel_exp.detach()
|
||||
|
||||
diff_pdt_pos = batch_pdt_pos[:, 1:, :] - batch_pdt_pos[:, :-1, :]
|
||||
diff_tgt_pos = batch_tgt_pos[:, 1:, :] - batch_tgt_pos[:, :-1, :]
|
||||
loss_vol_pos = self.loss_func_wing(diff_pdt_pos, diff_tgt_pos) / 3
|
||||
loss_dict["loss_vol_pos"] = loss_vol_pos.detach()
|
||||
loss_vel_pos = self.loss_func_wing(diff_pdt_pos, diff_tgt_pos) / 3
|
||||
loss_dict["loss_vel_pos"] = loss_vel_pos.detach()
|
||||
|
||||
loss += loss_vol_exp * self.opt.LOSS.lambda_vol_exp
|
||||
loss += loss_vol_pos * self.opt.LOSS.lambda_vol_pos
|
||||
loss += loss_vel_exp * self.opt.LOSS.lambda_vel_exp
|
||||
loss += loss_vel_pos * self.opt.LOSS.lambda_vel_pos
|
||||
|
||||
# geo rec
|
||||
loss_rec_geo = self.loss_func_wing(batch_pdt_geo, batch_tgt_geo)
|
||||
@@ -262,9 +262,9 @@ class Audio2motionLive3Model(Base):
|
||||
# geo volocity
|
||||
diff_pdt_geo = batch_pdt_geo[:, 1:, :] - batch_pdt_geo[:, :-1, :]
|
||||
diff_tgt_geo = batch_tgt_geo[:, 1:, :] - batch_tgt_geo[:, :-1, :]
|
||||
loss_vol_geo = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo)
|
||||
loss_dict["loss_vol_geo"] = loss_vol_geo.detach()
|
||||
loss += loss_vol_geo * self.opt.LOSS.lambda_vol_geo
|
||||
loss_vel_geo = self.loss_func_wing(diff_pdt_geo, diff_tgt_geo)
|
||||
loss_dict["loss_vel_geo"] = loss_vel_geo.detach()
|
||||
loss += loss_vel_geo * self.opt.LOSS.lambda_vel_geo
|
||||
|
||||
|
||||
# total loss
|
||||
|
||||
Reference in new issue
Block a user