LightCNN
Fast and accurate face recognition model optimized for Central Asian faces. This PyTorch implementation provides an easy-to-use interface for face verification and feature extraction.
Features
- LightCNN-V4 architecture optimized for Central Asian faces
- Fast and lightweight face verification
- Automatic face alignment and preprocessing
- Easy-to-use Python API
- Pre-trained model weights included
Installation
pip install lightcnn-pytorch
Quick Start
from lightcnn_pytorch import LightCNN
# Initialize model (automatically downloads weights)
model = LightCNN()
# Verify two face images
similarity, is_same, confidence = model.verify("person1.jpg", "person2.jpg")
print(f"Similarity score: {similarity:.3f}")
print(f"Same person: {is_same}")
print(f"Confidence: {confidence:.3f}%")
Usage
Face Verification
# Compare two face images
similarity, is_same, confidence = model.verify(image1, image2)
The verify method returns:
similarity: Cosine similarity score (-1 to 1)is_same: Boolean indicating if images are of the same personconfidence: Confidence score (0-100%)
Feature Extraction
# Get face embedding features
features = model.get_features(image)
Input Formats
- File path (
str) - BGR image array (
numpy.ndarray) - RGB image array will be converted to BGR automatically
Device Selection
# Use specific device
model = LightCNN(device="cuda") # or "cpu"
Model Details
- Architecture: LightCNN-V4
- Input: 128x128 BGR image
- Preprocessing:
(x - 127.5) / 128.0 - Output: 256-dimensional feature vector
- Verification threshold: 0.7
Metadata
Release files for lightcnn-pytorch 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lightcnn_pytorch-1.2.1.tar.gz | 6.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lightcnn_pytorch-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB
Release files / lightcnn_pytorch-1.2.1.tar.gz
| Download URL | lightcnn_pytorch-1.2.1.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4893899bfbb29f758cf2d865d1d1df5309a2a38c661114a2ac8a63243e995ce3
|
|
BLAKE2b-256 checksum How to use checksums |
ae0de7cbc0e6d47a6bb4cd31f1d69773a3d7d57c78035a00e0e0e49a3678df70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / lightcnn_pytorch-1.2.1-py3-none-any.whl
| Download URL | lightcnn_pytorch-1.2.1-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed5b7745b196310719c06e6845b2d6aba6ba8d78dd5e86a30712dfcdceda38d4
|
|
BLAKE2b-256 checksum How to use checksums |
58e2e4c9f72df9e0ee6bb7d9e8cb06ad65319584671041f7fdd73c5f2aa8db82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|