localization::ssd::config::config(nlohmann::json js)
{
    if (js.is_null())
    {
        throw std::runtime_error("missing ssd config in json config");
    }

    for (auto& info : config_list)
    {
        info->parse(js);
    }
    verify_config("localization_ssd", config_list, js);

    add_shape_type({2, 1}, "int32_t");
    add_shape_type({max_gt_boxes, 4}, "float");
    add_shape_type({1, 1}, "int32_t");
    add_shape_type({max_gt_boxes, 1}, "int32_t");

    // 'difficult' tag for gt_boxes
    add_shape_type({max_gt_boxes, 1}, "int32_t");

    class_name_map.clear();
    for (int i = 0; i < class_names.size(); i++)
    {
        class_name_map.insert({class_names[i], i});
    }

    validate();
}
Esempio n. 2
0
 /**
  * Import parameters from given json object.
  * Throw std::runtime_error if given json is malformated.
  */
 inline void loadJSON(const nlohmann::json& j)
 {
     //Empty case
     if (j.is_null()) {
         return;
     }
     //Check json type
     if (!j.is_object()) {
         throw std::runtime_error(
             "ParametersContainer load parameters json not object");
     }
     //Iterate on json entries
     for (nlohmann::json::const_iterator it=j.begin();it!=j.end();it++) {
         if (it.value().is_boolean()) {
             //Boolean
             if (_paramsBool.count(it.key()) == 0) {
                 throw std::runtime_error(
                     "ParametersContainer load parameters json bool does not exist: " 
                     + it.key());
             } else {
                 paramBool(it.key()).value = it.value();
             }
         } else if (it.value().is_number()) {
             //Number
             if (_paramsNumber.count(it.key()) == 0) {
                 throw std::runtime_error(
                     "ParametersContainer load parameters json number does not exist: " 
                     + it.key());
             } else {
                 paramNumber(it.key()).value = it.value();
             }
         } else if (it.value().is_string()) {
             //String
             if (_paramsStr.count(it.key()) == 0) {
                 throw std::runtime_error(
                     "ParametersContainer load parameters json str does not exist: " 
                     + it.key());
             } else {
                 paramStr(it.key()).value = it.value();
             }
         } else {
             throw std::runtime_error(
                 "ParametersContainer load parameters json malformated");
         }
     }
 }
Esempio n. 3
0
    config(nlohmann::json js)
        : frame(js["frame"])
    {
        if (js.is_null())
        {
            throw std::runtime_error("missing video config in json config");
        }

        for (auto& info : config_list)
        {
            info->parse(js);
        }
        verify_config("video", config_list, js);

        // channel major only
        add_shape_type({frame.channels, max_frame_count, frame.height, frame.width},
                       {"channels", "frames", "height", "width"},
                       frame.output_type);
    }