# Running the DocSentry Demo App ## Quick start (3 commands) ```powershell # From: C:\Users\HP\Desktop\Anomaly Based project\ pip install -r requirements.txt streamlit run app.py ``` That's it. Streamlit will open the app at http://localhost:8501 in your browser. ## Optional: install Tesseract OCR (for full text-rule checks) 1. Download from https://github.com/UB-Mannheim/tesseract/wiki 2. Run the `.exe` installer 3. Check "Add Tesseract to system PATH" during install 4. Restart your terminal, then `streamlit run app.py` again The app works without Tesseract too — only the text/OCR-based checks are skipped. ## What's in the app **Tab 1 — Single-document analysis** *(your primary demo)* - Drag-drop a PNG / JPG / PDF - See risk band (LOW / MEDIUM / HIGH / CRITICAL) in big colored text - Sub-score breakdown bar chart - ELA heatmap, copy-move match visualization, noise inconsistency heatmap (image files) - Producer / creator / fonts table (PDFs) - Trained ML model verdict (if `models/forgery_rf.joblib` exists) - Download audit JSON or formatted PDF report **Tab 2 — Cross-document consistency check** *(the novel angle)* - Upload 2–4 documents for the same applicant - App extracts name, DOB, address, account, IFSC from each - Field-by-field comparison table with green/yellow/red status - Mismatch detector with similarity scores - Download consistency report JSON **Tab 3 — Batch audit** - Point at a folder, scan every file in it - Get risk band per file as a sortable table - Download CSV for the underwriting team ## Demo flow (for the pitch) 1. **Open Tab 1**, drop in a clean `land_000.png` from `data/images/originals/` → "LOW" green band, no evidence 2. **Drop in a `land_005_copy_move.png`** from `data/images/tampered/` → "HIGH" orange band, copy-move evidence 3. **Click through the heatmap tabs** → judges see real visualizations, not just numbers 4. **Click "Download audit PDF"** → a bank-letterhead report renders 5. **Switch to Tab 2**, upload 2 different `agreement_*.png` files → "HIGH" mismatch because names differ 6. **Switch to Tab 3**, point at `data/` → batch-process 250+ files in a few seconds Total demo time: 3 minutes. Hands the judges something to download. ## Project file layout ``` C:\Users\HP\Desktop\Anomaly Based project\ ├── app.py <-- Streamlit UI (this app) ├── forensics.py <-- Core detection module ├── audit_report.py <-- PDF report generator ├── requirements.txt <-- pip dependencies ├── RUN_APP.md <-- this file ├── DATASETS.md <-- where to get more training data ├── COLAB_QUICKSTART.md <-- Colab usage guide ├── anomaly_detection_banking.ipynb <-- local Jupyter notebook ├── anomaly_detection_banking_COLAB.ipynb <-- Colab notebook ├── data/ │ ├── images/originals/ 130 genuine docs │ ├── images/tampered/ 130 tampered docs │ ├── pdfs/originals/ 30 PDFs │ ├── pdfs/tampered/ 30 tampered PDFs │ └── statements/ 60 statements └── models/ └── forgery_rf.joblib (created after running Section 7.5 in the notebook) ``` ## Common issues **"ModuleNotFoundError: No module named 'forensics'"** You're not in the project folder. `cd "C:\Users\HP\Desktop\Anomaly Based project"` first, then `streamlit run app.py`. **"streamlit: command not found"** Streamlit didn't install. Re-run `pip install -r requirements.txt`. On Windows, you may need `python -m streamlit run app.py` instead. **The "Download audit PDF" button shows a warning** Make sure `reportlab` installed cleanly. Re-run `pip install reportlab`. **Cross-doc tab says "ocr_skipped" for every field** You don't have Tesseract installed. The forensic checks still work; only the cross-doc field extraction needs OCR. Install Tesseract (see above) to unlock that tab. **The trained ML model section doesn't appear** You haven't run Section 7.5 in the notebook yet. Open `anomaly_detection_banking.ipynb`, run all cells through Section 7.5; that creates `models/forgery_rf.joblib`. The Streamlit app picks it up automatically. ## Architecture sketch ``` ┌──────────────────────────────────────────────┐ │ app.py (Streamlit) │ │ Tab1: Single doc Tab2: Cross-doc │ │ Tab3: Batch audit Downloads: JSON + PDF │ └──────────────────┬───────────────────────────┘ │ imports ┌──────────┴──────────┐ ▼ ▼ forensics.py audit_report.py - ELA / copy-move - ReportLab PDF - noise / EXIF - Heatmap embeds - PDF audit - Bank letterhead - OCR + text rules - Evidence list - RF model load - Cross-doc check ``` All three files run on plain Python 3.10+, CPU-only, no paid APIs.