GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Skywiper/Invoice-Manager: 发票管理助手,基于OCR + LLM 进行发票管理

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
backend
backend
 
 
docs/images
docs/images
 
 
frontend
frontend
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
docker-compose.yml
docker-compose.yml
 
 

Repository files navigation

Invoice Manager 🧾

AI-Powered Chinese Invoice Recognition with Dual-Source Verification

AI驱动的中文发票识别系统 · OCR+LLM双源验证

MIT License Python 3.10+ FastAPI React Docker PaddleOCR

English | 简体中文


🎯 不只是OCR,是让AI帮你双重检查每一张发票

传统OCR识别率只有70-80%,商业方案价格昂贵。Invoice Manager 使用 OCR + LLM 双源验证, 让两个AI互相校验,准确率大幅提升,而且完全免费开源!


✨ Highlights

  • 🔍 Dual-Source Verification - OCR + LLM double-check every field, conflicts auto-flagged for review
  • 🤖 Multi-LLM Support - GPT-4o / Claude / Gemini / Qwen / DeepSeek / Zhipu GLM
  • 🇨🇳 Chinese Invoice Optimized - PaddleOCR + custom prompts for VAT invoices (增值税发票)
  • ⚡ Parallel Processing - OCR and LLM run simultaneously for faster results
  • 🐳 One-Click Deploy - Docker Compose, ready in 3 minutes
  • 🔒 Privacy First - Self-hosted, your data never leaves your server

✨ 亮点

  • 🔍 双源验证 - OCR + LLM 双重识别,字段冲突自动标记待审核
  • 🤖 多模型支持 - 支持 GPT-4o / Claude / Gemini / 通义千问 / DeepSeek / 智谱GLM
  • 🇨🇳 中文发票优化 - PaddleOCR 深度优化 + 增值税发票专用提示词
  • ⚡ 并行处理 - OCR 和 LLM 同时运行,识别更快
  • 🐳 一键部署 - Docker Compose 启动,3分钟搞定
  • 🔒 数据安全 - 本地私有部署,数据不离开服务器

🖼️ 截图预览 | Screenshots

发票详情 & OCR vs LLM 比对 | Invoice Detail & Dual-Source Comparison

Invoice Detail

左侧:发票基础信息和原始文件预览 | 下方:OCR与LLM识别结果对比,可一键选择或自定义

截图亮点 | Screenshot Highlights:

  • 📋 发票信息卡片 - 清晰展示所有提取字段
  • 📄 原始文件预览 - PDF/图片内嵌预览,无需下载
  • ⚖️ OCR vs LLM 比对表 - 并排显示两种识别结果
  • 🏷️ 状态标签 - 已解决/待确认,一目了然
  • 🖱️ 一键选择 - 点击"选择"采用该结果,或"自定义"手动输入

列表页面

Invoice List

🎯 解决的问题 | Problem Solved

😫 传统方式的痛点

  • ❌ 手动录入发票信息,费时费力
  • ❌ 单一OCR识别率不够高(70-80%)
  • ❌ 商业方案价格昂贵(按张收费)
  • ❌ 现有开源方案功能单一
  • ❌ 数据上传第三方,隐私风险

😊 Invoice Manager 的解决方案

  • ✅ 自动识别,批量上传处理
  • ✅ 双源验证,准确率显著提升
  • ✅ 完全免费,MIT 开源协议
  • ✅ 全流程管理,从识别到报销
  • ✅ 本地部署,数据完全可控

🏗️ 核心架构 | Architecture

                              ┌─────────────────┐
                              │   发票上传       │
                              │  Invoice Upload  │
                              └────────┬────────┘
                                       │
                    ┌──────────────────┼──────────────────┐
                    │                  │                  │
                    ▼                  │                  ▼
           ┌───────────────┐           │         ┌───────────────┐
           │   PaddleOCR   │           │         │   LLM Vision  │
           │   中文OCR识别  │           │         │  GPT-4/Claude │
           └───────┬───────┘           │         └───────┬───────┘
                   │                   │                 │
                   │         ┌────────────────┐          │
                   └────────►│  智能比对引擎  │◄─────────┘
                             │ Diff Engine   │
                             └───────┬───────┘
                                     │
                    ┌────────────────┼────────────────┐
                    ▼                                 ▼
           ┌───────────────┐                 ┌───────────────┐
           │   ✅ 匹配      │                 │   ⚠️ 冲突     │
           │  自动确认      │                 │  人工复核     │
           │  CONFIRMED    │                 │  REVIEWING    │
           └───────────────┘                 └───────────────┘

