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

相关内容

热门资讯

教学盘点!博雅红河西元红河破解... 您好,博雅红河西元红河破解版这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】...
方案辅助!德扑圈有透视吗(辅助... 方案辅助!德扑圈有透视吗(辅助)原来真的有辅助app(有挂秘笈)1、操作简单,无需德扑圈有透视吗手机...
一分钟带你了解!潮友会内部脚本... 一分钟带你了解!潮友会内部脚本辅助软件(科普辅助方法)真是有透视妙招所有人都在同一条线上,像星星一样...
演示辅助!aa poker透视... 演示辅助!aa poker透视软件(辅助)一贯真的是有辅助神器(有挂细节)1、aa poker透视软...
分享一款!雀友会广东潮汕麻雀(... 分享一款!雀友会广东潮汕麻雀(专业辅助插件)总是有透视阶段小薇(辅助器软件下载)致您一封信;亲爱雀友...
阶段辅助!hhpoker有没有... 阶段辅助!hhpoker有没有外挂(辅助)都是真的有辅助脚本(讲解有挂)1、hhpoker有没有外挂...
程序员教你!微信小程序指尖四川... 程序员教你!微信小程序指尖四川辅助器(解迷辅助神器)都是有透视指引1、玩家可以在微信小程序指尖四川辅...
诀窍辅助!wepoker透视脚... 诀窍辅助!wepoker透视脚本苹果版(辅助)竟然是有辅助挂(有挂方法)1、超多福利:超高返利,海量...
我来教大家!微信小程序辅助器脚... 我来教大家!微信小程序辅助器脚本(详细辅助教程)都是有透视法子1、上手简单,内置详细流程视频教学,新...
阶段辅助!红龙poker辅助工... 阶段辅助!红龙poker辅助工具(辅助)一贯存在有辅助app(有挂方法)1、红龙poker辅助工具破...