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透视挂是真的吗AI 游戏攻略黑科技上线本地缓存功能,离线查阅能力开挂。提前下载对应游戏...
揭秘几款,新版德扑之星透视,德... 揭秘几款,新版德扑之星透视,德州扑克多功能ai辅助秘籍教程主打本地运行的 AI 黑科技工具迎来新版本...
透明挂教程,德扑之星破解app... 本地部署 AI 黑科技工具迎来新版本,不用上传文件到云端就能完成德扑之星破解app下载解析、 AI ...
科普常识,wepoker是不是... 科普常识,wepoker是不是有透视软件,德州扑克多功能ai开挂法子工具是一款可以让一直输的玩家,快...
玩家必看分享,wpk辅助kaq... 很多人使用云端 AI 时,都担心wpk辅助kaq665、内部资料上传带来隐私风险。这款本地运行的 A...
攻略方法,微扑克辅助工具免费版... 一款 AI 游戏攻略黑科技工具上线,查攻略效率直接开挂。它整合版本更新、装备搭配、BOSS 打法、牌...
总算了解!,runit德州透视... 本地部署 AI 黑科技工具迎来新版本,不用上传文件到云端就能完成runit德州透视软件辅助挂解析、 ...
今日公布,德州辅助软件,WPK... 今日公布,德州辅助软件,WPK多功能ai辅助器方针教程主打赛后复盘的 AI 游戏攻略黑科技走红,对局...
让我来分享经验,wepoker... 您好:wepoker辅助器教程这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多...
攻略讲解,德扑之星开挂作弊,A... 攻略讲解,德扑之星开挂作弊,AApoker多功能ai辅助器手筋脚本是一款可以让一直输的玩家,快速成为...