Why Dual-Source Verification Works | 为什么双源验证更准确

场景 单一OCR 单一LLM 双源验证
模糊字符 ❌ 可能误识别 ✅ 理解上下文 ✅ 互相校验
非标准格式 ❌ 正则失效 ✅ 智能解析 ✅ 双重保障
金额数字 ✅ 精确识别 ⚠️ 可能幻觉 ✅ 数值比对
处理成本 💰 低 💰💰 高 💰 按需调用

🚀 快速开始 | Quick Start

最简3步启动 | 3 Steps to Start

# 1. 克隆项目 | Clone
git clone https://github.com/YOUR_USERNAME/invoice_manager.git
cd invoice_manager

# 2. 配置LLM (可选) | Configure LLM (Optional)
# 在 backend/.env 中设置 API Key,或稍后在界面中配置
# Set API Key in backend/.env, or configure later in UI

# 3. 启动服务 | Start Services
docker-compose up -d

访问地址 | Access URLs

服务 地址 说明
前端界面 http://localhost:5173 主操作界面
后端 API http://localhost:8000 REST API
API 文档 http://localhost:8000/docs Swagger UI

配置 LLM | Configure LLM

系统支持 6 种 LLM 提供商,可在界面中实时切换:

Provider Models 获取 API Key
OpenAI GPT-4o, GPT-4o-mini platform.openai.com
Anthropic Claude 3.5 Sonnet, Claude 3 Opus console.anthropic.com
Google Gemini 1.5 Pro, Gemini 1.5 Flash aistudio.google.com
阿里云 通义千问 Qwen-VL dashscope.console.aliyun.com
DeepSeek DeepSeek-VL platform.deepseek.com
智谱 GLM-4V open.bigmodel.cn

💡 提示: 即使不配置LLM,系统也能正常运行(仅使用OCR)。配置LLM后可获得双源验证能力。


📋 功能特性 | Features

发票处理 | Invoice Processing

功能 描述
📤 批量上传 支持 PDF、JPG、PNG,单次多文件上传
🔍 OCR识别 PaddleOCR 中文优化,300DPI 高清识别
🤖 LLM解析 Vision 模型直接理解发票图像
⚖️ 智能比对 自动对比OCR和LLM结果,标记差异
✏️ 人工复核 冲突字段可视化,一键选择正确值
📊 统计报表 金额汇总、税额统计、状态分布

提取字段 | Extracted Fields

├── 基础信息
│   ├── 发票号码 (invoice_number)
│   ├── 开票日期 (issue_date)
│   └── 项目名称 (item_name)
│
├── 购买方信息
│   ├── 购买方名称 (buyer_name)
│   └── 购买方税号 (buyer_tax_id)
│
├── 销售方信息
│   ├── 销售方名称 (seller_name)
│   └── 销售方税号 (seller_tax_id)
│
└── 金额信息
    ├── 金额 (amount)
    ├── 税率 (tax_rate)
    ├── 税额 (tax_amount)
    └── 价税合计 (total_with_tax)

状态流转 | Status Workflow

UPLOADED → PROCESSING → REVIEWING → CONFIRMED → REIMBURSED
  上传       识别中       待审核       已确认       已报销
                            ↓
                      NOT_REIMBURSED
                         未报销

📡 API 接口 | API Reference

核心接口 | Core Endpoints

# 上传发票 | Upload Invoice
POST /api/invoices/upload
Content-Type: multipart/form-data

# 获取列表 | Get List (with pagination & filters)
GET /api/invoices?status=REVIEWING&owner=张三&page=1&page_size=20

# 获取详情 | Get Detail (includes OCR, LLM, Diff results)
GET /api/invoices/{id}

# 更新信息 | Update Invoice
PUT /api/invoices/{id}
{
  "invoice_number": "12345678",
  "total_with_tax": "1000.00",
  "status": "CONFIRMED"
}

# 重新处理 | Reprocess
POST /api/invoices/{id}/process?use_ocr=true&use_llm=true

# 批量操作 | Batch Operations
POST /api/invoices/batch-update
POST /api/invoices/batch-delete
POST /api/invoices/batch-reprocess

# 统计数据 | Statistics
GET /api/invoices/statistics

# LLM配置 | LLM Configuration
GET  /api/settings/llm/status
POST /api/settings/llm/configure
POST /api/settings/llm/test

完整 API 文档请访问 http://localhost:8000/docs


