Add GPU support, Quit on missing model, Remove globals (sorry)

This commit is contained in:
henryruhs
2023-05-30 00:40:02 +02:00
committed by Somdev Sangwan
parent d05b9ea6e6
commit 8701123ee3
6 changed files with 19 additions and 12 deletions

View File

@@ -1,11 +1,15 @@
import os
import cv2
import insightface
import onnxruntime
import core.globals
from core.config import get_face
from core.utils import rreplace
face_swapper = insightface.model_zoo.get_model('inswapper_128.onnx', providers=core.globals.providers)
if os.path.isfile('inswapper_128.onnx'):
face_swapper = insightface.model_zoo.get_model('inswapper_128.onnx', providers=onnxruntime.get_available_providers())
else:
quit('File "inswapper_128.onnx" does not exist!')
def process_video(source_img, frame_paths):
@@ -25,6 +29,7 @@ def process_video(source_img, frame_paths):
pass
print(flush=True)
def process_img(source_img, target_path):
frame = cv2.imread(target_path)
face = get_face(frame)