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

网站建设哪里有百度免费建网站

网站建设哪里有,百度免费建网站,第三方小程序开发平台有哪些,品牌注册费用表情识别模块1.环境部署1.1同样采用fastDeploy库1.2相关模型2.封装成静态库2.1参考[百度Paddle中PP-Mattingv2的部署并将之封装并调用一个C静态库](https://blog.csdn.net/weixin_43564060/article/details/128882099)2.2项目依赖添加2.3生成成功3.test3.1创建emotion_test项目…

表情识别模块

  • 1.环境部署
    • 1.1同样采用fastDeploy库
    • 1.2相关模型
  • 2.封装成静态库
    • 2.1参考[百度Paddle中PP-Mattingv2的部署并将之封装并调用一个C++静态库](https://blog.csdn.net/weixin_43564060/article/details/128882099)
    • 2.2项目依赖添加
    • 2.3生成成功
  • 3.test
    • 3.1创建emotion_test项目
    • 3.2进行项目配置
    • 3.3解决dll文件缺失的问题
    • 3.4运行结果

1.环境部署

1.1同样采用fastDeploy库

可以参考百度Paddle中PP-Mattingv2的部署并将之封装并调用一个C++静态库,部署过程大致一样,只是核心的代码进行了改动。

1.2相关模型

模型使用的自训练resnet50模型,其中输出的标签为:

  • 0.angry
  • 1.disgust
  • 2.fear
  • 3.happy
  • 4.neutral
  • 5.sad
  • 6.surprise
    模型需要三个文件:model.pdmodel,model.pdiparams,model.yml

2.封装成静态库

2.1参考百度Paddle中PP-Mattingv2的部署并将之封装并调用一个C++静态库

framework.h代码:

#pragma once#define WIN32_LEAN_AND_MEAN             // 从 Windows 头文件中排除极少使用的内容
#include "fastdeploy/vision.h"std::string emotion_CpuInfer(const std::string& model_dir, const cv::Mat& image_file);std::string emotion_GpuInfer(const std::string& model_dir, const cv::Mat& image_file);int emotion_infer_by_camera(const std::string& device, const std::string& model_dir, const std::string& window_name);

在这里插入图片描述

emotion_StaticLib.cpp代码为:

// emotion_StaticLib.cpp : 定义静态库的函数。
//#include "pch.h"#include "framework.h"#ifdef WIN32
const char sep = '\\';
#else
const char sep = '/';
#endifstd::string emotion_CpuInfer(const std::string& model_dir, const cv::Mat& image_file) {auto model_file = model_dir + sep + "model.pdmodel";auto params_file = model_dir + sep + "model.pdiparams";auto config_file = model_dir + sep + "inference.yml";auto option = fastdeploy::RuntimeOption();option.UseCpu();auto model = fastdeploy::vision::classification::PaddleClasModel(model_file, params_file, config_file, option);std::string result;if (!model.Initialized()) {std::cerr << "Failed to initialize." << std::endl;result = "Failed to initialize.";return result;}auto im = image_file;fastdeploy::vision::ClassifyResult res;if (!model.Predict(im, &res)) {std::cerr << "Failed to predict." << std::endl;result = "Failed to initialize.";return result;}// print resstd::cout << res.Str() << std::endl;return res.Str();
}std::string emotion_GpuInfer(const std::string& model_dir, const cv::Mat& image_file) {auto model_file = model_dir + sep + "model.pdmodel";auto params_file = model_dir + sep + "model.pdiparams";auto config_file = model_dir + sep + "inference.yml";auto option = fastdeploy::RuntimeOption();option.UseGpu();auto model = fastdeploy::vision::classification::PaddleClasModel(model_file, params_file, config_file, option);std::string result;if (!model.Initialized()) {std::cerr << "Failed to initialize." << std::endl;result = "Failed to initialize.";return result;}auto im = image_file;fastdeploy::vision::ClassifyResult res;if (!model.Predict(im, &res)) {std::cerr << "Failed to predict." << std::endl;result = "Failed to initialize.";return result;}// print resstd::cout << res.Str() << std::endl;return res.Str();
}int emotion_infer_by_camera(const std::string& device, const std::string& model_dir, const std::string& window_name = "video") {cv::VideoCapture cap;cap.open(0);std::string result;if (!cap.isOpened()) {std::cout << "open camera failed!" << std::endl;return 0;}cv::namedWindow(window_name, 1);while (1) {time_t t_now = time(0);cv::Mat frame;cap >> frame;if (frame.empty()) {return 0;}cv::imshow(window_name, frame);emotion_CpuInfer(model_dir, frame);if (device == "gpu") {cv::imshow(window_name, frame);result = emotion_GpuInfer(model_dir, frame);}else {cv::imshow(window_name, frame);result = emotion_CpuInfer(model_dir, frame);}std::cout << "emotion此帧共消耗" << (time(0) - t_now) << "秒" << std::endl;if (cv::waitKey(30) >= 0) break;}cap.release();return 1;
}

在这里插入图片描述

所有的环境部署步骤与百度Paddle中PP-Mattingv2的部署并将之封装并调用一个C++静态库一致,在该部署过程中,只进行了cpu环境的部署

2.2项目依赖添加

在这里插入图片描述
在这里插入图片描述
注意:所有的环境必须是Release X64
在这里插入图片描述

2.3生成成功

在这里插入图片描述
在这里插入图片描述
到此为止封装已经超过了,在项目里面即可部署使用。

3.test

3.1创建emotion_test项目

在这里插入图片描述
emotion_test.cpp

#include <vector>
#include <iostream>
#include <string>
#include "C:/Users/44869/Desktop/emotion_StaticLib/emotion_StaticLib/pch.h"int main() {emotion_infer_by_camera("cpu", "A:/emotion/resnet50", "emotion");return 0;
}

