From 289bcff9a3857e497e7df4dc7fb1184bbee7cc01 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Sun, 4 Jun 2023 09:51:05 +0200 Subject: [PATCH] CoreMLExecutionProvider support for Apple Silicon --- requirements.txt | 3 ++- roop/core.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 821a485..0d36af5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,8 @@ psutil==5.9.5 tk==0.1.0 pillow==9.5.0 torch==2.0.1 -onnxruntime==1.15.0; sys_platform == 'darwin' +onnxruntime==1.15.0; sys_platform == 'darwin' and platform_machine != 'arm64' +onnxruntime-silicon==1.13.1; sys_platform == 'darwin' and platform_machine == 'arm64' onnxruntime-gpu==1.15.0; sys_platform != 'darwin' tensorflow==2.13.0rc1; sys_platform == 'darwin' tensorflow==2.12.0; sys_platform != 'darwin' diff --git a/roop/core.py b/roop/core.py index fb6ea1c..65c0a2d 100755 --- a/roop/core.py +++ b/roop/core.py @@ -35,7 +35,7 @@ parser.add_argument('--all-faces', help='swap all faces in frame', dest='all_fac parser.add_argument('--max-memory', help='maximum amount of RAM in GB to be used', dest='max_memory', type=int) parser.add_argument('--cpu-threads', help='number of threads to be use for CPU mode', dest='cpu_threads', type=int) parser.add_argument('--gpu-threads', help='number of threads to be use for GPU mode', dest='gpu_threads', type=int) -parser.add_argument('--gpu-vendor', help='choice your gpu vendor', dest='gpu_vendor', choices=['amd', 'intel', 'nvidia']) +parser.add_argument('--gpu-vendor', help='choice your gpu vendor', dest='gpu_vendor', choices=['apple', 'amd', 'intel', 'nvidia']) args = {} for name, value in vars(parser.parse_args()).items(): @@ -78,6 +78,9 @@ def pre_check(): model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../inswapper_128.onnx') if not os.path.isfile(model_path): quit('File "inswapper_128.onnx" does not exist!') + if roop.globals.gpu_vendor == 'apple': + if 'CoreMLExecutionProvider' not in roop.globals.providers: + quit("You are using --gpu=apple flag but CoreML isn't available or properly installed on your system.") if roop.globals.gpu_vendor == 'amd': if 'ROCMExecutionProvider' not in roop.globals.providers: quit("You are using --gpu=amd flag but ROCM isn't available or properly installed on your system.")