Skip to content

Instantly share code, notes, and snippets.

@fathonix
Last active May 14, 2024 04:16
Show Gist options
  • Save fathonix/3b9bda262226ac8842338d65ae505673 to your computer and use it in GitHub Desktop.
Save fathonix/3b9bda262226ac8842338d65ae505673 to your computer and use it in GitHub Desktop.
Install Rembg with CoreML support to use Neural Engine
#!/bin/bash -e
# Install Rembg with CoreML support to use Neural Engine
# Tested on macOS 14.1, M1 MBP, 2024-05-14
# Licensed under MIT. (c) 2024 Aldo Adirajasa Fathoni
# Assuming Xcode CLT and Homebrew have been installed
brew install [email protected]
mkdir rembg-env
/opt/homebrew/bin/python3.9 -m venv rembg-env
source rembg-env/bin/activate
curl -Lo rembg-2.0.56.tar.gz https://github.com/danielgatis/rembg/archive/refs/tags/v2.0.56.tar.gz
curl -LO https://gist.github.com/fathonix/3b9bda262226ac8842338d65ae505673/raw/8f8f714876b6a463b3118e84c8b9fbbf8f1160d8/rembg-use-onnxruntime-silicon.patch
tar xf rembg-2.0.56.tar.gz
patch -d rembg-2.0.56 -p1 < rembg-use-onnxruntime-silicon.patch
pip install './rembg-2.0.56[cli]'
./rembg-env/bin/rembg --version
diff --git a/setup.py b/setup.py
index a400a65..053e9bc 100644
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,7 @@ long_description = (here / "README.md").read_text(encoding="utf-8")
install_requires = [
"jsonschema",
"numpy",
- "onnxruntime",
+ "onnxruntime-silicon",
"opencv-python-headless",
"pillow",
"pooch",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment