-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: pest | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.1' | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
- run: python -m pip install --upgrade pip | ||
- run: pip install deepface | ||
- run: composer install --no-interaction --no-scripts | ||
- run: vendor/bin/pest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Feature Test Suite"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use Astrotomic\DeepFace\Data\AnalyzeResult; | ||
use Astrotomic\DeepFace\Enums\Emotion; | ||
use Astrotomic\DeepFace\Enums\Gender; | ||
use Astrotomic\DeepFace\Enums\Race; | ||
use PHPUnit\Framework\Assert; | ||
|
||
describe('analyze', function ():void { | ||
it('analyzes: img1', function ():void { | ||
$img = $this->image('img1.jpg'); | ||
$results = $this->deepface()->analyze($img); | ||
|
||
Assert::assertCount(1, $results); | ||
Assert::assertContainsOnlyInstancesOf(AnalyzeResult::class, $results); | ||
|
||
$result = $results[0]; | ||
|
||
Assert::assertSame($img, $result->img_path); | ||
Assert::assertSame(339, $result->facial_area->x); | ||
Assert::assertSame(218, $result->facial_area->y); | ||
Assert::assertSame(768, $result->facial_area->w); | ||
Assert::assertSame(768, $result->facial_area->h); | ||
Assert::assertSame(Emotion::HAPPY, $result->dominant_emotion); | ||
Assert::assertSame(Gender::WOMAN, $result->dominant_gender); | ||
Assert::assertSame(Race::LATINO_HISPANIC, $result->dominant_race); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
pest()->extend(Tests\TestCase::class)->in('Feature'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Astrotomic\DeepFace\DeepFace; | ||
use PHPUnit\Framework\TestCase as BaseTestCase; | ||
|
||
abstract class TestCase extends BaseTestCase | ||
{ | ||
protected function deepface(): DeepFace | ||
{ | ||
return new DeepFace('/opt/homebrew/bin/python3.11'); | ||
} | ||
|
||
protected function image(string $img): string | ||
{ | ||
return realpath(__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures'. DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $img); | ||
} | ||
} |