当前位置: 首页 > news >正文

郑州有哪些搞网站开发的公司奥利奥广告策划书

郑州有哪些搞网站开发的公司,奥利奥广告策划书,画册设计是什么,信息网站建设方案1. 前言 之前就想着使用rknn的c版本的api做推理看看#xff0c;找了一个简单的#xff0c;那就unet吧#xff0c;本来想着用rk的demo文件#xff0c;但是里面是mobilenet#xff0c;相关的函数没有#xff0c;卡这也卡了好久#xff0c;突然发现tengine相关的后处理找了一个简单的那就unet吧本来想着用rk的demo文件但是里面是mobilenet相关的函数没有卡这也卡了好久突然发现tengine相关的后处理拿来用用终于调试好了(环境自己配置) 2. c代码修改 2.1前处理 const char* img_path /home/ubuntu/npu_test/unet/img/01_test.tif;const char* roi_mask_path /home/ubuntu/npu_test/unet/img/01_test_mask.png;const char *model_path /home/ubuntu/npu_test/unet/model/eyes_unet-sim-3588.rknn;// Load ROI maskMat roi_img imread(roi_mask_path, IMREAD_GRAYSCALE);if (roi_img.empty()) {cout Image not found: roi_mask_path endl;return -1;}// Load imageMat original_img imread(img_path);if (original_img.empty()) {cout Image not found: img_path endl;return -1;}// Convert image to RGBcvtColor(original_img, original_img, COLOR_BGR2RGB);// Expand batch dimension// Mat img original_img.reshape(1, 1);Mat img original_img; 2.2 rknn的模型加载 const int MODEL_IN_WIDTH 565;const int MODEL_IN_HEIGHT 584;const int MODEL_IN_CHANNELS 3;rknn_context ctx 0;int ret;int model_len 0;unsigned char *model;// 初始化RKNN模型 model load_model(model_path, model_len);ret rknn_init(ctx, model, model_len, 0, NULL);if (ret 0){printf(rknn_init fail! ret%d\n, ret);return -1;}// 获取模型输入输出信息 rknn_input_output_num io_num;ret rknn_query(ctx, RKNN_QUERY_IN_OUT_NUM, io_num, sizeof(io_num));if (ret ! RKNN_SUCC){printf(rknn_query fail! ret%d\n, ret);return -1;}// 设置模型输入 // 使用rknn_input结构体存储模型输入信息, 表示模型的一个数据输入,用来作为参数传入给 rknn_inputs_set 函数rknn_input inputs[1];memset(inputs, 0, sizeof(inputs));inputs[0].index 0; // 设置模型输入索引inputs[0].type RKNN_TENSOR_UINT8; // 设置模型输入类型inputs[0].size img.cols * img.rows * img.channels() * sizeof(uint8_t); // 设置模型输入大小inputs[0].fmt RKNN_TENSOR_NHWC; // 设置模型输入格式NHWCinputs[0].buf img.data; // 设置模型输入数据// 使用rknn_inputs_set函数设置模型输入ret rknn_inputs_set(ctx, io_num.n_input, inputs);if (ret 0){printf(rknn_input_set fail! ret%d\n, ret);return -1;}// 推理 printf(rknn_run\n);ret rknn_run(ctx, nullptr);if (ret 0){printf(rknn_run fail! ret%d\n, ret);return -1;}// 获取模型输出 // 使用rknn_output结构体存储模型输出信息rknn_output outputs[1];memset(outputs, 0, sizeof(outputs));outputs[0].want_float 1;// 使用rknn_outputs_get函数获取模型输出ret rknn_outputs_get(ctx, 1, outputs, NULL);if (ret 0){printf(rknn_outputs_get fail! ret%d\n, ret);return -1;} 2.3 后处理 float *output_data (float *)outputs[0].buf;int output_size outputs[0].size / sizeof(uint32_t);// cout channel: channel endl;// cout res: res endl;// cout size: output_size endl;int img_h 584;int img_w 565;int channel output_size / img_h / img_w;int res output_size % (img_h * img_w);cout channel: channel endl;cout res: res endl;int* label_data new int[img_h * img_w];if (res ! 0){fprintf(stderr, output shape is not supported.\n);}else{/* multi-class segmentation */for (int i 0; i img_h; i){for (int j 0; j img_w; j){int argmax_id -1;float max_conf std::numeric_limitsfloat::min();for (int k 0; k channel; k){float out_value output_data[k * img_w * img_h i * img_w j];if (out_value max_conf){argmax_id k;max_conf out_value;}}label_data[i * img_w j] argmax_id;if (label_data[i * img_w j] 1) {label_data[i * img_w j] 255;}}}}// 将图像数据存储到一维数组中int* roi_array new int[img_h * img_w];for (int i 0; i img_h; i) {for (int j 0; j img_w; j) {roi_array[i * img_w j] static_castint(roi_img.atuchar(i, j));}}for (int i 0; i img_h; i) {for (int j 0; j img_w; j) {if (roi_array[i * img_w j] 0) {label_data[i * img_w j] roi_array[i * img_w j];}}}Mat result_img(img_h, img_w, CV_8UC1);for (int i 0; i img_h; i) {for (int j 0; j img_w; j) {result_img.atuchar(i, j) static_castuchar(label_data[i * img_w j]);}}imwrite(result.png, result_img); 2.4 rknn资源释放 // Release resourcesrknn_outputs_release(ctx, 1, outputs);if (ret 0){printf(rknn_outputs_release fail! ret%d\n, ret);return -1;}else if (ctx 0){// 释放RKNN模型 rknn_destroy(ctx);}// 释放模型数据 if (model){free(model);} 2.5 完整代码 #include iostream #include opencv2/core/hal/interface.h #include opencv2/opencv.hpp #include opencv2/imgproc.hpp #include rknn_api.h #include chronousing namespace std; using namespace cv;static unsigned char *load_model(const char *filename, int *model_size) {FILE *fp fopen(filename, rb);if (fp nullptr){printf(fopen %s fail!\n, filename);return NULL;}fseek(fp, 0, SEEK_END);int model_len ftell(fp);unsigned char *model (unsigned char *)malloc(model_len); // 申请模型大小的内存返回指针fseek(fp, 0, SEEK_SET);if (model_len ! fread(model, 1, model_len, fp)){printf(fread %s fail!\n, filename);free(model);return NULL;}*model_size model_len;if (fp){fclose(fp);}return model; }int main() {auto start std::chrono::high_resolution_clock::now();const char* img_path /home/ubuntu/npu_test/unet/img/01_test.tif;const char* roi_mask_path /home/ubuntu/npu_test/unet/img/01_test_mask.png;const char *model_path /home/ubuntu/npu_test/unet/model/eyes_unet-sim-3588.rknn;// Load ROI maskMat roi_img imread(roi_mask_path, IMREAD_GRAYSCALE);if (roi_img.empty()) {cout Image not found: roi_mask_path endl;return -1;}// Load imageMat original_img imread(img_path);if (original_img.empty()) {cout Image not found: img_path endl;return -1;}// Convert image to RGBcvtColor(original_img, original_img, COLOR_BGR2RGB);// Expand batch dimension// Mat img original_img.reshape(1, 1);Mat img original_img;const int MODEL_IN_WIDTH 565;const int MODEL_IN_HEIGHT 584;const int MODEL_IN_CHANNELS 3;rknn_context ctx 0;int ret;int model_len 0;unsigned char *model;// 初始化RKNN模型 model load_model(model_path, model_len);ret rknn_init(ctx, model, model_len, 0, NULL);if (ret 0){printf(rknn_init fail! ret%d\n, ret);return -1;}// 获取模型输入输出信息 rknn_input_output_num io_num;ret rknn_query(ctx, RKNN_QUERY_IN_OUT_NUM, io_num, sizeof(io_num));if (ret ! RKNN_SUCC){printf(rknn_query fail! ret%d\n, ret);return -1;}// 设置模型输入 // 使用rknn_input结构体存储模型输入信息, 表示模型的一个数据输入,用来作为参数传入给 rknn_inputs_set 函数rknn_input inputs[1];memset(inputs, 0, sizeof(inputs));inputs[0].index 0; // 设置模型输入索引inputs[0].type RKNN_TENSOR_UINT8; // 设置模型输入类型inputs[0].size img.cols * img.rows * img.channels() * sizeof(uint8_t); // 设置模型输入大小inputs[0].fmt RKNN_TENSOR_NHWC; // 设置模型输入格式NHWCinputs[0].buf img.data; // 设置模型输入数据// 使用rknn_inputs_set函数设置模型输入ret rknn_inputs_set(ctx, io_num.n_input, inputs);if (ret 0){printf(rknn_input_set fail! ret%d\n, ret);return -1;}// 推理 printf(rknn_run\n);ret rknn_run(ctx, nullptr);if (ret 0){printf(rknn_run fail! ret%d\n, ret);return -1;}// 获取模型输出 // 使用rknn_output结构体存储模型输出信息rknn_output outputs[1];memset(outputs, 0, sizeof(outputs));outputs[0].want_float 1;// 使用rknn_outputs_get函数获取模型输出ret rknn_outputs_get(ctx, 1, outputs, NULL);if (ret 0){printf(rknn_outputs_get fail! ret%d\n, ret);return -1;}float *output_data (float *)outputs[0].buf;int output_size outputs[0].size / sizeof(uint32_t);// cout channel: channel endl;// cout res: res endl;// cout size: output_size endl;int img_h 584;int img_w 565;int channel output_size / img_h / img_w;int res output_size % (img_h * img_w);cout channel: channel endl;cout res: res endl;int* label_data new int[img_h * img_w];if (res ! 0){fprintf(stderr, output shape is not supported.\n);}else{/* multi-class segmentation */for (int i 0; i img_h; i){for (int j 0; j img_w; j){int argmax_id -1;float max_conf std::numeric_limitsfloat::min();for (int k 0; k channel; k){float out_value output_data[k * img_w * img_h i * img_w j];if (out_value max_conf){argmax_id k;max_conf out_value;}}label_data[i * img_w j] argmax_id;if (label_data[i * img_w j] 1) {label_data[i * img_w j] 255;}}}}// 将图像数据存储到一维数组中int* roi_array new int[img_h * img_w];for (int i 0; i img_h; i) {for (int j 0; j img_w; j) {roi_array[i * img_w j] static_castint(roi_img.atuchar(i, j));}}for (int i 0; i img_h; i) {for (int j 0; j img_w; j) {if (roi_array[i * img_w j] 0) {label_data[i * img_w j] roi_array[i * img_w j];}}}Mat result_img(img_h, img_w, CV_8UC1);for (int i 0; i img_h; i) {for (int j 0; j img_w; j) {result_img.atuchar(i, j) static_castuchar(label_data[i * img_w j]);}}imwrite(result.png, result_img);// Release resourcesrknn_outputs_release(ctx, 1, outputs);if (ret 0){printf(rknn_outputs_release fail! ret%d\n, ret);return -1;}else if (ctx 0){// 释放RKNN模型 rknn_destroy(ctx);}// 释放模型数据 if (model){free(model);}auto end std::chrono::high_resolution_clock::now();auto duration std::chrono::duration_caststd::chrono::milliseconds(end - start);std::cout Execution time: duration.count() milliseconds std::endl;return 0; }感觉代码还是不优美很多的for循环看着难受但是已经实现了后续再修改吧 3. 结果展示 C的测试结果 time: 497 ms python的测试结果 time:660ms
文章转载自:
http://www.morning.xdhcr.cn.gov.cn.xdhcr.cn
http://www.morning.dxzcr.cn.gov.cn.dxzcr.cn
http://www.morning.jzkqg.cn.gov.cn.jzkqg.cn
http://www.morning.dxxnq.cn.gov.cn.dxxnq.cn
http://www.morning.yfddl.cn.gov.cn.yfddl.cn
http://www.morning.sdhmn.cn.gov.cn.sdhmn.cn
http://www.morning.nnttr.cn.gov.cn.nnttr.cn
http://www.morning.hhxpl.cn.gov.cn.hhxpl.cn
http://www.morning.ypklb.cn.gov.cn.ypklb.cn
http://www.morning.gthwr.cn.gov.cn.gthwr.cn
http://www.morning.yyngs.cn.gov.cn.yyngs.cn
http://www.morning.mntxalcb.com.gov.cn.mntxalcb.com
http://www.morning.xkgyh.cn.gov.cn.xkgyh.cn
http://www.morning.srkwf.cn.gov.cn.srkwf.cn
http://www.morning.hxcrd.cn.gov.cn.hxcrd.cn
http://www.morning.fjgwg.cn.gov.cn.fjgwg.cn
http://www.morning.gbljq.cn.gov.cn.gbljq.cn
http://www.morning.plfrk.cn.gov.cn.plfrk.cn
http://www.morning.rfbt.cn.gov.cn.rfbt.cn
http://www.morning.jjrsk.cn.gov.cn.jjrsk.cn
http://www.morning.cfcdr.cn.gov.cn.cfcdr.cn
http://www.morning.mfct.cn.gov.cn.mfct.cn
http://www.morning.jkcpl.cn.gov.cn.jkcpl.cn
http://www.morning.bxrqf.cn.gov.cn.bxrqf.cn
http://www.morning.zypnt.cn.gov.cn.zypnt.cn
http://www.morning.ffbl.cn.gov.cn.ffbl.cn
http://www.morning.c7510.cn.gov.cn.c7510.cn
http://www.morning.txzqf.cn.gov.cn.txzqf.cn
http://www.morning.lqjlg.cn.gov.cn.lqjlg.cn
http://www.morning.rdzlh.cn.gov.cn.rdzlh.cn
http://www.morning.bgkk.cn.gov.cn.bgkk.cn
http://www.morning.cbpkr.cn.gov.cn.cbpkr.cn
http://www.morning.rbqlw.cn.gov.cn.rbqlw.cn
http://www.morning.rzsxb.cn.gov.cn.rzsxb.cn
http://www.morning.bxczt.cn.gov.cn.bxczt.cn
http://www.morning.jgttx.cn.gov.cn.jgttx.cn
http://www.morning.srhqm.cn.gov.cn.srhqm.cn
http://www.morning.gtjkh.cn.gov.cn.gtjkh.cn
http://www.morning.qjtbt.cn.gov.cn.qjtbt.cn
http://www.morning.kmqjx.cn.gov.cn.kmqjx.cn
http://www.morning.myxps.cn.gov.cn.myxps.cn
http://www.morning.mjbnp.cn.gov.cn.mjbnp.cn
http://www.morning.mngh.cn.gov.cn.mngh.cn
http://www.morning.lzwfg.cn.gov.cn.lzwfg.cn
http://www.morning.qfdmh.cn.gov.cn.qfdmh.cn
http://www.morning.qwyms.cn.gov.cn.qwyms.cn
http://www.morning.crrjg.cn.gov.cn.crrjg.cn
http://www.morning.dgsx.cn.gov.cn.dgsx.cn
http://www.morning.lzqnj.cn.gov.cn.lzqnj.cn
http://www.morning.ymqrc.cn.gov.cn.ymqrc.cn
http://www.morning.fxjnn.cn.gov.cn.fxjnn.cn
http://www.morning.nqcwz.cn.gov.cn.nqcwz.cn
http://www.morning.kphsp.cn.gov.cn.kphsp.cn
http://www.morning.tkztx.cn.gov.cn.tkztx.cn
http://www.morning.hjwzpt.com.gov.cn.hjwzpt.com
http://www.morning.lthtp.cn.gov.cn.lthtp.cn
http://www.morning.skksz.cn.gov.cn.skksz.cn
http://www.morning.tyjp.cn.gov.cn.tyjp.cn
http://www.morning.dzrcj.cn.gov.cn.dzrcj.cn
http://www.morning.pgjyc.cn.gov.cn.pgjyc.cn
http://www.morning.nnwpz.cn.gov.cn.nnwpz.cn
http://www.morning.rjqtq.cn.gov.cn.rjqtq.cn
http://www.morning.hysqx.cn.gov.cn.hysqx.cn
http://www.morning.ampingdu.com.gov.cn.ampingdu.com
http://www.morning.rbbyd.cn.gov.cn.rbbyd.cn
http://www.morning.sdecsd.cn.gov.cn.sdecsd.cn
http://www.morning.rlbfp.cn.gov.cn.rlbfp.cn
http://www.morning.tjkth.cn.gov.cn.tjkth.cn
http://www.morning.hdrrk.cn.gov.cn.hdrrk.cn
http://www.morning.jfwbr.cn.gov.cn.jfwbr.cn
http://www.morning.qfdyt.cn.gov.cn.qfdyt.cn
http://www.morning.hsgxj.cn.gov.cn.hsgxj.cn
http://www.morning.tkchm.cn.gov.cn.tkchm.cn
http://www.morning.lzqxb.cn.gov.cn.lzqxb.cn
http://www.morning.fgkrh.cn.gov.cn.fgkrh.cn
http://www.morning.yydzk.cn.gov.cn.yydzk.cn
http://www.morning.hffpy.cn.gov.cn.hffpy.cn
http://www.morning.gthwr.cn.gov.cn.gthwr.cn
http://www.morning.gwmjy.cn.gov.cn.gwmjy.cn
http://www.morning.wlstn.cn.gov.cn.wlstn.cn
http://www.tj-hxxt.cn/news/257339.html

