anshul32/legal-summarizer
0
⚖️ Legal Contract Summarizer
Hybrid Computer Vision + NLP Legal Contract Analysis System
Fine-tuned T5-small on LEDGAR · ROUGE-1: 0.93 · EasyOCR · OpenCV
🚀 Features
🧠 NLP Pipeline
Contract Text / OCR Output
↓
Text Cleaning + Normalization
↓
Chunked Summarization (T5-small, max 400 words/chunk)
↓
Regex Field Extraction (parties, dates, payment, governing law...)
↓
Clause Detection (18 clause types via regex patterns)
↓
Risk Scoring (missing clauses + red flag language)
↓
HTML Report + JSON Export🔬 Computer Vision Pipeline
📥 Input Formats
- Tab 1: Paste raw contract text directly
- Tab 2: Upload
.txtor digital.pdf - Tab 3: Upload scanned contract image (
.jpg,.png) — runs full CV → OCR → NLP
🏗️ Architecture
┌─────────────────────────────────┐
│ Gradio Web Interface (3 tabs) │
└───────────┬─────────────────────┘
│
┌─────────────────┼─────────────────┐
▼ ▼ ▼
[Text Input] [File Upload] [Image Upload]
│ │ │
│ │ CV Pipeline
│ │ (8 steps, OpenCV)
│ │ │
└─────────────────┴──────────────────┘
│
EasyOCR (if image)
│
NLP Pipeline
(T5 + Regex)
│
┌───────────┴───────────┐
▼ ▼
HTML Report JSON Export🛠️ Tech Stack
- Model:
anshul32/t5-legal-summarizer(T5-small fine-tuned on LEDGAR) - OCR: EasyOCR
- CV: OpenCV (
opencv-python-headless) - UI: Gradio 4+
- PDF: PyMuPDF (fitz)
- Visualization: Matplotlib
⚠️ Disclaimer
This tool is for educational and informational purposes only. It is not a substitute for professional legal advice. Always consult a qualified attorney for legal matters.
👤 Author
Anshul Kumar · HuggingFace · Kaggle
Computer Vision + NLP Academic Project
