4

Is it possible to load the model for a FaceRecognizer from memory or a string rather than from a saved file. The API docs do not show a 'FromString or Buffer' version.

The current code loads from file:

model = cv2.createLBPHFaceRecognizer()
model.load('model.xml')

Some more background. The presisted models are stored in S3. I don't want to retrieve from S3 and then save to disk in order to use. I would rather load directly from s3 into the model or load the xml string/document into the model.

1 Answer 1

4

unfortunately, not possible from python ( cv2 ) atm.

while you can do it from c++ ,

string yml; // the whole schlepp in a string
FileStorage fs;
fs.open(yml,FileStorage::READ|FileStorage::MEMORY);
facereco->load(fs);
fs.release();

sad as it is, you can neither access FileStorage api, nor the FaceReco::load(FileStorage&) methods from python

(sidenote : at least you could resave them once from the facereco as yml.gz, to get the traffic down to 1/5 of the uncompressed xml)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the info. Too bad I can't do it from python yet - this would be a nice feature to add to cv2. Will also look into using yml.
yea, i know, been playing around with heroku and such myself, where ther's no treal filesystem, or only an ephemeral one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.