-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Features #14
New Features #14
Conversation
Update php-deepface
Fix Unicode characters
Fixed return wrong result
…o Astrotomic-main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that big upgrade! 🥳
Just a few points I spotted.
And it seems CodeStyle is failing: composer fix
src/DeepFace.php
Outdated
); | ||
} catch(DeepFaceException $e){ | ||
// if any of these images fails the spoof detection, it will throw 'Exception while processing imgX_path' | ||
return array("error" => $e->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's way easier to let these exceptions bubble up and let the user decide how to handle them. There's a special exception for this package the user can catch and do whatever needed. While catching the array will be harder and also not as straight forward.
Or what's the reason to catch the exception in package and only provide an array to the user? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verify
method would throw Exception while processing imgX_path
if any of the images is spoofed, since it uses extract_faces
when verifying, and since the function returns a VerifyResult
, I added array as a return to catch the exception message.
I can change it to any other way to return the exception or handle it in a different way if you have a better idea 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think best would be to let the exception just bubble up and do nothing about it in the package (for all methods). That way each user can decide what they do with that exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
src/DeepFace.php
Outdated
$errorResult = json_decode($lastJson, true); | ||
|
||
if ($errorResult !== null && isset($errorResult['error'])) { | ||
throw new DeepFaceException($errorResult['error']); // should return 'Spoof detected in the given image' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment isn't needed. If there's a special scenario for "Spoof detected in the given image" and that exception message stays the same we can make a dedicated exception for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left it there since I thought that Deepface returned "Spoof detected in the given image" everytime, but upon inspection of the recent changes they added, it returns a different message under ValueError
, so, $errorResult['error']
can be any error thrown by the script.
I can remove the comment if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, please remove it. Or if there is any special string we can match to a special exception do that one. But I'm fine with one exception for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I've seen #12 and forgot to point out that this update works with v0.0.92 of deepface, old versions of this package should work with <= v0.0.91 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it - thanks a lot! 🥳
Added new anti_spoofing feature
Fixed Unicode characters
Fixed wrong result being returned in Verify function
output['Verified']
to'True'
it would return false, resulting in the wrong outcome even if the face is verified.Updated scripts to handle Exceptions.
ValueError
exceptions and output the error usingstderr
.Added custom exception.
I published a new release on my fork, feel free to test it and let me know any problem!