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 包含以下内容,模型在文章关联资源处。
在这里插入图片描述

相关内容

热门资讯

透视了解!如何下载德普之星辅助... 透视了解!如何下载德普之星辅助软件,智星德州插件怎么下载(最初有开挂辅助挂);无需打开直接搜索薇:1...
6分钟了解!广西微乐小程序脚本... 6分钟了解!广西微乐小程序脚本,hhpoker透视脚本下载,AA德州教程!(有挂方法);无需打开直接...
第八分钟策略!收集微乐小程序游... 您好:收集微乐小程序游戏破解器这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多...
1刹那知晓“透视辅助器免费蜀山... 您好:透视辅助器免费蜀山四川这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用...
透明插件!wepoker辅助透... 透明插件!wepoker辅助透视软件,哈糖大菠萝挂法(原本有开挂辅助安装);无需打开直接搜索打开薇:...
第6分钟了解!微乐建房辅助工具... 第6分钟了解!微乐建房辅助工具免费入口,天酷互娱有辅助工具嘛,解说技巧(有挂详情);无需打开直接搜索...
第四分钟讲义!微乐小程序辅助器... 第四分钟讲义!微乐小程序辅助器免费(透视)新九哥智能辅助app(有挂规律);无需打开直接搜索加薇13...
两刹那晓得“微友辅助神器下载”... 两刹那晓得“微友辅助神器下载”原本有开挂辅助安装(果真有挂);无需打开直接搜索加薇136704302...
第二分钟了解!wpk德州局怎么... 第二分钟了解!wpk德州局怎么透视,微信小程序有挂吗辅助,可靠教程(证实有挂)1、下载安装好微信小程...
第五分钟指引!雀神广东麻将提高... 第五分钟指引!雀神广东麻将提高胜率(透视)微乐自建房脚本入口(有挂总结);无需打开直接搜索打开薇:1...