https://github.com/ternaus/insightfacewrapper
Wrapper for easier inference for insightface
https://github.com/ternaus/insightfacewrapper
face-recognition insightface python
Last synced: 6 months ago
JSON representation
Wrapper for easier inference for insightface
- Host: GitHub
- URL: https://github.com/ternaus/insightfacewrapper
- Owner: ternaus
- License: mit
- Created: 2022-06-28T21:14:42.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-07T01:05:28.000Z (almost 2 years ago)
- Last Synced: 2025-03-25T13:21:14.681Z (7 months ago)
- Topics: face-recognition, insightface, python
- Language: Python
- Homepage:
- Size: 37.1 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# insightfaceWrapper
Wrapper for easier inference for insightface## Install
```
pip install -U insightfacewrapper
```## Models
* `ms1mv3_arcface_r18`
* `ms1mv3_arcface_r34`
* `ms1mv3_arcface_r50`
* `ms1mv3_arcface_r100`
* `glint360k_cosface_r18`
* `glint360k_cosface_r34`
* `glint360k_cosface_r50`
* `glint360k_cosface_r100````python
from insightfacewrapper.get_model import get_model
model = get_model()
model.eval()
```### Inference
Based on the original
[inference script](https://github.com/deepinsight/insightface/blob/master/recognition/arcface_torch/inference.py),
image should be resized to `(112, 112)`.```python
def normalize(image: np.ndarray) -> np.ndarray:
image /= 255
image -= 0.5
image /= 0.5
return imagedef image2input(image: np.ndarray) -> np.ndarray:
transposed = np.transpose(image, (2, 0, 1)).astype(np.float32)
return torch.from_numpy(normalize(np.expand_dims(np.ascontiguousarray(transposed), 0)))torch_input = image2input(image)
with torch.inference_engine():
result = model(torch_input)[0].cpu().numpy()
```