You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request : ability to load Caffe/Tensorflow from FileStorage or from similar in-memory #9765
@r2d3, As you mentioned, Google Protobuf -based importers open file streams internally. You may start from Caffe and TensorFlow importers. I think it's not necessary to name methods differently. Just something like:
Activity
dkurt commentedon Oct 4, 2017
@r2d3, have you tried to save some of models in
xml.gzformat by http://docs.opencv.org/master/da/d56/classcv_1_1FileStorage.html#a5f12cb8b2f78e7a9708cd03c69133732? Does it give any compression profit?r2d3 commentedon Oct 4, 2017
Hello @dkurt,
the problem is not compressing the data. The use case is to load data that are not on disk or not in a .pb/.caffemodel/.prototxt file.
For example, the binary stream representing my pb/caffemodel file could be embedded in a .xml/.yml file loaded via FileStorage.
Presenting an API that accepts FileStorage/FileNode as input for readNetFrom*() will extend the way we could read it.
For example, readNetFromTensorflow is using a std::ifstream internally, so perhaps just exposing an API that accepts an std::istream could be OK.
Solonets commentedon Oct 31, 2017
That is a must-have feature: Raw model files are not usually accessible in final products: they can be embedded, encrypted or even dynamic.
r2d3 commentedon Oct 31, 2017
I have written a first version for TensorFlow : https://github.com/r2d3/opencv/tree/dnn_memory_load
https://github.com/r2d3/opencv/blob/dnn_memory_load/modules/dnn/src/tensorflow/tf_io.cpp
using
ZeroCopyInputStream* raw_input = new ArrayInputStream(data, len);
instead of
ZeroCopyInputStream* raw_input = new IstreamInputStream(&fs);
But at the moment, I have to think at the API to give. At the moment, I named it:
Net readNetFromTensorflowBuffer(const char *buffer, size_t len);
I am not sure if there is a "prettier" way to go.
I could make a PR for this patch, it will give a starting point
dkurt commentedon Oct 31, 2017
@r2d3, As you mentioned, Google Protobuf -based importers open file streams internally. You may start from Caffe and TensorFlow importers. I think it's not necessary to name methods differently. Just something like:
Also we need to check Python/Java wrappers for it.
Can I assign you to this issue?
r2d3 commentedon Oct 31, 2017
Yes, you can assign this issue to me
I will use the proposed naming convention
I will add loader for other framework than TensorFlow. Probably we will need to add this to the tests
Solonets commentedon Oct 31, 2017
@r2d3 Keep us informed, I can help with it as well.
r2d3 commentedon Nov 2, 2017
I submitted a first PullRequest to discuss various question: