void load_gd_param(configuration &conf, gd_param &gdp) { // mandatory learning parameters gdp.eta = conf.get_double("eta"); // optional learning parameters if (conf.exists("reg_time")) gdp.decay_time = conf.get_intg("reg_time"); if (conf.exists("reg_l1")) gdp.decay_l1 = conf.get_double("reg_l1"); if (conf.exists("reg_l2")) gdp.decay_l2 = conf.get_double("reg_l2"); if (conf.exists("inertia")) gdp.inertia = conf.get_double("inertia"); if (conf.exists("anneal_value")) gdp.anneal_value = conf.get_double("anneal_value"); if (conf.exists("anneal_period")) gdp.anneal_period = conf.get_intg("anneal_period"); if (conf.exists("gradient_threshold")) gdp.gradient_threshold = conf.get_double("gradient_threshold"); // printing parameters eblprint(gdp << std::endl); }
void detection_thread<T>::init_detector(detector<T> &detect, configuration &conf, std::string &odir, bool silent) { // multi-scaling parameters double maxs = conf.try_get_double("max_scale", 2.0); double mins = conf.try_get_double("min_scale", 1.0); t_scaling scaling_type = (t_scaling) conf.try_get_uint("scaling_type", SCALES_STEP); double scaling = conf.try_get_double("scaling", 1.4); std::vector<midxdim> scales; switch (scaling_type) { case MANUAL: if (!conf.exists("scales")) eblerror("expected \"scales\" variable to be defined in manual mode"); scales = string_to_midxdimvector(conf.get_cstring("scales")); detect.set_resolutions(scales); break ; case ORIGINAL: detect.set_scaling_original(); break ; case SCALES_STEP: detect.set_resolutions(scaling, maxs, mins); break ; case SCALES_STEP_UP: detect.set_resolutions(scaling, maxs, mins); detect.set_scaling_type(scaling_type); break ; default: detect.set_scaling_type(scaling_type); } // remove pads from target scales if requested if (conf.exists_true("scaling_remove_pad")) detect.set_scaling_rpad(true); // optimize memory usage by using only 2 buffers for entire flow state<T> input(1, 1, 1), output(1, 1, 1); if (!conf.exists_false("mem_optimization")) detect.set_mem_optimization(input, output, true); // TODO: always keep inputs, otherwise detection doesnt work. fix this. // conf.exists_true("save_detections") || // (display && !mindisplay)); // zero padding float hzpad = conf.try_get_float("hzpad", 0); float wzpad = conf.try_get_float("wzpad", 0); detect.set_zpads(hzpad, wzpad); if (conf.exists("input_min")) // limit inputs size detect.set_min_resolution(conf.get_uint("input_min")); if (conf.exists("input_max")) // limit inputs size detect.set_max_resolution(conf.get_uint("input_max")); if (silent) detect.set_silent(); if (conf.exists_bool("save_detections")) { std::string detdir = odir; detdir += "detections"; uint nsave = conf.try_get_uint("save_max_per_frame", 0); bool diverse = conf.exists_true("save_diverse"); detdir = detect.set_save(detdir, nsave, diverse); } detect.set_scaler_mode(conf.exists_true("scaler_mode")); if (conf.exists("bbox_decision")) detect.set_bbox_decision(conf.get_uint("bbox_decision")); if (conf.exists("bbox_scalings")) { mfidxdim scalings = string_to_fidxdimvector(conf.get_cstring("bbox_scalings")); detect.set_bbox_scalings(scalings); } // nms configuration ////////////////////////////////////////////////////// t_nms nms_type = (t_nms) conf.try_get_uint("nms", 0); float pre_threshold = conf.try_get_float("pre_threshold", 0.0); float post_threshold = conf.try_get_float("post_threshold", 0.0); float pre_hfact = conf.try_get_float("pre_hfact", 1.0); float pre_wfact = conf.try_get_float("pre_wfact", 1.0); float post_hfact = conf.try_get_float("post_hfact", 1.0); float post_wfact = conf.try_get_float("post_wfact", 1.0); float woverh = conf.try_get_float("woverh", 1.0); float max_overlap = conf.try_get_float("max_overlap", 0.0); float max_hcenter_dist = conf.try_get_float("max_hcenter_dist", 0.0); float max_wcenter_dist = conf.try_get_float("max_wcenter_dist", 0.0); float vote_max_overlap = conf.try_get_float("vote_max_overlap", 0.0); float vote_mhd = conf.try_get_float("vote_max_hcenter_dist", 0.0); float vote_mwd = conf.try_get_float("vote_max_wcenter_dist", 0.0); detect.set_nms(nms_type, pre_threshold, post_threshold, pre_hfact, pre_wfact, post_hfact, post_wfact, woverh, max_overlap, max_hcenter_dist, max_wcenter_dist, vote_max_overlap, vote_mhd, vote_mwd); if (conf.exists("raw_thresholds")) { std::string srt = conf.get_string("raw_thresholds"); std::vector<float> rt = string_to_floatvector(srt.c_str()); detect.set_raw_thresholds(rt); } if (conf.exists("outputs_threshold")) detect.set_outputs_threshold(conf.get_double("outputs_threshold"), conf.try_get_double("outputs_threshold_val", -1)); /////////////////////////////////////////////////////////////////////////// if (conf.exists("netdims")) { idxdim d = string_to_idxdim(conf.get_string("netdims")); detect.set_netdim(d); } if (conf.exists("smoothing")) { idxdim ker; if (conf.exists("smoothing_kernel")) ker = string_to_idxdim(conf.get_string("smoothing_kernel")); detect.set_smoothing(conf.get_uint("smoothing"), conf.try_get_double("smoothing_sigma", 1), &ker, conf.try_get_double("smoothing_sigma_scale", 1)); } if (conf.exists("background_name")) detect.set_bgclass(conf.get_cstring("background_name")); if (conf.exists_true("bbox_ignore_outsiders")) detect.set_ignore_outsiders(); if (conf.exists("corners_inference")) detect.set_corners_inference(conf.get_uint("corners_inference")); if (conf.exists("input_gain")) detect.set_input_gain(conf.get_double("input_gain")); if (conf.exists_true("dump_outputs")) { std::string fname; fname << odir << "/dump/detect_out"; detect.set_outputs_dumping(fname.c_str()); } }