34 std::string config_file =
37 AERROR <<
"Read config failed: " << config_file;
41 AINFO <<
"Load config Success: " << model_param_.ShortDebugString();
43 const auto &model_info = model_param_.
info();
44 std::string model_path =
GetModelPath(model_info.name());
45 std::string proto_file =
46 GetModelFile(model_path, model_info.proto_file().file());
47 std::string weight_file =
48 GetModelFile(model_path, model_info.weight_file().file());
51 std::vector<std::string> input_names =
53 std::vector<std::string> output_names =
57 model_info.framework(), proto_file, weight_file, output_names,
58 input_names, model_path));
59 ACHECK(
nullptr != net_) <<
"Failed to init CNNAdapter";
61 gpu_id_ = GlobalConfig::Instance()->track_feature_gpu_id;
62 net_->set_gpu_id(gpu_id_);
63 net_->set_max_batch_size(100);
65 std::map<std::string, std::vector<int>> shape_map;
69 if (!net_->Init(shape_map)) {
70 AERROR << model_info.name() <<
"init failed!";
80 auto input_blob = net_->get_blob(model_param_.
info().inputs(0).name());
81 auto output_blob = net_->get_blob(model_param_.
info().outputs(0).name());
90 cudaDeviceSynchronize();
92 cudaDeviceSynchronize();
95 output_blob->shape(2), output_blob->shape(3)});
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
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)