[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-rdumasia303--deepseek_ocr_app":3,"tool-rdumasia303--deepseek_ocr_app":64},[4,17,26,40,48,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},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,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,2,"2026-04-03T11:11:01",[13,14,15],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":23,"last_commit_at":32,"category_tags":33,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,34,35,36,15,37,38,13,39],"数据工具","视频","插件","其他","语言模型","音频",{"id":41,"name":42,"github_repo":43,"description_zh":44,"stars":45,"difficulty_score":10,"last_commit_at":46,"category_tags":47,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,38,37],{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":10,"last_commit_at":54,"category_tags":55,"status":16},519,"PaddleOCR","PaddlePaddle\u002FPaddleOCR","PaddleOCR 是一款基于百度飞桨框架开发的高性能开源光学字符识别工具包。它的核心能力是将图片、PDF 等文档中的文字提取出来，转换成计算机可读取的结构化数据，让机器真正“看懂”图文内容。\n\n面对海量纸质或电子文档，PaddleOCR 解决了人工录入效率低、数字化成本高的问题。尤其在人工智能领域，它扮演着连接图像与大型语言模型（LLM）的桥梁角色，能将视觉信息直接转化为文本输入，助力智能问答、文档分析等应用场景落地。\n\nPaddleOCR 适合开发者、算法研究人员以及有文档自动化需求的普通用户。其技术优势十分明显：不仅支持全球 100 多种语言的识别，还能在 Windows、Linux、macOS 等多个系统上运行，并灵活适配 CPU、GPU、NPU 等各类硬件。作为一个轻量级且社区活跃的开源项目，PaddleOCR 既能满足快速集成的需求，也能支撑前沿的视觉语言研究，是处理文字识别任务的理想选择。",74913,"2026-04-05T10:44:17",[38,14,13,37],{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":23,"last_commit_at":62,"category_tags":63,"status":16},2471,"tesseract","tesseract-ocr\u002Ftesseract","Tesseract 是一款历史悠久且备受推崇的开源光学字符识别（OCR）引擎，最初由惠普实验室开发，后由 Google 维护，目前由全球社区共同贡献。它的核心功能是将图片中的文字转化为可编辑、可搜索的文本数据，有效解决了从扫描件、照片或 PDF 文档中提取文字信息的难题，是数字化归档和信息自动化的重要基础工具。\n\n在技术层面，Tesseract 展现了强大的适应能力。从版本 4 开始，它引入了基于长短期记忆网络（LSTM）的神经网络 OCR 引擎，显著提升了行识别的准确率；同时，为了兼顾旧有需求，它依然支持传统的字符模式识别引擎。Tesseract 原生支持 UTF-8 编码，开箱即用即可识别超过 100 种语言，并兼容 PNG、JPEG、TIFF 等多种常见图像格式。输出方面，它灵活支持纯文本、hOCR、PDF、TSV 等多种格式，方便后续数据处理。\n\nTesseract 主要面向开发者、研究人员以及需要构建文档处理流程的企业用户。由于它本身是一个命令行工具和库（libtesseract），不包含图形用户界面（GUI），因此最适合具备一定编程能力的技术人员集成到自动化脚本或应用程序中",73286,"2026-04-03T01:56:45",[13,14],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":76,"owner_company":76,"owner_location":76,"owner_email":76,"owner_twitter":76,"owner_website":76,"owner_url":78,"languages":79,"stars":104,"forks":105,"last_commit_at":106,"license":107,"difficulty_score":10,"env_os":108,"env_gpu":109,"env_ram":110,"env_deps":111,"category_tags":123,"github_topics":76,"view_count":10,"oss_zip_url":76,"oss_zip_packed_at":76,"status":16,"created_at":124,"updated_at":125,"faqs":126,"releases":157},462,"rdumasia303\u002Fdeepseek_ocr_app","deepseek_ocr_app","A quick vibe coded app for deepseek OCR","deepseek_ocr_app 是一个基于 React 前端和 FastAPI 后端的现代化 OCR 网页应用，专注于将扫描文档、PDF 文件和图像中的文字高效提取并转换为可编辑格式。它解决了传统 OCR 工具在处理多页 PDF 时的格式混乱、图像丢失、公式识别困难等问题，特别适合需要处理复杂文档的场景。\n\n对于开发者，它提供了完整的 API 接口和 Docker 部署方案，可快速集成到工作流中；研究人员可通过其 LaTeX 公式识别功能处理学术论文；设计师和内容创作者则能利用多格式导出（Markdown\u002FHTML\u002FWord\u002FJSON）实现文档格式迁移；普通用户也能轻松将纸质文件数字化。其核心亮点在于：支持 100MB 以内 PDF 的多页 OCR 处理，自动提取并嵌入图像，保留表格、公式和排版结构，且提供实时进度追踪功能。技术实现上采用 DeepSeek-OCR 模型，结合前后端分离架构，既保证了处理效率，又通过 .env 配置文件实现了灵活的参数调整。无论是批量处理企业报告、学术资料转换，还是日常文档编辑需求，都能通过这一工具显著提升工作效率。","# 🚀 DeepSeek OCR - React + FastAPI\n\nModern OCR web application powered by DeepSeek-OCR with a stunning React frontend and FastAPI backend. **Now with PDF processing and multi-format document conversion!**\n\n![DeepSeek OCR in Action](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_readme_1963fa923387.png)\n\n## ✨ What's New in v2.2.0 - PDF Processing & Document Conversion\n\nWe've added powerful PDF processing capabilities based on community feedback! Here's what you can do now:\n\n### 📄 Process Entire PDF Documents\n- Upload PDF files up to 100MB\n- Automatic multi-page OCR processing\n- Real-time progress tracking for large documents\n- Extract text from scanned PDFs or image-based documents\n\n### 🔄 Convert to Multiple Formats\nExport your OCR results in the format you need:\n- **Markdown (.md)** - Clean, structured text perfect for documentation\n- **HTML (.html)** - Styled documents with embedded images and tables\n- **Word (.docx)** - Professional documents with formatting, tables, and images\n- **JSON** - Structured data for programmatic access\n\n### 🖼️ Automatic Image Extraction\n- Detects and extracts images from PDF pages\n- Embeds images in exported documents\n- Preserves image placement and context\n\n### 📐 Formula & Formatting Preservation\n- Maintains mathematical formulas (LaTeX syntax)\n- Preserves tables, headings, and document structure\n- Cleans up special characters while keeping formatting intact\n\n### 🎯 Use Cases\n- **Document Digitization** - Convert scanned PDFs to editable formats\n- **Data Extraction** - Pull structured data from forms and invoices\n- **Content Migration** - Convert PDFs to Markdown for wikis\u002Fdocumentation\n- **Academic Papers** - Extract text and formulas from research papers\n- **Business Documents** - Convert reports to Word for editing\n\n---\n\n> **Latest Updates (v2.2.0)** - November 2025\n> - 🎉 **NEW: PDF Processing** - Upload PDFs and extract text from all pages\n> - 🎉 **NEW: Multi-Format Export** - Convert to Markdown, HTML, DOCX, or JSON\n> - 🎉 **NEW: Automatic Image Extraction** - Extract and preserve images from PDFs\n> - 🎉 **NEW: Progress Tracking** - Real-time progress for multi-page documents\n> - ✅ Dual mode: Image OCR + PDF Processing with format conversion\n> - ✅ Enhanced document processing with formula and formatting preservation\n>\n> **Previous Updates (v2.1.1)**\n> - ✅ Fixed image removal button - now properly clears and allows re-upload\n> - ✅ Fixed multiple bounding boxes parsing - handles `[[x1,y1,x2,y2], [x1,y1,x2,y2]]` format\n> - ✅ Simplified to 4 core working modes for better stability\n> - ✅ Fixed bounding box coordinate scaling (normalized 0-999 → actual pixels)\n> - ✅ Fixed HTML rendering (model outputs HTML, not Markdown)\n> - ✅ Increased file upload limit to 100MB (configurable)\n> - ✅ Added .env configuration support\n\n## Quick Start\n\n1. **Clone and configure:**\n   ```bash\n   git clone \u003Crepository-url>\n   cd deepseek_ocr_app\n   \n   # Copy and customize environment variables\n   cp .env.example .env\n   # Edit .env to configure ports, upload limits, etc.\n   ```\n\n2. **Start the application:**\n   ```bash\n   docker compose up --build\n   ```\n\n   The first run will download the model (~5-10GB), which may take some time.\n\n3. **Access the application:**\n   - **Frontend**: http:\u002F\u002Flocalhost:3000 (or your configured FRONTEND_PORT)\n   - **Backend API**: http:\u002F\u002Flocalhost:8000 (or your configured API_PORT)\n   - **API Docs**: http:\u002F\u002Flocalhost:8000\u002Fdocs\n\n## 🎓 How to Use\n\n### Processing Images (Single Image OCR)\n\n1. Select **\"Image OCR\"** mode in the toggle\n2. Upload an image (PNG, JPG, WEBP, etc.)\n3. Choose your OCR mode:\n   - **Plain OCR** - Extract all text\n   - **Describe** - Get image description\n   - **Find** - Locate specific terms\n   - **Freeform** - Use custom prompts\n4. Click **\"Analyze Image\"**\n5. View results with bounding boxes (if enabled)\n6. Copy or download the extracted text\n\n### Processing PDFs (Multi-Page Documents) - NEW!\n\n1. Select **\"PDF Processing\"** mode in the toggle\n2. Upload a PDF file (up to 100MB)\n3. Choose your OCR mode (same as above)\n4. Select **output format**:\n   - 📝 **Markdown** - For documentation, wikis, GitHub\n   - 🌐 **HTML** - For web publishing, styled viewing\n   - 📄 **DOCX** - For Word editing, professional documents\n   - 📊 **JSON** - For programmatic access, data extraction\n5. Click **\"Process PDF\"**\n6. Watch the progress bar as pages are processed\n7. Your file downloads automatically when complete!\n\n### Tips for Best Results\n\n- **For scanned documents**: Use higher DPI (144-300) in advanced settings\n- **For tables**: The model excels at extracting structured data\n- **For formulas**: Mathematical notation is preserved in output\n- **For images in PDFs**: Enable \"Extract Images\" to include them in output\n- **For large PDFs**: JSON format is fastest, DOCX takes longer due to formatting\n\n### Output Format Comparison\n\n| Format | Best For | Features | File Size |\n|--------|----------|----------|-----------|\n| **Markdown** | Documentation, GitHub, wikis | Clean text, tables, code blocks | Smallest |\n| **HTML** | Web viewing, sharing | Styled output, embedded images, tables | Medium |\n| **DOCX** | Editing, professional docs | Full formatting, images, tables | Largest |\n| **JSON** | Data processing, APIs | Structured data, metadata, page info | Small |\n\n## Features\n\n### Dual Processing Modes\n#### 📸 **Image OCR** (4 Core Modes)\n- **Plain OCR** - Raw text extraction from any image\n- **Describe** - Generate intelligent image descriptions\n- **Find** - Locate specific terms with visual bounding boxes\n- **Freeform** - Custom prompts for specialized tasks\n\n#### 📄 **PDF Processing** (NEW!)\n- **Multi-Page Processing** - Process entire PDF documents page by page\n- **Format Conversion** - Export to Markdown, HTML, DOCX, or JSON\n- **Image Extraction** - Automatically extract and preserve embedded images\n- **Formula Preservation** - Maintain mathematical formulas and special formatting\n- **Progress Tracking** - Real-time progress updates for large documents\n\n### UI Features\n- 🎨 Glass morphism design with animated gradients\n- 🎯 Drag & drop file upload (Images up to 10MB, PDFs up to 100MB)\n- 🔄 Easy file removal and re-upload\n- 📦 Grounding box visualization with proper coordinate scaling\n- ✨ Smooth animations (Framer Motion)\n- 📋 Copy\u002FDownload results in multiple formats\n- 🎛️ Advanced settings dropdown\n- 📝 HTML and Markdown rendering for formatted output\n- 🔍 Multiple bounding box support (handles multiple instances of found terms)\n- 📊 Progress bars for multi-page PDF processing\n- 💾 Direct download for converted documents (MD, HTML, DOCX)\n\n## Configuration\n\nThe application can be configured via the `.env` file:\n\n```bash\n# API Configuration\nAPI_HOST=0.0.0.0\nAPI_PORT=8000\n\n# Frontend Configuration\nFRONTEND_PORT=3000\n\n# Model Configuration\nMODEL_NAME=deepseek-ai\u002FDeepSeek-OCR\nHF_HOME=\u002Fmodels\n\n# Upload Configuration\nMAX_UPLOAD_SIZE_MB=100  # Maximum file upload size\n\n# Processing Configuration\nBASE_SIZE=1024         # Base processing resolution\nIMAGE_SIZE=640         # Tile processing resolution\nCROP_MODE=true         # Enable dynamic cropping for large images\n```\n\n### Environment Variables\n\n- `API_HOST`: Backend API host (default: 0.0.0.0)\n- `API_PORT`: Backend API port (default: 8000)\n- `FRONTEND_PORT`: Frontend port (default: 3000)\n- `MODEL_NAME`: HuggingFace model identifier\n- `HF_HOME`: Model cache directory\n- `MAX_UPLOAD_SIZE_MB`: Maximum file upload size in megabytes\n- `BASE_SIZE`: Base image processing size (affects memory usage)\n- `IMAGE_SIZE`: Tile size for dynamic cropping\n- `CROP_MODE`: Enable\u002Fdisable dynamic image cropping\n\n## Tech Stack\n\n### Frontend\n- **Framework**: React 18 + Vite 5\n- **Styling**: TailwindCSS 3 + Custom Glass Morphism\n- **Animations**: Framer Motion 11\n- **HTTP Client**: Axios\n- **File Upload**: React Dropzone\n\n### Backend\n- **API Framework**: FastAPI (async Python web framework)\n- **ML\u002FAI**: PyTorch + Transformers 4.46 + DeepSeek-OCR\n- **PDF Processing**: PyMuPDF (fitz) + img2pdf\n- **Document Conversion**:\n  - python-docx (Word documents)\n  - markdown (Markdown processing)\n  - Custom HTML generator\n- **Configuration**: python-decouple for environment management\n\n### Infrastructure\n- **Server**: Nginx (reverse proxy & static file serving)\n- **Container**: Docker + Docker Compose with multi-stage builds\n- **GPU**: NVIDIA CUDA support (tested on RTX 3090, RTX 5090)\n\n## Project Structure\n\n```\ndeepseek-ocr\u002F\n├── backend\u002F                  # FastAPI backend\n│   ├── main.py              # Main API with OCR and PDF endpoints\n│   ├── pdf_utils.py         # PDF processing utilities (NEW)\n│   ├── format_converter.py  # Document format conversion (NEW)\n│   ├── requirements.txt\n│   └── Dockerfile\n├── frontend\u002F                 # React frontend\n│   ├── src\u002F\n│   │   ├── components\u002F\n│   │   │   ├── ImageUpload.jsx    # File upload (images & PDFs)\n│   │   │   ├── PDFProcessor.jsx   # PDF processing UI (NEW)\n│   │   │   ├── ModeSelector.jsx\n│   │   │   ├── ResultPanel.jsx\n│   │   │   └── AdvancedSettings.jsx\n│   │   ├── App.jsx           # Main app with dual mode support\n│   │   └── main.jsx\n│   ├── package.json\n│   ├── nginx.conf\n│   └── Dockerfile\n├── models\u002F                   # Model cache\n└── docker-compose.yml\n```\n\n## Development\n\nDocker compose cycle to test:\n```bash\ndocker compose down\ndocker compose up --build\n```\n\n## Requirements\n\n### Hardware\n- NVIDIA GPU with CUDA support\n  - Recommended: RTX 3090, RTX 4090, RTX 5090, or better\n  - Minimum: 8-12GB VRAM for the model\n  - More VRAM always good!\n\n### Software\n- **Docker & Docker Compose** (latest version recommended)\n\n- **NVIDIA Driver** - Installing NVIDIA Drivers on Ubuntu (Blackwell\u002FRTX 5090)\n\n  **Note**: Getting NVIDIA drivers working on Blackwell GPUs can be a pain! Here's what worked:\n\n  The key requirements for RTX 5090 on Ubuntu 24.04:\n  - Use the open-source driver (nvidia-driver-570-open or newer, like nvidia-driver-580-open)\n  - Upgrade to kernel 6.11+ (6.14+ recommended for best stability)\n  - Enable Resize Bar in BIOS\u002FUEFI (critical!)\n\n  **Step-by-Step Instructions:**\n\n  1. Install NVIDIA Open Driver (580 or newer)\n     ```bash\n     sudo add-apt-repository ppa:graphics-drivers\u002Fppa\n     sudo apt update\n     sudo apt remove --purge nvidia*\n     sudo nvidia-installer --uninstall  # If you have it\n     sudo apt autoremove\n     sudo apt install nvidia-driver-580-open\n     ```\n\n  2. Upgrade Linux Kernel to 6.11+ (for Ubuntu 24.04 LTS)\n     ```bash\n     sudo apt install --install-recommends linux-generic-hwe-24.04 linux-headers-generic-hwe-24.04\n     sudo update-initramfs -u\n     sudo apt autoremove\n     ```\n\n  3. Reboot\n     ```bash\n     sudo reboot\n     ```\n\n  4. Enable Resize Bar in UEFI\u002FBIOS\n     - Restart and enter UEFI (usually F2, Del, or F12 during boot)\n     - Find and enable \"Resize Bar\" or \"Smart Access Memory\"\n     - This will also enable \"Above 4G Decoding\" and disable \"CSM\" (Compatibility Support Module)—that's expected!\n     - Save and exit\n\n  5. Verify Installation\n     ```bash\n     nvidia-smi\n     ```\n     You should see your RTX 5090 listed!\n\n  💡 **Why open drivers?** I dunno, but the open drivers have better support for Blackwell GPUs. Without Resize Bar enabled, you'll get a black screen even with correct drivers!\n\n  Credit: Solution adapted from [this Reddit thread](https:\u002F\u002Fwww.reddit.com\u002Fr\u002Flinux_gaming\u002Fcomments\u002F1i3h4gn\u002Fblackwell_on_linux\u002F).\n\n- **NVIDIA Container Toolkit** (required for GPU access in Docker)\n  - Installation guide: https:\u002F\u002Fdocs.nvidia.com\u002Fdatacenter\u002Fcloud-native\u002Fcontainer-toolkit\u002Flatest\u002Finstall-guide.html\n\n### System Requirements\n- ~20GB free disk space (for model weights and Docker images)\n- 16GB+ system RAM recommended\n- Fast internet connection for initial model download (~5-10GB)\n\n## Known Issues & Fixes\n\n### ✅ FIXED: Image removal and re-upload (v2.1.1)\n- **Issue**: Couldn't remove uploaded image and upload a new one\n- **Fix**: Added prominent \"Remove\" button that clears image state and allows fresh upload\n\n### ✅ FIXED: Multiple bounding boxes (v2.1.1)\n- **Issue**: Only single bounding box worked, multiple boxes like `[[x1,y1,x2,y2], [x1,y1,x2,y2]]` failed\n- **Fix**: Updated parser to handle both single and array of coordinate arrays using `ast.literal_eval`\n\n### ✅ FIXED: Grounding box coordinate scaling (v2.1)\n- **Issue**: Bounding boxes weren't displaying correctly\n- **Cause**: Model outputs coordinates normalized to 0-999, not actual pixel dimensions\n- **Fix**: Backend now properly scales coordinates using the formula: `actual_coord = (normalized_coord \u002F 999) * image_dimension`\n\n### ✅ FIXED: HTML vs Markdown rendering (v2.1)\n- **Issue**: Output was being rendered as Markdown when model outputs HTML\n- **Cause**: Model is trained to output HTML (especially for tables)\n- **Fix**: Frontend now detects and renders HTML properly using `dangerouslySetInnerHTML`\n\n### ✅ FIXED: Limited upload size (v2.1)\n- **Issue**: Large images couldn't be uploaded\n- **Fix**: Increased nginx `client_max_body_size` to 100MB (configurable via .env)\n\n### ⚠️ Simplified Mode Selection (v2.1.1)\n- **Change**: Reduced from 12 modes to 4 core working modes\n- **Reason**: Advanced modes (tables, layout, PII, multilingual) need additional testing\n- **Working modes**: Plain OCR, Describe, Find, Freeform\n- **Future**: Additional modes will be re-enabled after thorough testing\n\n## How the Model Works\n\n### Coordinate System\nThe DeepSeek-OCR model uses a normalized coordinate system (0-999) for bounding boxes:\n- All coordinates are output in range [0, 999]\n- Backend scales: `pixel_coord = (model_coord \u002F 999) * actual_dimension`\n- This ensures consistency across different image sizes\n\n### Dynamic Cropping\nFor large images, the model uses dynamic cropping:\n- Images ≤640x640: Direct processing\n- Larger images: Split into tiles based on aspect ratio\n- Global view (BASE_SIZE) + Local views (IMAGE_SIZE tiles)\n- See `process\u002Fimage_process.py` for implementation details\n\n### Output Format\n- Plain text modes: Return raw text\n- Table modes: Return HTML tables or CSV\n- JSON modes: Return structured JSON\n- Grounding modes: Return text with `\u003C|ref|>label\u003C|\u002Fref|>\u003C|det|>[[coords]]\u003C|\u002Fdet|>` tags\n\n## API Usage\n\n### POST \u002Fapi\u002Focr\n\n**Parameters:**\n- `image` (file, required) - Image file to process (up to 100MB)\n- `mode` (string) - OCR mode: `plain_ocr` | `describe` | `find_ref` | `freeform`\n- `prompt` (string) - Custom prompt for freeform mode\n- `grounding` (bool) - Enable bounding boxes (auto-enabled for find_ref)\n- `find_term` (string) - Term to locate in find_ref mode (supports multiple matches)\n- `base_size` (int) - Base processing size (default: 1024)\n- `image_size` (int) - Tile size for cropping (default: 640)\n- `crop_mode` (bool) - Enable dynamic cropping (default: true)\n- `include_caption` (bool) - Add image description (default: false)\n\n**Response:**\n```json\n{\n  \"success\": true,\n  \"text\": \"Extracted text or HTML output...\",\n  \"boxes\": [{\"label\": \"field\", \"box\": [x1, y1, x2, y2]}],\n  \"image_dims\": {\"w\": 1920, \"h\": 1080},\n  \"metadata\": {\n    \"mode\": \"layout_map\",\n    \"grounding\": true,\n    \"base_size\": 1024,\n    \"image_size\": 640,\n    \"crop_mode\": true\n  }\n}\n```\n\n**Note on Bounding Boxes:**\n- The model outputs coordinates normalized to 0-999\n- The backend automatically scales them to actual image dimensions\n- Coordinates are in [x1, y1, x2, y2] format (top-left, bottom-right)\n- **Supports multiple boxes**: When finding multiple instances, format is `[[x1,y1,x2,y2], [x1,y1,x2,y2], ...]`\n- Frontend automatically displays all boxes overlaid on the image with unique colors\n\n### POST \u002Fapi\u002Fprocess-pdf (NEW!)\n\nProcess PDF documents with OCR and export to various formats.\n\n**Parameters:**\n- `pdf_file` (file, required) - PDF file to process (up to 100MB)\n- `mode` (string) - OCR mode: `plain_ocr` | `describe` | `find_ref` | `freeform`\n- `prompt` (string) - Custom prompt for freeform mode\n- `output_format` (string) - Output format: `markdown` | `html` | `docx` | `json`\n- `grounding` (bool) - Enable bounding boxes (default: false)\n- `include_caption` (bool) - Add image descriptions (default: false)\n- `extract_images` (bool) - Extract embedded images from PDF (default: true)\n- `dpi` (int) - PDF rendering resolution (default: 144)\n- `base_size` (int) - Base processing size (default: 1024)\n- `image_size` (int) - Tile size for cropping (default: 640)\n- `crop_mode` (bool) - Enable dynamic cropping (default: true)\n\n**Response Formats:**\n\n**JSON Format** (`output_format=json`):\n```json\n{\n  \"success\": true,\n  \"total_pages\": 5,\n  \"pages\": [\n    {\n      \"page_number\": 1,\n      \"text\": \"Extracted and cleaned text...\",\n      \"raw_text\": \"Raw model output with tags...\",\n      \"boxes\": [{\"label\": \"field\", \"box\": [x1, y1, x2, y2]}],\n      \"images\": [\"base64_encoded_image_data...\"],\n      \"image_dims\": {\"w\": 1920, \"h\": 1080}\n    }\n  ],\n  \"metadata\": {\n    \"mode\": \"plain_ocr\",\n    \"grounding\": false,\n    \"extract_images\": true,\n    \"dpi\": 144\n  }\n}\n```\n\n**File Downloads** (`output_format=markdown|html|docx`):\n- Returns the document as a downloadable file\n- Markdown: `.md` file with preserved formatting\n- HTML: `.html` file with embedded styling and images\n- DOCX: `.docx` Word document with tables and formatting\n\n**Features:**\n- 📄 Multi-page processing with progress tracking\n- 🖼️ Automatic image extraction and embedding\n- 📐 Formula and formatting preservation\n- 🎨 Styled HTML output with tables and code blocks\n- 📝 Clean Markdown with proper structure\n- 📋 Professional DOCX with headings and tables\n\n## Examples\n\nHere are some example images showcasing different OCR capabilities:\n\n### Visual Understanding\n![Helmet Description](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_readme_18b7ebe718a0.png)\n\n### Table Extraction from Chart\n![Chart to Table](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_readme_4330e659cb77.png)\n\n### Image Description\n![Describe Mode](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_readme_379f555f9f4e.png)\n\n## Troubleshooting\n\n### GPU not detected\n```bash\nnvidia-smi\ndocker run --rm --gpus all nvidia\u002Fcuda:11.8.0-base-ubuntu22.04 nvidia-smi\n```\n\n### Port conflicts\n```bash\nsudo lsof -i :3000\nsudo lsof -i :8000\n```\n\n### Frontend build issues\n```bash\ncd frontend\nrm -rf node_modules package-lock.json\ndocker-compose build frontend\n```\n\n## License\n\nThis project uses the DeepSeek-OCR model. Refer to the model's license terms.\n\n\n\u003C!-- Small note and direct link to license at the bottom -->\n\u003C!-- MIT License: this repository is licensed under the MIT License. See the full text in the LICENSE file. -->\nNote: Licensed under the MIT License. View the full license: [LICENSE](.\u002FLICENSE)\n","# 🚀 DeepSeek OCR - React + FastAPI\n\n基于 DeepSeek-OCR 的现代 OCR 网页应用（光学字符识别），采用惊艳的 React 前端和 FastAPI 后端。**现已支持 PDF 处理和多格式文档转换！**\n\n![DeepSeek OCR 实际效果](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_readme_1963fa923387.png)\n\n## ✨ v2.2.0 新增功能 - PDF 处理与文档转换\n\n我们根据社区反馈新增了强大的 PDF 处理功能！现在您可以：\n\n### 📄 处理完整 PDF 文档\n- 上传最大 100MB 的 PDF 文件\n- 自动多页 OCR 处理\n- 大文件实时进度追踪\n- 从扫描版 PDF 或图像文档中提取文本\n\n### 🔄 转换为多种格式\n将 OCR 结果导出为您需要的格式：\n- **Markdown (.md)** - 清晰的结构化文本，适合文档编写\n- **HTML (.html)** - 嵌入图像和表格的样式化文档\n- **Word (.docx)** - 包含格式、表格和图像的专业文档\n- **JSON** - 用于程序访问的结构化数据\n\n### 🖼️ 自动图像提取\n- 检测并提取 PDF 页面中的图像\n- 在导出文档中嵌入图像\n- 保留图像位置和上下文\n\n### 📐 公式与格式保留\n- 保留数学公式（LaTeX 语法）\n- 保留表格、标题和文档结构\n- 清理特殊字符的同时保持格式完整\n\n### 🎯 应用场景\n- **文档数字化** - 将扫描版 PDF 转换为可编辑格式\n- **数据提取** - 从表单和发票中提取结构化数据\n- **内容迁移** - 将 PDF 转换为 Markdown 用于维基\u002F文档\n- **学术论文** - 提取研究论文中的文本和公式\n- **商业文档** - 将报告转换为 Word 以便编辑\n\n---\n\n> **最新更新 (v2.2.0)** - 2025 年 11 月\n> - 🎉 **新增：PDF 处理** - 上传 PDF 并提取所有页面文本\n> - 🎉 **新增：多格式导出** - 转换为 Markdown、HTML、DOCX 或 JSON\n> - 🎉 **新增：自动图像提取** - 提取并保留 PDF 中的图像\n> - 🎉 **新增：进度追踪** - 多页文档的实时进度\n> - ✅ 双模式：图像 OCR + PDF 处理及格式转换\n> - ✅ 增强文档处理，保留公式和格式\n>\n> **历史更新 (v2.1.1)**\n> - ✅ 修复图像移除按钮 - 现在可正确清除并重新上传\n> - ✅ 修复多个边界框解析 - 支持 `[[x1,y1,x2,y2], [x1,y1,x2,y2]]` 格式\n> - ✅ 简化为 4 个核心工作模式以提高稳定性\n> - ✅ 修复边界框坐标缩放（归一化 0-999 → 实际像素）\n> - ✅ 修复 HTML 渲染（模型输出 HTML，而非 Markdown）\n> - ✅ 增加文件上传限制至 100MB（可配置）\n> - ✅ 添加 .env 配置支持\n\n## 快速开始\n\n1. **克隆并配置：**\n   ```bash\n   git clone \u003Crepository-url>\n   cd deepseek_ocr_app\n   \n   # 复制并自定义环境变量\n   cp .env.example .env\n   # 编辑 .env 以配置端口、上传限制等\n   ```\n\n2. **启动应用：**\n   ```bash\n   docker compose up --build\n   ```\n\n   首次运行将下载模型（约 5-10GB），可能需要一些时间。\n\n3. **访问应用：**\n   - **前端**: http:\u002F\u002Flocalhost:3000（或配置的 FRONTEND_PORT）\n   - **后端 API**: http:\u002F\u002Flocalhost:8000（或配置的 API_PORT）\n   - **API 文档**: http:\u002F\u002Flocalhost:8000\u002Fdocs\n\n## 🎓 使用方法\n\n### 处理图像（单图像 OCR）\n\n1. 在切换器中选择 **\"Image OCR\"** 模式\n2. 上传图像（PNG、JPG、WEBP 等）\n3. 选择 OCR 模式：\n   - **Plain OCR** - 提取所有文本\n   - **Describe** - 获取图像描述\n   - **Find** - 定位特定术语\n   - **Freeform** - 使用自定义提示\n4. 点击 **\"Analyze Image\"**\n5. 查看结果（启用时显示边界框）\n6. 复制或下载提取的文本\n\n### 处理 PDF（多页文档）- 新增！\n\n1. 在切换器中选择 **\"PDF Processing\"** 模式\n2. 上传 PDF 文件（最大 100MB）\n3. 选择 OCR 模式（同上）\n4. 选择 **输出格式**：\n   - 📝 **Markdown** - 用于文档、维基、GitHub\n   - 🌐 **HTML** - 用于网页发布、样式化查看\n   - 📄 **DOCX** - 用于 Word 编辑、专业文档\n   - 📊 **JSON** - 用于程序访问、数据提取\n5. 点击 **\"Process PDF\"**\n6. 观察进度条处理各页面\n7. 文件处理完成后自动下载！\n\n### 最佳效果提示\n\n- **扫描文档**：在高级设置中使用更高 DPI（144-300）\n- **表格**：模型擅长提取结构化数据\n- **公式**：数学符号在输出中保留\n- **PDF 中的图像**：启用 \"Extract Images\" 以包含在输出中\n- **大型 PDF**：JSON 格式最快，DOCX 因格式化耗时更长\n\n### 输出格式对比\n\n| 格式 | 最佳用途 | 特性 | 文件大小 |\n|--------|----------|----------|-----------|\n| **Markdown** | 文档、GitHub、维基 | 清晰文本、表格、代码块 | 最小 |\n| **HTML** | 网页查看、分享 | 样式化输出、嵌入图像、表格 | 中等 |\n| **DOCX** | 编辑、专业文档 | 完整格式、图像、表格 | 最大 |\n| **JSON** | 数据处理、API | 结构化数据、元数据、页面信息 | 小 |\n\n## 功能\n\n### 双处理模式\n#### 📸 **图像 OCR**（4 核心模式）\n- **Plain OCR** - 从任何图像中提取原始文本\n- **Describe** - 生成智能图像描述\n- **Find** - 通过视觉边界框定位特定术语\n- **Freeform** - 自定义提示用于专业任务\n\n#### 📄 **PDF 处理**（新增！）\n- **多页处理** - 逐页处理完整 PDF 文档\n- **格式转换** - 导出为 Markdown、HTML、DOCX 或 JSON\n- **图像提取** - 自动提取并保留嵌入图像\n- **公式保留** - 保留数学公式和特殊格式\n- **进度追踪** - 大型文档的实时进度更新\n\n### UI 功能\n- 🎨 玻璃形态设计与动画渐变\n- 🎯 拖放文件上传（图像最大 10MB，PDF 最大 100MB）\n- 🔄 简单的文件移除和重新上传\n- 📦 接地框可视化与正确坐标缩放\n- ✨ 流畅动画（Framer Motion）\n- 📋 多格式复制\u002F下载结果\n- 🎛️ 高级设置下拉菜单\n- 📝 样式化输出的 HTML 和 Markdown 渲染\n- 🔍 多边界框支持（处理找到术语的多个实例）\n- 📊 多页 PDF 处理进度条\n- 💾 转换文档直接下载（MD、HTML、DOCX）\n\n## 配置\n\n通过 `.env` 文件进行配置：\n\n```bash\n# API 配置\nAPI_HOST=0.0.0.0\nAPI_PORT=8000\n\n# 前端配置\nFRONTEND_PORT=3000\n\n# 模型配置\nMODEL_NAME=deepseek-ai\u002FDeepSeek-OCR\nHF_HOME=\u002Fmodels\n\n# 上传配置\nMAX_UPLOAD_SIZE_MB=100  # 最大文件上传大小\n```\n\n# 处理配置\nBASE_SIZE=1024         # 基础处理分辨率\nIMAGE_SIZE=640         # 图块处理分辨率\nCROP_MODE=true         # 启用大图像动态裁剪\n```\n\n### 环境变量\n\n- `API_HOST`: 后端API主机 (默认: 0.0.0.0)\n- `API_PORT`: 后端API端口 (默认: 8000)\n- `FRONTEND_PORT`: 前端端口 (默认: 3000)\n- `MODEL_NAME`: HuggingFace模型标识符\n- `HF_HOME`: 模型缓存目录\n- `MAX_UPLOAD_SIZE_MB`: 最大文件上传大小（单位：MB）\n- `BASE_SIZE`: 基础图像处理尺寸（影响内存使用）\n- `IMAGE_SIZE`: 动态裁剪图块尺寸\n- `CROP_MODE`: 启用\u002F禁用动态图像裁剪\n\n## 技术栈\n\n### 前端\n- **框架**: React 18 + Vite 5\n- **样式**: TailwindCSS 3 + 自定义玻璃磨砂效果\n- **动画**: Framer Motion 11\n- **HTTP客户端**: Axios\n- **文件上传**: React Dropzone\n\n### 后端\n- **API框架**: FastAPI（异步Python Web框架）\n- **ML\u002FAI**: PyTorch + Transformers 4.46 + DeepSeek-OCR\n- **PDF处理**: PyMuPDF (fitz) + img2pdf\n- **文档转换**:\n  - python-docx（Word文档）\n  - markdown（Markdown处理）\n  - 自定义HTML生成器\n- **配置**: python-decouple 用于环境管理\n\n### 基础设施\n- **服务器**: Nginx（反向代理与静态文件服务）\n- **容器**: Docker + Docker Compose 多阶段构建\n- **GPU**: NVIDIA CUDA 支持（测试环境：RTX 3090, RTX 5090）\n\n## 项目结构\n\n```\ndeepseek-ocr\u002F\n├── backend\u002F                  # FastAPI后端\n│   ├── main.py              # 包含OCR和PDF接口的主API\n│   ├── pdf_utils.py         # PDF处理工具（新增）\n│   ├── format_converter.py  # 文档格式转换（新增）\n│   ├── requirements.txt\n│   └── Dockerfile\n├── frontend\u002F                 # React前端\n│   ├── src\u002F\n│   │   ├── components\u002F\n│   │   │   ├── ImageUpload.jsx    # 文件上传（图片 & PDF）\n│   │   │   ├── PDFProcessor.jsx   # PDF处理UI（新增）\n│   │   │   ├── ModeSelector.jsx\n│   │   │   ├── ResultPanel.jsx\n│   │   │   └── AdvancedSettings.jsx\n│   │   ├── App.jsx           # 支持双模式的主应用\n│   │   └── main.jsx\n│   ├── package.json\n│   ├── nginx.conf\n│   └── Dockerfile\n├── models\u002F                   # 模型缓存\n└── docker-compose.yml\n```\n\n## 开发\n\nDocker compose测试流程：\n```bash\ndocker compose down\ndocker compose up --build\n```\n\n## 要求\n\n### 硬件\n- 支持CUDA的NVIDIA GPU\n  - 推荐: RTX 3090, RTX 4090, RTX 5090 或更高\n  - 最低: 8-12GB 显存\n  - 显存越大越好！\n\n### 软件\n- **Docker & Docker Compose**（推荐最新版本）\n\n- **NVIDIA驱动** - 在Ubuntu上安装NVIDIA驱动（Blackwell\u002FRTX 5090）\n\n  **注意**: 在Blackwell GPU上安装NVIDIA驱动可能会遇到问题！以下是解决方案：\n\n  RTX 5090在Ubuntu 24.04上的关键要求：\n  - 使用开源驱动（nvidia-driver-570-open 或更新版本，如 nvidia-driver-580-open）\n  - 升级到内核 6.11+（推荐 6.14+ 以获得最佳稳定性）\n  - 在BIOS\u002FUEFI中启用Resize Bar（关键！）\n\n  **分步指南**:\n\n  1. 安装NVIDIA开源驱动（580或更新）\n     ```bash\n     sudo add-apt-repository ppa:graphics-drivers\u002Fppa\n     sudo apt update\n     sudo apt remove --purge nvidia*\n     sudo nvidia-installer --uninstall  # 如果已安装\n     sudo apt autoremove\n     sudo apt install nvidia-driver-580-open\n     ```\n\n  2. 升级Linux内核到6.11+（Ubuntu 24.04 LTS）\n     ```bash\n     sudo apt install --install-recommends linux-generic-hwe-24.04 linux-headers-generic-hwe-24.04\n     sudo update-initramfs -u\n     sudo apt autoremove\n     ```\n\n  3. 重启\n     ```bash\n     sudo reboot\n     ```\n\n  4. 在UEFI\u002FBIOS中启用Resize Bar\n     - 重启并进入UEFI（通常在启动时按F2、Del或F12）\n     - 找到并启用 \"Resize Bar\" 或 \"Smart Access Memory\"\n     - 这也会启用 \"Above 4G Decoding\" 并禁用 \"CSM\"（兼容性支持模块）——这是预期行为！\n     - 保存并退出\n\n  5. 验证安装\n     ```bash\n     nvidia-smi\n     ```\n     你应该能看到RTX 5090被列出！\n\n  💡 **为什么使用开源驱动**？不清楚，但开源驱动对Blackwell GPU的支持更好。如果没有启用Resize Bar，即使安装了正确驱动也会出现黑屏！\n\n  致谢：解决方案改编自 [这个Reddit帖子](https:\u002F\u002Fwww.reddit.com\u002Fr\u002Flinux_gaming\u002Fcomments\u002F1i3h4gn\u002Fblackwell_on_linux\u002F)。\n\n- **NVIDIA容器工具包**（Docker访问GPU所需）\n  - 安装指南: https:\u002F\u002Fdocs.nvidia.com\u002Fdatacenter\u002Fcloud-native\u002Fcontainer-toolkit\u002Flatest\u002Finstall-guide.html\n\n### 系统要求\n- ~20GB 可用磁盘空间（模型权重和Docker镜像）\n- 推荐16GB+ 系统内存\n- 快速网络连接（初始模型下载约5-10GB）\n\n## 已知问题与修复\n\n### ✅ 已修复: 图片移除和重新上传 (v2.1.1)\n- **问题**: 无法移除已上传图片并重新上传新图片\n- **修复**: 添加了显眼的 \"移除\" 按钮，清除图片状态并允许重新上传\n\n### ✅ 已修复: 多个边界框 (v2.1.1)\n- **问题**: 仅单个边界框有效，多个框如 `[[x1,y1,x2,y2], [x1,y1,x2,y2]]` 失败\n- **修复**: 使用 `ast.literal_eval` 更新解析器以处理单个和坐标数组\n\n### ✅ 已修复: 接地框坐标缩放 (v2.1)\n- **问题**: 边界框显示不正确\n- **原因**: 模型输出坐标归一化到0-999，而非实际像素尺寸\n- **修复**: 后端现在使用公式 `实际坐标 = (归一化坐标 \u002F 999) * 图像尺寸` 正确缩放坐标\n\n### ✅ 已修复: HTML vs Markdown 渲染 (v2.1)\n- **问题**: 模型输出HTML时却被渲染为Markdown\n- **原因**: 模型训练输出HTML（尤其是表格）\n- **修复**: 前端现在通过 `dangerouslySetInnerHTML` 正确检测并渲染HTML\n\n### ✅ 已修复: 上传大小限制 (v2.1)\n- **问题**: 大图片无法上传\n- **修复**: 将nginx的 `client_max_body_size` 增加到100MB（可通过.env配置）\n\n### ⚠️ 简化模式选择 (v2.1.1)\n- **变更**: 从12种模式减少到4种核心工作模式\n- **原因**: 高级模式（表格、布局、PII、多语言）需要额外测试\n- **可用模式**: 普通OCR、描述、查找、自由模式\n- **未来**: 所有模式将在充分测试后重新启用\n\n## 模型工作原理\n\n### 坐标系统\nDeepSeek-OCR模型使用归一化坐标系统（0-999）进行边界框处理：\n- 所有坐标输出范围 [0, 999]\n- 后端缩放公式: `像素坐标 = (模型坐标 \u002F 999) * 实际尺寸`\n- 这确保了不同图像尺寸的一致性\n\n### 动态裁剪\n对于大尺寸图像，模型使用动态裁剪：\n- 图像 ≤640x640: 直接处理\n- 更大图像: 根据宽高比分割为瓦片\n- 全局视图 (BASE_SIZE) + 局部视图 (IMAGE_SIZE 瓦片)\n- 实现细节请参见 `process\u002Fimage_process.py`\n\n### 输出格式\n- 纯文本模式: 返回原始文本\n- 表格模式: 返回 HTML 表格或 CSV\n- JSON 模式: 返回结构化 JSON\n- 接地模式: 返回带 `\u003C|ref|>label\u003C|\u002Fref|>\u003C|det|>[[coords]]\u003C|\u002Fdet|>` 标签的文本\n\n## API 使用\n\n### POST \u002Fapi\u002Focr\n\n**参数：**\n- `image` (文件, 必填) - 要处理的图像文件（最大100MB）\n- `mode` (字符串) - OCR 模式: `plain_ocr` | `describe` | `find_ref` | `freeform`\n- `prompt` (字符串) - 自定义提示（用于 freeform 模式）\n- `grounding` (布尔值) - 启用边界框（find_ref 模式自动启用）\n- `find_term` (字符串) - find_ref 模式中要查找的术语（支持多匹配）\n- `base_size` (整数) - 基础处理尺寸（默认: 1024）\n- `image_size` (整数) - 裁剪瓦片尺寸（默认: 640）\n- `crop_mode` (布尔值) - 启用动态裁剪（默认: true）\n- `include_caption` (布尔值) - 添加图像描述（默认: false）\n\n**响应：**\n```json\n{\n  \"success\": true,\n  \"text\": \"Extracted text or HTML output...\",\n  \"boxes\": [{\"label\": \"field\", \"box\": [x1, y1, x2, y2]}],\n  \"image_dims\": {\"w\": 1920, \"h\": 1080},\n  \"metadata\": {\n    \"mode\": \"layout_map\",\n    \"grounding\": true,\n    \"base_size\": 1024,\n    \"image_size\": 640,\n    \"crop_mode\": true\n  }\n}\n```\n\n**关于边界框的说明：**\n- 模型输出的坐标已归一化到 0-999 范围\n- 后端会自动将其缩放至实际图像尺寸\n- 坐标格式为 [x1, y1, x2, y2]（左上角，右下角）\n- **支持多个边界框**：当查找多个实例时，格式为 `[[x1,y1,x2,y2], [x1,y1,x2,y2], ...]`\n- 前端会自动将所有边界框以不同颜色叠加显示在图像上\n\n### POST \u002Fapi\u002Fprocess-pdf (新增！)\n\n使用 OCR 处理 PDF 文档并导出为多种格式。\n\n**参数：**\n- `pdf_file` (文件, 必填) - 要处理的 PDF 文件（最大100MB）\n- `mode` (字符串) - OCR 模式: `plain_ocr` | `describe` | `find_ref` | `freeform`\n- `prompt` (字符串) - 自定义提示（用于 freeform 模式）\n- `output_format` (字符串) - 输出格式: `markdown` | `html` | `docx` | `json`\n- `grounding` (布尔值) - 启用边界框（默认: false）\n- `include_caption` (布尔值) - 添加图像描述（默认: false）\n- `extract_images` (布尔值) - 从 PDF 提取嵌入图像（默认: true）\n- `dpi` (整数) - PDF 渲染分辨率（默认: 144）\n- `base_size` (整数) - 基础处理尺寸（默认: 1024）\n- `image_size` (整数) - 裁剪瓦片尺寸（默认: 640）\n- `crop_mode` (布尔值) - 启用动态裁剪（默认: true）\n\n**响应格式：**\n\n**JSON 格式** (`output_format=json`)：\n```json\n{\n  \"success\": true,\n  \"total_pages\": 5,\n  \"pages\": [\n    {\n      \"page_number\": 1,\n      \"text\": \"Extracted and cleaned text...\",\n      \"raw_text\": \"Raw model output with tags...\",\n      \"boxes\": [{\"label\": \"field\", \"box\": [x1, y1, x2, y2]}],\n      \"images\": [\"base64_encoded_image_data...\"],\n      \"image_dims\": {\"w\": 1920, \"h\": 1080}\n    }\n  ],\n  \"metadata\": {\n    \"mode\": \"plain_ocr\",\n    \"grounding\": false,\n    \"extract_images\": true,\n    \"dpi\": 144\n  }\n}\n```\n\n**文件下载** (`output_format=markdown|html|docx`)：\n- 返回可下载的文档文件\n- Markdown: `.md` 文件保留格式\n- HTML: `.html` 文件包含内嵌样式和图像\n- DOCX: `.docx` Word 文档包含表格和格式\n\n**功能特点：**\n- 📄 支持多页处理并跟踪进度\n- 🖼️ 自动提取并嵌入图像\n- 📐 公式和格式保留\n- 🎨 带表格和代码块的样式化 HTML 输出\n- 📝 结构清晰的 Markdown\n- 📋 带标题和表格的专业 DOCX 文档\n\n## 示例\n\n以下示例展示了不同 OCR 功能的效果：\n\n### 视觉理解\n![头盔描述](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_readme_18b7ebe718a0.png)\n\n### 图表转表格\n![图表转表格](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_readme_4330e659cb77.png)\n\n### 图像描述\n![描述模式](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_readme_379f555f9f4e.png)\n\n## 故障排除\n\n### 未检测到 GPU\n```bash\nnvidia-smi\ndocker run --rm --gpus all nvidia\u002Fcuda:11.8.0-base-ubuntu22.04 nvidia-smi\n```\n\n### 端口冲突\n```bash\nsudo lsof -i :3000\nsudo lsof -i :8000\n```\n\n### 前端构建问题\n```bash\ncd frontend\nrm -rf node_modules package-lock.json\ndocker-compose build frontend\n```\n\n## 许可证\n\n本项目使用 DeepSeek-OCR 模型。请参考模型的许可条款。\n\nNote: 遵循 MIT 许可证。查看完整许可证: [LICENSE](.\u002FLICENSE)","# DeepSeek OCR 快速上手指南\n\n## 环境准备\n\n### 系统要求\n- **GPU**：NVIDIA 显卡（推荐 RTX 3090\u002F4090\u002F5090，最低 8-12GB 显存）\n- **CPU**：16GB+ 内存\n- **存储**：20GB+ 可用空间（含模型文件和 Docker 镜像）\n- **操作系统**：Ubuntu 22.04+\u002F24.04+（推荐）\n\n### 前置依赖\n1. **Docker & Docker Compose**（建议最新版本）\n2. **NVIDIA 驱动**：\n   - 安装开源驱动 `nvidia-driver-580-open` 或更高版本\n   - 升级内核至 6.11+（Ubuntu 24.04 可用）\n   - 启用 BIOS 中的 Resize Bar 功能\n3. **NVIDIA Container Toolkit**（用于 Docker GPU 支持）\n   - 安装指南：https:\u002F\u002Fdocs.nvidia.com\u002Fdatacenter\u002Fcloud-native\u002Fcontainer-toolkit\u002Flatest\u002Finstall-guide.html\n\n> 🚀 **国内加速建议**：  \n> - 配置 Docker 国内镜像加速（如阿里云、DaoCloud）  \n> - 使用 `--build-arg HF_MIRROR=https:\u002F\u002Fhf-mirror.com` 参数加速模型下载\n\n---\n\n## 安装步骤\n\n1. **克隆项目并配置环境**\n   ```bash\n   git clone \u003Crepository-url>\n   cd deepseek_ocr_app\n   cp .env.example .env\n   # 编辑 .env 修改端口或上传限制（可选）\n   ```\n\n2. **启动应用**\n   ```bash\n   docker compose up --build\n   ```\n   > ⏱️ **首次运行**：需下载约 5-10GB 模型文件，建议使用高速网络\n\n3. **访问服务**\n   - **前端界面**：http:\u002F\u002Flocalhost:3000  \n   - **API 文档**：http:\u002F\u002Flocalhost:8000\u002Fdocs\n\n---\n\n## 基本使用\n\n### 示例 1：图像 OCR（单图识别）\n1. 打开前端页面，选择 **\"Image OCR\"** 模式\n2. 上传图片（支持 PNG\u002FJPG\u002FWEBP）\n3. 选择识别模式：\n   - **Plain OCR**：提取全部文字\n   - **Describe**：生成图片描述\n   - **Find**：定位特定关键词\n   - **Freeform**：自定义提示词\n4. 点击 **\"Analyze Image\"** 查看结果\n\n### 示例 2：PDF 文档处理（多页识别）\n1. 切换到 **\"PDF Processing\"** 模式\n2. 上传 PDF 文件（最大 100MB）\n3. 选择输出格式：\n   - Markdown（文档\u002F维基）\n   - HTML（网页展示）\n   - DOCX（Word 编辑）\n   - JSON（数据接口）\n4. 点击 **\"Process PDF\"**，下载处理后的文件\n\n---\n\n## 格式选择建议\n| 格式     | 适用场景               | 特点                     |\n|----------|------------------------|--------------------------|\n| Markdown | 文档编辑、GitHub       | 清晰结构，最小文件体积   |\n| HTML     | 网页展示               | 支持样式与嵌入图片       |\n| DOCX     | 专业文档编辑           | 保留格式与表格           |\n| JSON     | 数据分析、程序处理     | 结构化数据，便于解析     |\n\n> ⚠️ **大文件处理提示**：  \n> - JSON 格式处理速度最快  \n> - DOCX 格式因排版耗时较长  \n> - 开启 \"Extract Images\" 选项可保留 PDF 中的图片","某高校数学系研究生正在整理一篇手写公式密集的会议论文PDF，需要将其转换为可编辑的Word文档用于后续修改和引用。\n\n### 没有 deepseek_ocr_app 时\n- 需要逐页扫描PDF后手动输入公式，单篇论文耗时超过8小时\n- OCR工具无法识别手写数学符号，导致公式错误率高达40%\n- 原文中的图表被识别为模糊图像，无法与文字内容对应\n- 多页PDF处理时频繁出现内存溢出，单次只能处理3-5页\n- 导出的文本丢失原有排版，需要重新调整标题层级和公式编号\n\n### 使用 deepseek_ocr_app 后\n- 10分钟内完成200页PDF的全文OCR，自动识别手写LaTeX公式\n- 通过PDF模式实现多页连续处理，实时显示进度条和剩余时间\n- 自动提取并嵌入17张图表，保持与原文本的上下文关联\n- 导出的Word文档完整保留章节结构，公式以MathType格式可编辑\n- 支持JSON格式导出，便于后续开发人员构建自动化处理流程\n\n核心价值：将学术文档数字化效率提升8倍以上，同时确保复杂排版和数学公式的准确转换，解决科研人员长期面临的\"扫描文档不可编辑\"痛点。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Frdumasia303_deepseek_ocr_app_1963fa92.png","rdumasia303",null,"https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Frdumasia303_09d1a255.png","https:\u002F\u002Fgithub.com\u002Frdumasia303",[80,84,88,92,96,100],{"name":81,"color":82,"percentage":83},"JavaScript","#f1e05a",54.9,{"name":85,"color":86,"percentage":87},"Python","#3572A5",40.3,{"name":89,"color":90,"percentage":91},"CSS","#663399",1.7,{"name":93,"color":94,"percentage":95},"TypeScript","#3178c6",1.4,{"name":97,"color":98,"percentage":99},"Dockerfile","#384d54",1.1,{"name":101,"color":102,"percentage":103},"HTML","#e34c26",0.7,1737,301,"2026-04-05T08:42:15","MIT","Linux, macOS","需要 NVIDIA GPU，显存 8GB+，推荐 RTX 3090\u002F4090\u002F5090，需安装 CUDA 驱动及 Resize Bar 功能","16GB+",{"notes":112,"python":113,"dependencies":114},"需安装 Docker 及 NVIDIA Container Toolkit；Ubuntu 24.04 需升级内核至 6.11+ 并安装 nvidia-driver-580-open 及以上；首次运行需下载约 5-10GB 模型文件；需启用 Resize Bar 功能以支持 Blackwell GPU","未说明",[115,116,117,118,119,120,121,122],"fastapi","torch","transformers>=4.46","PyMuPDF","img2pdf","python-docx","markdown","python-decouple",[14],"2026-03-27T02:49:30.150509","2026-04-06T07:14:20.293508",[127,132,137,142,147,152],{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},1798,"如何解决请求失败状态码 502 的问题？","502 错误通常由服务器过载导致。请检查服务器状态，等待其恢复。同时，可通过查看 Docker 日志排查本地配置问题：\n1. 运行 `docker logs \u003C容器名>` 检查后端日志\n2. 确保前端和 API 容器配置正确\n3. 网络问题可尝试重启服务","https:\u002F\u002Fgithub.com\u002Frdumasia303\u002Fdeepseek_ocr_app\u002Fissues\u002F15",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},1799,"如何解决模型下载失败导致的启动问题？","当无法访问 huggingface.co 时，可通过以下方式手动下载模型：\n1. 修改 docker-compose.yml 的 volumes 配置：\n   ```yaml\n   volumes:\n     - \u002FYour\u002FPath\u002FDeepSeek-OCR:\u002Fmodels\u002Fdeepseek-ai\u002FDeepSeek-OCR\n   ```\n2. 使用 `huggingface-cli download` 预下载模型到指定目录\n3. 设置环境变量禁用加速通道：\n   ```bash\n   HF_HUB_DISABLE_XET=1 HF_HUB_ENABLE_HF_TRANSFER=0\n   ```","https:\u002F\u002Fgithub.com\u002Frdumasia303\u002Fdeepseek_ocr_app\u002Fissues\u002F9",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},1800,"如何确认模型是否正在下载？","可通过以下方式监控下载进度：\n1. 观察缓存目录体积增长：\n   ```bash\n   watch -n 1 'du -sh .\u002Fhf-cache || true'\n   ```\n2. 启用详细日志：\n   ```bash\n   export HUGGINGFACE_HUB_VERBOSITY=debug\n   export TRANSFORMERS_VERBOSITY=info\n   ```\n3. 检查 .safetensors 文件生成：\n   ```bash\n   find \u002Froot\u002F.cache\u002Fhuggingface -name \"*.safetensors\" -printf \"%p %k KB\\n\" | tail\n   ```","https:\u002F\u002Fgithub.com\u002Frdumasia303\u002Fdeepseek_ocr_app\u002Fissues\u002F2",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},1801,"如何解决 NVIDIA 驱动版本过旧的问题？","错误提示显示 NVIDIA 驱动版本过低，请执行以下操作：\n1. 访问 NVIDIA 官网下载最新驱动\n2. 在 Windows 设备管理器中更新显卡驱动\n3. 确保 Docker 使用的 NVIDIA 容器工具版本与驱动兼容","https:\u002F\u002Fgithub.com\u002Frdumasia303\u002Fdeepseek_ocr_app\u002Fissues\u002F5",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},1802,"是否支持在 Windows 上部署？","支持通过 WSL2 在 Windows 上运行：\n1. 安装 WSL2 并启用 Linux 子系统\n2. 安装 Docker Desktop for Windows\n3. 按照 Linux 部署文档配置容器\n4. 确保安装 NVIDIA 容器工具包（如需 GPU 支持）","https:\u002F\u002Fgithub.com\u002Frdumasia303\u002Fdeepseek_ocr_app\u002Fissues\u002F16",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},1803,"项目使用什么许可证？","该项目已采用 MIT 许可证，与 DeepSeek-OCR 模型的许可证一致。具体可查看 LICENSE 文件获取完整条款。","https:\u002F\u002Fgithub.com\u002Frdumasia303\u002Fdeepseek_ocr_app\u002Fissues\u002F12",[]]