mirror of
https://github.com/s0md3v/roop.git
synced 2025-12-06 18:08:29 +00:00
Update processor.py
This commit is contained in:
parent
c0f486ed83
commit
ab2fc1c221
@ -2,6 +2,7 @@ import os
|
|||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import insightface
|
import insightface
|
||||||
|
import core.globals
|
||||||
from core.config import get_face
|
from core.config import get_face
|
||||||
|
|
||||||
FACE_SWAPPER = None
|
FACE_SWAPPER = None
|
||||||
@ -11,7 +12,7 @@ def get_face_swapper():
|
|||||||
global FACE_SWAPPER
|
global FACE_SWAPPER
|
||||||
if FACE_SWAPPER is None:
|
if FACE_SWAPPER is None:
|
||||||
model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../inswapper_128.onnx')
|
model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../inswapper_128.onnx')
|
||||||
FACE_SWAPPER = insightface.model_zoo.get_model(model_path)
|
FACE_SWAPPER = insightface.model_zoo.get_model(model_path, providers=core.globals.providers)
|
||||||
return FACE_SWAPPER
|
return FACE_SWAPPER
|
||||||
|
|
||||||
|
|
||||||
@ -38,4 +39,4 @@ def process_img(source_img, target_path, output_file):
|
|||||||
source_face = get_face(cv2.imread(source_img))
|
source_face = get_face(cv2.imread(source_img))
|
||||||
result = get_face_swapper().get(frame, face, source_face, paste_back=True)
|
result = get_face_swapper().get(frame, face, source_face, paste_back=True)
|
||||||
cv2.imwrite(output_file, result)
|
cv2.imwrite(output_file, result)
|
||||||
print("\n\nImage saved as:", output_file, "\n\n")
|
print("\n\nImage saved as:", output_file, "\n\n")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user