https://github.com/astrotomic/php-deepface
A PHP adapter for the python deepface framework.
https://github.com/astrotomic/php-deepface
age-prediction arcface deep-learning deepface deepid emotion-recognition face-analysis face-recognition facenet facial-expression-recognition facial-recognition gender-prediction hacktoberfest machine-learning openface race-classification treeware vgg-face
Last synced: 3 months ago
JSON representation
A PHP adapter for the python deepface framework.
- Host: GitHub
- URL: https://github.com/astrotomic/php-deepface
- Owner: Astrotomic
- License: mit
- Created: 2023-10-09T13:41:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-15T14:40:07.000Z (over 1 year ago)
- Last Synced: 2024-10-29T21:06:02.418Z (about 1 year ago)
- Topics: age-prediction, arcface, deep-learning, deepface, deepid, emotion-recognition, face-analysis, face-recognition, facenet, facial-expression-recognition, facial-recognition, gender-prediction, hacktoberfest, machine-learning, openface, race-classification, treeware, vgg-face
- Language: PHP
- Homepage: https://github.com/serengil/deepface
- Size: 60.5 KB
- Stars: 36
- Watchers: 4
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHP DeepFace: Advanced Face Recognition for PHP
[](https://packagist.org/packages/astrotomic/php-deepface)
[](https://github.com/Astrotomic/php-deepface/blob/master/LICENSE)
[](https://plant.treeware.earth/Astrotomic/php-deepface)
[](https://www.larabelles.com/)
[](https://packagist.org/packages/astrotomic/php-deepface)
[](https://packagist.org/packages/astrotomic/php-deepface)
[](https://github.com/Astrotomic/php-deepface/actions/workflows/pint.yml)
[](https://packagist.org/packages/astrotomic/php-deepface)
[](https://forest.astrotomic.info)
[](https://forest.astrotomic.info)
[](https://github.com/sponsors/Gummibeer)
Welcome to PHP DeepFace, a powerful face recognition and facial attribute analysis package for PHP. With PHP DeepFace, you can effortlessly integrate cutting-edge deep learning models into your PHP applications for a wide range of face-related tasks. Here's how you can get started:
## Installation
To get started, you'll need to install the [deepface](https://github.com/serengil/deepface/tree/master#installation--) Python framework. You can do this using pip:
```bash
pip install deepface
```
Once you've installed deepface, you can then install the PHP adapter via Composer:
```bash
composer require astrotomic/php-deepface
```
## Configuration
Configuring PHP DeepFace is a breeze. Simply instantiate the `Astrotomic\DeepFace\DeepFace` class, and it will automatically detect your local Python executable:
```php
$deepface = new \Astrotomic\DeepFace\DeepFace();
```
If you have a specific Python version you'd like to use, you can provide the path to the Python executable as an argument:
```php
$deepface = new \Astrotomic\DeepFace\DeepFace(
python: '/usr/bin/python3',
);
```
## Usage
PHP DeepFace provides a wide range of functionalities for face recognition and facial attribute analysis. Here are some key features:
### Build Model
You can build a deepface face recognition or facial attribute model with ease:
```php
$deepface->buildModel(\Astrotomic\DeepFace\Enums\FaceRecognitionModel::VGGFACE);
```
### Face Detection
Perform face detection and alignment using this function:
```php
$deepface->extractFaces(
img_path: '~/test.png',
);
```
### Face Verification
Verify whether two images belong to the same person or different persons. This function calculates the similarity between facial image vectors:
```php
$deepface->verify(
img1_path: '~/test.png',
img2_path: '~/id.jpg',
);
```
### Face Recognition
Find identities in a database by applying verification multiple times:
```php
$deepface->find(
img_path: '~/test.png',
db_path: '~/db',
);
```
### Face Embeddings
Generate vector embeddings for facial images using convolutional neural networks models:
```php
$deepface->represent(
img_path: '~/test.png',
);
```
### Facial Attribute Analysis
Analyze facial attributes including age, gender, emotion, and race. This function builds convolutional neural network models to classify these attributes:
```php
$deepface->analyze(
img_path: '~/test.png',
);
```
## Testing
Run tests to ensure everything is working as expected:
```bash
composer fix
```
## Contributing
We welcome contributions! Please see our [CONTRIBUTING](https://github.com/Astrotomic/.github/blob/master/CONTRIBUTING.md) guidelines for details. You may also want to review our [CODE OF CONDUCT](https://github.com/Astrotomic/.github/blob/master/CODE_OF_CONDUCT.md).
### Security
If you discover any security-related issues, please follow the steps outlined in our [SECURITY](https://github.com/Astrotomic/.github/blob/master/SECURITY.md) guidelines to report them.
## Credits
- [Tom Herrmann](https://github.com/Gummibeer)
- [Sefik Ilkin Serengil](https://github.com/serengil), the creator of [deepface](https://github.com/serengil/deepface)
- [All Contributors](../../contributors)
## License
PHP DeepFace is released under the MIT License. Please see the [License File](LICENSE.md) for more information.
## Treeware
You're free to use this package, but if it makes it to your production environment, we kindly request that you contribute to a greener world by planting a tree.
Trees play a vital role in combating climate change and preserving our environment.
You can buy trees at [offset.earth/treeware](https://plant.treeware.earth/Astrotomic/php-deepface). Help us make a positive impact! 🌳