This commit is contained in:
harisreedhar 2024-09-20 15:52:23 +05:30
parent 8958e12149
commit 4fb286c502

View File

@ -479,6 +479,7 @@ def convert_embedding(source_face : Face) -> Tuple[Embedding, Embedding]:
def prepare_crop_frame(crop_vision_frame : VisionFrame) -> VisionFrame:
model_mean = get_model_options().get('mean')
model_standard_deviation = get_model_options().get('standard_deviation')
crop_vision_frame = crop_vision_frame[:, :, ::-1] / 255.0
crop_vision_frame = (crop_vision_frame - model_mean) / model_standard_deviation
crop_vision_frame = crop_vision_frame.transpose(2, 0, 1)
@ -490,8 +491,9 @@ def normalize_crop_frame(crop_vision_frame : VisionFrame) -> VisionFrame:
model_template = get_model_options().get('type')
model_mean = get_model_options().get('mean')
model_standard_deviation = get_model_options().get('standard_deviation')
crop_vision_frame = crop_vision_frame.transpose(1, 2, 0)
if model_template != 'simswap':
if model_template == 'ghost' or model_template == 'uniface':
crop_vision_frame = crop_vision_frame * model_standard_deviation + model_mean
crop_vision_frame = crop_vision_frame.clip(0, 1)
crop_vision_frame = crop_vision_frame[:, :, ::-1] * 255