Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,132 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- face-detection
|
| 5 |
+
- face-alignment
|
| 6 |
+
- face-parsing
|
| 7 |
+
- face-restoration
|
| 8 |
+
- computer-vision
|
| 9 |
+
- python-3-14
|
| 10 |
+
- wheels
|
| 11 |
+
- comfyui
|
| 12 |
+
- stable-diffusion
|
| 13 |
+
- forge
|
| 14 |
+
library_name: facexlib
|
| 15 |
---
|
| 16 |
+
|
| 17 |
+
# FaceXLib (Universal Python 3.12 / 3.13 / 3.14 Compatible Build)
|
| 18 |
+
|
| 19 |
+
Universal, pure-Python wheel distribution for **`facexlib`** (v0.3.0), optimized for modern Python runtime environments (Python 3.10 through Python 3.14+).
|
| 20 |
+
|
| 21 |
+
Original upstream repository: [xinntao/facexlib](https://github.com/xinntao/facexlib)
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## Overview
|
| 26 |
+
|
| 27 |
+
`facexlib` is a foundational computer vision library providing standardized face processing modules (detection, alignment, parsing, tracking, assessment, and restoration preprocessing) widely utilized across AI generation and restoration ecosystems, including **ComfyUI**, **Stable Diffusion WebUI Forge**, **GFPGAN**, **CodeFormer**, **RestoreFormer**, **IOPaint**, and **ReActor**.
|
| 28 |
+
|
| 29 |
+
Standard upstream releases pin legacy dependencies (specifically `numba` and restrictive `filterpy` builds) that frequently fail to compile or install on modern Python releases (Python 3.12, 3.13, and 3.14). This universal build solves those environment blockers while preserving 100% API and functional compatibility.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## Key Improvements in this Release
|
| 34 |
+
|
| 35 |
+
1. **Numba-Free / Safe JIT Fallback**:
|
| 36 |
+
- Upstream `data_association.py` hard-required `numba.jit`, causing installation and import failures in Python 3.12+ environments where prebuilt Numba wheels were unavailable.
|
| 37 |
+
- Replaced with a graceful fallback wrapper (`try ... except ImportError`) that defaults to native vectorized NumPy/SciPy operations when Numba is not installed.
|
| 38 |
+
2. **Cleaned & Minimal Dependency Tree**:
|
| 39 |
+
- Removed strict dependency pins. Core requirements are lightweight and modern:
|
| 40 |
+
- `numpy`
|
| 41 |
+
- `opencv-python`
|
| 42 |
+
- `Pillow`
|
| 43 |
+
- `scipy`
|
| 44 |
+
- `tqdm`
|
| 45 |
+
3. **Universal Pure-Python Wheel (`py3-none-any.whl`)**:
|
| 46 |
+
- Platform-independent (Windows, Linux, macOS) and architecture-independent (x86_64, ARM64/Apple Silicon).
|
| 47 |
+
- Zero C/C++ compilation requirements during `pip install`.
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## Installation
|
| 52 |
+
|
| 53 |
+
### Direct Install via pip
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
pip install https://huggingface.co/ussoewwin/facexlib/resolve/main/facexlib-0.3.0-py3-none-any.whl
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### In `requirements.txt`
|
| 60 |
+
|
| 61 |
+
```text
|
| 62 |
+
facexlib @ https://huggingface.co/ussoewwin/facexlib/resolve/main/facexlib-0.3.0-py3-none-any.whl
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
## Core Capabilities
|
| 68 |
+
|
| 69 |
+
| Module | Available Backends / Models | Typical Use Case |
|
| 70 |
+
| :--- | :--- | :--- |
|
| 71 |
+
| **`detection`** | RetinaFace (`resnet50`, `mobile0.25`), YOLOv5-face | High-precision face bounding box & 5-point landmark detection |
|
| 72 |
+
| **`alignment`** | 5-point similarity transformation, cropped affine warping | Face normalization for restoration models (GFPGAN / CodeFormer) |
|
| 73 |
+
| **`parsing`** | BiSeNet (19-class semantic segmentation) | Hair, skin, eye, mouth, and accessory segmentation |
|
| 74 |
+
| **`tracking`** | SORT with Kalman Filter | Real-time temporal face association in video pipelines |
|
| 75 |
+
| **`assessment`** | HyperIQA, MUSIQ | No-reference image and facial perceptual quality evaluation |
|
| 76 |
+
| **`recognition`** | ArcFace | Deep facial feature extraction and verification |
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
## Quick Start Example
|
| 81 |
+
|
| 82 |
+
### 1. Face Detection & Landmark Extraction
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
import cv2
|
| 86 |
+
import torch
|
| 87 |
+
from facexlib.detection import init_detection_model, detect_faces
|
| 88 |
+
|
| 89 |
+
# Initialize RetinaFace detector (auto-downloads weights on first run)
|
| 90 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 91 |
+
det_net = init_detection_model("retinaface_resnet50", half=False, device=device)
|
| 92 |
+
|
| 93 |
+
# Load image (BGR)
|
| 94 |
+
img = cv2.imread("input.jpg")
|
| 95 |
+
|
| 96 |
+
# Detect faces
|
| 97 |
+
with torch.no_grad():
|
| 98 |
+
bboxes = detect_faces(det_net, img, device=device)
|
| 99 |
+
|
| 100 |
+
print(f"Detected {len(bboxes)} faces.")
|
| 101 |
+
# bboxes format: [[x1, y1, x2, y2, score, landmark_5x2...], ...]
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
### 2. Face Semantic Parsing (BiSeNet)
|
| 105 |
+
|
| 106 |
+
```python
|
| 107 |
+
import torch
|
| 108 |
+
from facexlib.parsing import init_parsing_model, parsenet
|
| 109 |
+
|
| 110 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 111 |
+
parse_net = init_parsing_model(model_name="bisenet", device=device)
|
| 112 |
+
|
| 113 |
+
# Input: Cropped & aligned 512x512 face tensor
|
| 114 |
+
with torch.no_grad():
|
| 115 |
+
# out tensor contains 19-class segmentation logits
|
| 116 |
+
pass
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
## Automatic Weight Management
|
| 122 |
+
|
| 123 |
+
Pretrained model weights continue to be automatically fetched and cached in standard local directories on demand:
|
| 124 |
+
- Windows: `%USERPROFILE%/.cache/facexlib/weights/`
|
| 125 |
+
- Linux / macOS: `~/.cache/facexlib/weights/`
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## License
|
| 130 |
+
|
| 131 |
+
- **Library & Code**: Apache License 2.0 (compatible with upstream `facexlib`).
|
| 132 |
+
- **Underlying Model Checkpoints**: Subject to their respective original licenses (RetinaFace, BiSeNet, ArcFace, etc.).
|