[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-NanoNets--docstrange":3,"tool-NanoNets--docstrange":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",144730,2,"2026-04-07T23:26:32",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107888,"2026-04-06T11:32:50",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":76,"owner_twitter":77,"owner_website":78,"owner_url":79,"languages":80,"stars":100,"forks":101,"last_commit_at":102,"license":103,"difficulty_score":10,"env_os":104,"env_gpu":105,"env_ram":106,"env_deps":107,"category_tags":112,"github_topics":113,"view_count":10,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":127,"updated_at":128,"faqs":129,"releases":160},2987,"NanoNets\u002Fdocstrange","docstrange","Extract and convert data from any document, images, pdfs, word doc, ppt or URL into multiple formats (Markdown, JSON, CSV, HTML) with intelligent structured data extraction and advanced OCR.","DocStrange 是一款强大的开源文档处理工具，旨在将 PDF、Word、PPT、Excel、图片乃至网页链接等多种格式的文件，快速转换为 Markdown、JSON、CSV 或 HTML 等结构化数据。它主要解决了传统转换工具在识别复杂排版、提取表格内容以及处理扫描件时精度不足的问题，能够智能去除页面干扰元素，输出干净且专为大语言模型（LLM）优化的文本，是构建 RAG（检索增强生成）应用的理想预处理方案。\n\n无论是需要高效清洗数据的开发者、从事文档分析的研究人员，还是希望离线处理敏感文件的普通用户，都能从中受益。DocStrange 的独特亮点在于其内置了升级后的 7B 参数大模型，显著提升了深度文档理解能力；同时支持高级 OCR 技术，能精准提取图片与扫描文档中的文字。更值得一提的是，它提供了灵活的部署方式：既可通过免费云端 API 即时处理，也支持完全私密的本地运行模式（兼容 GPU\u002FCPU），并配有便捷的拖拽式本地 Web 界面，确保数据不出本地即可轻松完成转换。","![DocStrange Banner](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_readme_b05a0a106bba.png)\n\n# \u003Cimg src=\"https:\u002F\u002Fpublic-vlms.s3.us-west-2.amazonaws.com\u002Fdocstrange_logo.svg\" alt=\"DocStrange\" width=\"32\" style=\"vertical-align: middle; margin-right: 8px;\">  DocStrange\n\n[![PyPI version](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Fdocstrange.svg?v=2)](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Fdocstrange)\n[![Python](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fpyversions\u002Fdocstrange.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fdocstrange\u002F)\n[![PyPI Downloads](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_readme_1c7d3ce53766.png)](https:\u002F\u002Fpepy.tech\u002Fprojects\u002Fdocstrange)\n[![GitHub stars](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002FNanoNets\u002Fdocstrange?style=social)](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange)\n[![GitHub forks](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fforks\u002FNanoNets\u002Fdocstrange?style=social)](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n[![Platform](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fplatform-linux%20%7C%20macOS%20%7C%20windows-lightgrey)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fdocstrange\u002F)\n[![Maintenance](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMaintained%3F-yes-green.svg)](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fgraphs\u002Fcommit-activity)\n\n> 🚀 **[Try DocStrange Online →](https:\u002F\u002Fdocstrange.nanonets.com\u002F)**\n\n# DocStrange\n\nDocStrange converts documents to Markdown, JSON, CSV, and HTML quickly and accurately.\n\n- Converts PDF, image, PPTX, DOCX, XLSX, and URL files.\n- Formats tables into clean, LLM-optimized Markdown.\n- Powered by an upgraded 7B model for higher accuracy and deeper document understanding.\n- Extracts text from images and scanned documents with advanced OCR.\n- Removes page artifacts for clean, readable output.\n- Does structured extraction, given specific fields or a JSON schema.\n- Includes a built-in, local Web UI for easy drag-and-drop conversion.\n- Offers a free cloud API for instant processing or a 100% private, local mode.\n- Works on GPU or CPU when running locally.\n- Integrates with Claude Desktop via an MCP server for intelligent document navigation.\n\n---\n\n![DocStrange Demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_readme_4091e6f5df05.gif)\n\n\n## Processing Modes\n> **☁️ Free Cloud Processing upto 10000 docs per month !**  \n> Extract documents data instantly with the cloud processing - no complex setup needed \n\n> **🔒 Local Processing !**  \n> Use `gpu` mode for 100% local processing - no data sent anywhere, everything stays on your machine.\n\n\n## **What's New**\n\n**August 2025**\n\n- 🚀 **Major Model Upgrade**: The core model has been upgraded to **7B parameters**, delivering significantly higher accuracy and deeper understanding of complex documents.\n- 🖥️ **Local Web Interface**: Introducing a built-in, local GUI. Now you can convert documents with a simple drag-and-drop interface, 100% offline.\n\n---\n\n## About\n\nConvert and extract data from PDF, DOCX, images, and more into clean Markdown and structured JSON. Plus: Advanced table extraction, 100% local processing, and a built-in web UI.\n\n`DocStrange` is a Python library for converting a wide range of document formats—including **PDF**, **DOCX**, **PPTX**, **XLSX**, and **images** — into clean, usable data. It produces LLM-optimized **Markdown**, structured **JSON** (with schema support), **HTML**, and **CSV** outputs, making it an ideal tool for preparing content for RAG pipelines and other AI applications.\n\nThe library offers both a powerful cloud API and a 100% private, offline mode that runs locally on your GPU. Developed by **Nanonets**, DocStrange is built on a powerful pipeline of OCR and layout detection models and currently requires **Python >=3.8**.\n\n**To report a bug or request a feature, [please file an issue](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fissues). To ask a question or request assistance, please use the [discussions forum](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fdiscussions).**\n\n---\n\n## **How DocStrange Differs**\n\n`DocStrange` focuses on end-to-end document understanding (OCR → layout → tables → clean Markdown or structured JSON) that you can run 100% locally. It is designed to deliver high-quality results from scans and photos without requiring the integration of multiple services.\n\n- **vs. Cloud AI Services (like AWS Textract)**: `DocStrange` offers a completely private, local processing option and gives you full control over the conversion pipeline.\n- **vs. Orchestration Frameworks (like LangChain)**: `DocStrange` is a ready-to-use parsing pipeline, not just a framework. It handles the complex OCR and layout analysis so you don't have to build it yourself.\n- **vs. Other Document Parsers**: `DocStrange` is specifically built for robust OCR on scans and phone photos, not just digitally-native PDFs.\n\n### **When to Pick DocStrange**\n- You need a **free cloud api** to extract information in structured format (markdown, json, csv, html) from different document types\n- You need **local processing** for privacy and compliance.\n- You are working with **scans, phone photos, or receipts** where high-quality OCR is critical.\n- You need a **fast path to clean Markdown or structured JSON** without training a model.\n\n---\n\n## **Examples**\n\nTry the live demo: Test `DocStrange` instantly in your browser with no installation required at [docstrange.nanonets.com](https:\u002F\u002Fdocstrange.nanonets.com\u002F)\n\n**See it in action:**\n\n![DocStrange Demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_readme_1890c85ec905.gif) \n\n\u003C!-- \n**Example outputs: Here's a quick preview of the quality of output**\n\n| Document Type | Source File | Output (Markdown) | Output (JSON) | Output (CSV) |\n| --- | --- | --- | --- | --- |\n| **Invoice PDF** | invoice.pdf | View Markdown | View JSON | View CSV |\n| **Research Paper** | paper.pdf | View Markdown | View JSON | NA |\n| **Word Document** | report.docx | View Markdown | View JSON | NA |\n| **Scanned Invoice** | [Ziebart.JPG](https:\u002F\u002Fnanonets.com\u002Fmedia\u002F1587320232578_ziebart.jpeg) | View Markdown | View JSON | View CSV | -->\n\n---\n\n## **Installation**\nInstall the library using pip:\n\n```bash\npip install docstrange\n```\n\n## **Quick Start**\n\n> 💡 **New to DocStrange?** Try the [online demo](https:\u002F\u002Fdocstrange.nanonets.com\u002F) first - no installation needed!\n\n**1. Convert any Document to LLM-Ready Markdown**\n\nThis is the most common use case. Turn a complex PDF or DOCX file into clean, structured Markdown, perfect for RAG pipelines and other LLM applications.\n\n```python\nfrom docstrange import DocumentExtractor\n\n# Initialize extractor (cloud mode by default)\nextractor = DocumentExtractor()\n\n# Convert any document to clean markdown\nresult = extractor.extract(\"document.pdf\")\nmarkdown = result.extract_markdown()\nprint(markdown)\n```\n\n**2. Extract Structured Data as JSON**\n\nGo beyond plain text and extract all detected entities and content from your document into a structured JSON format.\n\n```python\nfrom docstrange import DocumentExtractor\n\n# Extract document as structured JSON\nextractor = DocumentExtractor()\nresult = extractor.extract(\"document.pdf\")\n\n# Get all important data as flat JSON\njson_data = result.extract_data()\nprint(json_data)\n```\n\n**3. Extract Specific Fields from a PDF or Invoice** \n\nTarget only the key-value data you need, such as extracting the invoice_number or total_amount directly from a document.\n\n```python\nfrom docstrange import DocumentExtractor\n\n# Extract only the fields you need\nextractor = DocumentExtractor()\nresult = extractor.extract(\"invoice.pdf\")\n\n# Specify exactly which fields to extract\nfields = result.extract_data(specified_fields=[\n    \"invoice_number\", \"total_amount\", \"vendor_name\", \"due_date\"\n])\nprint(fields)\n```\n\n**4. Extract with Custom JSON Schema**\n\nEnsure the structure of your output by providing a custom JSON schema. This is ideal for getting reliable, nested data structures for applications that process contracts or complex forms.\n\n```python\nfrom docstrange import DocumentExtractor\n\n# Extract data conforming to your schema\nextractor = DocumentExtractor()\nresult = extractor.extract(\"contract.pdf\")\n\n# Define your required structure\nschema = {\n    \"contract_number\": \"string\",\n    \"parties\": [\"string\"],\n    \"total_value\": \"number\",\n    \"start_date\": \"string\",\n    \"terms\": [\"string\"]\n}\n\nstructured_data = result.extract_data(json_schema=schema)\nprint(structured_data)\n```\n\n**Local Processing**\n\nFor complete privacy and offline capability, run DocStrange entirely on your own machine using GPU processing.\n\n```python\n# Force local GPU processing (requires CUDA)\nextractor = DocumentExtractor(gpu=True)\n```\n\n---\n\n## Local Web Interface\n\n💡 Want a GUI? Run the simple, drag-and-drop local web interface for private, offline document conversion.\n\nFor users who prefer a graphical interface, DocStrange includes a powerful, self-hosted web UI. This allows for easy drag-and-drop conversion of PDF, DOCX, and other files directly in your browser, with 100% private, offline processing on your own GPU. The interface automatically downloads required models on its first run.\n\n### How to get started?\n\n1. **Install with web dependencies:**\n\n```bash\npip install \"docstrange[web]\"\n```\n\n2. **Run the web interface:**\n\n```bash\n# Method 1: Using the CLI command\ndocstrange web\n\n# Method 2: Using Python module\npython -m docstrange.web_app\n\n# Method 3: Direct Python import\npython -c \"from docstrange.web_app import run_web_app; run_web_app()\"\n```\n\n3. **Open your browser:** Navigate to `http:\u002F\u002Flocalhost:8000` (or the port shown in the terminal)\n\n### **Features of DocStrange's Local Web Interface:**\n\n- 🖱️ Drag & Drop Interface: Simply drag files onto the upload area.\n- 📁 Multiple File Types: Supports PDF, DOCX, XLSX, PPTX, images, and more.\n- ⚙️ Processing Modes: Choose between Cloud and Local GPU processing.\n- 📊 Multiple Output Formats: Get Markdown, HTML, JSON, CSV, and Flat JSON.\n- 🔒 Privacy Options: Choose between cloud processing (default) or local GPU processing.\n- 📱 Responsive Design: Works on desktop, tablet, and mobile\n\n### **Supported File Types:**\n\n- **Documents**: PDF, DOCX, DOC, PPTX, PPT\n- **Spreadsheets**: XLSX, XLS, CSV\n- **Images**: PNG, JPG, JPEG, TIFF, BMP\n- **Web**: HTML, HTM\n- **Text**: TXT\n\n### **Processing Modes:**\n\n- **Cloud processing:** For instant, zero-setup conversion, you can head over to [docstrange.nanonets.com](http:\u002F\u002Fdocstrange.nanonets.com\u002F) **—** no setup (default)\n- **Local GPU**: Fastest local processing, requires CUDA support\n\n### **Output Formats:**\n\n- **Markdown**: Clean, structured text perfect for documentation\n- **HTML**: Formatted output with styling and layout\n- **CSV**: Table data in spreadsheet format\n- **Flat JSON**: Simplified JSON structure\n- **Specific Fields**: Specific information from documents\n\n\n### **Advanced Usage:**\n\n1. Run on a Custom Port:\n\n```bash\n# Run on a different port\ndocstrange web --port 8080\npython -c \"from docstrange.web_app import run_web_app; run_web_app(port=8080)\"\n```\n\n2. Run in Development Mode:\n\n```bash\n# Run with debug mode for development\npython -c \"from docstrange.web_app import run_web_app; run_web_app(debug=True)\"\n```\n\n3. Run on a Custom Host (to make it accessible on your local network):\n\n```bash\n# Make accessible from other devices on the network\npython -c \"from docstrange.web_app import run_web_app; run_web_app(host='0.0.0.0')\"\n```\n\n### **Troubleshooting**\n\n1. Port Already in Use:\n\n```bash\n# Use a different port\ndocstrange web --port 8001\n```\n\n2. GPU Not Available:\n\n- The interface automatically detects GPU availability\n- GPU option will be disabled if CUDA is not available\n- Error will be thrown\n\n3. Model Download Issues:\n\n- Models are downloaded automatically on first startup\n- Check your internet connection during initial setup\n- Download progress is shown in the terminal\n\n4. Installation Issues:\n\n```bash\n# Install with all dependencies\npip install -e \".[web]\"\n# Or install Flask separately\npip install Flask\n```\n\n**Cloud Alternative**\n\nNeed cloud processing? Use the official DocStrange Cloud service: 🔗 **[docstrange.nanonets.com](https:\u002F\u002Fdocstrange.nanonets.com\u002F)**\n\n---\n\n## Usage and Features\n\nYou can use DocStrange in three main ways: as a simple Web Interface, as a flexible Python Library, or as a powerful Command Line Interface (CLI). This section provides a summary of the library's key capabilities, followed by detailed guides and examples for each method.\n\n1. **Convert Multiple File Types**\n\nDocStrange natively handles a wide variety of formats, returning the most appropriate output for each.\n\n```python\nfrom docstrange import DocumentExtractor\n\nextractor = DocumentExtractor()\n\n# PDF document\npdf_result = extractor.extract(\"report.pdf\")\nprint(pdf_result.extract_markdown())\n\n# Word document\ndocx_result = extractor.extract(\"document.docx\")\nprint(docx_result.extract_data())\n\n# Excel spreadsheet\nexcel_result = extractor.extract(\"data.xlsx\")\nprint(excel_result.extract_csv())\n\n# PowerPoint presentation\npptx_result = extractor.extract(\"slides.pptx\")\nprint(pptx_result.extract_html())\n\n# Image with text\nimage_result = extractor.extract(\"screenshot.png\")\nprint(image_result.extract_text())\n\n# Web page\nurl_result = extractor.extract(\"https:\u002F\u002Fexample.com\")\nprint(url_result.extract_markdown())\n```\n\n**b. Extract Tables to CSV**\n\nEasily extracts all tables from a document into a clean CSV format.\n\n```python\n# Extract all tables from a document\nresult = extractor.extract(\"financial_report.pdf\")\ncsv_data = result.extract_csv()\nprint(csv_data)\n```\n\n\n**c. Extract Specific Fields & Structured Data**\n\nYou can go beyond simple conversion and extract data in the exact structure you require. There are two ways to do this. You can either target and pull only the key-value data you need or ensure the structure of your output by providing a custom JSON schema. \n\n```python\n# Extract specific fields from any document\nresult = extractor.extract(\"invoice.pdf\")\n\n# Method 1: Extract specific fields\nextracted = result.extract_data(specified_fields=[\n    \"invoice_number\",\n    \"total_amount\", \n    \"vendor_name\",\n    \"due_date\"\n])\n\n# Method 2: Extract using JSON schema\nschema = {\n    \"invoice_number\": \"string\",\n    \"total_amount\": \"number\", \n    \"vendor_name\": \"string\",\n    \"line_items\": [{\n        \"description\": \"string\",\n        \"amount\": \"number\"\n    }]\n}\n\nstructured = result.extract_data(json_schema=schema)\n```\n\n**d. Cloud Mode Usage Examples:**\n\nUse DocStrange's cloud mode to extract precise, structured data from various documents by either specifying a list of fields to find or enforcing a custom JSON schema for the output. Authenticate with DocStrange login or a free API key to get 10,000 documents\u002Fmonth.\n\n```python\nfrom docstrange import DocumentExtractor\n\n# Default cloud mode (rate-limited without API key)\nextractor = DocumentExtractor()\n\n# Authenticated mode (10k docs\u002Fmonth) - run 'docstrange login' first\nextractor = DocumentExtractor()  # Auto-uses cached credentials\n\n# With API key for 10k docs\u002Fmonth (alternative to login)\nextractor = DocumentExtractor(api_key=\"your_api_key_here\")\n\n# Extract specific fields from invoice\nresult = extractor.extract(\"invoice.pdf\")\n\n# Extract key invoice information\ninvoice_fields = result.extract_data(specified_fields=[\n    \"invoice_number\",\n    \"total_amount\", \n    \"vendor_name\",\n    \"due_date\",\n    \"items_count\"\n])\n\nprint(\"Extracted Invoice Fields:\")\nprint(invoice_fields)\n# Output: {\"extracted_fields\": {\"invoice_number\": \"INV-001\", ...}, \"format\": \"specified_fields\"}\n\n# Extract structured data using schema\ninvoice_schema = {\n    \"invoice_number\": \"string\",\n    \"total_amount\": \"number\",\n    \"vendor_name\": \"string\",\n    \"billing_address\": {\n        \"street\": \"string\",\n        \"city\": \"string\", \n        \"zip_code\": \"string\"\n    },\n    \"line_items\": [{\n        \"description\": \"string\",\n        \"quantity\": \"number\",\n        \"unit_price\": \"number\",\n        \"total\": \"number\"\n    }],\n    \"taxes\": {\n        \"tax_rate\": \"number\",\n        \"tax_amount\": \"number\"\n    }\n}\n\nstructured_invoice = result.extract_data(json_schema=invoice_schema)\nprint(\"Structured Invoice Data:\")\nprint(structured_invoice)\n# Output: {\"structured_data\": {...}, \"schema\": {...}, \"format\": \"structured_json\"}\n\n# Extract from different document types\nreceipt = extractor.extract(\"receipt.jpg\")\nreceipt_data = receipt.extract_data(specified_fields=[\n    \"merchant_name\", \"total_amount\", \"date\", \"payment_method\"\n])\n\ncontract = extractor.extract(\"contract.pdf\") \ncontract_schema = {\n    \"parties\": [{\n        \"name\": \"string\",\n        \"role\": \"string\"\n    }],\n    \"contract_value\": \"number\",\n    \"start_date\": \"string\",\n    \"end_date\": \"string\",\n    \"key_terms\": [\"string\"]\n}\ncontract_data = contract.extract_data(json_schema=contract_schema)\n```\n\n\n**e. Chain with LLM**\n\nThe clean Markdown output is perfect for use in Retrieval-Augmented Generation (RAG) and other LLM workflows. \n\n```python\n# Perfect for LLM workflows\ndocument_text = extractor.extract(\"research_paper.pdf\").extract_markdown()\n\n# Use with any LLM\nresponse = your_llm_client.chat(\n    messages=[{\n        \"role\": \"user\", \n        \"content\": f\"Summarize this research paper:\\n\\n{document_text}\"\n    }]\n)\n```\n\n### **Key Capabilities**\n\n- **🌐 Universal Input**: Process a wide range of formats, including **PDF**, **DOCX**, **PPTX**, **XLSX**, images, and URLs.\n- **🔒 Dual Processing Modes**: Choose between a cloud API for instant processing or **100% private, local processing** on your own CPU or GPU.\n- **🤖 Intelligent Extraction**: Extract **specific fields** or enforce a nested **JSON schema** to get structured data output.\n- **🖼️ Advanced OCR**: Handle scanned documents and images with an OCR pipeline that includes **multiple engine fallbacks**.\n- **📊 Table & Structure Recognition**: Accurately **extract tables** and preserve document structure, producing clean, **LLM-optimized** output.\n- **🖥️ Built-in Web UI**: Use the built-in **drag-and-drop web interface** for easy local conversions.\n\n### **How It Works**\n\nDocStrange uses a multi-stage process to create structured output from documents.\n\n1. **Ingestion**: It natively handles various file formats, including PDF, DOCX, PPTX, images, and URLs.\n2. **Layout Detection**: The library identifies the structure of the document, such as headers, paragraphs, lists, and tables, to preserve the original reading order.\n3. **OCR & Text Extraction**: It employs advanced OCR for scanned documents and directly extracts text from digital files.\n4. **Formatting & Cleaning**: The extracted content is converted into clean, LLM-optimized Markdown and other formats, removing page artifacts.\n5. **Structured Extraction (Optional)**: If a schema or specific fields are provided, DocStrange uses an LLM to populate the desired JSON structure.\n\n---\n\n## Cloud API Tiers and Rate Limits\n\n`DocStrange` offers free cloud processing with different tiers to ensure fair usage.\n\n- **🔐 Authenticated Access (Recommended)**\n    - **Rate Limit**: **10,000 documents\u002Fmonth**.\n    - **Setup**: A single command: `docstrange login`.\n    - **Benefits**: Links to your Google account for a significantly higher free limit.\n- **🔑 API Key Access (Alternative)**\n    - **Rate Limit**: **10,000 documents\u002Fmonth**.\n    - **Setup**: Get a free API key from [docstrange.nanonets.com](https:\u002F\u002Fdocstrange.nanonets.com\u002F).\n    - Usage: Pass the API key when initializing the library.\n\n```python\n# Free tier usage (limited calls daily)\nextractor = DocumentExtractor()\n\n# Authenticated access (10k docs\u002Fmonth) - run 'docstrange login' first\nextractor = DocumentExtractor()  # Auto-uses cached credentials\n\n# API key access (10k docs\u002Fmonth)\nextractor = DocumentExtractor(api_key=\"your_api_key_here\")\n```\n\n💡 **Tip**: Start with the anonymous free tier to test functionality, then authenticate with `docstrange login` for the full 10,000 documents\u002Fmonth limit.\n\n---\n\n## **Command Line Interface (CLI)**\n\n💡 **Prefer a GUI?** Try the [web interface](https:\u002F\u002Fdocstrange.nanonets.com\u002F) for drag-and-drop document conversion!\n\nFor automation, scripting, and batch processing, you can use DocStrange directly from your terminal.\n\n**Authentication Commands**\n\n```bash\n# One-time login for free 10k docs\u002Fmonth (alternative to api key)\ndocstrange login\n\n# Alternatively\ndocstrange --login\n\n# Re-authenticate if needed\ndocstrange login --reauth\n\n# Logout and clear cached credentials\ndocstrange --logout\n```\n\n**Document Processing**\n\n```bash\n# Basic conversion (cloud mode default - limited calls free!)\ndocstrange document.pdf\n\n# Authenticated processing (10k docs\u002Fmonth for free after login)\ndocstrange document.pdf\n\n# With API key for 10k docs\u002Fmonth access (alternative to login)\ndocstrange document.pdf --api-key YOUR_API_KEY\n\n# Local processing modes\ndocstrange document.pdf --gpu-mode\n\n# Different output formats\ndocstrange document.pdf --output json\ndocstrange document.pdf --output html\ndocstrange document.pdf --output csv\n\n# Extract specific fields\ndocstrange invoice.pdf --output json --extract-fields invoice_number total_amount\n\n# Extract with JSON schema\ndocstrange document.pdf --output json --json-schema schema.json\n\n# Multiple files\ndocstrange *.pdf --output markdown\n\n# Save to file\ndocstrange document.pdf --output-file result.md\n\n# Comprehensive field extraction examples\ndocstrange invoice.pdf --output json --extract-fields invoice_number vendor_name total_amount due_date line_items\n\n# Extract from different document types with specific fields\ndocstrange receipt.jpg --output json --extract-fields merchant_name total_amount date payment_method\n\ndocstrange contract.pdf --output json --extract-fields parties contract_value start_date end_date\n\n# Using JSON schema files for structured extraction\ndocstrange invoice.pdf --output json --json-schema invoice_schema.json\ndocstrange contract.pdf --output json --json-schema contract_schema.json\n\n# Combine with authentication for 10k docs\u002Fmonth access (after 'docstrange login')\ndocstrange document.pdf --output json --extract-fields title author date summary\n\n# Or use API key for 10k docs\u002Fmonth access (alternative to login)\ndocstrange document.pdf --api-key YOUR_API_KEY --output json --extract-fields title author date summary\n\n```\n\n**Example schema.json file:**\n\n```json\n{\n  \"invoice_number\": \"string\",\n  \"total_amount\": \"number\",\n  \"vendor_name\": \"string\",\n  \"billing_address\": {\n    \"street\": \"string\",\n    \"city\": \"string\",\n    \"zip_code\": \"string\"\n  },\n  \"line_items\": [{\n    \"description\": \"string\",\n    \"quantity\": \"number\",\n    \"unit_price\": \"number\"\n  }]\n}\n```\n\n## **API Reference for library**\n\nThis section details the main classes and methods for programmatic use. \n\n1. **DocumentExtractor**\n\n```python\nDocumentExtractor(\n    api_key: str = None,              # API key for 10k docs\u002Fmonth (or use 'docstrange login' for same limits)\n    model: str = None,                # Model for cloud processing (\"gemini\", \"openapi\", \"nanonets\")\n    cpu: bool = False,                # Force local CPU processing\n    gpu: bool = False                 # Force local GPU processing\n)\n```\n\n**b. ConversionResult Methods**\n\n```python\nresult.extract_markdown() -> str                    # Clean markdown output\nresult.extract_data(                              # Structured JSON\n    specified_fields: List[str] = None,       # Extract specific fields\n    json_schema: Dict = None                  # Extract with schema\n) -> Dict\nresult.extract_html() -> str                      # Formatted HTML\nresult.extract_csv() -> str                       # CSV format for tables\nresult.extract_text() -> str                      # Plain text\n```\n\n---\n\n## **🤖 MCP Server for Claude Desktop (Local Development)**\n\nThe DocStrange repository includes an optional MCP (Model Context Protocol) server for local development that enables intelligent document processing in Claude Desktop with token-aware navigation.\n\n> Note: The MCP server is designed for local development and is **not included** in the PyPI package. Clone the repository to use it locally.\n\n**Features**\n\n- **Smart Token Counting**: Automatically counts tokens and recommends processing strategy\n- **Hierarchical Navigation**: Navigate documents by structure when they exceed context limits\n- **Intelligent Chunking**: Automatically splits large documents into token-limited chunks\n- **Advanced Search**: Search within documents and get contextual results\n\n**Local Setup**\n\n1. Clone the repository:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fnanonets\u002Fdocstrange.git\ncd docstrange\n```\n\n2. Install in development mode:\n\n```bash\npip install -e \".[dev]\"\n```\n\n3. Add to your Claude Desktop config (`~\u002FLibrary\u002FApplication Support\u002FClaude\u002Fclaude_desktop_config.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"docstrange\": {\n      \"command\": \"python3\",\n      \"args\": [\"\u002Fpath\u002Fto\u002Fdocstrange\u002Fmcp_server_module\u002Fserver.py\"]\n    }\n  }\n}\n```\n\n4. Restart Claude Desktop\n\nFor detailed setup and usage, see [mcp_server_module\u002FREADME.md](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fblob\u002Fmain\u002Fmcp_server_module\u002FREADME.md)\n\n---\n\n\n## **The Nanonets Ecosystem**\n\n`DocStrange` is a powerful open-source library developed and maintained by the team at **Nanonets**. The full Nanonets platform is an AI-driven solution for automating end-to-end document processing for businesses. The platform allows technical and non-technical teams to build complete automated document workflows.\n\n## **Community, Support, & License**\n\nThis is an actively developed open-source project, and we welcome your feedback and contributions.\n\n- **Discussions**: For questions, ideas, and to show what you've built, please visit our [**GitHub Discussions**](https:\u002F\u002Fwww.google.com\u002Fsearch?q=URL_TO_GITHUB_DIScussions).\n- **Issues**: For bug reports and feature requests, please open an [**Issue**](https:\u002F\u002Fwww.google.com\u002Fsearch?q=URL_TO_GITHUB_ISSUES).\n- **Email**: For private inquiries, you can reach us at [**support@nanonets.com**](mailto:support@nanonets.com).\n\n⭐ Star this repo if you find it helpful! Your support helps us improve the library.\n\n**License:** This project is licensed under the **MIT License.** \n","![DocStrange 横幅](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_readme_b05a0a106bba.png)\n\n# \u003Cimg src=\"https:\u002F\u002Fpublic-vlms.s3.us-west-2.amazonaws.com\u002Fdocstrange_logo.svg\" alt=\"DocStrange\" width=\"32\" style=\"vertical-align: middle; margin-right: 8px;\">  DocStrange\n\n[![PyPI版本](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Fdocstrange.svg?v=2)](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Fdocstrange)\n[![Python](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fpyversions\u002Fdocstrange.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fdocstrange\u002F)\n[![PyPI下载量](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_readme_1c7d3ce53766.png)](https:\u002F\u002Fpepy.tech\u002Fprojects\u002Fdocstrange)\n[![GitHub 星标](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002FNanoNets\u002Fdocstrange?style=social)](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange)\n[![GitHub 分支](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fforks\u002FNanoNets\u002Fdocstrange?style=social)](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange)\n[![许可证：MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n[![平台](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fplatform-linux%20%7C%20macOS%20%7C%20windows-lightgrey)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fdocstrange\u002F)\n[![维护状态](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMaintained%3F-yes-green.svg)](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fgraphs\u002Fcommit-activity)\n\n> 🚀 **[在线试用 DocStrange →](https:\u002F\u002Fdocstrange.nanonets.com\u002F)**\n\n# DocStrange\n\nDocStrange 能够快速且准确地将文档转换为 Markdown、JSON、CSV 和 HTML 格式。\n\n- 支持 PDF、图片、PPTX、DOCX、XLSX 和 URL 文件的转换。\n- 将表格格式化为简洁、适合大语言模型优化的 Markdown。\n- 基于升级后的 7B 参数模型，提供更高的准确性和更深入的文档理解能力。\n- 通过先进的 OCR 技术从图片和扫描件中提取文本。\n- 自动去除页面杂乱内容，输出整洁易读的结果。\n- 可根据指定字段或 JSON 模式进行结构化数据提取。\n- 内置本地 Web UI，支持便捷的拖放式文件转换。\n- 提供免费云端 API 实现即时处理，同时也支持完全私密的本地模式。\n- 在本地运行时可选择 GPU 或 CPU 加速。\n- 通过 MCP 服务器与 Claude Desktop 集成，实现智能文档导航。\n\n---\n\n![DocStrange 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_readme_4091e6f5df05.gif)\n\n\n## 处理模式\n> **☁️ 免费云端处理，每月最多 10000 篇文档！**  \n> 使用云端处理功能即可立即提取文档数据，无需复杂配置。  \n\n> **🔒 本地处理！**  \n> 选择 `gpu` 模式可实现 100% 的本地处理——所有数据均保留在您的设备上，不会被发送到任何地方。\n\n\n## **最新动态**\n\n**2025 年 8 月**\n\n- 🚀 **核心模型重大升级**：核心模型已升级至 **7B 参数**，显著提升了对复杂文档的准确性和深度理解能力。\n- 🖥️ **本地 Web 界面**：新增内置本地 GUI，您现在可以通过简单的拖放操作完成文档转换，全程离线使用。\n\n---\n\n## 关于\n\n将 PDF、DOCX、图片等文件转换并提取为干净的 Markdown 和结构化的 JSON 数据。此外，还支持高级表格提取、100% 本地处理以及内置 Web UI。\n\n`DocStrange` 是一个 Python 库，用于将多种文档格式（包括 **PDF**、**DOCX**、**PPTX**、**XLSX** 和 **图片**）转换为干净、可用的数据。它能够生成适合大语言模型优化的 **Markdown**、带模式支持的 **JSON**、**HTML** 和 **CSV** 输出，是为 RAG 流水线和其他 AI 应用准备内容的理想工具。\n\n该库同时提供强大的云端 API 和完全私密的本地模式，可在您的 GPU 上本地运行。由 **Nanonets** 开发，DocStrange 基于强大的 OCR 和版面检测模型流水线构建，目前需要 **Python >=3.8**。\n\n**如需报告错误或请求功能，请 [提交问题](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fissues)。如有疑问或需要帮助，请使用 [讨论区](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fdiscussions)。**\n\n---\n\n## **DocStrange 的独特之处**\n\n`DocStrange` 专注于端到端的文档理解流程（OCR → 版面分析 → 表格识别 → 清洁 Markdown 或结构化 JSON），并且可以在本地 100% 运行。它旨在直接从扫描件和照片中获得高质量结果，而无需集成多个服务。\n\n- **与云上 AI 服务（如 AWS Textract）相比**：`DocStrange` 提供完全私密的本地处理选项，并让您完全掌控整个转换流程。\n- **与编排框架（如 LangChain）相比**：`DocStrange` 是一个开箱即用的解析流水线，而非单纯的框架。它负责复杂的 OCR 和版面分析工作，您无需自行搭建。\n- **与其他文档解析器相比**：`DocStrange` 专为扫描件和手机照片设计，具备强大的 OCR 功能，而不仅仅是针对原生数字 PDF 文件。\n\n### **何时选择 DocStrange**\n- 您需要一个 **免费的云端 API**，以便从不同类型的文档中提取结构化信息（Markdown、JSON、CSV、HTML）。\n- 您需要 **本地处理** 以确保隐私和合规性。\n- 您正在处理 **扫描件、手机照片或收据**，其中高质量 OCR 至关重要。\n- 您希望找到一条 **快速路径**，直接获取干净的 Markdown 或结构化 JSON，而无需训练模型。\n\n---\n\n## **示例**\n\n试试实时演示：无需安装即可在浏览器中立即测试 `DocStrange`，访问地址：[docstrange.nanonets.com](https:\u002F\u002Fdocstrange.nanonets.com\u002F)\n\n**实际效果展示：**\n\n![DocStrange 演示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_readme_1890c85ec905.gif) \n\n\u003C!-- \n**示例输出：以下是输出质量的快速预览**\n\n| 文档类型 | 源文件 | 输出（Markdown） | 输出（JSON） | 输出（CSV） |\n| --- | --- | --- | --- | --- |\n| **发票 PDF** | invoice.pdf | 查看 Markdown | 查看 JSON | 查看 CSV |\n| **研究论文** | paper.pdf | 查看 Markdown | 查看 JSON | 不适用 |\n| **Word 文档** | report.docx | 查看 Markdown | 查看 JSON | 不适用 |\n| **扫描发票** | [Ziebart.JPG](https:\u002F\u002Fnanonets.com\u002Fmedia\u002F1587320232578_ziebart.jpeg) | 查看 Markdown | 查看 JSON | 查看 CSV | -->\n\n---\n\n## **安装**\n使用 pip 安装该库：\n\n```bash\npip install docstrange\n```\n\n## **快速入门**\n\n> 💡 **初次使用 DocStrange？** 先试试 [在线演示](https:\u002F\u002Fdocstrange.nanonets.com\u002F) 吧——无需安装！\n\n**1. 将任意文档转换为适合大语言模型的 Markdown**\n\n这是最常见的用法。将复杂的 PDF 或 DOCX 文件转化为简洁、结构化的 Markdown，非常适合 RAG 流水线和其他大语言模型应用。\n\n```python\nfrom docstrange import DocumentExtractor\n\n# 初始化提取器（默认为云端模式）\nextractor = DocumentExtractor()\n\n# 将任意文档转换为干净的 Markdown\nresult = extractor.extract(\"document.pdf\")\nmarkdown = result.extract_markdown()\nprint(markdown)\n```\n\n**2. 提取结构化数据为 JSON**\n\n超越纯文本，将文档中检测到的所有实体和内容提取为结构化的 JSON 格式。\n\n```python\nfrom docstrange import DocumentExtractor\n\n# 将文档提取为结构化的 JSON\nextractor = DocumentExtractor()\nresult = extractor.extract(\"document.pdf\")\n\n# 获取所有重要数据，以扁平化 JSON 格式\njson_data = result.extract_data()\nprint(json_data)\n```\n\n**3. 从 PDF 或发票中提取特定字段**\n\n仅提取您需要的键值对数据，例如直接从文档中提取 invoice_number 或 total_amount。\n\n```python\nfrom docstrange import DocumentExtractor\n\n# 只提取所需字段\nextractor = DocumentExtractor()\nresult = extractor.extract(\"invoice.pdf\")\n\n# 指定要提取的具体字段\nfields = result.extract_data(specified_fields=[\n    \"invoice_number\", \"total_amount\", \"vendor_name\", \"due_date\"\n])\nprint(fields)\n```\n\n**4. 使用自定义 JSON 模式提取数据**\n\n通过提供自定义 JSON 模式来确保输出的结构。这对于为处理合同或复杂表单的应用程序获取可靠、嵌套的数据结构非常理想。\n\n```python\nfrom docstrange import DocumentExtractor\n\n# 提取符合您模式的数据\nextractor = DocumentExtractor()\nresult = extractor.extract(\"contract.pdf\")\n\n# 定义所需的结构\nschema = {\n    \"contract_number\": \"string\",\n    \"parties\": [\"string\"],\n    \"total_value\": \"number\",\n    \"start_date\": \"string\",\n    \"terms\": [\"string\"]\n}\n\nstructured_data = result.extract_data(json_schema=schema)\nprint(structured_data)\n```\n\n**本地处理**\n\n为了完全保护隐私并实现离线功能，您可以使用 GPU 处理在自己的机器上运行 DocStrange。\n\n```bash\n# 强制使用本地 GPU 处理（需要 CUDA）\nextractor = DocumentExtractor(gpu=True)\n```\n\n---\n\n## 本地 Web 界面\n\n💡 想要图形界面吗？运行简单、拖放式的本地 Web 界面，实现私密、离线的文档转换。\n\n对于喜欢图形界面的用户，DocStrange 提供了一个功能强大的自托管 Web UI。它允许您在浏览器中轻松地拖放 PDF、DOCX 等文件进行转换，并且所有处理都在您的本地 GPU 上进行，100% 私密、离线。该界面首次运行时会自动下载所需的模型。\n\n### 如何开始？\n\n1. **安装包含 Web 依赖项的包：**\n\n```bash\npip install \"docstrange[web]\"\n```\n\n2. **运行 Web 界面：**\n\n```bash\n# 方法 1：使用 CLI 命令\ndocstrange web\n\n# 方法 2：使用 Python 模块\npython -m docstrange.web_app\n\n# 方法 3：直接导入 Python 脚本\npython -c \"from docstrange.web_app import run_web_app; run_web_app()\"\n```\n\n3. **打开浏览器：** 导航到 `http:\u002F\u002Flocalhost:8000`（或终端显示的端口）\n\n### DocStrange 本地 Web 界面的功能：\n\n- 🖱️ 拖放界面：只需将文件拖放到上传区域。\n- 📁 支持多种文件类型：PDF、DOCX、XLSX、PPTX、图片等。\n- ⚙️ 处理模式：可选择云端处理或本地 GPU 处理。\n- 📊 多种输出格式：Markdown、HTML、JSON、CSV 和扁平化 JSON。\n- 🔒 隐私选项：可以选择云端处理（默认）或本地 GPU 处理。\n- 📱 响应式设计：适用于桌面、平板和手机。\n\n### 支持的文件类型：\n\n- **文档：** PDF、DOCX、DOC、PPTX、PPT\n- **电子表格：** XLSX、XLS、CSV\n- **图片：** PNG、JPG、JPEG、TIFF、BMP\n- **网页：** HTML、HTM\n- **文本：** TXT\n\n### 处理模式：\n\n- **云端处理：** 如果您希望立即进行转换且无需任何设置，可以访问 [docstrange.nanonets.com](http:\u002F\u002Fdocstrange.nanonets.com\u002F) —— 默认为云端处理。\n- **本地 GPU：** 最快的本地处理方式，需要 CUDA 支持。\n\n### 输出格式：\n\n- **Markdown：** 干净、结构化的文本，非常适合文档编写。\n- **HTML：** 带有样式和布局的格式化输出。\n- **CSV：** 电子表格格式的表格数据。\n- **扁平化 JSON：** 简化的 JSON 结构。\n- **特定字段：** 从文档中提取特定信息。\n\n### 高级用法：\n\n1. 在自定义端口上运行：\n\n```bash\n# 在不同端口上运行\ndocstrange web --port 8080\npython -c \"from docstrange.web_app import run_web_app; run_web_app(port=8080)\"\n```\n\n2. 以开发模式运行：\n\n```bash\n# 开启调试模式进行开发\npython -c \"from docstrange.web_app import run_web_app; run_web_app(debug=True)\"\n```\n\n3. 在自定义主机上运行（以便在本地网络中访问）：\n\n```bash\n# 使其他设备可以在本地网络中访问\npython -c \"from docstrange.web_app import run_web_app; run_web_app(host='0.0.0.0')\"\n```\n\n### 故障排除\n\n1. 端口已被占用：\n\n```bash\n# 使用其他端口\ndocstrange web --port 8001\n```\n\n2. GPU 不可用：\n\n- 界面会自动检测 GPU 是否可用。\n- 如果没有 CUDA，GPU 选项将被禁用。\n- 系统会抛出错误。\n\n3. 模型下载问题：\n\n- 模型会在首次启动时自动下载。\n- 请检查初始设置期间的互联网连接。\n- 终端会显示下载进度。\n\n4. 安装问题：\n\n```bash\n# 安装包含所有依赖项的包\npip install -e \".[web]\"\n# 或单独安装 Flask\npip install Flask\n```\n\n**云端替代方案**\n\n需要云端处理吗？请使用官方的 DocStrange 云服务：🔗 **[docstrange.nanonets.com](https:\u002F\u002Fdocstrange.nanonets.com\u002F)**\n\n---\n\n## 使用方法与功能\n\n您可以以三种主要方式使用 DocStrange：作为简单的 Web 界面、灵活的 Python 库，或强大的命令行接口 (CLI)。本节将总结该库的主要功能，并为每种方法提供详细的指南和示例。\n\n1. **转换多种文件类型**\n\nDocStrange 原生支持多种格式，并为每种格式返回最合适的输出。\n\n```python\nfrom docstrange import DocumentExtractor\n\nextractor = DocumentExtractor()\n\n# PDF 文档\npdf_result = extractor.extract(\"report.pdf\")\nprint(pdf_result.extract_markdown())\n\n# Word 文档\ndocx_result = extractor.extract(\"document.docx\")\nprint(docx_result.extract_data())\n\n# Excel 表格\nexcel_result = extractor.extract(\"data.xlsx\")\nprint(excel_result.extract_csv())\n\n# PowerPoint 演示文稿\npptx_result = extractor.extract(\"slides.pptx\")\nprint(pptx_result.extract_html())\n\n# 包含文字的图片\nimage_result = extractor.extract(\"screenshot.png\")\nprint(image_result.extract_text())\n\n# 网页\nurl_result = extractor.extract(\"https:\u002F\u002Fexample.com\")\nprint(url_result.extract_markdown())\n```\n\n**b. 将表格提取为 CSV**\n\n轻松将文档中的所有表格提取为整洁的 CSV 格式。\n\n```python\n# 提取文档中的所有表格\nresult = extractor.extract(\"financial_report.pdf\")\ncsv_data = result.extract_csv()\nprint(csv_data)\n```\n\n\n**c. 提取特定字段及结构化数据**\n\n您不仅可以进行简单的转换，还可以按所需的精确结构提取数据。有两种方法可以做到这一点：要么只提取您需要的键值对数据，要么通过提供自定义 JSON 模式来确保输出的结构。\n\n```python\n# 从任何文档中提取特定字段\nresult = extractor.extract(\"invoice.pdf\")\n\n# 方法 1：提取特定字段\nextracted = result.extract_data(specified_fields=[\n    \"invoice_number\",\n    \"total_amount\", \n    \"vendor_name\",\n    \"due_date\"\n])\n\n# 方法 2：使用 JSON 模式提取\nschema = {\n    \"invoice_number\": \"string\",\n    \"total_amount\": \"number\", \n    \"vendor_name\": \"string\",\n    \"line_items\": [{\n        \"description\": \"string\",\n        \"amount\": \"number\"\n    }]\n}\n\nstructured = result.extract_data(json_schema=schema)\n```\n\n**d. 云模式使用示例：**\n\n使用 DocStrange 的云模式，通过指定要查找的字段列表或强制输出自定义 JSON 模式，从各种文档中提取精确的结构化数据。使用 DocStrange 登录或免费 API 密钥进行身份验证，即可获得每月 10,000 次文档处理额度。\n\n```python\nfrom docstrange import DocumentExtractor\n\n# 默认云模式（未提供 API 密钥时有速率限制）\nextractor = DocumentExtractor()\n\n# 已认证模式（每月 1 万次文档处理）——需先运行 'docstrange login'\nextractor = DocumentExtractor()  # 自动使用缓存的凭据\n\n# 使用 API 密钥实现每月 1 万次文档处理（替代登录方式）\nextractor = DocumentExtractor(api_key=\"your_api_key_here\")\n\n# 从发票中提取特定字段\nresult = extractor.extract(\"invoice.pdf\")\n\n# 提取关键发票信息\ninvoice_fields = result.extract_data(specified_fields=[\n    \"invoice_number\",\n    \"total_amount\", \n    \"vendor_name\",\n    \"due_date\",\n    \"items_count\"\n])\n\nprint(\"提取的发票字段：\")\nprint(invoice_fields)\n# 输出：{\"extracted_fields\": {\"invoice_number\": \"INV-001\", ...}, \"format\": \"specified_fields\"}\n\n# 使用模式提取结构化数据\ninvoice_schema = {\n    \"invoice_number\": \"string\",\n    \"total_amount\": \"number\",\n    \"vendor_name\": \"string\",\n    \"billing_address\": {\n        \"street\": \"string\",\n        \"city\": \"string\", \n        \"zip_code\": \"string\"\n    },\n    \"line_items\": [{\n        \"description\": \"string\",\n        \"quantity\": \"number\",\n        \"unit_price\": \"number\",\n        \"total\": \"number\"\n    }],\n    \"taxes\": {\n        \"tax_rate\": \"number\",\n        \"tax_amount\": \"number\"\n    }\n}\n\nstructured_invoice = result.extract_data(json_schema=invoice_schema)\nprint(\"结构化的发票数据：\")\nprint(structured_invoice)\n# 输出：{\"structured_data\": {...}, \"schema\": {...}, \"format\": \"structured_json\"}\n\n# 从不同类型的文档中提取信息\nreceipt = extractor.extract(\"receipt.jpg\")\nreceipt_data = receipt.extract_data(specified_fields=[\n    \"merchant_name\", \"total_amount\", \"date\", \"payment_method\"\n])\n\ncontract = extractor.extract(\"contract.pdf\") \ncontract_schema = {\n    \"parties\": [{\n        \"name\": \"string\",\n        \"role\": \"string\"\n    }],\n    \"contract_value\": \"number\",\n    \"start_date\": \"string\",\n    \"end_date\": \"string\",\n    \"key_terms\": [\"string\"]\n}\ncontract_data = contract.extract_data(json_schema=contract_schema)\n```\n\n\n**e. 与 LLM 结合**\n\n干净的 Markdown 输出非常适合用于检索增强生成（RAG）和其他 LLM 工作流。\n\n```python\n# 非常适合 LLM 工作流\ndocument_text = extractor.extract(\"research_paper.pdf\").extract_markdown()\n\n# 可与任何 LLM 配合使用\nresponse = your_llm_client.chat(\n    messages=[{\n        \"role\": \"user\", \n        \"content\": f\"请总结这篇研究论文：\\n\\n{document_text}\"\n    }]\n)\n```\n\n### **核心功能**\n\n- **🌐 通用输入**：支持多种格式，包括 **PDF**、**DOCX**、**PPTX**、**XLSX**、图片和 URL。\n- **🔒 双重处理模式**：可选择云端 API 进行即时处理，或在您自己的 CPU 或 GPU 上进行 **100% 私密的本地处理**。\n- **🤖 智能提取**：提取 **特定字段** 或强制使用嵌套的 **JSON 模式**，以获取结构化数据输出。\n- **🖼️ 先进的 OCR**：通过包含 **多引擎回退机制** 的 OCR 流程，轻松处理扫描文档和图像。\n- **📊 表格与结构识别**：准确 **提取表格** 并保留文档结构，生成干净、**适合 LLM 的** 输出。\n- **🖥️ 内置 Web UI**：使用内置的 **拖放式 Web 界面** 轻松完成本地转换。\n\n### **工作原理**\n\nDocStrange 采用多阶段流程，将文档转换为结构化输出。\n\n1. **摄取**：原生支持多种文件格式，包括 PDF、DOCX、PPTX、图片和 URL。\n2. **布局检测**：库会识别文档的结构，例如页眉、段落、列表和表格，以保持原始阅读顺序。\n3. **OCR 与文本提取**：对扫描文档采用先进的 OCR 技术，而数字文件则直接提取文本。\n4. **格式化与清理**：提取的内容会被转换为干净、适合 LLM 的 Markdown 和其他格式，同时去除页面上的杂乱内容。\n5. **结构化提取（可选）**：如果提供了模式或特定字段，DocStrange 会使用 LLM 填充所需的 JSON 结构。\n\n---\n\n## 云 API 层级与速率限制\n\n`DocStrange` 提供免费的云处理服务，并设有不同的层级以确保公平使用。\n\n- **🔐 已认证访问（推荐）**\n    - **速率限制**：**每月 10,000 次文档处理**。\n    - **设置**：只需一条命令：`docstrange login`。\n    - **优势**：与您的 Google 账号关联后，可获得显著更高的免费额度。\n- **🔑 API 密钥访问（替代方案）**\n    - **速率限制**：**每月 10,000 次文档处理**。\n    - **设置**：从 [docstrange.nanonets.com](https:\u002F\u002Fdocstrange.nanonets.com\u002F) 获取免费 API 密钥。\n    - **使用方法**：在初始化库时传入 API 密钥。\n\n```python\n# 免费层级使用（每日调用次数有限）\nextractor = DocumentExtractor()\n\n# 已认证访问（每月 1 万次文档处理）——需先运行 'docstrange login'\nextractor = DocumentExtractor()  # 自动使用缓存的凭据\n\n# 使用 API 密钥访问（每月 1 万次文档处理）\nextractor = DocumentExtractor(api_key=\"your_api_key_here\")\n```\n\n💡 **提示**：可以先使用匿名免费层级测试功能，然后通过 `docstrange login` 进行认证，以获得完整的每月 1 万次文档处理额度。\n\n---\n\n## **命令行界面（CLI）**\n\n💡 **更喜欢图形界面吗？** 试试 [web 界面](https:\u002F\u002Fdocstrange.nanonets.com\u002F)，支持拖放式文档转换！\n\n对于自动化、脚本编写和批量处理，您可以直接在终端中使用 DocStrange。\n\n**身份验证命令**\n\n```bash\n# 一次性登录以获得免费的每月 1 万次文档处理额度（替代 API 密钥）\ndocstrange login\n\n# 或者\ndocstrange --login\n\n# 如需重新认证\ndocstrange login --reauth\n\n# 注销并清除缓存的凭据\ndocstrange --logout\n```\n\n**文档处理**\n\n```bash\n# 基本转换（默认云模式——免费但调用次数有限！）\ndocstrange document.pdf\n\n# 已认证处理（登录后可免费获得每月 1 万次文档处理额度）\ndocstrange document.pdf\n\n# 使用 API 密钥实现每月 1 万次文档处理访问（替代登录方式）\ndocstrange document.pdf --api-key YOUR_API_KEY\n\n# 本地处理模式\ndocstrange document.pdf --gpu-mode\n\n# 不同输出格式\ndocstrange document.pdf --output json\ndocstrange document.pdf --output html\ndocstrange document.pdf --output csv\n\n# 提取特定字段\ndocstrange invoice.pdf --output json --extract-fields invoice_number total_amount\n\n# 使用 JSON 模式提取\ndocstrange document.pdf --output json --json-schema schema.json\n\n# 处理多个文件\ndocstrange *.pdf --output markdown\n\n# 保存到文件\ndocstrange document.pdf --output-file result.md\n\n# 全面的字段提取示例\ndocstrange invoice.pdf --output json --extract-fields invoice_number vendor_name total_amount due_date line_items\n\n# 从不同类型的文档中提取特定字段\ndocstrange receipt.jpg --output json --extract-fields merchant_name total_amount date payment_method\n\ndocstrange contract.pdf --output json --extract-fields parties contract_value start_date end_date\n\n# 使用 JSON 模式文件进行结构化提取\ndocstrange invoice.pdf --output json --json-schema invoice_schema.json\ndocstrange contract.pdf --output json --json-schema contract_schema.json\n\n# 结合身份验证实现每月 1 万份文档的访问权限（执行 'docstrange login' 后）\ndocstrange document.pdf --output json --extract-fields title author date summary\n\n# 或者使用 API 密钥实现每月 1 万份文档的访问权限（作为登录的替代方案）\ndocstrange document.pdf --api-key YOUR_API_KEY --output json --extract-fields title author date summary\n\n```\n\n**schema.json 文件示例：**\n\n```json\n{\n  \"invoice_number\": \"string\",\n  \"total_amount\": \"number\",\n  \"vendor_name\": \"string\",\n  \"billing_address\": {\n    \"street\": \"string\",\n    \"city\": \"string\",\n    \"zip_code\": \"string\"\n  },\n  \"line_items\": [{\n    \"description\": \"string\",\n    \"quantity\": \"number\",\n    \"unit_price\": \"number\"\n  }]\n}\n```\n\n## **库的 API 参考**\n\n本节详细介绍了用于程序化使用的主要类和方法。\n\n1. **DocumentExtractor**\n\n```python\nDocumentExtractor(\n    api_key: str = None,              # 用于每月 1 万份文档访问权限的 API 密钥（或使用 'docstrange login' 达到相同限制）\n    model: str = None,                # 用于云端处理的模型（\"gemini\"、\"openapi\"、\"nanonets\"）\n    cpu: bool = False,                # 强制在本地 CPU 上进行处理\n    gpu: bool = False                 # 强制在本地 GPU 上进行处理\n)\n```\n\n**b. ConversionResult 方法**\n\n```python\nresult.extract_markdown() -> str                    # 清洁的 Markdown 输出\nresult.extract_data(                              # 结构化的 JSON\n    specified_fields: List[str] = None,       # 提取特定字段\n    json_schema: Dict = None                  # 使用模式提取\n) -> Dict\nresult.extract_html() -> str                      # 格式的 HTML\nresult.extract_csv() -> str                       # 表格的 CSV 格式\nresult.extract_text() -> str                      # 纯文本\n```\n\n---\n\n## **🤖 Claude Desktop 的 MCP 服务器（本地开发）**\n\nDocStrange 仓库包含一个可选的 MCP（模型上下文协议）服务器，用于本地开发，可在 Claude Desktop 中实现智能文档处理，并支持基于令牌感知的导航。\n\n> 注意：MCP 服务器专为本地开发设计，**不包含**在 PyPI 包中。请克隆仓库以在本地使用。\n\n**功能**\n\n- **智能令牌计数**：自动计算令牌并推荐处理策略\n- **层次化导航**：当文档超出上下文限制时，按结构导航\n- **智能分块**：自动将大文档拆分为符合令牌限制的块\n- **高级搜索**：在文档中搜索并获取上下文相关的结果\n\n**本地设置**\n\n1. 克隆仓库：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fnanonets\u002Fdocstrange.git\ncd docstrange\n```\n\n2. 以开发模式安装：\n\n```bash\npip install -e \".[dev]\"\n```\n\n3. 将以下内容添加到你的 Claude Desktop 配置文件中（`~\u002FLibrary\u002FApplication Support\u002FClaude\u002Fclaude_desktop_config.json`）：\n\n```json\n{\n  \"mcpServers\": {\n    \"docstrange\": {\n      \"command\": \"python3\",\n      \"args\": [\"\u002Fpath\u002Fto\u002Fdocstrange\u002Fmcp_server_module\u002Fserver.py\"]\n    }\n  }\n}\n```\n\n4. 重启 Claude Desktop\n\n有关详细的设置和使用方法，请参阅 [mcp_server_module\u002FREADME.md](https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fblob\u002Fmain\u002Fmcp_server_module\u002FREADME.md)\n\n---\n\n\n## **Nanonets 生态系统**\n\n`DocStrange` 是由 **Nanonets** 团队开发和维护的强大开源库。Nanonets 平台是一个基于 AI 的解决方案，旨在为企业实现端到端的文档自动化处理。该平台使技术团队和非技术团队都能够构建完整的自动化文档工作流。\n\n## **社区、支持与许可**\n\n这是一个积极开发中的开源项目，我们欢迎您的反馈和贡献。\n\n- **讨论区**：如有疑问、想法或想分享您构建的内容，请访问我们的 [GitHub 讨论区](https:\u002F\u002Fwww.google.com\u002Fsearch?q=URL_TO_GITHUB_DIScussions)。\n- **问题**：如需报告错误或提出功能请求，请在 [GitHub 问题页面](https:\u002F\u002Fwww.google.com\u002Fsearch?q=URL_TO_GITHUB_ISSUES)提交。\n- **电子邮件**：如有私人咨询，您可以通过 [support@nanonets.com](mailto:support@nanonets.com) 联系我们。\n\n⭐ 如果您觉得此仓库有帮助，请给它点个赞！您的支持将帮助我们不断改进这个库。\n\n**许可证**：本项目采用 **MIT 许可证**。","# DocStrange 快速上手指南\n\nDocStrange 是一款强大的文档解析工具，可将 PDF、图片、PPTX、DOCX、XLSX 等格式快速转换为 Markdown、JSON、CSV 和 HTML。它内置升级的 7B 模型，支持高精度 OCR 和表格提取，专为 RAG 管道和 AI 应用优化。支持免费云端 API 和 100% 隐私的本地 GPU 运行模式。\n\n## 环境准备\n\n*   **操作系统**：Linux、macOS 或 Windows\n*   **Python 版本**：>= 3.8\n*   **硬件要求**：\n    *   **云端模式**：无特殊要求，联网即可。\n    *   **本地模式**：如需本地离线处理，建议配备 NVIDIA GPU 并安装 CUDA 驱动以获得最佳性能；CPU 也可运行但速度较慢。\n*   **网络要求**：首次安装或运行本地 Web 界面时需联网下载模型依赖。\n\n## 安装步骤\n\n使用 pip 安装基础库：\n\n```bash\npip install docstrange\n```\n\n若需使用内置的本地 Web 图形界面（拖拽上传功能），请安装包含 Web 依赖的版本：\n\n```bash\npip install \"docstrange[web]\"\n```\n\n> 💡 **提示**：国内用户若遇到下载缓慢问题，可使用清华或阿里镜像源加速安装：\n> `pip install docstrange -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`\n\n## 基本使用\n\n### 1. Python 代码调用\n\n以下示例展示如何将文档转换为适合 LLM 使用的 Markdown 格式，或提取结构化 JSON 数据。默认使用免费云端模式。\n\n**转换为 Markdown：**\n\n```python\nfrom docstrange import DocumentExtractor\n\n# 初始化提取器（默认为云端模式）\nextractor = DocumentExtractor()\n\n# 转换任意文档为干净的 Markdown\nresult = extractor.extract(\"document.pdf\")\nmarkdown = result.extract_markdown()\nprint(markdown)\n```\n\n**提取结构化数据（JSON）：**\n\n```python\nfrom docstrange import DocumentExtractor\n\nextractor = DocumentExtractor()\nresult = extractor.extract(\"document.pdf\")\n\n# 获取扁平化的 JSON 数据\njson_data = result.extract_data()\nprint(json_data)\n```\n\n**指定字段提取（例如发票信息）：**\n\n```python\nfrom docstrange import DocumentExtractor\n\nextractor = DocumentExtractor()\nresult = extractor.extract(\"invoice.pdf\")\n\n# 仅提取指定字段\nfields = result.extract_data(specified_fields=[\n    \"invoice_number\", \"total_amount\", \"vendor_name\", \"due_date\"\n])\nprint(fields)\n```\n\n**启用本地 GPU 模式（完全离线）：**\n\n```python\n# 强制使用本地 GPU 处理（需安装 CUDA）\nextractor = DocumentExtractor(gpu=True)\n```\n\n### 2. 使用本地 Web 界面\n\n如果你更喜欢图形化操作，可以启动本地 Web 服务进行拖拽式转换：\n\n1.  **启动服务**：\n    ```bash\n    docstrange web\n    ```\n    或者使用 Python 模块运行：\n    ```bash\n    python -m docstrange.web_app\n    ```\n\n2.  **访问界面**：\n    在浏览器中打开 `http:\u002F\u002Flocalhost:8000`。\n\n3.  **开始转换**：\n    将文件拖入上传区域，选择处理模式（Cloud 或 Local GPU）及输出格式（Markdown\u002FJSON\u002FCSV 等），即可一键转换。","某金融科技公司数据团队需将数千份历史扫描版财务报表（PDF 与图片混合）快速转化为结构化数据，以构建企业级 RAG 知识库支持智能问答。\n\n### 没有 docstrange 时\n- 传统 OCR 工具无法识别复杂报表中的合并单元格与跨页表格，导致提取的 CSV 数据行列错乱，人工校对耗时极长。\n- 扫描件中的页眉、页脚及水印等页面伪影被误识别为正文内容，严重干扰后续大模型的上下文理解与检索精度。\n- 缺乏统一的 JSON Schema 支持，针对不同字段（如“净利润”、“营收”）的提取需编写大量定制化正则脚本，维护成本高昂。\n- 敏感财务数据必须离线处理，但现有本地方案要么不支持 GPU 加速导致速度极慢，要么无法兼顾高精度布局分析。\n\n### 使用 docstrange 后\n- 依托升级后的 7B 模型与高级布局检测，docstrange 能精准还原复杂表格结构，直接输出整洁的 Markdown 或 JSON，表格准确率大幅提升。\n- 内置的页面伪影去除功能自动过滤水印与页码，确保输入给大模型的文本纯净无噪，显著降低幻觉率。\n- 支持指定 JSON Schema 进行结构化提取，只需定义目标字段即可批量获取标准化数据，无需再写繁琐的正则代码。\n- 启用本地 GPU 模式后，所有数据在内部服务器闭环处理，既保障了金融数据的绝对隐私，又实现了比纯 CPU 快数倍的转换效率。\n\ndocstrange 通过高精度的本地化文档理解能力，将非结构化财务档案转化为高质量 AI 燃料，让知识库构建从“人工清洗周”缩短为“自动化小时级”。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FNanoNets_docstrange_b05a0a10.png","NanoNets","Nanonets","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FNanoNets_063a620d.jpg","",null,"nanonets_","https:\u002F\u002Fnanonets.com","https:\u002F\u002Fgithub.com\u002FNanoNets",[81,85,89,93,96],{"name":82,"color":83,"percentage":84},"Python","#3572A5",85.5,{"name":86,"color":87,"percentage":88},"HTML","#e34c26",8.7,{"name":90,"color":91,"percentage":92},"JavaScript","#f1e05a",2.8,{"name":94,"color":95,"percentage":92},"CSS","#663399",{"name":97,"color":98,"percentage":99},"Shell","#89e051",0.3,1404,124,"2026-04-02T22:06:58","MIT","Linux, macOS, Windows","本地 GPU 模式需要 NVIDIA GPU 且支持 CUDA；CPU 模式也可运行。具体显存大小和 CUDA 版本未在文档中明确说明，但提到核心模型为 7B 参数。","未说明",{"notes":108,"python":109,"dependencies":110},"该工具提供云端和本地两种模式。本地模式下，首次运行会自动下载所需模型文件。若使用 Web 界面需安装额外依赖（pip install \"docstrange[web]\"）。本地 GPU 模式可实现 100% 离线隐私处理，若无 GPU 则自动禁用相关选项或报错。","3.8+",[64,111],"Flask (用于 Web UI)",[15,16,35,14,13],[114,115,116,117,118,119,120,121,122,123,124,125,126],"image-to-markdown","llm","markdown","ocr","pdf-to-markdown","structured-data","ai","document-parser","document-parsing","pdf-parser","pdf-to-json","structured-data-capture","tables","2026-03-27T02:49:30.150509","2026-04-08T16:25:35.858259",[130,135,140,145,150,155],{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},13780,"如何在 VLLM 中部署 Nanonets-OCR2-3B 模型以及如何对其进行微调？","该模型是 Qwen2.5-VL 的进阶版本，可以使用 LLama-Factory 轻松进行微调。在 VLLM 中部署的命令如下：\n```bash\nvllm serve nanonets\u002FNanonets-OCR2-3B\n```","https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fissues\u002F32",{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},13781,"运行 Web GUI 时出现 500 内部服务器错误（TemplateNotFound: index.html）怎么办？","这是一个已知问题，已在最新版本中修复。请尝试升级到最新的包即可解决：\n```bash\npip install --upgrade docstrange\n```\n该错误是由于缺少模板文件导致的，更新后会自动包含所需的 `templates` 目录和 `index.html` 文件。","https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fissues\u002F16",{"id":141,"question_zh":142,"answer_zh":143,"source_url":144},13782,"如何去除输出文档开头自动添加的\"# GPU Processed Document\"头部信息？","该问题已在最新代码中修复。更新库后，`extract_markdown()` 和 `extract_text()` 函数将不再自动添加\"# GPU Processed Document\"或类似的头部信息，用户可以直接获得干净的文档输出。\n请确保安装最新版本：\n```bash\npip install --upgrade docstrange\n```","https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fissues\u002F14",{"id":146,"question_zh":147,"answer_zh":148,"source_url":149},13783,"云处理端点支持的最大 PDF 文件大小或页数是多少？","目前云处理端点限制约为 10 页。开发团队已针对大文档处理推送了更新，建议重新测试。如果您有更大的文件处理需求，可以向团队提供具体的大小要求以便后续优化。","https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fissues\u002F4",{"id":151,"question_zh":152,"answer_zh":153,"source_url":154},13784,"是否支持通过 OpenAI API 使用其他提供商（如 LM-studio 或 Ollama）的模型？","在云模式下，您可以通过传递参数 `model=nanonets` 来使用 `nanonets-ocr-s` 模型。目前云模式暂不支持其他第三方模型（如 Ollama 或 LM-studio 托管的模型）。","https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fissues\u002F3",{"id":156,"question_zh":157,"answer_zh":158,"source_url":159},13785,"项目宣称\"隐私优先\"但默认使用云处理，这是否矛盾？","维护者已接受该反馈并修正了相关宣传措辞，以确保\"隐私优先\"的描述与默认的云端处理行为保持一致，避免误导用户。未来可能会考虑增加本地处理作为默认选项或添加明确的运行时警告。","https:\u002F\u002Fgithub.com\u002FNanoNets\u002Fdocstrange\u002Fissues\u002F1",[]]