3.2进行项目配置

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.3解决dll文件缺失的问题

运行C:\Users\44869\Desktop\emotion_StaticLib\fastdeploy-win-x64-1.0.3下的fastdeploy_init.bat
生成的所有dll文件复制到C:\Users\44869\Desktop\emotion_StaticLib\emotion_test\x64\Release下即可

3.4运行结果

在这里插入图片描述

http://www.hrbkazy.com/news/9811.html

相关文章:

  • 大连手机网站开发销售策略和营销策略
  • 淮南服装网站建设地址企业新闻稿发布平台
  • 建筑人才网 中高端招聘网站免费下载app并安装
  • 寻找哈尔滨网站建设b站在线观看人数在哪
  • 用dw做购票网站百度24小时人工客服电话
  • 网站空间指的是什么意思国际实时新闻
  • wengdo网站开发创意设计百度入口
  • 想开民宿自己怎么做介绍的网站网页制作工具有哪些
  • 西安网站建设 大德百度网站收录查询
  • 备案编号在哪里能看到西安官网seo公司
  • 有什么学做木工的网站吗百度广告投放公司
  • 淮安做微信网站小红书推广费用一般多少
  • 阳泉推广型网站开发企业网站推广方法实验报告
  • 百度上传网站服务器产品软文代写
  • 做牙科设计的网站灰色行业关键词优化
  • 湖北省勘察设计协会网站淘宝竞价排名
  • 宜昌小程序开发公司最好的优化公司
  • 一佰互联自助建站如何进行网络推广和宣传
  • 代理网关app未运行网站搜索引擎优化的步骤
  • 在线设计平台的发展趋势seo免费课程
  • 官方网页qq登陆邯郸网站seo
  • 微网站公司移动建站模板
  • 自己做网站的流程视频教程应用下载app排行榜
  • 网站建设与管理学什么网站快速收录教程
  • 建设免费网站2022年7到8月份的十大新闻
  • 做网站销售水果网站seo优化免费
  • 旅游公司网站建设40个免费靠谱网站
  • 济南建设项目竣工验收公示网站中国今天最新军事新闻
  • 如何设计一个logoseo优化的主要任务
  • 手机兼职在哪个网站做网店如何做推广