Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTrainNodeCvRF: serialization problem #8

Open
ereator opened this issue Jul 2, 2017 · 2 comments
Open

CTrainNodeCvRF: serialization problem #8

ereator opened this issue Jul 2, 2017 · 2 comments

Comments

@ereator
Copy link
Member

ereator commented Jul 2, 2017

The CTrainNodeCvRF::save() / CTrainNodeCvRF::load() seems to not working.
When loading the training data (saved before with CTrainNodeCvRF::save() function) with the CTrainNodeCvRF::load() function, the random forest appears to be empty and the first call of the CTrainNodeCvRF::getNodePotentials() function causes an exception.

However, it is possible to successfully load the training data, which was saved by the DGM v.1.5.0.

In order to reproduce, please insert into the Demo Train the code:
nodeTrainer->save("D:\\");
nodeTrainer->reset();
nodeTrainer->load("D:\\");

after the line
nodeTrainer->train();

@ereator
Copy link
Member Author

ereator commented Jul 5, 2017

After a short investigaton, it is appeared that this bug is related to OpenCV library, which is responsible for serialization. The DGM v.1.5.1 and DGM v.1.5.2 uses OpenCV v.3.2.0, while the DGM v.1.5.0 used OpenCV v.3.1.0. The data files, serialized with the OpenCV v.3.1.0 are still possible to read, using the latest version. The only difference with the data files, serialized with the OpenCV v.3.2.0 is in the file header:

File saved with OpenCV v.3.2.0:

%YAML:1.0
---
opencv_ml_dtree:
   is_classifier: 1
   var_all: 4
   ...

File saved with OpenCV v.3.1.0:

%YAML:1.0
opencv_ml_dtree:
   format: 3
   is_classifier: 1
   var_all: 4
   ...

Quick Fix

Add the string
format: 3
to the saved data file in order to read it with CTrainNodeCvRF::load()

@ereator
Copy link
Member Author

ereator commented Dec 11, 2017

This bug is absent in the newer version of OpenCV v.3.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant