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

相关内容

热门资讯

9分钟辅助挂!德州私人局脚本,... 9分钟辅助挂!德州私人局脚本,wepoker辅助分析器,介绍教程(有挂讲解)-哔哩哔哩在进入wepo...
四分钟了解(微乐刨幺)外挂透明... 四分钟了解(微乐刨幺)外挂透明挂辅助app(透视)曝光教程(2026已更新)(哔哩哔哩);微乐刨幺最...
第七分钟了解“微乐自建房怎么提... 第七分钟了解“微乐自建房怎么提高胜率”详细透视开挂辅助下载-哔哩哔哩;AI辅助机器人普及解说快速成为...
第七分钟神器!wepoker轻... 第七分钟神器!wepoker轻量版辅助,红龙poker辅助,2025教程(真实有挂)-哔哩哔哩1、下...
第2分钟了解(德州软件工具)外... 第2分钟了解(德州软件工具)外挂辅助插件(透视)曝光教程(2020已更新)(哔哩哔哩);德州软件工具...
第5分钟了解“竹简茶馆辅助”详... 第5分钟了解“竹简茶馆辅助”详细透视开挂辅助插件-哔哩哔哩;竹简茶馆辅助最新版本免费下载安装哦,具体...
第一分钟普及!hhpoker辅... 第一分钟普及!hhpoker辅助软件下载,pokemmo辅助脚本,教你攻略(有挂方略)-哔哩哔哩1、...
1分钟了解(云扑克辅助挂)外挂... 1分钟了解(云扑克辅助挂)外挂辅助挂(透视)科技教程(2024已更新)(哔哩哔哩);1、让任何用户在...
第六分钟了解“钱塘十水三插件”... 第六分钟了解“钱塘十水三插件”详细透视开挂辅助插件-哔哩哔哩;超受欢迎的钱塘十水三插件稳赢小游戏,经...
7分钟领会!wepoker轻量... 7分钟领会!wepoker轻量版辅助,红龙poker透视工具,AI教程(有挂工具)-哔哩哔哩红龙po...