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

相关内容

热门资讯

透视中牌率!德普之星辅助正版,... 透视中牌率!德普之星辅助正版,wepoker软件靠谱么(详细辅助可靠技巧);支持多人共享记分板与复盘...
透视讲解!拱趴大菠萝挂,闲逸辅... 透视讲解!拱趴大菠萝挂,闲逸辅助软件下载(都是有挂)1、闲逸辅助软件下载系统规律教程、闲逸辅助软件下...
德普之星辅助正版!epoker... 德普之星辅助正版!epoker透视,hhpoker透视下载链接在哪里(详细辅助AI教程)1、不需要A...
透视最新“aapoker辅助工... 透视最新“aapoker辅助工具免费下载”竟然是有挂(辅助挂)详细辅助技巧教程;进入游戏-大厅左侧-...
透视教程!wepoker底牌透... 透视教程!wepoker底牌透视脚本app,wpk私人辅助(详细辅助第三方教程);大神普及一款德州a...
透视了解!wepoker辅助器... 透视了解!wepoker辅助器下载,佛手在线做辅助下载(好像是有挂)1、超多福利:超高返利,海量正版...
wepoker辅助器是真的的吗... wepoker辅助器是真的的吗!hhpoker是真的还是假的,hhpoker免费透视脚本(详细辅助线...
透视工具“德普之星辅助器app... 透视工具“德普之星辅助器app”都是有挂(辅助挂)详细辅助爆料教程辅助器中分为三种模型:软件透明挂辅...
透视app!wepoker辅助... 透视app!wepoker辅助器怎么用,wepoker私人局辅助挂(详细辅助必赢教程)1、点击下载安...
透视教学!wpk透视是真的吗,... 透视教学!wpk透视是真的吗,崇阳斗棋辅助脚本视频(其实是有挂);崇阳斗棋辅助脚本视频辅助器中分为三...