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

相关内容

热门资讯

透视透视!xpoker辅助神器... 透视透视!xpoker辅助神器,hhpoker德州有挂吗,讲义教程(有挂技巧)-哔哩哔哩hhpoke...
第4分钟曝光!aapoker辅... 第4分钟曝光!aapoker辅助软件合法吗(透视)竟然有挂,微扑克教程(发现有挂)-哔哩哔哩一、aa...
透视能赢!wepoker底牌透... 透视能赢!wepoker底牌透视脚本(透视)原来是真的挂,靠谱教程(有挂后台)-哔哩哔哩1、玩家可以...
辅助透视!aa poker透视... 辅助透视!aa poker透视软件,wpk模拟器是什么,妙招教程(今日头条)-哔哩哔哩1、wpk模拟...
第6分钟解谜!wepoker有... 第6分钟解谜!wepoker有透视功能吗(透视)真是有挂,大神讲解(有挂助手)-哔哩哔哩亲,关键说明...
透视计算!wejoker私人辅... 透视计算!wejoker私人辅助软件(透视)确实是真的挂,黑科技教程(有挂存在)-哔哩哔哩1、下载好...
透视智能ai!智星菠萝有挂吗,... 透视智能ai!智星菠萝有挂吗,wepoker辅助器安装包定制,法门教程(存在有挂)-哔哩哔哩1、we...
第7分钟揭幕!wepoker轻... 第7分钟揭幕!wepoker轻量版透视系统(透视)一贯真的有挂,透视教程(存在有挂)-哔哩哔哩一、w...
透视存在!wepoker钻石怎... 透视存在!wepoker钻石怎么看底牌(透视)原来是有挂,解密教程(有挂俱乐部)-哔哩哔哩亲,关键说...
透视讲解!wepoker永久免... 透视讲解!wepoker永久免费脚本,wepoker有没有挂,总结教程(有挂教程)-哔哩哔哩1、实时...