380 lines
20 KiB
HTML
380 lines
20 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Marathi Handwritten Hospital Form Extraction</title>
|
|
<meta name="description"
|
|
content="Extract handwritten Marathi text from hospital forms using AI Vision Document Intelligence. Supports patient registration, medical notes, and prescriptions in Devanagari script.">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
|
<link rel="icon"
|
|
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📝</text></svg>">
|
|
</head>
|
|
|
|
<body>
|
|
<!-- ═══ Loading Overlay ═══ -->
|
|
<div id="loading-overlay" class="loading-overlay">
|
|
<div class="loading-content">
|
|
<div class="loading-spinner-large"></div>
|
|
<div class="loading-text">Processing Document</div>
|
|
<div class="loading-subtext">Reading handwritten Marathi text...</div>
|
|
<div id="loading-step" class="loading-step">Initializing...</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="app-container">
|
|
<!-- ═══ Header ═══ -->
|
|
<header class="app-header">
|
|
<div class="header-left">
|
|
<div class="header-icon-box">📋</div>
|
|
<div>
|
|
<h1 class="app-title">
|
|
Hospital Form Extraction · <span class="marathi">मराठी व इंग्रजी नोंदणी अर्ज</span>
|
|
</h1>
|
|
<p class="app-subtitle">
|
|
Automated extraction for Marathi & English hospital forms with strict zero-hallucination grounding
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="header-badge">
|
|
<span class="dot"></span>
|
|
AI Vision · Bilingual OCR
|
|
</div>
|
|
</header>
|
|
|
|
<!-- ═══ Config Alerts ═══ -->
|
|
{% if config_errors %}
|
|
{% for err in config_errors %}
|
|
<div class="config-alert">
|
|
<span class="alert-icon">⚠️</span>
|
|
<div>
|
|
<strong>Configuration Required:</strong> {{ err }}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
<!-- ═══ Dashboard ═══ -->
|
|
<div class="dashboard">
|
|
|
|
<!-- ── Upload Card ── -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="card-title">
|
|
<span class="icon">📄</span>
|
|
Upload Document
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div id="upload-zone" class="upload-zone">
|
|
<input type="file" id="file-input" accept=".jpg,.jpeg,.png,.pdf,.bmp,.tiff,.tif">
|
|
<span class="upload-icon">📋</span>
|
|
<div class="upload-title">Drop your document here</div>
|
|
<div class="upload-hint">or click to browse files (English or Marathi Form)</div>
|
|
<div class="upload-formats">
|
|
<span class="format-tag">JPG</span>
|
|
<span class="format-tag">PNG</span>
|
|
<span class="format-tag">PDF</span>
|
|
<span class="format-tag">TIFF</span>
|
|
<span class="format-tag">BMP</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="file-preview" class="file-preview">
|
|
<span style="font-size:28px">📎</span>
|
|
<div class="file-info">
|
|
<div id="file-name" class="file-name"></div>
|
|
<div id="file-size" class="file-size"></div>
|
|
</div>
|
|
<button id="remove-file" class="remove-file" title="Remove file">✕</button>
|
|
</div>
|
|
|
|
<!-- Options -->
|
|
<div class="options-panel">
|
|
<div class="option-group">
|
|
<span class="option-label">AI Vision Engine / Model</span>
|
|
<select id="model-select" class="select-styled">
|
|
<option value="auto">🤖 Auto (Best Configured Model)</option>
|
|
<option value="gemini" {% if models_status and models_status.gemini %}selected{% endif %}>🔷 Google Gemini Flash (Vision)</option>
|
|
<option value="sarvam" {% if models_status and not models_status.gemini and models_status.sarvam %}selected{% endif %}>🔶 DocVision AI (Sarvam Vision)</option>
|
|
<option value="compare">⚖️ Run Both Models & Compare (Benchmark)</option>
|
|
</select>
|
|
</div>
|
|
<div class="option-group" id="gemini-model-group">
|
|
<span class="option-label">Gemini Vision Model</span>
|
|
<select id="gemini-model-select" class="select-styled">
|
|
<option value="gemini-3.8-flash" selected>gemini-3.8-flash (Recommended • Active & Tested)</option>
|
|
<option value="gemini-flash-latest">gemini-flash-latest (Auto Latest Flash • Active)</option>
|
|
<option value="gemini-3.6-flash">gemini-3.6-flash (Fast • Auto-fallback if quota exceeded)</option>
|
|
<option value="gemini-3.5-flash">gemini-3.5-flash (Fast • Auto-fallback)</option>
|
|
<option value="gemini-2.5-flash">gemini-2.5-flash (Active & Stable)</option>
|
|
<option value="custom">✏️ Custom Model Name...</option>
|
|
</select>
|
|
<input type="text" id="gemini-custom-input" class="input-styled" placeholder="e.g. gemini-3.6-flash" style="display:none; margin-top:6px; font-size:12px; padding:6px 10px;">
|
|
</div>
|
|
<div class="option-group">
|
|
<span class="option-label">Form Language</span>
|
|
<select id="language-select" class="select-styled">
|
|
<option value="auto">🌐 Auto Detect (Marathi / English)</option>
|
|
<option value="mr-IN">🇮🇳 Marathi (रुग्ण नावनोंदणी अर्ज)</option>
|
|
<option value="en-IN">🇬🇧 English (Patient Registration Form)</option>
|
|
</select>
|
|
</div>
|
|
<div class="option-group">
|
|
<span class="option-label">Extraction Method</span>
|
|
<select id="method-select" class="select-styled">
|
|
<option value="auto">Auto (Extract → Fallback)</option>
|
|
<option value="extract">Schema-based Extract</option>
|
|
<option value="digitise">Raw OCR Digitise</option>
|
|
</select>
|
|
</div>
|
|
<div class="option-group">
|
|
<span class="option-label">Preprocessing</span>
|
|
<div class="toggle-wrapper">
|
|
<label class="toggle">
|
|
<input type="checkbox" id="preprocess-toggle">
|
|
<span class="toggle-track"></span>
|
|
</label>
|
|
<span class="toggle-text">Enhance image quality</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Dual Alphabet & Anti-Hallucination Shield -->
|
|
<div class="anti-hallucination-banner">
|
|
<div class="banner-top">
|
|
<div class="banner-title">
|
|
<span>🛡️</span>
|
|
<strong>Anti-Hallucination & AI Auto-Repair Active</strong>
|
|
</div>
|
|
<span class="banner-tag">STRICT MODE</span>
|
|
</div>
|
|
<div class="banner-details">
|
|
<div><strong>Dual Script Grounding:</strong> Marathi Devanagari (स्वर, व्यंजने, बाराखडी, ०-९) & English Latin (A-Z, a-z, 0-9)</div>
|
|
<div><strong>Auto English Conversion:</strong> Marathi entries are converted to standard, capitalized English spellings</div>
|
|
<div><strong>Smart Error Repair:</strong> Corrects patient handwriting typos, phonetic slips, and formatting errors while extracting</div>
|
|
<div class="banner-rule">⚡ <em>Zero Hallucination: Unfilled boxes and blank dotted lines strictly evaluate to null</em></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="btn-group" style="margin-top:20px">
|
|
<button id="extract-btn" class="btn btn-primary flex-1" disabled>
|
|
<span class="spinner"></span>
|
|
<span class="btn-text">🔍 Extract Form Data</span>
|
|
</button>
|
|
<button id="reset-btn" class="btn btn-secondary">
|
|
🔄 Reset
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Error Display -->
|
|
<div id="error-display" class="error-display">
|
|
<div class="error-title">❌ Error</div>
|
|
<div id="error-message" class="error-message"></div>
|
|
<div id="error-details" class="error-details"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── Preview Card ── -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="card-title">
|
|
<span class="icon">🖼️</span>
|
|
Document Preview
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div id="image-preview-container" class="image-preview-container">
|
|
<div class="preview-panel">
|
|
<div class="preview-label">Original</div>
|
|
<img id="original-image" alt="Original document" src="">
|
|
</div>
|
|
<div id="processed-panel" class="preview-panel" style="display:none">
|
|
<div class="preview-label">Preprocessed</div>
|
|
<img id="processed-image" alt="Preprocessed document" src="">
|
|
</div>
|
|
</div>
|
|
<div id="preprocess-info" class="preprocess-info" style="display:none"></div>
|
|
<div id="no-preview-msg" class="text-center text-muted" style="padding:60px 20px">
|
|
<span style="font-size:48px;display:block;margin-bottom:12px;opacity:0.3">🖼️</span>
|
|
Upload a document to see a preview
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══ Results Card (full width) ═══ -->
|
|
<div id="results-container" class="card full-width results-container">
|
|
<div class="card-header">
|
|
<div class="card-title">
|
|
<span class="icon">📊</span>
|
|
Extraction Results
|
|
</div>
|
|
<div class="btn-group">
|
|
<button id="download-json" class="btn btn-sm btn-secondary">⬇ JSON</button>
|
|
<button id="download-text" class="btn btn-sm btn-secondary">⬇ Text</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<!-- Stats -->
|
|
<div class="stats-bar">
|
|
<div class="stat-chip">
|
|
<span class="stat-icon">⏱️</span>
|
|
<div>
|
|
<div id="stat-time" class="stat-value">—</div>
|
|
<div class="stat-label">Response Time</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-chip">
|
|
<span class="stat-icon">🌐</span>
|
|
<div>
|
|
<div id="stat-lang" class="stat-value">—</div>
|
|
<div class="stat-label">Form Language</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-chip">
|
|
<span class="stat-icon">✅</span>
|
|
<div>
|
|
<div id="stat-fields" class="stat-value">—</div>
|
|
<div class="stat-label">Fields Extracted</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-chip">
|
|
<span class="stat-icon">✨</span>
|
|
<div>
|
|
<div id="stat-repairs" class="stat-value">0</div>
|
|
<div class="stat-label">Repaired Slips</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-chip">
|
|
<span class="stat-icon">⚠️</span>
|
|
<div>
|
|
<div id="stat-missing" class="stat-value">—</div>
|
|
<div class="stat-label">Unfilled Fields</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-chip">
|
|
<span class="stat-icon">🔧</span>
|
|
<div>
|
|
<div id="stat-method" class="stat-value">—</div>
|
|
<div class="stat-label">Method Used</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-chip">
|
|
<span class="stat-icon">🤖</span>
|
|
<div>
|
|
<div id="stat-model" class="stat-value">—</div>
|
|
<div class="stat-label">AI Engine</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tabs -->
|
|
<div class="tabs">
|
|
<button class="tab active" data-tab="fields">📋 Extracted Fields</button>
|
|
<button class="tab" data-tab="repairs">✨ Auto-Repairs (<span id="tab-repairs-count">0</span>)</button>
|
|
<button class="tab" data-tab="model-compare" id="tab-btn-model-compare" style="display:none">⚖️ Model Comparison (<span id="model-match-pct">0%</span>)</button>
|
|
<button class="tab" data-tab="json">🔤 JSON Output</button>
|
|
<button class="tab" data-tab="transcription">📝 Raw Transcription</button>
|
|
<button class="tab" data-tab="compare">🔀 Compare</button>
|
|
</div>
|
|
|
|
<!-- Tab: Fields -->
|
|
<div id="tab-fields" class="tab-content active">
|
|
<div id="fields-grid" class="fields-grid"></div>
|
|
</div>
|
|
|
|
<!-- Tab: Repairs -->
|
|
<div id="tab-repairs" class="tab-content">
|
|
<div id="repairs-container" class="repairs-container"></div>
|
|
</div>
|
|
|
|
<!-- Tab: Model Comparison -->
|
|
<div id="tab-model-compare" class="tab-content">
|
|
<div id="model-compare-container" class="model-compare-container"></div>
|
|
</div>
|
|
|
|
<!-- Tab: JSON -->
|
|
<div id="tab-json" class="tab-content">
|
|
<pre id="json-viewer" class="json-viewer"></pre>
|
|
</div>
|
|
|
|
<!-- Tab: Transcription -->
|
|
<div id="tab-transcription" class="tab-content">
|
|
<div id="transcription-box" class="transcription-box"></div>
|
|
</div>
|
|
|
|
<!-- Tab: Compare -->
|
|
<div id="tab-compare" class="tab-content">
|
|
<p class="text-sm text-muted" style="margin-bottom:12px">
|
|
Paste a reference JSON (with the same structure) to compare extraction accuracy:
|
|
</p>
|
|
<textarea id="compare-textarea" class="compare-textarea"
|
|
placeholder='{"patient_details":{"patient_name":"राम शिंदे","age":"45 वर्षे",...},...}'></textarea>
|
|
<button id="compare-btn" class="btn btn-secondary btn-block">
|
|
🔀 Compare Against Reference
|
|
</button>
|
|
<div id="compare-results" class="compare-results"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══ Test History Card (full width) ═══ -->
|
|
<div class="card full-width">
|
|
<div class="card-header">
|
|
<div class="card-title">
|
|
<span class="icon">📜</span>
|
|
Persistent Test History
|
|
<span id="history-count" class="badge-count">0 tests</span>
|
|
</div>
|
|
<div class="card-header-actions">
|
|
<a href="/api/test-results/export/csv" class="btn btn-sm btn-secondary"
|
|
title="Download CSV summary of test runs">📥 Export CSV</a>
|
|
<a href="/api/test-results/export/json" class="btn btn-sm btn-secondary"
|
|
title="Download full JSON dataset">📥 Export JSON</a>
|
|
<button id="clear-history-btn" class="btn btn-sm btn-danger" onclick="clearAllHistory()"
|
|
title="Clear all stored test history">🗑️ Clear History</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="history-table-wrapper">
|
|
<table class="history-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Document & Date</th>
|
|
<th>Model Engine</th>
|
|
<th>Method</th>
|
|
<th>Status</th>
|
|
<th>API Time</th>
|
|
<th>Extracted</th>
|
|
<th>Missing</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="history-body">
|
|
<tr>
|
|
<td colspan="8" class="text-center text-muted" style="padding:40px">
|
|
No tests run yet. Upload a document and extract to begin.
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<!-- /dashboard -->
|
|
|
|
<!-- Footer -->
|
|
<footer class="app-footer">
|
|
Automated Healthcare Document Intelligence · <strong>Marathi (मराठी) Vision OCR</strong>
|
|
</footer>
|
|
</div>
|
|
|
|
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
|
|
</body>
|
|
|
|
</html> |