Comments (8)
Yep seems like you are right. Looking at the weight loader it's a simple scaling operation to dequantize the weights.
Awesome! I will try to get this running soon, decreasing the model size from 28mb to 7mb looks promising.
from face-api.js.
And here it is :)
model weights have been quantized, to reduce the model size by ~75%:
- face detection model: 21.7 MB -> 5.4 MB
- face recognition model: 28.7 MB -> 7.0 MB
- face landmark model: 21.9 MB -> 6.2 MB
plus model weights are sharded in chunks of 4 MB to allow them to be cached in the browser
from face-api.js.
Hi,
You are right, the weights are not quantized. I am not familar yet with how to run inference with a quantized model and whether it's possible with tfjs. But it would be awesome if we could reduce the model sizes that way. I will dig into it.
from face-api.js.
The process of quantization is just changing your weights from float32 to uint8 so you get a 4 times size decrease. I usually do it trough the converter
from face-api.js.
I know that you can quantize the weights using bazel, but do the weights simply get dequantized once you load them again?
I read somewhere that the ops in the network have to be aware of the quantized weights to run inference, but I might be wrong here.
In the first case, that should hopefully be easy to implement.
from face-api.js.
I'm not sure I never did manual quantization.
https://github.com/tensorflow/tfjs-converter/blob/master/python/tensorflowjs/quantization_test.py
From the looks of it there could be a default scaling based on type
from face-api.js.
Update: So I managed to quantize the weights for the face detection and the face landmark model. Currently the changes are available on this branch.
Apparently quantizing the face recognition model is not as straight forward, as it originally was not a tensorflow model. The issue here is that simply quantizing all weights will make the model unusable, in a way that it returns wrong outputs. Right now, it seems that leaving the weights for the conv64 layers uncompressed and quantize the rest does work out however.
Long story short: I am still working on it.
from face-api.js.
Thanks, will check it out
from face-api.js.
Related Issues (20)
- Samsung device has low accuracy when detect face
- Unable to load the content of http://localhost:5173/node_modules/face-api.js/src/faceProcessor/FaceProcessor.ts (HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE). HOT 1
- Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'e.isContextLost')
- Perhaps a stupid question - Is this project still in active development ? If so where is the latest version. HOT 1
- Security vulnerability - patch HOT 1
- Source map failed warning issue
- Can face-api.js filter faces from webRTC streams in real time?
- Integration with React Native? HOT 1
- How to boost performance speed on browser? HOT 1
- No detections when there is big backlight or black mask on faces
- Wow
- How do I import with vite?
- problem detection HOT 1
- Initialization of backend wasm failed
- Face recognition and emotion detection is not working on some devices
- How to I get current coordinates by viewport for a detected face for different devices HOT 1
- mysql
- slow
- descriptors for reference
- Error: readFile - filesystem not available for browser environment HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from face-api.js.