YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

MinerUapi - PDF Processing Serverless API

基于 magic-pdf 0.9.2 版本的 PDF 处理 Serverless API。

功能特性

  • PDF文本提取和OCR处理
  • 自动识别文本PDF和OCR PDF
  • 支持混合模式PDF处理
  • S3存储集成

API 使用说明

请求格式

json { "pdf_bytes": "base64编码的PDF文件内容", "lang": "zh", // 可选,默认"zh" "layout_model": true, // 可选,默认true "formula_enable": true, // 可选,默认true "table_enable": true, // 可选,默认true "is_debug": false // 可选,默认false }

响应格式

成功响应:

json { "status": "success", "data": { "_parse_type": "txt或ocr", "_version_name": "0.9.2", "_lang": "zh", // 其他PDF解析结果 } }

错误响应:

json { "status": "error", "message": "错误信息" }

环境变量要求

部署时需要配置以下环境变量:

  • S3_ACCESS_KEY: S3访问密钥
  • S3_SECRET_KEY: S3访问密钥密文
  • S3_ENDPOINT: S3服务端点
  • S3_BUCKET: S3存储桶名称

Python调用示例

python from huggingface_hub import InferenceClient import base64 def process_pdf(pdf_path: str, hf_token: str):

创建客户端

client = InferenceClient( model="kitjesen/MinerUapi", # 替换为您的模型ID token=hf_token )

读取并编码PDF

with open(pdf_path, 'rb') as f: pdf_bytes = base64.b64encode(f.read()).decode()

发送请求

response = client.post(json={ "pdf_bytes": pdf_bytes, "lang": "zh", "layout_model": True, "formula_enable": True, "table_enable": True }) return response

使用示例

try: result = process_pdf("example.pdf", "your_hf_token") if result["status"] == "success": print("解析类型:", result["data"]["_parse_type"]) print("版本:", result["data"]["_version_name"]) else: print("处理失败:", result["message"]) except Exception as e: print(f"调用出错: {str(e)}")

注意事项

  1. 文件限制:

    • PDF大小建议不超过10MB
    • 支持文本PDF和扫描PDF
  2. 处理时间:

    • 文本PDF: 通常几秒内完成
    • OCR PDF: 可能需要较长时间
  3. S3存储:

    • 确保配置的S3权限正确
    • 建议定期清理临时文件
  4. 版本说明:

    • 当前使用 magic-pdf 0.9.2 版本
    • 建议定期检查版本更新
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.