moskewcz / boda

Boda: A C++ Framework for Efficient Experiments in Computer Vision

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing default search path for prototxt files?

forresti opened this issue · comments

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]

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:

  • feel free to alter the source to change the default. it'll break the tests, but if you're not running them ...
  • put the --ptt_fn='%(models_dir)/%(in_model)/trainval.prototxt' on every command line, maybe using a shell alias like:

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

  • use symlinks to point from nets/train_val.prototxt --> whereever/trainval.prototxt

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