Now `kflite` supports reshaping model output. But ...
# feed
s
Now
kflite
supports reshaping model output. But what does "reshaping" mean in this context? reshaping is changing the structure (dimensions) of a tensor (model output) without changing its actual data values, for example, converting [1, 40, 8400] into [1, 8400, 40]. It reorganizes how the same elements are indexed in memory so the model output matches the format expected by the next processing step. check it out: github.com/ShadAdman/kflite
s
I'd love to use KMP ML models, but I'm currently relying on Deep Java Library because it provides production-ready examples for face detection with RetinaFace and face recognition: github.com/deepjavalibrary/…/face Would it be possible for your library to provide similar end-to-end sample code? Having complete, production-ready examples would make it much easier to get started and adopt your library.
🔥 1
f
Yeah I'm new to all of this and I remember looking at your library before, but I'd love to have samples for face recognition etc..
👍 1
s
@Stefan Oltmann @Fernando thank you. actually we already have good examples. beside the smaple project inside the library you can also checkout kamera for live detection using camera feed. but the general idea is the same as the sample app inside the library itself, which is running an object detection sample. if you needed help while using, feel free to ask. github.com/Kashif-E/Kamera @Stefan Oltmann by the way the djl library is old and it might have 16kb issue on Android.
s
Do you have examples doing the same thing? Face detection and recognition? Can I simply migrate to your lib?
I'm not (yet) quite familiar with adopting ML models to my needs, so I'm looking for ready-to-use face detection (like RetinaFace) and face recognition (fingerprinting faces to recognize persons). DeepJavaLibrary has its problems, but they offer great examples for different use cases that actually work.
s
@Stefan Oltmann I have exmaples of object detection but if you give me your model i can put an example related to your. I'll be happy to help you migrate, but i'll consider how deep you got with djl. kflite has a simple usage with a straightforward pipeline. i'm currently working on support for desktop too. if you decided to migrate you can also create an example repo based on what you need and invite me to collaborate. here is my email: adman.shadman@gmail.com If you consider contributing, that will b more then great
s
@Shadman github.com/deepjavalibrary/…/face has a sample for detection with RetinaFace and face recognition with a model unknown to me - I guess it's FaceNet or something like that. I use a Kotlin port of that exact code. Those are PyTorch models. Can you showcase how to use these models with your engine instead of DJL?
👀 1
s
@Stefan Oltmann will see. i'll let you know
👀 1
s
@Shadman Do you have any updates regarding this?
Doesn't need to be that exact models. Could be something more modern than RetinaFace like yolo v5
Just something that's easy to understand and to use
s
@Stefan Oltmann hi. I actually worked on it for couple of days. the model you mentioned earlier was using pytorch mobile for backend. i added pytorch mobile but then i found out its deprecated and its been replaced with executorch, so i added the executorch as a runtime option to kflite. if you are ok with other model i higly recemmend using tflite models. they are very small and fast. checkout this one: huggingface.co/qualcomm/Lightweight-Face-Detection/blob/…/Lightweight-Face-Detection.tflite i can put a sample on how to use it in the library.
s
To be honest I'm not so sure about that. I tried some smaller models like UltraFace and detection quality was not what I wanted. Currently I use github.com/yakhyo/retinaface-pytorch through ONNX runtime. Claude Opus helped me to migrate away from DJL and it detected the same faces on some test photos, which makes me assume that it's the same model as before. As far as I know RetinaFace has the reputation of being the most accurate open source face detection model. In my use case it's fine for an image to be detected in 50ms if results are accurate. I don't need it to detect wrong face boxes in 5ms.
To decide it would help if Qualcomm would release a WIDER FACE easy/medium/hard score. I don't find a lot of info about that particular model. Do you use it somewhere?
OK, I think I'll just test it with my own photos and run a comparison. As Qualcomm's model is faster and has a more clear license situation it might be worth it. You can show me how to use huggingface.co/qualcomm/Lightweight-Face-Detection and I'll give it a try. 🙂 Can you give me an example for huggingface.co/qualcomm/Facial-Landmark-Detection, too? I currently do face recognition in my app using SFace and for that I need landmarks from the model, too.
@Shadman I noticed that the library is now called EdgeRT ... doesn't it run on the JVM Desktop target? I've an app that runs on Desktop & Android with planned iOS support.
s
@Stefan Oltmann i'll put the examples. Yes i renamed to EdgeRt. jvm support is on the way.
👍 1
s
I ran a test on the Qualcomm detection. In 319 out of 2074 my private test photos (portraits) it missed faces or found extra ones compared to RetinaFace. That's an 15% error rate. 😕 But the model is much smaller and has a more clear license, so I guess I make the switch. Users will need to fix the faces for 15% of their photos themselves. I'll provide tooling for that.
👍 1