elucideye / acf

Aggregated Channel Feature object detection in C++ and OpenGL ES 2.0 based on https://github.com/pdollar/toolbox
BSD 3-Clause "New" or "Revised" License
49 stars 20 forks source link

Documentation request: model files; use of library #38

Closed mz64 closed 6 years ago

mz64 commented 6 years ago

Quick start | HOWTO is pretty self-explanatory and seems to find Lena :) but the following would be useful:

  1. minimal example or link on how to train your own models, ideally without Matlab
    • I assume that mat2cpb converts Matlab models to Cereal (?)
  2. minimal example on how to include the library (libacf?) in your own code
headupinclouds commented 6 years ago

minimal example or link on how to train your own models, ideally without Matlab

This isn't possible currently, it requires Piotr's Matlab Toolbox. It would be nice to get the training part in C++, but I haven't gotten around to it. I could probably add a pointer to the relevant toolbox scripts needed for training with a high level overview.

I assume that mat2cpb converts Matlab models to Cereal

Yes. Typically, I build w/ cvmatio support as needed to convert new *.mat models to a cereal *.cpb (portable binary archive) format, and use a cereal only build in a final application. This behavior can be controlled with the following CMake options from the command line:

ACF_SERIALIZE_WITH_CVMATIO
ACF_SERIALIZE_WITH_CEREAL

minimal example on how to include the library (libacf?) in your own code

I can add more details, or pointers to existing documentation where needed. There are two main paths for integration: 1) build your application or library using Hunter, and the dependency will be handled automatically; 2) build ACF as a shared library (or framework) so it grabs the symbols it needs from the static dependencies and include the final acf.{dylib,so,framework} in your application.

headupinclouds commented 6 years ago

For now, here is a pointer to one of the training scripts that can be used as a starting point:

https://github.com/pdollar/toolbox/blob/master/detector/acfDemoCal.m

When you have your final model you can just convert it with mat2cpb --input=model.mat --output=model.cpb then when you pass it as act-detect --model=model.cpb it should load fine.

I admit the Matlab training is a pain, but there is a home license now that is pretty reasonable. If you run into issues with training or loading let know.

mz64 commented 6 years ago

Thanks! Exactly what I needed. The main training script has pretty good documentation: https://github.com/pdollar/toolbox/blob/master/detector/acfTrain.m

I will try to train with on Octave + report back. If that works, I agree that C++ code for training is not required. The main issue with the MATLAB home license is the restriction against commercial projects.

headupinclouds commented 6 years ago

Thanks! Exactly what I needed.

Great. For now, I've added short training and integration sections to the readme w/ some relevant links:

I agree that C++ code for training is not required.

It would be a nice addition though...

mz64 commented 6 years ago

Update: Piotr's Matlab ACF scripts (git-1a3c9869033548a) do not work out-of-the-box in Octave (v.4.0), e.g.: error: ‘size_t’ was not declared in this scope

So far the issues seem to be related to C/C++ compiler settings in Octave. I will keep on digging + get back with if I can find a solution.

Piotr (in separate communication) seemed mildly sceptical about whether this is possible:

[...] I know parts of my code ran in octave. That being said it may be tough for some of the ACF as it uses SSE operations and makes assumptions about memory layout etc. that may be specific to Matlab.

Opinion: since there is no immediate way to train a model without relying on MATLAB, I think that you should leave this as an open issue.

Reasoning:

headupinclouds commented 6 years ago

I will keep on digging + get back with if I can find a solution.

Okay, thanks for the update. That would be a nice option if it worked.

I think that you should leave this as an open issue.

Sure. Please open a new issue for the training feature.