UniFace: A Unified Face Analysis Library for Python | Detection, alignment, landmarks, face-mesh, recognition, parsing, gaze, attributes and anti-spoofing under one API.
Python computer-visiondeep-learningface-alignmentface-analysisface-anonymizationface-anti-spoofingface-attributesface-detectionface-meshface-parsingface-quality-assessmentface-recognitionface-segmentationface-trackingfacial-landmarksgaze-estimationhead-pose-estimationonnxruntimeportrait-mattingpython
feat: Update the release workflow and package installation command (#110)
Yakhyokhuja Valikhujaev13c4ac83d8e7
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 136b4f2..43824a0 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -37,6 +37,8 @@ jobs:python-version: "3.10"- os: ubuntu-latestpython-version: "3.11"+ - os: ubuntu-latest+ python-version: "3.12"- os: ubuntu-latestpython-version: "3.13"- os: ubuntu-latest@@ -59,7 +61,7 @@ jobs:- name: Install dependenciesrun: |python -m pip install --upgrade pip- python -m pip install .[dev]+ python -m pip install ".[cpu,dev]"- name: Check ONNX Runtime providersrun: |diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.ymlindex 6e51940..33b71bb 100644--- a/.github/workflows/docs.yml+++ b/.github/workflows/docs.yml@@ -1,9 +1,8 @@name: Deploy docson:- push:- tags:- - "v*.*.*"+ release:+ types: [released] # Fires only for stable releases (not pre-releases), after publish.yml creates the Releaseworkflow_dispatch:permissions:diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.ymlindex c8745bd..4312a50 100644--- a/.github/workflows/publish.yml+++ b/.github/workflows/publish.yml@@ -54,7 +54,7 @@ jobs:strategy:fail-fast: falsematrix:- python-version: ["3.10", "3.11", "3.13"]+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]steps:- name: Checkout code@@ -69,7 +69,7 @@ jobs:- name: Install dependenciesrun: |python -m pip install --upgrade pip- python -m pip install .[dev]+ python -m pip install ".[cpu,dev]"- name: Run testsrun: pytest -v@@ -112,8 +112,18 @@ jobs:TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}run: twine upload dist/*+ - name: Detect pre-release+ id: prerelease+ run: |+ if [[ "${{ needs.validate.outputs.version }}" =~ (a|b|rc|\.dev)[0-9]+ ]]; then+ echo "is_prerelease=true" >> $GITHUB_OUTPUT+ else+ echo "is_prerelease=false" >> $GITHUB_OUTPUT+ fi+- name: Create GitHub Releaseuses: softprops/action-gh-release@v1with:files: dist/*generate_release_notes: true+ prerelease: ${{ steps.prerelease.outputs.is_prerelease }}diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlnew file mode 100644index 0000000..ef15b21--- /dev/null+++ b/.github/workflows/release.yml@@ -0,0 +1,84 @@+name: Release++on:+ workflow_dispatch:+ inputs:+ version:+ description: 'Version (e.g. 3.6.0, 3.6.0b1, 3.6.0rc1)'+ required: true++concurrency:+ group: release+ cancel-in-progress: false++jobs:+ release:+ runs-on: ubuntu-latest+ timeout-minutes: 5+ permissions:+ contents: write++ steps:+ - name: Checkout code+ uses: actions/checkout@v4+ with:+ fetch-depth: 0+ token: ${{ secrets.RELEASE_TOKEN }}++ - name: Set up Python+ uses: actions/setup-python@v5+ with:+ python-version: "3.11"++ - name: Validate version (PEP 440)+ run: |+ python - <<'EOF'+ import re, sys+ v = "${{ inputs.version }}"+ # PEP 440 subset: X.Y.Z, optional aN / bN / rcN / .devN+ if not re.fullmatch(r'\d+\.\d+\.\d+((a|b|rc)\d+|\.dev\d+)?', v):+ print(f"Invalid version: {v}")+ print("Expected forms: 3.6.0, 3.6.0a1, 3.6.0b1, 3.6.0rc1, 3.6.0.dev1")+ sys.exit(1)+ EOF++ - name: Check tag does not exist+ run: |+ if git rev-parse "v${{ inputs.version }}" >/dev/null 2>&1; then+ echo "Tag v${{ inputs.version }} already exists."+ exit 1+ fi++ - name: Update pyproject.toml+ run: |+ python - <<'EOF'+ import re, pathlib+ p = pathlib.Path('pyproject.toml')+ text = p.read_text()+ new = re.sub(r'^version\s*=\s*".*"', f'version = "${{ inputs.version }}"', text, count=1, flags=re.M)+ if new == text:+ raise SystemExit("Failed to update version in pyproject.toml")+ p.write_text(new)+ EOF++ - name: Update uniface/__init__.py+ run: |+ python - <<'EOF'+ import re, pathlib+ p = pathlib.Path('uniface/__init__.py')+ text = p.read_text()+ new = re.sub(r"^__version__\s*=\s*'.*'", f"__version__ = '${{ inputs.version }}'", text, count=1, flags=re.M)+ if new == text:+ raise SystemExit("Failed to update __version__ in uniface/__init__.py")+ p.write_text(new)+ EOF++ - name: Commit, tag, push+ run: |+ git config user.name "github-actions[bot]"+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"+ git add pyproject.toml uniface/__init__.py+ git commit -m "chore: Release v${{ inputs.version }}"+ git tag "v${{ inputs.version }}"+ git push origin HEAD:${{ github.ref_name }}+ git push origin "v${{ inputs.version }}"diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex b6d9e23..51cb056 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -59,12 +59,12 @@ This project uses [Ruff](https://docs.astral.sh/ruff/) for linting and formattin#### General Rules- **Line length:** 120 characters maximum-- **Python version:** 3.11+ (use modern syntax)+- **Python version:** 3.10+ (use modern syntax)- **Quote style:** Single quotes for strings, double quotes for docstrings#### Type Hints-Use modern Python 3.11+ type hints (PEP 585 and PEP 604):+Use modern Python 3.10+ type hints (PEP 585 and PEP 604):```python# Preferred (modern)@@ -188,6 +188,49 @@ Example notebooks demonstrating library usage:| Face Vector Store | [10_face_vector_store.ipynb](examples/10_face_vector_store.ipynb) || Head Pose Estimation | [11_head_pose_estimation.ipynb](examples/11_head_pose_estimation.ipynb) |+## Release Process++Releases are fully automated via GitHub Actions. Only maintainers with branch-protection bypass privileges on `main` can trigger a release.++### Cutting a release++1. Go to **Actions → Release → Run workflow** on GitHub.+2. Enter the version following [PEP 440](https://peps.python.org/pep-0440/):+ - Stable: `0.7.0`, `1.0.0`+ - Pre-release: `0.7.0rc1`, `0.7.0b1`, `0.7.0a1`, `0.7.0.dev1`+3. Click **Run workflow**.++### What happens automatically++The `Release` workflow:++1. Validates the version string.+2. Updates `pyproject.toml` and `uniface/__init__.py`.+3. Commits `chore: Release vX.Y.Z` to `main`.+4. Creates and pushes tag `vX.Y.Z`.++Pushing the tag then triggers:++- **Publish to PyPI** — builds the package, runs tests on Python 3.10–3.14, uploads to PyPI, and creates a GitHub Release (flagged as pre-release for `a`/`b`/`rc`/`.dev` versions).+- **Deploy docs** — fires only after a **stable** GitHub Release is published. Pre-releases do not update the live documentation site.++### Verifying a release++- PyPI: <https://pypi.org/project/uniface/>+- GitHub Releases: <https://github.com/yakhyo/uniface/releases>+- Docs (stable only): <https://yakhyo.github.io/uniface/>++### Installing a pre-release++End users can opt in to pre-releases with the `--pre` flag:++```bash+pip install uniface --pre # latest pre-release+pip install uniface==0.7.0rc1 # specific pre-release+```++Without `--pre`, `pip install uniface` always resolves to the latest stable version.+## Questions?Open an issue or start a discussion on GitHub.diff --git a/README.md b/README.mdindex 4d0a8bb..e15c7a7 100644--- a/README.md+++ b/README.md@@ -76,23 +76,25 @@## Installation-**Standard installation**+**CPU / Apple Silicon**```bash-pip install uniface+pip install uniface[cpu]```-**GPU support (CUDA)**+**GPU support (NVIDIA CUDA)**```bashpip install uniface[gpu]```+> **Why separate extras?** `onnxruntime` and `onnxruntime-gpu` conflict when both are installed — they own the same Python namespace. Installing only the extra you need prevents that conflict entirely.+**From source (latest version)**```bashgit clone https://github.com/yakhyo/uniface.git-cd uniface && pip install -e .+cd uniface && pip install -e ".[cpu]" # or .[gpu] for CUDA```**FAISS vector store**diff --git a/docs/concepts/execution-providers.md b/docs/concepts/execution-providers.mdindex 618cf81..ab777e4 100644--- a/docs/concepts/execution-providers.md+++ b/docs/concepts/execution-providers.md@@ -93,7 +93,7 @@ print("Available providers:", providers)No additional setup required. ARM64 optimizations are built into `onnxruntime`:```bash-pip install uniface+pip install uniface[cpu]```Verify ARM64:@@ -110,7 +110,7 @@ python -c "import platform; print(platform.machine())"### NVIDIA GPU (CUDA)-Install with GPU support:+Install with GPU support (this installs `onnxruntime-gpu`, which already includes CPU fallback):```bashpip install uniface[gpu]@@ -140,7 +140,7 @@ else:CPU execution is always available:```bash-pip install uniface+pip install uniface[cpu]```Works on all platforms without additional configuration.@@ -215,7 +215,7 @@ for image_path in image_paths:3. Reinstall with GPU support:```bash- pip uninstall onnxruntime onnxruntime-gpu+ pip uninstall onnxruntime onnxruntime-gpu -ypip install uniface[gpu]```diff --git a/docs/contributing.md b/docs/contributing.mdindex 672a9ba..a188fe7 100644--- a/docs/contributing.md+++ b/docs/contributing.md@@ -99,6 +99,14 @@ docs: Update installation instructions---+## Releases++Releases are automated via GitHub Actions. Maintainers trigger **Actions → Release → Run workflow** with a [PEP 440](https://peps.python.org/pep-0440/) version (e.g. `0.7.0`, `0.7.0rc1`). The workflow bumps `pyproject.toml` + `uniface/__init__.py`, tags the commit, and publishes to PyPI. Docs redeploy only for stable releases.++See [CONTRIBUTING.md](https://github.com/yakhyo/uniface/blob/main/CONTRIBUTING.md#release-process) for the full process.++---+## Questions?Open an issue on [GitHub](https://github.com/yakhyo/uniface/issues).diff --git a/docs/index.md b/docs/index.mdindex d47f9db..bbe743e 100644--- a/docs/index.md+++ b/docs/index.md@@ -92,12 +92,12 @@ FAISS-backed embedding store for fast multi-identity face search.UniFace runs inference primarily via **ONNX Runtime**; some optional components (e.g., emotion TorchScript, torchvision NMS) require **PyTorch**.-**Standard**+**CPU / Apple Silicon**```bash-pip install uniface+pip install uniface[cpu]```-**GPU (CUDA)**+**GPU (NVIDIA CUDA)**```bashpip install uniface[gpu]```@@ -106,7 +106,7 @@ pip install uniface[gpu]```bashgit clone https://github.com/yakhyo/uniface.gitcd uniface-pip install -e .+pip install -e ".[cpu]" # or .[gpu] for CUDA```---diff --git a/docs/installation.md b/docs/installation.mdindex b081050..ed24379 100644--- a/docs/installation.md+++ b/docs/installation.md@@ -11,15 +11,27 @@ This guide covers all installation options for UniFace.---+## Why Two Extras?++`onnxruntime` (CPU) and `onnxruntime-gpu` (CUDA) both own the same Python namespace.+Installing both at the same time causes file conflicts and silent provider mismatches.+UniFace exposes them as separate, mutually exclusive extras so you install exactly one.++---+## Quick Install-The simplest way to install UniFace:+=== "CPU / Apple Silicon"-```bash-pip install uniface-```+ ```bash+ pip install uniface[cpu]+ ```-This installs the CPU version with all core dependencies.+=== "NVIDIA GPU (CUDA)"++ ```bash+ pip install uniface[gpu]+ ```---@@ -27,14 +39,16 @@ This installs the CPU version with all core dependencies.### macOS (Apple Silicon - M1/M2/M3/M4)-For Apple Silicon Macs, the standard installation automatically includes ARM64 optimizations:+The `[cpu]` extra pulls in the standard `onnxruntime` package, which has native ARM64 support+built in since version 1.13. No additional setup is needed for CoreML acceleration.```bash-pip install uniface+pip install uniface[cpu]```!!! tip "Native Performance"- The base `onnxruntime` package has native Apple Silicon support with ARM64 optimizations built-in since version 1.13+. No additional configuration needed.+ `onnxruntime` 1.13+ includes ARM64 optimizations out of the box.+ UniFace automatically detects and enables `CoreMLExecutionProvider` on Apple Silicon.Verify ARM64 installation:@@ -47,18 +61,22 @@ python -c "import platform; print(platform.machine())"### Linux/Windows with NVIDIA GPU-For CUDA acceleration on NVIDIA GPUs:-```bashpip install uniface[gpu]```+This installs `onnxruntime-gpu`, which includes both `CUDAExecutionProvider` and+`CPUExecutionProvider` — no separate CPU package is needed.+**Requirements:**-- `uniface[gpu]` automatically installs `onnxruntime-gpu`. Requirements depend on the ORT version and execution provider.+- NVIDIA driver compatible with your CUDA version+- CUDA 11.x or 12.x toolkit+- cuDNN 8.x!!! info "CUDA Compatibility"- See the [ONNX Runtime GPU compatibility matrix](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html) for matching CUDA and cuDNN versions.+ See the [ONNX Runtime GPU compatibility matrix](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html)+ for matching CUDA and cuDNN versions.Verify GPU installation:@@ -70,23 +88,10 @@ print("Available providers:", ort.get_available_providers())----### FAISS Vector Store--For fast multi-identity face search using a FAISS vector store:--```bash-pip install faiss-cpu # CPU-pip install faiss-gpu # NVIDIA GPU (CUDA)-```--See the [Stores module](modules/stores.md) for usage.------### CPU-Only (All Platforms)```bash-pip install uniface+pip install uniface[cpu]```Works on all platforms with automatic CPU fallback.@@ -100,37 +105,58 @@ For development or the latest features:```bashgit clone https://github.com/yakhyo/uniface.gitcd uniface-pip install -e .++pip install -e ".[cpu]" # CPU / Apple Silicon+pip install -e ".[gpu]" # NVIDIA GPU```With development dependencies:```bash-pip install -e ".[dev]"+pip install -e ".[cpu,dev]"+```++---++## FAISS Vector Store++For fast multi-identity face search using a FAISS vector store:++```bash+pip install faiss-cpu # CPU+pip install faiss-gpu # NVIDIA GPU (CUDA)```+See the [Stores module](modules/stores.md) for usage.+---## Dependencies-UniFace has minimal dependencies:+UniFace has minimal core dependencies:| Package | Purpose ||---------|---------|| `numpy` | Array operations || `opencv-python` | Image processing |-| `onnxruntime` | Model inference || `scikit-image` | Geometric transforms |+| `scipy` | Signal processing || `requests` | Model download || `tqdm` | Progress bars |-**Optional:**+**Runtime extras (install exactly one):**++| Extra | Package | Use case |+|-------|---------|---------|+| `uniface[cpu]` | `onnxruntime` | CPU inference, Apple Silicon |+| `uniface[gpu]` | `onnxruntime-gpu` | NVIDIA CUDA inference |++**Other optional packages:**-| Package | Install extra | Purpose |-|---------|---------------|---------|+| Package | Install | Purpose |+|---------|---------|---------|| `faiss-cpu` / `faiss-gpu` | `pip install faiss-cpu` | FAISS vector store |-| `onnxruntime-gpu` | `uniface[gpu]` | CUDA acceleration |-| `torch` | `pip install torch` | Emotion model uses TorchScript |+| `torch` | `pip install torch` | Emotion model (TorchScript) || `torchvision` | `pip install torchvision` | Faster NMS for YOLO detectors |---@@ -155,17 +181,81 @@ print("Installation successful!")---+## Upgrading++When upgrading UniFace, stay consistent with your runtime extra:++```bash+pip install --upgrade uniface[cpu] # or uniface[gpu]+```++If you are switching from CPU to GPU (or vice versa):++```bash+pip uninstall onnxruntime onnxruntime-gpu -y+pip install uniface[gpu] # install the one you want+```++---++## Pre-release Versions++UniFace ships release candidates and betas to PyPI ahead of stable releases (versions like `0.7.0rc1`, `0.7.0b1`, `0.7.0a1`). These let you try upcoming features before they're finalized.++`pip install uniface` always installs the latest **stable** release. To opt in to pre-releases:++```bash+# Latest pre-release (if newer than latest stable)+pip install uniface[cpu] --pre++# A specific pre-release+pip install uniface[cpu]==0.7.0rc1+```++Pre-releases are not recommended for production — APIs may still change before the stable release.++---+## Troubleshooting+### onnxruntime Not Found++If you see:++```+ImportError: onnxruntime is not installed. Install it with one of:+ pip install uniface[cpu] # CPU / Apple Silicon+ pip install uniface[gpu] # NVIDIA GPU (CUDA)+```++You installed uniface without an extra. Run the appropriate command above.++---++### Both onnxruntime and onnxruntime-gpu Installed++If you previously ran `pip install uniface[gpu]` on top of a `pip install uniface[cpu]`+(or vice versa), you may have both packages installed simultaneously, which causes conflicts.+Fix it with:++```bash+pip uninstall onnxruntime onnxruntime-gpu -y+pip install uniface[gpu] # or uniface[cpu]+```++---+### Import Errors-If you encounter import errors, ensure you're using Python 3.10+:+Ensure you're using Python 3.10+:```bashpython --version# Should show: Python 3.10.x or higher```+---+### Model Download IssuesModels are automatically downloaded on first use. If downloads fail:@@ -179,6 +269,25 @@ model_path = verify_model_weights(RetinaFaceWeights.MNET_V2)print(f"Model downloaded to: {model_path}")```+---++### CUDA Not Detected++1. Verify CUDA installation:+ ```bash+ nvidia-smi+ ```++2. Check CUDA version compatibility with ONNX Runtime.++3. Reinstall the GPU extra cleanly:+ ```bash+ pip uninstall onnxruntime onnxruntime-gpu -y+ pip install uniface[gpu]+ ```++---+### Performance Issues on MacVerify you're using the ARM64 build (not x86_64 via Rosetta):diff --git a/docs/notebooks.md b/docs/notebooks.mdindex 4078c3d..3f5add0 100644--- a/docs/notebooks.md+++ b/docs/notebooks.md@@ -34,7 +34,7 @@ git clone https://github.com/yakhyo/uniface.gitcd uniface# Install dependencies-pip install uniface jupyter+pip install "uniface[cpu]" jupyter # or uniface[gpu] for CUDA# Launch Jupyterjupyter notebook examples/diff --git a/examples/01_face_detection.ipynb b/examples/01_face_detection.ipynbindex 78aaa8a..dda052f 100644--- a/examples/01_face_detection.ipynb+++ b/examples/01_face_detection.ipynb@@ -31,7 +31,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/02_face_alignment.ipynb b/examples/02_face_alignment.ipynbindex eb50652..bc07a21 100644--- a/examples/02_face_alignment.ipynb+++ b/examples/02_face_alignment.ipynb@@ -34,7 +34,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/03_face_verification.ipynb b/examples/03_face_verification.ipynbindex d70e16c..0bb8360 100644--- a/examples/03_face_verification.ipynb+++ b/examples/03_face_verification.ipynb@@ -30,7 +30,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/04_face_search.ipynb b/examples/04_face_search.ipynbindex fb55cf6..a6c1ac7 100644--- a/examples/04_face_search.ipynb+++ b/examples/04_face_search.ipynb@@ -28,7 +28,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/05_face_analyzer.ipynb b/examples/05_face_analyzer.ipynbindex 9166e3a..a0b1998 100644--- a/examples/05_face_analyzer.ipynb+++ b/examples/05_face_analyzer.ipynb@@ -30,7 +30,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/06_face_parsing.ipynb b/examples/06_face_parsing.ipynbindex c668aa7..1e8b153 100644--- a/examples/06_face_parsing.ipynb+++ b/examples/06_face_parsing.ipynb@@ -32,7 +32,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/07_face_anonymization.ipynb b/examples/07_face_anonymization.ipynbindex 3fa815c..cd08cb0 100644--- a/examples/07_face_anonymization.ipynb+++ b/examples/07_face_anonymization.ipynb@@ -31,7 +31,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/08_gaze_estimation.ipynb b/examples/08_gaze_estimation.ipynbindex f307941..f4756ae 100644--- a/examples/08_gaze_estimation.ipynb+++ b/examples/08_gaze_estimation.ipynb@@ -30,7 +30,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/09_face_segmentation.ipynb b/examples/09_face_segmentation.ipynbindex 9cd29bf..7ebdcaf 100644--- a/examples/09_face_segmentation.ipynb+++ b/examples/09_face_segmentation.ipynb@@ -32,7 +32,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/10_face_vector_store.ipynb b/examples/10_face_vector_store.ipynbindex 9a3cbc1..c807aac 100644--- a/examples/10_face_vector_store.ipynb+++ b/examples/10_face_vector_store.ipynb@@ -33,7 +33,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface faiss-cpu\n",+ "%pip install -q \"uniface[cpu]\" faiss-cpu\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/11_head_pose_estimation.ipynb b/examples/11_head_pose_estimation.ipynbindex 8a85707..9c48fb5 100644--- a/examples/11_head_pose_estimation.ipynb+++ b/examples/11_head_pose_estimation.ipynb@@ -30,7 +30,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/12_face_recognition.ipynb b/examples/12_face_recognition.ipynbindex cb7fb6f..fb9fc17 100644--- a/examples/12_face_recognition.ipynb+++ b/examples/12_face_recognition.ipynb@@ -44,7 +44,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/examples/13_portrait_matting.ipynb b/examples/13_portrait_matting.ipynbindex b1605bd..469e3be 100644--- a/examples/13_portrait_matting.ipynb+++ b/examples/13_portrait_matting.ipynb@@ -30,7 +30,7 @@"metadata": {},"outputs": [],"source": [- "%pip install -q uniface\n",+ "%pip install -q \"uniface[cpu]\"\n","\n","# Clone repo for assets (Colab only)\n","import os\n",diff --git a/pyproject.toml b/pyproject.tomlindex 0089368..59ad4ab 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -44,7 +44,6 @@ classifiers = [dependencies = ["numpy>=1.21.0","opencv-python>=4.5.0",- "onnxruntime>=1.16.0","scikit-image>=0.22.0","scipy>=1.7.0","requests>=2.28.0",@@ -52,8 +51,15 @@ dependencies = [][project.optional-dependencies]-dev = ["pytest>=7.0.0", "ruff>=0.4.0"]+cpu = ["onnxruntime>=1.16.0"]gpu = ["onnxruntime-gpu>=1.16.0"]+dev = ["pytest>=7.0.0", "ruff>=0.4.0", "pre-commit>=3.0.0"]+docs = [+ "mkdocs-material>=9.0",+ "pymdown-extensions>=10.0",+ "mkdocs-git-committers-plugin-2>=1.0",+ "mkdocs-git-revision-date-localized-plugin>=2.0",+][project.urls]Homepage = "https://github.com/yakhyo/uniface"diff --git a/requirements.txt b/requirements.txtindex f19f9f5..1951b4b 100644--- a/requirements.txt+++ b/requirements.txt@@ -1,7 +1,9 @@numpy>=1.21.0opencv-python>=4.5.0-onnxruntime>=1.16.0scikit-image>=0.22.0scipy>=1.7.0requests>=2.28.0tqdm>=4.64.0+# Install ONE of the following (not both):+# onnxruntime>=1.16.0 # CPU / Apple Silicon → pip install uniface[cpu]+# onnxruntime-gpu>=1.16.0 # NVIDIA CUDA → pip install uniface[gpu]diff --git a/uniface/landmark/models.py b/uniface/landmark/models.pyindex f230ad9..bc0a368 100644--- a/uniface/landmark/models.py+++ b/uniface/landmark/models.py@@ -58,7 +58,7 @@ class Landmark106(BaseLandmarker):self.model_path = verify_model_weights(model_name)self._initialize_model()- def _initialize_model(self):+ def _initialize_model(self) -> None:"""Initialize the ONNX model from the stored model path.diff --git a/uniface/onnx_utils.py b/uniface/onnx_utils.pyindex bfb7c9b..2af2b4e 100644--- a/uniface/onnx_utils.py+++ b/uniface/onnx_utils.py@@ -12,7 +12,15 @@ from __future__ import annotationsimport functools-import onnxruntime as ort+try:+ import onnxruntime as ort+except ImportError as e:+ raise ImportError(+ 'onnxruntime is not installed. Install it with one of:\n'+ ' pip install uniface[cpu] # CPU / Apple Silicon\n'+ ' pip install uniface[gpu] # NVIDIA GPU (CUDA)\n'+ 'Do not install both — they conflict.'+ ) from efrom uniface.log import Loggerdiff --git a/uniface/privacy/blur.py b/uniface/privacy/blur.pyindex 936ad50..509109e 100644--- a/uniface/privacy/blur.py+++ b/uniface/privacy/blur.py@@ -4,11 +4,14 @@from __future__ import annotations-from typing import ClassVar+from typing import TYPE_CHECKING, ClassVarimport cv2import numpy as np+if TYPE_CHECKING:+ from uniface.types import Face+__all__ = ['BlurFace', 'EllipticalBlur']@@ -137,7 +140,7 @@ class BlurFace:def anonymize(self,image: np.ndarray,- faces: list,+ faces: list[Face],inplace: bool = False,) -> np.ndarray:"""Anonymize faces in an image.