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

相关内容

热门资讯

2027版开挂!乐乐川南字牌开... 2027版开挂!乐乐川南字牌开挂多功能AI软件,乐乐川南字牌好像真的有开挂软件1、乐乐川南字牌破解器...
2027版透视器!紫峰麻将透视... 2027版透视器!紫峰麻将透视器多功能AI攻略,紫峰麻将切实存在有透视器攻略1、紫峰麻将透视辅助软件...
2027版透视挂!一起温州麻将... 您好,一起温州麻将这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在...
2027版开挂!乐吧游戏开挂多... 2027版开挂!乐吧游戏开挂多功能AI脚本,乐吧游戏确实存在有开挂脚本1、点击下载安装,乐吧游戏脚本...
2027版开挂!威信茶馆开挂多... 2027版开挂!威信茶馆开挂多功能AI插件,威信茶馆果然有开挂插件1、许多玩家不知道威信茶馆辅助怎么...
2027版开挂!鸿运会开挂多功... 2027版开挂!鸿运会开挂多功能AI方法,鸿运会切实有开挂方法1、全新机制【鸿运会ai辅助工具激活码...
2027版辅助!微乐常州麻将辅... 2027版辅助!微乐常州麻将辅助多功能AI方法,微乐常州麻将确实真的是有辅助方法1、上手简单,内置详...
2027版透视挂!呼伦贝尔麻将... 2027版透视挂!呼伦贝尔麻将透视挂多功能AI软件,呼伦贝尔麻将果然有透视挂软件1、下载好呼伦贝尔麻...
2027版开挂!二丫麻将开挂多... 2027版开挂!二丫麻将开挂多功能AI技巧,二丫麻将都是真的有开挂技巧1、完成二丫麻将辅助器v3.3...
2027版辅助器!雀神麻将辅助... 2027版辅助器!雀神麻将辅助器多功能AI工具,雀神麻将都是有辅助器工具1、雀神麻将辅助器安装包、雀...