Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions inference.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### INFERENCE.PY:

import argparse
import subprocess
import python_speech_features
Expand Down Expand Up @@ -40,7 +42,7 @@ def draw_annotation_box( image, rotation_vector, translation_vector, color=(255,
point_3d.append((front_size, front_size, front_depth))
point_3d.append((front_size, -front_size, front_depth))
point_3d.append((-front_size, -front_size, front_depth))
point_3d = np.array(point_3d, dtype=np.float).reshape(-1, 3)
point_3d = np.array(point_3d, dtype=float).reshape(-1, 3)

# Map to 2d image points
(point_2d, _) = cv2.projectPoints(point_3d,
Expand Down Expand Up @@ -138,15 +140,15 @@ def audio2head(audio_path, img_path, model_path, save_path):

config_file = r"./config/vox-256.yaml"
with open(config_file) as f:
config = yaml.load(f)
config = yaml.safe_load(f)
kp_detector = KPDetector(**config['model_params']['kp_detector_params'],
**config['model_params']['common_params'])
generator = OcclusionAwareGenerator(**config['model_params']['generator_params'],
**config['model_params']['common_params'])
kp_detector = kp_detector.cuda()
generator = generator.cuda()

opt = argparse.Namespace(**yaml.load(open("./config/parameters.yaml")))
opt = argparse.Namespace(**yaml.safe_load(open("./config/parameters.yaml")))
audio2kp = AudioModel3D(opt).cuda()

checkpoint = torch.load(model_path)
Expand Down Expand Up @@ -248,4 +250,4 @@ def audio2head(audio_path, img_path, model_path, save_path):
parse = parser.parse_args()

os.makedirs(parse.save_path,exist_ok=True)
audio2head(parse.audio_path,parse.img_path,parse.model_path,parse.save_path)
audio2head(parse.audio_path,parse.img_path,parse.model_path,parse.save_path)