From f07e38c556697ecc37f17ca3aa6ff02b2f78dc13 Mon Sep 17 00:00:00 2001 From: wuzy361 Date: Fri, 2 Jan 2026 13:11:19 +0800 Subject: [PATCH] feat: add Apple Silicon (MPS) support and Mac-specific requirements - Add MPS device detection in AILab_BiRefNet.py and AILab_RMBG.py - Add requirements_mac.txt for Mac-compatible dependencies - Remove Windows-specific packages (triton-windows, onnxruntime-gpu) for Mac --- py/AILab_BiRefNet.py | 7 ++++++- py/AILab_RMBG.py | 7 ++++++- requirements_mac.txt | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 requirements_mac.txt diff --git a/py/AILab_BiRefNet.py b/py/AILab_BiRefNet.py index 94e2a7e..792ed31 100644 --- a/py/AILab_BiRefNet.py +++ b/py/AILab_BiRefNet.py @@ -22,7 +22,12 @@ from safetensors.torch import load_file import cv2 -device = "cuda" if torch.cuda.is_available() else "cpu" +if torch.cuda.is_available(): + device = "cuda" +elif torch.backends.mps.is_available(): + device = "mps" +else: + device = "cpu" # Add model path folder_paths.add_model_folder_path("rmbg", os.path.join(folder_paths.models_dir, "RMBG")) diff --git a/py/AILab_RMBG.py b/py/AILab_RMBG.py index 06c5a63..c402cf3 100644 --- a/py/AILab_RMBG.py +++ b/py/AILab_RMBG.py @@ -31,7 +31,12 @@ import cv2 import types -device = "cuda" if torch.cuda.is_available() else "cpu" +if torch.cuda.is_available(): + device = "cuda" +elif torch.backends.mps.is_available(): + device = "mps" +else: + device = "cpu" folder_paths.add_model_folder_path("rmbg", os.path.join(folder_paths.models_dir, "RMBG")) diff --git a/requirements_mac.txt b/requirements_mac.txt new file mode 100644 index 0000000..1611e73 --- /dev/null +++ b/requirements_mac.txt @@ -0,0 +1,18 @@ +# Base dependencies +huggingface-hub>=0.19.0 +transparent-background>=1.1.2 +segment-anything>=1.0 +groundingdino-py>=0.4.0 +opencv-python>=4.7.0 +onnxruntime>=1.15.0 +protobuf>=3.20.2,<6.0.0 + +#SAM2 +hydra-core>=1.3.0 +omegaconf>=2.3.0 +iopath>=0.1.9 + +#SAM3 +ftfy +typing_extensions +