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透视... 透视黑科技!wepoker透视脚本网页,模拟器打开hhpoker(详细辅助总结教程);致您一封信;亲...
透视科技“红龙poker透视工... 透视科技“红龙poker透视工具”果然真的是有挂(辅助挂)详细辅助揭秘教程1、许多玩家不知道辅助软件...
透视线上!steampoker... 透视线上!steampokermaster辅助,海盗来了辅助器无限炮(其实是有挂)透视线上!stea...
wepoker免费永久脚本!w... wepoker免费永久脚本!wepoker代打辅助机器人,wepoekr底牌透视(详细辅助透视教程)...
透视透视!aapoker辅助插... 透视透视!aapoker辅助插件工具下载,wepoker亲友圈有用吗(详细辅助详细教程)准备好在we...
透视数据!wepoker有机器... 透视数据!wepoker有机器人吗,决战卡五星辅助看牌器(竟然存在有挂)1、操作简单,无需注册,只需...
透视挂“红龙poker脚本”切... 透视挂“红龙poker脚本”切实是真的有挂(辅助挂)详细辅助介绍教程;进入游戏-大厅左侧-新手福利-...
aapoker透视脚本!xpo... aapoker透视脚本!xpoker透视辅助,aapoker辅助插件工具下载(详细辅助透明挂教程);...
透视脚本!wepoker辅助下... 透视脚本!wepoker辅助下载,hhpoker德州透视挂(详细辅助细节方法)是一款可以让一直输的玩...
透视透视!hhpoker辅助软... 透视透视!hhpoker辅助软件,博雅红河西元红河修改器(确实有挂)一、博雅红河西元红河修改器AI软...