31 const std::string& model_root) {
34 model_root, model_info.proto_file().file());
36 model_root, model_info.weight_file().file());
39 std::vector<std::string> input_names =
41 std::vector<std::string> output_names =
45 const auto& framework = model_info.framework();
46 std::string plugin_name = model_info.infer_plugin();
47 static const std::string class_namespace =
"apollo::perception::inference::";
48 if (model_info.has_infer_plugin() && !plugin_name.empty()) {
49 plugin_name = class_namespace + plugin_name;
52 net_->set_model_info(proto_file, input_names, output_names);
53 AINFO <<
"net load plugin success: " << plugin_name;
56 weight_file, output_names,
57 input_names, model_root));
63 std::map<std::string, std::vector<int>> shape_map;
67 if (!
net_->Init(shape_map)) {
68 AERROR << model_info.name() <<
"init failed!";
static PluginManager * Instance()
get singleton instance of PluginManager
std::shared_ptr< Base > CreateInstance(const std::string &derived_class)
create plugin instance of derived class based on Base
virtual bool InitNetwork(const common::ModelInfo &model_info, const std::string &model_root)
Interface for network initialization
std::shared_ptr< inference::Inference > net_
std::string GetAbsolutePath(const std::string &prefix, const std::string &relative_path)
Get absolute path by concatenating prefix and relative_path.
std::vector< std::string > GetBlobNames(const google::protobuf::RepeatedPtrField< common::ModelBlob > &model_blobs)
void AddShape(std::map< std::string, std::vector< int > > *shape_map, const google::protobuf::RepeatedPtrField< common::ModelBlob > &model_blobs)
Inference * CreateInferenceByName(const std::string &frame_work, const std::string &proto_file, const std::string &weight_file, const std::vector< std::string > &outputs, const std::vector< std::string > &inputs, const std::string &model_root)