Skip to content

Commit

Permalink
ncnn2tengine deconv (#945)
Browse files Browse the repository at this point in the history
* Update ncnn2tengine.cpp

* apply code-format changes

Co-authored-by: nihui <[email protected]>
  • Loading branch information
nihui and nihui authored Jul 28, 2021
1 parent 6a13dcc commit d8fba09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 8 additions & 10 deletions examples/tm_scrfd_trt_fp16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ static void draw_objects(const cv::Mat& bgr, const std::vector<FaceObject>& obje
void show_usage()
{
fprintf(
stderr,
"[Usage]: [-h]\n [-m model_file] [-i image_file] [-r repeat_count] [-t thread_count]\n");
stderr,
"[Usage]: [-h]\n [-m model_file] [-i image_file] [-r repeat_count] [-t thread_count]\n");
}

void get_input_data_scrfd(const char* image_file, float* input_data, int letterbox_rows, int letterbox_cols, const float* mean, const float* scale)
Expand Down Expand Up @@ -334,8 +334,8 @@ int main(int argc, char* argv[])
const char* image_file = nullptr;

int img_c = 3;
const float mean[3] = { 127.5f, 127.5f, 127.5f };
const float scale[3] = { 1 / 128.f, 1 / 128.f, 1 / 128.f };
const float mean[3] = {127.5f, 127.5f, 127.5f};
const float scale[3] = {1 / 128.f, 1 / 128.f, 1 / 128.f};

// allow none square letterbox, set default letterbox size
int letterbox_rows = 320;
Expand Down Expand Up @@ -409,9 +409,8 @@ int main(int argc, char* argv[])
}
fprintf(stderr, "tengine-lite library version: %s\n", get_tengine_version());


/* create NVIDIA TensorRT backend */
trt_option trt_opt = { 0 };
trt_option trt_opt = {0};
trt_opt.dev_name = "TensorRT";
trt_opt.dla_index = 0;
trt_opt.gpu_index = 0;
Expand All @@ -424,7 +423,6 @@ int main(int argc, char* argv[])
return -1;
}


/* create graph, load tengine model xxx.tmfile */
graph_t graph = create_graph(trt_context, "tengine", model_file);
if (graph == nullptr)
Expand All @@ -434,7 +432,7 @@ int main(int argc, char* argv[])
}

int img_size = letterbox_rows * letterbox_cols * img_c;
int dims[] = { 1, 3, letterbox_rows, letterbox_cols };
int dims[] = {1, 3, letterbox_rows, letterbox_cols};
std::vector<float> input_data(img_size);

tensor_t input_tensor = get_graph_input_tensor(graph, 0, 0);
Expand Down Expand Up @@ -485,15 +483,15 @@ int main(int argc, char* argv[])
max_time = (std::max)(max_time, cur);
}
fprintf(stderr, "Repeat %d times, thread %d, avg time %.2f ms, max_time %.2f ms, min_time %.2f ms\n", repeat_count, num_thread,
total_time / repeat_count, max_time, min_time);
total_time / repeat_count, max_time, min_time);
fprintf(stderr, "--------------------------------------\n");

/* postprocess */
const float prob_threshold = 0.3f;
const float nms_threshold = 0.45f;

std::vector<FaceObject> proposals, objects;
int strides[] = { 8, 16, 32 };
int strides[] = {8, 16, 32};
for (int stride_index = 0; stride_index < 3; stride_index++)
{
tensor_t score_tensor = get_graph_tensor(graph, score_pred_name[stride_index]);
Expand Down
1 change: 1 addition & 0 deletions tools/convert_tool/ncnn/ncnn2tengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,7 @@ void ncnn_serializer::register_op_load()
op_load_map["Slice"] = std::pair<int, op_load_t>(OP_SLICE, load_slice);
op_load_map["Sigmoid"] = std::pair<int, op_load_t>(OP_SIGMOID, load_no_param);
op_load_map["UnaryOp"] = std::pair<int, op_load_t>(OP_UNARY, load_unary);
op_load_map["Deconvolution"] = std::pair<int, op_load_t>(OP_DECONV, load_deconv);
op_load_map["DeconvolutionDepthWise"] = std::pair<int, op_load_t>(OP_DECONV, load_deconv);
}
/*
Expand Down

0 comments on commit d8fba09

Please sign in to comment.