shubham0204 / facerecognition_with_facenet_android Goto Github PK
View Code? Open in Web Editor NEWFace Recognition using the FaceNet model and MLKit on Android.
License: Apache License 2.0
Face Recognition using the FaceNet model and MLKit on Android.
License: Apache License 2.0
Hi Shubham,
I wanted to test the efficiency of facenet tf lite model so i tried running your app but it always gives the toast as " could not read images make sure you have files according to readme "
I rebuild your app and added the google services file, i added all the READ/WRITE permissions and i found that imageDir give the proper director but imageDir.listfiles return a null exception. I have directories in the images folder as specified but it is unable to list them
Hi,
I try to build the project and debug it after press USE THIS FOLDER button, suddenly the apps crash and here is the error message
` detectFacesImageByteArray.start()
Access denied finding property "ro.mediatek.platform"
detectFacesImageByteArray.end()
FATAL EXCEPTION: main
Process: com.ml.quaterion.facenetdetection, PID: 5566
java.lang.IllegalArgumentException: x must be >= 0
at android.graphics.Bitmap.checkXYSign(Bitmap.java:432)
at android.graphics.Bitmap.createBitmap(Bitmap.java:862)
at android.graphics.Bitmap.createBitmap(Bitmap.java:825)
at com.ml.quaterion.facenetdetection.BitmapUtils$Companion.cropRectFromBitmap(BitmapUtils.kt:46)
at com.ml.quaterion.facenetdetection.FileReader$getEmbedding$2.invokeSuspend(FileReader.kt:109)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4a30289, Dispatchers.Main]
Please help!
Hi,
Could you please let me know how to train the facenet model ??
Any reference or links??
Thanks in advance
when I using rear camera for scanning face. It doesn't show bounding box overlay correctly.
Hi everyone,
I got the error i.e.,
E/Model: Exception in FrameAnalyser ......... : Cannot copy to a TensorFlowLite tensor (input_1) with 307200 bytes from a Java Buffer with 150528 bytes.
if face is there in the frame then only i got this error.
Please help anyone to resolve this issue
I apologize for asking something so basic.
How can I save in a local text file the name of the faces that the application has detected?
Thank you very much for your help.
I've created the images folder as you mentioned in ReadMe document but still face recognition is not happening. I'm getting following logs
2020-09-14 22:31:51.541 26060-26060/com.ml.quaterion.facenetdetection E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 22:31:51.550 26060-26060/com.ml.quaterion.facenetdetection E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 22:31:51.564 26060-26060/com.ml.quaterion.facenetdetection E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 22:31:51.589 26060-26093/com.ml.quaterion.facenetdetection E/libc: Access denied finding property "persist.vendor.camera.privapp.list"
2020-09-14 22:31:51.603 26060-26078/com.ml.quaterion.facenetdetection E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 22:31:51.603 26060-26078/com.ml.quaterion.facenetdetection E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 22:31:51.722 26060-26093/com.ml.quaterion.facenetdetection E/libc: Access denied finding property "persist.vendor.camera.privapp.list"
2020-09-14 22:31:51.733 26060-26078/com.ml.quaterion.facenetdetection E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 22:31:52.414 26060-26212/com.ml.quaterion.facenetdetection E/Infoooooooooooooo: 90
2020-09-14 22:31:53.088 26060-26212/com.ml.quaterion.facenetdetection E/Infoooooooooooooo: 90
How about implementing options for Front Camera?
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8387)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: java.lang.IllegalArgumentException: Internal error: Failed to apply delegate: ModifyGraphWithDelegate is disallowed when graph is immutable.
at org.tensorflow.lite.NativeInterpreterWrapper.applyDelegate(Native Method)
at org.tensorflow.lite.NativeInterpreterWrapper.applyDelegates(NativeInterpreterWrapper.java:373)
at org.tensorflow.lite.NativeInterpreterWrapper.init(NativeInterpreterWrapper.java:85)
at org.tensorflow.lite.NativeInterpreterWrapper.(NativeInterpreterWrapper.java:63)
at org.tensorflow.lite.Interpreter.(Interpreter.java:277)
at com.ml.quaterion.facenetdetection.model.FaceNetModel.(FaceNetModel.kt:73)
at com.ml.quaterion.facenetdetection.MainActivity.onCreate(MainActivity.kt:122)
at android.app.Activity.performCreate(Activity.java:8121)
at android.app.Activity.performCreate(Activity.java:8109)
private val useGpu = true
private val useXNNPack = true
private val modelInfo = Models.FACENET_QUANTIZED
Hello,
The application runs well in two phones that I tested but not in a tablet, when i try to install it show an error message "There was a problem parsing the package".
What could it be?
Hi, i am getting facelist.size is ''0'' . may i know why this is coming.
After that one i am getting this log I/Model: Average score for each user : {}
and then it is going into cache the error in cache was
E/Model: Exception in FrameAnalyser : null
Can you explain why this is going to cache and what i have to do to work the sample properly.
I am using using your latest code.
once the app is launched it cannot show the bounding box over the face.
Please solve my issue as possible as fast.
App working correctly on all devices I have, but somehow on Samsung A21s, it is producing incorrect results.
It is nearly producing same output for all faces probability between .2 .3, for l2, cosine is also the same.
I thought maybe camera is the problem, so I embedded the pictures inside drawable and matched, but still it is producing nearly the same results for everything.
I noticed FloatArray returned from getCroppedFaceEmbedding producing different results for different phones.
My xiaomi mi9 works alright.
Do you have any ideas?
I really appreciated this works very well with few images. How to avoid blocking UI and also to work smoothly with many no of images ?
when i run the app on tablet with landscap orientation the recognation is alaways unknown
Hi, I encounter the following error when using a tflite model that has been converted and quantized by toco.
Process: com.ml.quaterion.facenetdetection, PID: 4034
java.lang.IllegalArgumentException: Cannot copy to a TensorFlowLite tensor (input) with 76800 bytes from a Java Buffer with 307200 bytes.
at org.tensorflow.lite.TensorImpl.throwIfSrcShapeIsIncompatible(TensorImpl.java:416)
at org.tensorflow.lite.TensorImpl.setTo(TensorImpl.java:140)
at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:243)
at org.tensorflow.lite.InterpreterImpl.runForMultipleInputsOutputs(InterpreterImpl.java:107)
at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:80)
at org.tensorflow.lite.InterpreterImpl.run(InterpreterImpl.java:100)
at org.tensorflow.lite.Interpreter.run(Interpreter.java:80)
at com.ml.quaterion.facenetdetection.model.FaceNetModel.runFaceNet(FaceNetModel.kt:104)
at com.ml.quaterion.facenetdetection.model.FaceNetModel.getFaceEmbedding(FaceNetModel.kt:83)
at com.ml.quaterion.facenetdetection.FileReader$getEmbedding$2.invokeSuspend(FileReader.kt:108)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
The model is converted from facenet pretrained model to tflite by QUANTIZED_UINT8 format, the model size is reduced from 93MB to about 23MB, the problem should be caused by the mismatch between UINT8 and FLOAT, I would like to ask how to convert the tflite model in the assets directory of the project and reduce the model size while maintaining the FLOAT format.
I think we can migrate to Ml Kit now for this demo.
https://developers.google.com/ml-kit/migration
HI i am getting same name for every image i.e., first image name. may i know what is the problem. Please inform me is there any issue with code? If that face doesn't added in the folder also it is showing random name
App crashes on samsung mobile where as other ML KIT apps are working
First of all is it supported , current version recognizes but naming is flipped for users.
Hi I am trying to run it on API 21, But in FrameAnalyser.kt
line no 164 boundingBoxOverlay.invalidate()
will through exception.
Please help me I am a beginner Thanks in advance.
E/AndroidRuntime: FATAL EXCEPTION: Thread-3
Process: com.example.facerecognition, PID: 12921
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7809)
at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1338)
at android.view.ViewGroup.invalidateChild(ViewGroup.java:5446)
at android.view.View.invalidateInternal(View.java:14749)
at android.view.View.invalidate(View.java:14713)
at android.view.View.invalidate(View.java:14697)
at com.example.facerecognition.FrameAnalyser$analyze$1$1.run(FrameAnalyser.kt:150)
at java.lang.Thread.run(Thread.java:762)
how to detect and recognize face when the device is using landscape orientation?
Model is working fine, thanks for that. But how can I switch the metric used to cosine similarity so that I can compare its performance against l2norm thanks. Btw the variable metrictobeused in frameanalyzer kt as stated in the documents does not exist.
I've done the following test.
I take a photograph of a person (my friend Tom) and put it in his folder. I open the app and the app reads the folder (I only have one person).
ok, the app recognizes all people like Tom, shouldn't it show a warning that his photograph is missing or directly ignore those people?
(if necessary I can record a video showing it to you)
best regards.
FATAL EXCEPTION: main
Process: com.ml.quaterion.facenetdetection, PID: 11467
java.lang.IllegalArgumentException: Internal error: Failed to run on the given Interpreter: Can not open OpenCL library on this device - dlopen failed: library "libOpenCL.so" not found
Falling back to OpenGL
TfLiteGpuDelegate Invoke: GpuDelegate must run on the same thread where it was initialized.
Node number 181 (TfLiteGpuDelegateV2) failed to invoke.
at org.tensorflow.lite.NativeInterpreterWrapper.run(Native Method)
at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:249)
at org.tensorflow.lite.InterpreterImpl.runForMultipleInputsOutputs(InterpreterImpl.java:133)
at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:80)
at org.tensorflow.lite.InterpreterImpl.run(InterpreterImpl.java:126)
at org.tensorflow.lite.Interpreter.run(Interpreter.java:80)
at com.ml.quaterion.facenetdetection.model.FaceNetModel.runFaceNet(FaceNetModel.kt:87)
at com.ml.quaterion.facenetdetection.model.FaceNetModel.getFaceEmbedding(FaceNetModel.kt:79)
at com.ml.quaterion.facenetdetection.FileReader$getEmbedding$2.invokeSuspend(FileReader.kt:108)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@a0c68f4, Dispatchers.Main]
Hi,
It was a great code thanks for it.
I am struggling from few days, but could able to achieve face recognition.
Is it possible to have SVM integrated with this module?
Can we adapt codes to support Landscape mode?
Hi,
Do you think doing face alignment preprocessing before send to facenet model to generate the embedding will increase the accuracy?
Hi,
Can the source of the photo not be from storage but from a photo url?
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.