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有透视辅助妙招!wepo... WPK有透视辅助妙招!wepoker如何设置透视,微扑克ai多功能辅助脚本wepoker如何设置透视...
WPK透视透视挂方式!wpk模... WPK透视透视挂方式!wpk模拟器是什么,红龙PoKerai多功能透视挂软件1、wpk模拟器是什么模...
WPK四人辅助要领!wepok... WPK四人辅助要领!wepoker怎么拿到好牌,aapokerai多功能辅助教程1、wepoker怎...
WPK俱乐部透视妙计!wepo... WPK俱乐部透视妙计!wepoker透视脚本免费下载,菠萝智星德州ai多功能透视教程1、很好的工具软...
WPK真假开挂经验!wepok... WPK真假开挂经验!wepoker好友局透视,aapokerai多功能开挂脚本1、不需要AI权限,帮...
WPK透视版辅助器妙计!wpk... WPK透视版辅助器妙计!wpk作弊,红龙PoKerai多功能辅助器插件1、在wpk作弊插件功能辅助器...
WPK俱乐部透视挂方式!wpk... WPK俱乐部透视挂方式!wpk透视辅助靠谱吗,aapokerai多功能透视挂app1、超多福利:超高...
WPK模拟器开挂演示!德普之星... WPK模拟器开挂演示!德普之星透视,aapokerai多功能开挂插件德普之星透视能透视中分为三种模型...
WPK辅助透视课程!智星菠萝有... WPK辅助透视课程!智星菠萝有挂吗,德州扑克ai多功能透视攻略1)智星菠萝有挂吗辅助插件:进一步探索...
WPK辅助器透视操作!wepo... WPK辅助器透视操作!wepoker私人局透视教程,德扑之星ai多功能透视插件1、上手简单,内置详细...