Follow ONNX_Runtime_Perf_Tuning and introduce new args
This commit is contained in:
parent
8734a6c2e0
commit
6f38212bfd
@ -13,4 +13,3 @@ tensorflow==2.12.0; sys_platform != 'darwin'
|
||||
opennsfw2==0.10.2
|
||||
protobuf==4.23.2
|
||||
tqdm==4.65.0
|
||||
threadpoolctl==3.1.0
|
@ -1,4 +1,5 @@
|
||||
import insightface
|
||||
import onnxruntime
|
||||
import roop.globals
|
||||
|
||||
FACE_ANALYSER = None
|
||||
@ -7,6 +8,12 @@ FACE_ANALYSER = None
|
||||
def get_face_analyser():
|
||||
global FACE_ANALYSER
|
||||
if FACE_ANALYSER is None:
|
||||
session_options = onnxruntime.SessionOptions()
|
||||
if roop.globals.gpu_vendor is not None:
|
||||
session_options.intra_op_num_threads = roop.globals.gpu_threads
|
||||
else:
|
||||
session_options.intra_op_num_threads = roop.globals.cpu_threads
|
||||
session_options.execution_mode = onnxruntime.ExecutionMode.ORT_PARALLEL
|
||||
FACE_ANALYSER = insightface.app.FaceAnalysis(name='buffalo_l', providers=roop.globals.providers)
|
||||
FACE_ANALYSER.prepare(ctx_id=0, det_size=(640, 640))
|
||||
return FACE_ANALYSER
|
||||
|
13
roop/core.py
13
roop/core.py
@ -101,17 +101,6 @@ def pre_check():
|
||||
roop.globals.providers = ['CPUExecutionProvider']
|
||||
|
||||
|
||||
def start_processing():
|
||||
# gpu mode
|
||||
if roop.globals.gpu_vendor is not None:
|
||||
process_video(args['source_img'], args["frame_paths"])
|
||||
return
|
||||
# cpu mode
|
||||
with threadpool_limits(limits=roop.globals.cpu_threads):
|
||||
process_video(args['source_img'], args["frame_paths"])
|
||||
return
|
||||
|
||||
|
||||
def preview_image(image_path):
|
||||
img = Image.open(image_path)
|
||||
img = img.resize((180, 180), Image.ANTIALIAS)
|
||||
@ -223,7 +212,7 @@ def start():
|
||||
key=lambda x: int(x.split(sep)[-1].replace(".png", ""))
|
||||
))
|
||||
status("swapping in progress...")
|
||||
start_processing()
|
||||
process_video(args['source_img'], args["frame_paths"])
|
||||
status("creating video...")
|
||||
create_video(video_name, exact_fps, output_dir)
|
||||
status("adding audio...")
|
||||
|
@ -15,10 +15,9 @@ def get_face_swapper():
|
||||
session_options = onnxruntime.SessionOptions()
|
||||
if roop.globals.gpu_vendor is not None:
|
||||
session_options.intra_op_num_threads = roop.globals.gpu_threads
|
||||
session_options.execution_mode = onnxruntime.ExecutionMode.ORT_PARALLEL
|
||||
else:
|
||||
session_options.enable_cpu_mem_arena = True
|
||||
session_options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
|
||||
session_options.intra_op_num_threads = roop.globals.cpu_threads
|
||||
session_options.execution_mode = onnxruntime.ExecutionMode.ORT_PARALLEL
|
||||
model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../inswapper_128.onnx')
|
||||
FACE_SWAPPER = insightface.model_zoo.get_model(model_path, providers=roop.globals.providers, session_options=session_options)
|
||||
return FACE_SWAPPER
|
||||
|
Loading…
Reference in New Issue
Block a user