Spaces:
Runtime error
Runtime error
File size: 995 Bytes
6bcb009 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
from typing import Any, List, Callable
import roop.globals
import insightface
import cv2
import numpy as np
from roop.typing import Face, Frame
from roop.utilities import resolve_relative_path
class FaceSwapInsightFace():
model_swap_insightface = None
processorname = 'faceswap'
type = 'swap'
def Initialize(self, devicename):
if self.model_swap_insightface is None:
model_path = resolve_relative_path('../models/inswapper_128.onnx')
self.model_swap_insightface = insightface.model_zoo.get_model(model_path, providers=roop.globals.execution_providers)
def Run(self, source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
img_fake, M = self.model_swap_insightface.get(temp_frame, target_face, source_face, paste_back=False)
target_face.matrix = M
return img_fake
def Release(self):
del self.model_swap_insightface
self.model_swap_insightface = None
|