AI 模型本地推理 - YYPOLOE - Python - Windows - GPU - 吸烟检测(目标检测)- 有配套资源直接上手实现
创始人
2024-12-28 01:06:50
0

Python 运行 - GPU 推理 - windows

  • 环境准备
  • python 代码

环境准备

FastDeploy预编译库下载

conda config --add channels conda-forge && conda install cudatoolkit=11.2 cudnn=8.2 pip install fastdeploy_gpu_python-0.0.0-cp38-cp38-win_amd64.whl 

python 代码

  import fastdeploy as fd import cv2 import os   model_path = "D:\\file\\ai\\models\\paddle\\ppyoloe\\infer_model" image_path = "D:\\code\\fastdeploy\\pythonProject1\\image\\OIP1.jpg" topk = 1 device = "gpu" device_id = 1  # 仅当使用 GPU 时需要设置 backend = "paddle"  # 配置runtime,加载模型 # option = build_option(model_path, device, device_id, backend) option = fd.RuntimeOption()  model_file = os.path.join(model_path, "inference.pdmodel") params_file = os.path.join(model_path, "inference.pdiparams") config_file = os.path.join(model_path, "inference.yml") # 加载模型 model = fd.vision.detection.PaddleDetectionModel(     model_file, params_file, config_file, runtime_option=option) dump_result = dict() im = cv2.imread(image_path) # 推理 result = model.predict(im) print(result) # 预测结果可视化 vis_im = fd.vision.vis_detection(im, result, score_threshold=0.5) cv2.imwrite("visualized_result.jpg", vis_im) print("Visualized result save in ./visualized_result.jpg") 

model_path 包含以下内容,模型在文章关联资源处。
在这里插入图片描述

相关内容

热门资讯

现场直击!有哪些免费的wpk作... 现场直击!有哪些免费的wpk作必弊码,hhpoker这个软件靠谱吗,其实真的有辅助教程(哔哩哔哩)1...
专业透视!pokemmo脚本辅... 专业透视!pokemmo脚本辅助下载,拱趴大菠萝挂(透视)其实一直都是有辅助教程(哔哩哔哩)1、下载...
透视绝活儿!impoker辅助... 透视绝活儿!impoker辅助(透视)原来是真的辅助辅助器(哔哩哔哩)1、实时impoker辅助透视...
关于!微信小程序黑科技(外挂)... 关于!微信小程序黑科技(外挂),微信小程序微乐辅助器脚本原来真实有挂1、进入到微信小程序黑科技是否有...
近期!约局吧德州有挂吗,威信茶... 近期!约局吧德州有挂吗,威信茶馆解码器,总是是真的有辅助插件(哔哩哔哩)1、约局吧德州有挂吗公共底牌...
普及透视!拱趴大菠萝有什么挂,... 普及透视!拱趴大菠萝有什么挂,菠萝辅助器免费版的功能介绍(透视)真是存在有辅助工具(哔哩哔哩)菠萝辅...
透视绝活儿!fishpoker... 透视绝活儿!fishpoker透视(透视)真是真的有辅助插件(哔哩哔哩)1、全新机制【fishpok...
玩家攻略推荐!微信小程序免费黑... 玩家攻略推荐!微信小程序免费黑科技(外挂),微信小程序微乐辅助器脚本确实有人有挂进入游戏-大厅左侧-...
在玩家背景下!pokemmo脚... 在玩家背景下!pokemmo脚本最新版,财神十三章外g挂真的假的,都是真的是有辅助神器(哔哩哔哩)1...
详细透视!哈糖大菠萝万能挂,x... 详细透视!哈糖大菠萝万能挂,xpoker怎么作必弊(透视)一贯一直都是有辅助攻略(哔哩哔哩)1、在哈...