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

相关内容

热门资讯

透视实锤!werplan辅助软... 透视实锤!werplan辅助软件,wepoker辅助工具,项目教程(有挂工具)-哔哩哔哩1、进入到w...
透视透视挂!wepoker俱乐... 透视透视挂!wepoker俱乐部辅助(透视)都是真的有挂,力荐教程(有挂大厅)-哔哩哔哩1、下载好w...
6分钟详情!wejoker私人... 6分钟详情!wejoker私人辅助软件(透视)竟然是有挂,我来教教你(有人有挂)-哔哩哔哩1、wej...
透视了解!wepoker破解器... 透视了解!wepoker破解器激活码,wepoker破解是真的还是假的,总结教程(有挂头条)-哔哩哔...
透视辅助!wepoker底牌透... 透视辅助!wepoker底牌透视(透视)果然真的是有挂,2025新版教程(有挂代打ai)-哔哩哔哩1...
7分钟解谜!wepoker黑侠... 7分钟解谜!wepoker黑侠破解(透视)本来有挂,德州论坛(有挂详细)-哔哩哔哩1、wepoker...
透视了解!wejoker辅助脚... 透视了解!wejoker辅助脚本,steampokermaster辅助,指引教程(有挂教学)-哔哩哔...
透视软件!wepoker一直输... 透视软件!wepoker一直输的号能继续打吗(透视)切实是有挂,黑科技教程(有挂猫腻)-哔哩哔哩小薇...
7分钟解迷!wepoker透视... 7分钟解迷!wepoker透视破解版(透视)一直有挂,详细教程(确实有挂)-哔哩哔哩1、任何wepo...
透视app!hhpoker有没... 透视app!hhpoker有没有辅助,wpk有那种辅助吗,大纲教程(有人有挂)-哔哩哔哩暗藏猫腻,小...