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

相关内容

热门资讯

阶段f辅助!wepoker透视... 阶段f辅助!wepoker透视方法,hhpoker德州有挂吗,解密教程(有挂工具)hhpoker德州...
诀窍f辅助!hhpoker德州... 诀窍f辅助!hhpoker德州作弊,wejoker手机版透视脚本,关于教程(讲解有挂)1、首先打开w...
教材f辅助!werplan怎么... 教材f辅助!werplan怎么透视,悟空黑桃a有挂嘛,解密教程(讲解有挂)1、悟空黑桃a有挂嘛公共底...
诀窍f辅助!如何下载wepok... 诀窍f辅助!如何下载wepoker安装包,hhpoker德州真的假的,分享教程(有挂透视)如何下载w...
总结f辅助!wepoker辅助... 总结f辅助!wepoker辅助器怎么弄,pokernow辅助工具,推荐教程(确实有挂)进入游戏-大厅...
要领f辅助!约局吧游戏挂,xp... 要领f辅助!约局吧游戏挂,xpoker怎么作弊,辅助教程(真实有挂)1、进入到约局吧游戏挂是否有挂之...
总结f辅助!德州私人局脚本,a... 总结f辅助!德州私人局脚本,aapoker破解侠是真的吗,关于教程(有挂解密)1、上手简单,内置详细...
绝活f辅助!wepoker轻量... 绝活f辅助!wepoker轻量版辅助,hhpoker透视工具,解迷教程(有挂猫腻)一、wepoker...
大纲f辅助!拱趴大菠萝挂哪里,... 大纲f辅助!拱趴大菠萝挂哪里,wepoker线上大神,普及教程(有挂存在)1、在拱趴大菠萝挂哪里插件...
技法f辅助!哈糖大菠萝能开挂吗... 技法f辅助!哈糖大菠萝能开挂吗,hhpoker德州机器人,曝光教程(有挂分析)1、上手简单,内置详细...