vcpkg从零到实战:解决C++依赖管理与PowerShell报错全指南
2026/10/6 8:52:16
在文档处理自动化领域,YOLO X Layout作为基于YOLO模型的文档版面分析工具,能够精准识别文档中的11种常见元素类型。随着企业文档处理需求的增长,标准化API接口成为系统集成的关键环节。本文将详细介绍如何通过OpenAPI 3.0规范定义/predict接口的请求响应结构,帮助开发者快速集成这一强大的文档分析能力。
YOLO X Layout可识别以下文档元素:
系统提供三种预训练模型满足不同场景需求:
openapi: 3.0.0 info: title: YOLO X Layout API description: 文档版面分析服务接口规范 version: 1.0.0 servers: - url: http://localhost:7860/apipaths: /predict: post: summary: 文档版面分析 requestBody: multipart/form-data: schema: type: object properties: image: type: string format: binary description: 待分析文档图像 conf_threshold: type: number format: float default: 0.25 description: 置信度阈值(0-1)responses: '200': description: 分析成功 content: application/json: schema: type: object properties: result: type: array items: type: object properties: class_name: type: string example: "Text" confidence: type: number format: float example: 0.95 bbox: type: array items: type: number example: [100, 200, 300, 400] page_size: type: array items: type: number example: [2480, 3508]import requests def analyze_document(image_path, threshold=0.25): url = "http://localhost:7860/api/predict" with open(image_path, "rb") as f: files = {"image": f} data = {"conf_threshold": threshold} response = requests.post(url, files=files, data=data) return response.json() # 使用示例 result = analyze_document("contract.pdf") for item in result["result"]: print(f"检测到 {item['class_name']},置信度 {item['confidence']:.2f}")典型响应示例:
{ "result": [ { "class_name": "Title", "confidence": 0.98, "bbox": [120, 150, 800, 200], "page_size": [2480, 3508] }, { "class_name": "Table", "confidence": 0.92, "bbox": [300, 500, 1000, 800], "page_size": [2480, 3508] } ] }responses: '400': description: 无效请求参数 '500': description: 服务器内部错误 content: application/json: schema: type: object properties: error: type: string example: "Invalid image format"通过OpenAPI 3.0规范标准化YOLO X Layout的/predict接口,我们实现了:
获取更多AI镜像
想探索更多AI镜像和应用场景?访问 CSDN星图镜像广场,提供丰富的预置镜像,覆盖大模型推理、图像生成、视频生成、模型微调等多个领域,支持一键部署。