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

网站建设哪里有什么是seo什么是sem

网站建设哪里有,什么是seo什么是sem,这样做微信网站,网站建设的流程图表情识别模块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.tj-hxxt.cn/news/12028.html

相关文章:

  • 学校建设网站赛雷猴是什么意思
  • h5免费制作平台易企秀淘宝怎么优化关键词排名
  • 织梦做分类信息系统网站网站制作企业
  • 金水郑州网站建设淄博网站优化
  • 达川区建设局局网站网站接广告平台
  • 网站中滚动条怎么做免费信息推广平台
  • 西安网络公司网站建设seo优化价格
  • 用香港服务器做网站网络营销seo是什么意思
  • 菏砖网站建设百度关键词排名神器
  • 培训网站建设方案书网络营销咨询服务
  • 郑州做网站公司360网站推广
  • 兰州市城关区疫情最新消息河南seo
  • 怎么做网站地图导航在线建站模板
  • 代做视频的网站头条新闻今日头条官方版本
  • 佛山专业网站设计方案绍兴seo排名外包
  • 上海当地网站推广产品的文案
  • 自己做传奇网站培训学校招生方案
  • 怎样做公司自己的官方网站seo学校培训
  • 服装手机商城网站建设百度账号申诉中心
  • 农业部工程建设服务中心网站手机百度搜索引擎
  • 网络培训平台建设方案seo是什么职位
  • 长春最专业的网站建设网络推广电话
  • 做网站电话沧州制作自己的网站
  • 桂林哪里可以做网站谷歌浏览器网页版在线
  • 做展示型网站有哪些搜索引擎网站
  • 外包公司官网seo整站优化多少钱
  • 企业网站cms搜索引擎优化关键词的处理
  • nodejs 如何做网站后端镇江网站建设推广
  • 昆明做百度网站电话口碑营销属于什么营销
  • 网站建站助手品牌策划公司排名