🗺️ 路线图 | Roadmap

  • v0.1 - 基础OCR识别 + 发票管理
  • v0.2 - 多LLM支持 + 双源验证
  • v0.3 - 报表导出 (Excel/PDF)
  • v0.4 - 多用户权限管理
  • v0.5 - 发票真伪验证 (对接税务API)
  • v0.6 - 移动端适配
  • v1.0 - 企业级功能 (审批流程、ERP集成)

欢迎提 Issue 告诉我们你最需要的功能!


🛠️ 技术栈 | Tech Stack

Backend

FastAPI Python PostgreSQL

  • FastAPI 0.109 (Async REST API)
  • SQLAlchemy 2.0 + asyncpg (Async ORM)
  • PaddleOCR 2.7 (Chinese OCR)
  • Multi-LLM SDK Integration

Frontend

React TypeScript Ant Design

  • React 18.2 + TypeScript
  • Vite 5.0 (Build Tool)
  • Ant Design 5.13 (UI Components)
  • Axios (HTTP Client)

📁 项目结构 | Project Structure

invoice_manager/
├── backend/                    # FastAPI 后端
│   ├── app/
│   │   ├── models/            # SQLAlchemy 数据模型
│   │   │   └── invoice.py     # Invoice, OcrResult, LlmResult, ParsingDiff
│   │   ├── routers/           # API 路由
│   │   │   ├── invoices.py    # 发票 CRUD + 处理
│   │   │   └── settings.py    # LLM 配置
│   │   ├── services/          # 业务逻辑
│   │   │   ├── ocr_service.py # PaddleOCR 识别
│   │   │   ├── llm_service.py # 多 LLM 调用
│   │   │   └── invoice_service.py # 核心处理流程
│   │   ├── schemas/           # Pydantic 数据验证
│   │   ├── config.py          # 配置管理
│   │   └── main.py            # 应用入口
│   ├── requirements.txt
│   └── Dockerfile
│
├── frontend/                   # React 前端
│   ├── src/
│   │   ├── pages/             # 页面组件
│   │   │   ├── UploadPage.tsx # 上传页面
│   │   │   ├── InvoiceList.tsx# 列表页面
│   │   │   └── InvoiceDetail.tsx # 详情页面
│   │   ├── components/        # 通用组件
│   │   ├── services/          # API 调用
│   │   └── types/             # TypeScript 类型
│   ├── package.json
│   └── Dockerfile
│
├── docker-compose.yml          # 容器编排
└── README.md

🤝 参与贡献 | Contributing

我们欢迎所有形式的贡献!无论是:

  • 🐛 报告 Bug - 发现问题请提 Issue
  • 💡 功能建议 - 告诉我们你想要什么功能
  • 📝 完善文档 - 帮助改进文档
  • 🔧 提交代码 - Fork & PR

本地开发 | Local Development

# 后端 | Backend
cd backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload

# 前端 | Frontend
cd frontend
npm install
npm run dev

# 数据库 | Database (需要先启动 PostgreSQL)
docker-compose up -d db

代码规范 | Code Style

  • Python: Black + isort + flake8
  • TypeScript: ESLint + Prettier
  • Commit: Conventional Commits

💬 常见问题 | FAQ

Q: 不配置LLM可以使用吗?

A: 可以!系统会仅使用 PaddleOCR 进行识别。但配置LLM后可以获得双源验证能力,准确率会显著提升。

Q: 支持哪些发票类型?

A: 主要针对中国增值税发票(普通发票、专用发票)优化。其他格式的发票也可识别,但字段提取可能不完整。

Q: OCR 识别不准怎么办?

A: 1) 确保上传的图片清晰、方向正确;2) 配置LLM进行双源验证;3) 使用人工复核功能修正。

Q: 如何选择 LLM 提供商?

A:

  • 国内用户: 推荐通义千问或DeepSeek,速度快、价格低
  • 准确率优先: 推荐 GPT-4o 或 Claude 3.5 Sonnet
  • 成本优先: 推荐 GPT-4o-mini 或 Gemini 1.5 Flash
Q: 数据安全吗?

A: 系统完全本地部署,发票数据存储在你自己的服务器上。如果使用LLM,发票图片会发送到LLM提供商,请根据实际情况选择。


📜 License

MIT License - 可自由使用、修改、商用,但请保留版权声明。


🙏 致谢 | Acknowledgments

  • PaddleOCR - 强大的中文OCR引擎
  • FastAPI - 现代Python Web框架
  • Ant Design - 企业级UI组件库

如果这个项目对你有帮助,请给一个 ⭐ Star!

If this project helps you, please give it a ⭐ Star!


Made with ❤️ for the open source community

Report Bug · Request Feature · Discussions


About

发票管理助手,基于OCR + LLM 进行发票管理

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.