Skip to content

get the most core swap face code,for guys to use #108

@xiaohaipeng

Description

@xiaohaipeng

def swap_face(source,target,netArc,G,half=True):
target_norm = normalize_and_torch(np.array(target))
target_embeds = netArc(F.interpolate(target_norm, scale_factor=0.5, mode='bilinear', align_corners=True))

source_curr = normalize_and_torch(source)
source_embed = netArc(F.interpolate(source_curr, scale_factor=0.5, mode='bilinear', align_corners=True))

resized_image = cv2.resize(target,(256,256))
resized_frs = np.array([resized_image])
target_batch_rs = transform_target_to_torch(resized_frs, half=half)

if half:
        source_embed = source_embed.half()

Y_st = faceshifter_batch(source_embed, target_batch_rs, G)
return Y_st[0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions