Skip to content

Sicheng-zju/ocr_using_ollama_deepseek-ocr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Ollama DeepSeek OCR Web Client

本项目提供一个纯前端页面,调用本地 Ollama 的 deepseek-ocr:latest 模型,对图片或 PDF 进行文字识别,并支持将识别结果下载为 Markdown 文件。

功能特性

  • 支持拖拽或选择 JPG / PNG / WEBP 图片。
  • PDF 模式会在浏览器端使用 pdf.js 将每页转成图片后统一识别。
  • 内置多种 DeepSeek 官方提示词模板,可一键切换。
  • 识别结果实时展示,可复制文本或下载为 .md 文件。
  • 完全本地化:所有数据均在浏览器与本地 Ollama 服务之间传输。

⚠️ 当前版本仅提取文本内容,Markdown 中不会还原原始图片或版面。

环境要求

  • Windows / macOS / Linux 均可。
  • 安装 Ollama 并拉取模型:
    ollama pull deepseek-ocr:latest
  • 启动 Ollama 服务前设置跨域:
    set OLLAMA_ORIGINS=*
    ollama serve
  • 浏览器需通过本地 HTTP 服务访问页面(避免 file:// 模式导致的模块加载限制)。

快速开始

  1. 启动本地 HTTP 服务(示例使用 Python 3):
    python -m http.server 8000
  2. 浏览器访问 http://localhost:8000/ocrusingollama.html
  3. 点击“测试连接”确认模型可用。
  4. 选择提示词模板,上传图片或 PDF,点击“开始 OCR 识别”。
  5. 根据需要复制结果或点击“下载 Markdown”。

自定义

  • 提示词模板可在页面的“提示词模板”下拉框或直接编辑文本区域进行修改。
  • 若页面与 pdf.js 文件路径不同,请在 ocrusingollama.html 中调整相对路径:
    import('./pdfjs/pdf.js')
  • 如需使用其他模型,可修改脚本顶部的 MODEL_NAME 常量(当前固定为 deepseek-ocr:latest)。

已知限制

  • DeepSeek-OCR 仅输出文本描述,不返回分段后的图片。
  • PDF 中的复杂排版可能导致 Markdown 排版需要人工微调。
  • 浏览器需支持 ES Modules;推荐使用最新 Chrome / Edge / Firefox。

目录结构

ocrusingollama/
├── ocrusingollama.html   # 主页面
├── README.md             # 项目说明
├── LICENSE               # 开源许可证
├── pdfjs/                # 本地化 pdf.js 运行时
│   ├── pdf.js
│   └── pdf.worker.js
└── pdfjs-5.4.394-dist/   # 原始 pdf.js 分发包(可选)

许可协议

  • 代码主体使用 MIT License,详见 LICENSE
  • 本项目打包了 Apache License 2.0 授权的 PDF.js(参见 pdfjs-5.4.394-dist/LICENSE)。

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published