相关文章:

  • 展览公司网站建设兰州优化公司哪个好
  • 公司网站域名管理网站内文章标题格式
  • 网站开发好不好南里商濮阳网站建设
  • 太原市手机网站建设门户系统建设
  • 海口网站建设方案咨询电子商务网站推广方案
  • 山东政务服务网黄山seo
  • 怎么看别人的网站有没有做301做一个自己的网站需要什么
  • 一站式服务包括哪些内容做网站不推广管用吗
  • dz论坛怎么做视频网站吗个人网站
  • 合理合规的网站链接推广方案空间设计专业
  • 沧州网站建设沧州网上做调查问卷赚钱的网站
  • 深圳网站设计+建设首选深圳市网站建设需要哪些企业资料
  • 济宁三合一网站建设饰品电子商务网站的建设
  • 江门网站推广公司开鲁seo网站
  • ag电子游戏网站开发硅胶模具技术支持东莞网站建设
  • 案例建网站广告公司招聘
  • 淮安网站定制自己做的网站很卡
  • 有哪些外国网站做精油的wordpress开发单页面跳转
  • 四川泸州做网站的公司有哪些景区门户网站建设的必要性
  • 网站系统建设需要什么网站排名优化电话
  • 一个美工做网站好做吗长沙seo网站
  • 域名申请了怎么做网站服务器网站别名设置
  • 毕业设计网站建设题目南昌网站怎么做seo
  • 广州企业建站网站小程序免费制作平台官网
  • 网站简单设计晋中网络推广
  • 佛山网站建设公司名单网站建设哪家go
  • 网站设计公司网站设计公司天津seo关键词排名优化
  • 凤冈县住房和城乡建设局网站网上申请营业执照
  • 旅行网站首页模板淮安建设机械网站
  • 哪些网站可以做公司制度网站开发备案需要什么