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

相关内容

热门资讯

步骤辅助!wepoker有没有... 步骤辅助!wepoker有没有透视方法,wepoker私人局辅助,分享教程(有挂工具)1、游戏颠覆性...
手段辅助!poker红龙辅助,... 手段辅助!poker红龙辅助,德扑之心免费透视,有挂教程(有挂辅助)1、玩家可以在德扑之心免费透视透...
机巧辅助!wepoker透视最... 机巧辅助!wepoker透视最简单三个步骤,wepoker代打辅助,教你教程(有挂攻略)1、下载好w...
模板辅助!WePOker有没有... 模板辅助!WePOker有没有透视方法,菠萝德普辅助器免费版在哪里,了解教程(有挂实锤)1、首先打开...
技法辅助!wepoker透视脚... 技法辅助!wepoker透视脚本苹果版,wepoker私人局有透视吗,必备教程(新版有挂)1、金币登...
妙计辅助!哈糖大菠萝可以开挂吗... 妙计辅助!哈糖大菠萝可以开挂吗,hhpoker德州挂真的有吗,详细教程(果真有挂)1、哈糖大菠萝可以...
秘籍辅助!wepoker免费辅... 秘籍辅助!wepoker免费辅助器,德普之星透视辅助软件是真的吗,总结教程(有挂技巧)1、许多玩家不...
教材辅助!wepoker透视辅... 教材辅助!wepoker透视辅助下载,we poker游戏下,有挂教程(有挂细节)1、教材辅助!we...
绝活辅助!拱趴大菠萝十三水作弊... 绝活辅助!拱趴大菠萝十三水作弊,wepoker有没有机器人,专业教程(有挂讲解)1、任何拱趴大菠萝十...
讲义辅助!aapoker能控制... 讲义辅助!aapoker能控制牌吗,约局吧能不能开挂,必备教程(存在有挂)1、实时约局吧能不能开挂透...