moskewcz / boda

Boda: A C++ Framework for Efficient Experiments in Computer Vision
Other
63 stars 12 forks source link

Changing default search path for prototxt files? #8

Open forresti opened 8 years ago

forresti commented 8 years ago

I often name my caffe config files as trainval.prototxt instead of Boda's preferred train_val.prototxt.

According to boda cnet_ana --help, the default prototxt path (ptt_fn) is: '%(models_dir)/%(in_model)/train_val.prototxt'

In my lib/boda_cfg.xml file, I added the following:

<root verbose="0"
  ...
  ptt_fn='%(models_dir)/%(in_model)/trainval.prototxt'
  ...
/>

However, when I do this, I get the following error when running boda cnet_ana:

var 'ptt_fn': error: unable to expand ref 'in_model' in filename, ref not found
----STACK TRACE (FRAMES=15-2)----
  boda(boda::str_format_from_nvm(std::string&, std::string const&, boda::lexp_name_val_map_t&)+0x575) [0x5b8f35]
  boda(boda::nesi_filename_t_init(boda::lexp_name_val_map_t*, boda::tinfo_t const*, void*)+0x34) [0x5a65b4]
  boda(boda::init_var_from_nvm(boda::lexp_name_val_map_t*, boda::vinfo_t const*, void*)+0xea) [0x5a88da]
  boda(boda::nesi_struct_init_rec(boda::lexp_name_val_map_t*, boda::cinfo_t const*, void*)+0x7d) [0x5a903d]
  boda(boda::nesi_struct_init(boda::lexp_name_val_map_t*, boda::tinfo_t const*, void*)+0x54) [0x5a90b4]
  boda(boda::nesi_init_and_check_unused_from_nia(boda::lexp_name_val_map_t*, boda::tinfo_t const*, void*)+0x25) [0x5a6775]
  boda(boda::create_and_run_has_main_t(boost::shared_ptr<boda::lexp_t>)+0x2ab) [0x5a3d3b]
  boda(boda::boda_main_arg_proc(std::ostream&, int, char**)+0x5bb) [0x5d673b]
  boda(boda::boda_main(int, char**)+0x3a) [0x5d713a]
  boda(boda::boda_main_wrap(int, char**)+0xb) [0x5d730b]
  boda(main+0x6) [0x499376]
  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f0a58129ec5]
  boda() [0x4996b4]
moskewcz commented 8 years ago

the %() expansion, while fun/useful, has some issues/limitations/quirks.

in this case, what you're seeing is that the expansion uses lexical (not dynamic) scope rules. so, in_model isn't defined at the point where ptt_fn is declared. see: https://github.com/moskewcz/boda/blob/master/src/lexp.cc#L584

clear and well documented, right? anyway, in the past, i had used dynamic scope for expansion, and it's not out of the question to change it back or otherwise tweak it.

this use case seems pretty reasonable, and i'm not sure how i'd support it currently. some workarounds off the top of my head:

alias boda_cnet_ana="boda cnet_ana --ptt_fn='%(models_dir)/%(in_model)/trainval.prototxt'"

i'll ponder a 'real' solution. in the mean time, thanks for the feedback!