ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

如何启动 OmniParser Server FastAPI 解析服务并配置模型、设备与端口参数

如何启动 OmniParser Server FastAPI 解析服务并配置模型、设备与端口参数 如何启动 OmniParser Server FastAPI 解析服务并配置模型、设备与端口参数【免费下载链接】OmniParserA simple screen parsing tool towards pure vision based GUI agent项目地址: https://gitcode.com/GitHub_Trending/omn/OmniParserOmniParser 仓库中的omniparserserver是一个基于 FastAPI 的解析服务把截图Base64 图片转成结构化界面元素供 GUI Agent 等下游使用。本任务的目标是在已克隆的 OmniParser 仓库中搭建 conda 环境、下载模型权重、用python -m omniparserserver启动服务并通过/probe/与/parse/两个接口确认服务可用。参数配置模型路径、设备、端口、检测阈值全部通过命令行参数完成入口定义在 omnitool/omniparserserver/omniparserserver.py。准备 conda 环境omnitool/readme.md 中 omniparserserver 一节给出的安装步骤如下在仓库根目录执行cd OmniParser conda create -n omni python3.12 conda activate omni pip install -r requirements.txt要求 Python 3.12依赖清单见 requirements.txt包含 torch、easyocr、transformers、paddleocr、huggingface_hub 等。文档说明如果机器上已有 OmniParser 的 conda 环境可以直接复用跳到下载权重一步。下载模型权重服务需要两类权重YOLOv9-E 交互区域检测模型icon_detect_v3/model.pt和图标 caption 模型。在仓库根目录执行 omnitool/readme.md 给出的命令huggingface-cli download microsoft/OmniParser-v2.0 icon_detect_v3/model.pt --revision refs/pr/37 --local-dir weights rm -rf weights/icon_caption weights/icon_caption_florence huggingface-cli download microsoft/OmniParser-v2.0 --local-dir weights --repo-type model --include icon_caption/* mv weights/icon_caption weights/icon_caption_florence说明检测权重要从 Hugging Face PR 37 下载--revision refs/pr/37文档注明这是在该 PR 合并前的获取方式第二条rm -rf会删除本地已有的weights/icon_caption与weights/icon_caption_florence目录再重新下载属于文档自带步骤执行前确认这两个目录里没有自己改过的文件根目录 README.md 中也提供了等价的权重下载方式只下载icon_caption的config.json、generation_config.json、model.safetensors三个文件两者都落到weights/下任取其一即可。下载完成后检测权重位于weights/icon_detect_v3/model.ptcaption 权重位于weights/icon_caption_florence/。服务默认就会使用这些位置get_yolo_modelutil/utils.py优先找仓库根下的weights/icon_detect_v3/model.pt找不到时再回退到 Hugging Face 自动下载util/yolov9.py。启动服务与命令行参数进入服务目录后启动omnitool/readme.md 的原始步骤cd OmniParser/omnitool/omniparserserver python -m omniparserserver不带参数启动即使用全部默认值。需要指定模型、设备或端口时omniparserserver.py的 argparse 定义了以下参数默认值与 help 文本均取自源码参数默认值用途源码 help 原文--som_model_pathNoneOptional local detector path; V3 downloads from Hugging Face by default--caption_model_nameflorence2Name of the caption model--caption_model_path../../weights/icon_caption_florencePath to the caption model--devicecpuDevice to run the model--BOX_TRESHOLD0.05Threshold for box detection--host127.0.0.1Host for the API--port8000Port for the API源码文件头注释里给出的示例保持原文拼写BOX_TRESHOLDpython -m omniparserserver --caption_model_name florence2 --caption_model_path ../../weights/icon_caption_florence --device cuda --BOX_TRESHOLD 0.05几点与部署直接相关的说明--caption_model_path的默认值../../weights/icon_caption_florence是相对启动目录omnitool/omniparserserver的路径正好指向仓库根下按上文下载好的 caption 权重无需修改--host默认为127.0.0.1即默认只监听本机如果下游组件在另一台机器上需要相应调整该参数文档未给出具体取值示例关于--device命令行默认是cpu但Omniparser初始化时util/omniparser.py实际按torch.cuda.is_available()自行选择cuda或cpu也就是说机器上存在可用 GPU 时解析就跑在 GPU 上。omnitool/readme.md 的 Notes 说明 OmniParser V2 可以在 CPU 上运行只是较慢因此官方建议omniparserserver单独放在 GPU 服务器上omnibox与 Gradio 放在同一台 CPU 机器上服务通过 uvicorn 启动reloadTrue/parse/处理请求时终端会打印start parsing...、图片尺寸和本次耗时。验证服务是否就绪服务暴露两个接口定义见 omniparserserver.py健康检查GET http://host:port/probe/默认即http://127.0.0.1:8000/probe/。成功时返回{message: Omniparser API ready}解析接口POST http://host:port/parse/请求体为 JSON{base64_image: 图片的 Base64 字符串}返回包含三个字段的 JSONsom_image_base64画框标注后的图片 Base64、parsed_content_list解析出的元素列表、latency本次解析耗时实时测得不是固定值。仓库自带的下游校验方式启动 Gradio 时python app.py --windows_host_url localhost:8006 --omniparser_server_url localhost:8000omnitool/gradio/app.py 会对http://omniparser_server_url/probe发起探测OmniParser Server一栏探测通过说明端口和 host 配置正确。启动失败时先查什么omnitool/readme.md 的 Common setup errors 中与本服务直接相关的只有一条Windows 上若出现libpaddle: The specified module could not be found原因是 OmniParser 使用的 OCR 库 Paddle 依赖 Windows 的 C Redistributable。解决办法先安装 C Redistributable再重新执行pip install -r requirements.txt。如果探测端口不通回到上文检查是否从omnitool/omniparserserver目录执行了python -m omniparserserver、--host/--port与下游传入的--omniparser_server_urlhost:port 格式是否一致、weights/下两个权重目录是否按约定路径就位。【免费下载链接】OmniParserA simple screen parsing tool towards pure vision based GUI agent项目地址: https://gitcode.com/GitHub_Trending/omn/OmniParser创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表