Swift OCR: LLM Powered Fast OCR ⚡

Swift OCR: LLM Powered Fast OCR ⚡

swift-ocr-llm-powered-pdf-to-markdown An open-source OCR API that leverages OpenAI's powerful language models with optimized performance techniques like parallel processing and batching to deliver high-quality text extraction from complex PDF documents. Ideal for businesses seeking efficient document digitization and data extraction solutions. swift-ocr-llm-powered-pdf-to-markdown 项目地址: https://gitcode.com/gh_mirrors/sw/swift-ocr-llm-powered-pdf-to-markdown

1. 项目介绍

Swift OCR 是一个开源的 OCR(光学字符识别)API,它利用 OpenAI 强大的语言模型以及优化的性能技术,如并行处理和批处理,从而实现对复杂 PDF 文档的高质量文本提取。该项目非常适合企业进行高效的文档数字化和数据提取。

2. 项目快速启动

以下是快速启动 Swift OCR 项目的步骤:

环境准备

  • Python 3.8+
  • Git
  • Virtualenv(可选但推荐)

克隆仓库

git clone https://github.com/yigitkonur/llm-openai-ocr.git
cd llm-openai-ocr

创建虚拟环境

python3 -m venv venv
source venv/bin/activate

在 Windows 上:

venv\Scripts\activate

安装依赖

pip install -r requirements.txt

配置环境变量

在项目根目录下创建一个 .env 文件,并添加以下变量:

OPENAI_API_KEY=your_openai_api_key
AZURE_OPENAI_ENDPOINT=your_azure_openai_endpoint
OPENAI_DEPLOYMENT_ID=your_openai_deployment_id
OPENAI_API_VERSION=your_openai_api_version # 默认为 "gpt-4o"
BATCH_SIZE=10 # 可选:默认为 1
MAX_CONCURRENT_OCR_REQUESTS=5 # 可选:默认为 5
MAX_CONCURRENT_PDF_CONVERSION=4 # 可选:默认为 4

your_openai_api_keyyour_azure_openai_endpointyour_openai_deployment_id 替换为您的实际 OpenAI 凭据。

运行应用

uvicorn main:app --reload

API 将在 http://127.0.0.1:8000 上可用。

3. 应用案例和最佳实践

API 使用示例

  • 上传 PDF 文件:
curl -X POST "http://127.0.0.1:8000/ocr" -F "file=@/path/to/your/document.pdf"
  • 提供 PDF URL:
curl -X POST "http://127.0.0.1:8000/ocr" -F "ocr_request={\"url\":\"https://example.com/document.pdf\"}" -H "Content-Type: application/json"

响应示例

  • 成功响应:
{
  "text": "Extracted and formatted text from the PDF."
}
  • 错误响应:
{
  "400 Bad Request": "Invalid input parameters.",
  "422 Unprocessable Entity": "Validation errors.",
  "500 Internal Server Error": "Processing errors."
}

4. 典型生态项目

目前项目生态中还没有发布的相关包和版本,但是社区中的开发者可以贡献代码,扩展项目功能,或者根据需要在企业中集成和使用该项目。随着项目的成长,预计将会出现更多围绕 Swift OCR 的生态项目。

swift-ocr-llm-powered-pdf-to-markdown An open-source OCR API that leverages OpenAI's powerful language models with optimized performance techniques like parallel processing and batching to deliver high-quality text extraction from complex PDF documents. Ideal for businesses seeking efficient document digitization and data extraction solutions. swift-ocr-llm-powered-pdf-to-markdown 项目地址: https://gitcode.com/gh_mirrors/sw/swift-ocr-llm-powered-pdf-to-markdown

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宗廷国Kenyon

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值