Comments (12)
Do you mean the model or training data?
from facex.
Yes, you're right, I meant the model. After loading the model into memory, the process uses ~600MB.
from facex.
Er, could you try it again? It shouldn't consume so much memory. On my computer, the demo consume about 47MB. Here is a screenshot:
from facex.
I just double-checked your program and saw the same results. But in mine, the memory usage was extremely high. It only seems to happen when FaceX is called in a certain way.
I added a simple example here that causes the problem:
https://github.com/matthill/FaceX/tree/high_memory
from facex.
Does this happen when the model is being loaded or after being loaded?
In my computer, when loading the model, the memory consumption is high, but will decrease after loading. If this is what you come across, it's because of opencv. I use opencv format to store the model since it's easy to use. However, the loading process will consume much memory (will decrease after loading)
You can define your own binary format to solve this problem.
from facex.
Yes, it uses the memory when it first loads (which isn't a problem, as long as it's released). But when it's instantiated in another object (e.g., facewrapper in the branch I created) the memory is never released.
So in your main function, when you do this:
FaceX face_x(kModelFileName);
The memory is released.
But when you do this
facewrapper wrapper(kModelFileName);
The memory stays resident.
from facex.
This is what I'm seeing on this branch:
https://github.com/matthill/FaceX/tree/high_memory
from facex.
I tried your program. On windows, it just costs about 100M. On Linux, it indeed costs about 600M. I did some experiments and guess this is because there is a cache in OpenCV persistence module (just a guess). On Linux, the cache will retain for a long time.
Therefore, the solution is create a custom binary format to replace OpenCV persistence module I used.
from facex.
Are you sure that's the issue?
If I replace this section in regressor.cpp:
for( ; it != it_end; ++it, idx++ )
{
Fern f;
*it >> f;
ferns_.push_back(f);
}
With this one:
for( ; it != it_end; ++it, idx++ )
{
Fern f;
*it >> f;
//ferns_.push_back(f);
}
The memory issue seems to go away. The use of OpenCV's FileStorage seems exactly the same in both cases.
from facex.
I checked it for a long time, and still couldn't find where the problem lies. Therefore I asked on stackoverflow (http://stackoverflow.com/questions/31611741/how-to-debug-high-memory-consumption). Someone suggested me to use tcmalloc to check where the memory allocation happens. I followed his suggestion.
Then, mysterious thing happened: the problem was gone!
I still don't know where is the problem, but it seems use tcmalloc can solve it (just install gperftools and link the program with -ltcmalloc)
from facex.
just to report, running this on an old win32 box, there's only a single 350mb spike on startup, then falls down to <50mb while running. (not that bad, i'd say.)
from facex.
Yes, this problem doesn't happen on Windows.
from facex.
Related Issues (12)
- Train routines to train new model with different face detectors HOT 6
- Procrustes analysis question HOT 1
- MapShape question HOT 1
- CompressFerns question HOT 1
- speed question HOT 1
- why need a face rect? HOT 1
- kmeans question HOT 2
- space for improvement HOT 8
- optimization proposal HOT 2
- Solution for training code not working in Mac Os HOT 2
- How should I obtain a face area when training on a helen dataset? HOT 4
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 facex.