slimshadow-ocr / recognizer.html
sameernotes's picture
Upload 5 files
9382c04 verified
raw
history blame
23.8 kB
!DOCTYPE html>
<!-- Add lang attribute and potentially 'dark' class -->
<html lang="en" class=""> <!-- Start without 'dark' initially -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recognize Word - NIC Project</title>
<!-- Tailwind CSS via CDN -->
<script src="https://cdn.tailwindcss.com/3.4.1"></script>
<script>
// *** Add dark mode strategy to Tailwind config ***
tailwind.config = {
darkMode: 'class', // Enable class-based dark mode
theme: {
extend: {
colors: {
primary: '#1a73e8',
secondary: '#e8f0fe',
// Define dark mode colors if needed, or rely on Tailwind's defaults
// dark: {
// background: '#1a202c',
// text: '#e2e8f0',
// }
},
borderRadius: {
'none': '0px', 'sm': '4px', DEFAULT: '8px', 'md': '12px',
'lg': '16px', 'xl': '20px', '2xl': '24px', '3xl': '32px',
'full': '9999px', 'button': '8px'
}
}
}
}
</script>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;700&family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- Icons -->
<link href="https://cdn.jsdelivr.net/npm/remixicon@4.2.0/fonts/remixicon.css" rel="stylesheet">
<!-- Custom Styles -->
<style>
/* --- Font Definitions (Ensure loaded via <link> tags in base.html) --- */
body {
font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
-webkit-font-smoothing: antialiased; /* Smoother fonts */
-moz-osx-font-smoothing: grayscale;
}
.hindi-font {
font-family: 'Noto Sans Devanagari', sans-serif;
}
/* --- Custom Switch Styles (from provided HTML) --- */
.custom-switch {
position: relative;
display: inline-block;
width: 50px;
height: 24px;
}
.custom-switch-input {
opacity: 0;
width: 0;
height: 0;
}
.custom-switch-slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc; /* Default off color */
transition: .4s;
border-radius: 34px; /* Rounded */
}
.custom-switch-slider:before {
position: absolute;
content: "";
height: 18px;
width: 18px;
left: 3px;
bottom: 3px;
background-color: white; /* Changed from original rgb(136, 145, 212) to white for consistency with dark mode logic in base.html */
transition: .4s;
border-radius: 50%; /* Circle */
}
.custom-switch-input:checked + .custom-switch-slider {
background-color: #1a73e8; /* Primary color when on */
}
.custom-switch-input:checked + .custom-switch-slider:before {
transform: translateX(26px); /* Move the circle */
}
/* --- Accessibility: Ensure focus is visible --- */
/* Tailwind's default focus rings are usually good, but this is a fallback */
*:focus-visible {
outline: 2px solid #1a73e8; /* Use primary color for focus */
outline-offset: 2px;
box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.3); /* Optional softer focus ring */
}
/* --- Other Minimal Custom Styles (if any) --- */
/* Example: Add a specific style for the example image containers if needed beyond grid/aspect ratio */
.example-image-container {
/* Custom styles here */
/* aspect-ratio: 3 / 2; */ /* Tailwind handles aspect ratio now */
}
.example-image {
/* Custom image styles here */
}
/* Add base dark mode styles */
html.dark body {
background-color: #1a202c; /* Example dark background */
color: #e2e8f0; /* Example dark text */
}
html.dark header, html.dark footer { /* Adjust header/footer */
background-color: #2d3748;
color: #e2e8f0;
}
html.dark .card { /* Adjust card styles */
background-color: #2d3748;
border-color: #4a5568;
}
html.dark h1, html.dark h2, html.dark h3, html.dark h4, html.dark h5, html.dark h6, html.dark p, html.dark span, html.dark li, html.dark label, html.dark small {
/* Adjust general text elements */
color: #e2e8f0; /* Light text */
}
html.dark .text-gray-600, html.dark .text-gray-700, html.dark .text-gray-800, html.dark .text-gray-900 {
color: #a0aec0; /* Lighter gray for dark mode */
}
html.dark .text-muted {
color: #718096;
}
html.dark .bg-white { background-color: #2d3748 !important; }
html.dark .bg-gray-50 { background-color: #1a202c !important; }
html.dark .bg-gray-100 { background-color: #2d3748 !important; }
html.dark .border-gray-100, html.dark .border-gray-200 { border-color: #4a5568 !important; }
html.dark .hover\:bg-gray-50:hover { background-color: #4a5568 !important; }
html.dark .navbar-dark .navbar-brand, html.dark .navbar-dark .nav-link { color: #fff; }
html.dark .navbar-dark .nav-link.active { color: #fff; font-weight: bold; }
</style>
</head>
<!-- Add dark mode background/text for body base -->
<body class="bg-gray-50 dark:bg-gray-900 min-h-screen flex flex-col text-gray-900 dark:text-gray-200">
<!-- Header -->
<header class="bg-white dark:bg-gray-800 shadow-sm sticky top-0 z-50">
<div class="container mx-auto px-4 py-3 flex items-center justify-between">
<div class="flex items-center">
<!-- Add data-lang attribute -->
<a href="/" class="text-2xl font-['Pacifico'] text-primary mr-8" data-lang-en="HindiOCR" data-lang-hi="हिन्दी ओसीआर">HindiOCR</a>
<nav class="hidden md:flex space-x-6">
<a href="/index.html"
class="hover:text-primary dark:hover:text-blue-400 text-gray-600 dark:text-gray-300"
data-lang-en="Home" data-lang-hi="होम">Home</a>
<a href="/recognizer.html"
class="hover:text-primary dark:hover:text-blue-400 text-primary dark:text-blue-400 font-medium"
data-lang-en="Recognize" data-lang-hi="पहचानें">Recognize</a>
<a href="/examples.html"
class="hover:text-primary dark:hover:text-blue-400 text-gray-600 dark:text-gray-300"
data-lang-en="Examples" data-lang-hi="उदाहरण">Examples</a>
<a href="/technology.html"
class="hover:text-primary dark:hover:text-blue-400 text-gray-600 dark:text-gray-300"
data-lang-en="Technology" data-lang-hi="तकनीक">Technology</a>
<a href="/about.html"
class="hover:text-primary dark:hover:text-blue-400 text-gray-600 dark:text-gray-300"
data-lang-en="About" data-lang-hi="बारे में">About</a>
</nav>
</div>
<!-- Right side header items -->
<div class="flex items-center space-x-4">
<!-- Language Switch -->
<div class="items-center space-x-2 hidden md:flex">
<span class="text-sm text-gray-600 dark:text-gray-400">EN</span>
<label class="custom-switch">
<!-- *** Add ID: languageToggle *** -->
<input type="checkbox" id="languageToggle" class="custom-switch-input">
<span class="custom-switch-slider"></span>
</label>
<span class="text-sm text-gray-600 dark:text-gray-400 hindi-font">हिंदी</span>
</div>
<!-- Theme Switch -->
<div class="items-center space-x-2 hidden md:flex">
<span class="text-sm text-gray-600 dark:text-gray-400"><i class="ri-sun-line"></i></span>
<label class="custom-switch">
<!-- *** Add ID: themeToggle *** -->
<input type="checkbox" id="themeToggle" class="custom-switch-input">
<span class="custom-switch-slider"></span>
</label>
<span class="text-sm text-gray-600 dark:text-gray-400"><i class="ri-moon-line"></i></span>
</div>
<!-- User/Notification Icons (Keep as placeholders) -->
<div class="w-10 h-10 flex items-center justify-center bg-gray-100 dark:bg-gray-700 rounded-full cursor-pointer" title="User Profile (Placeholder)">
<i class="ri-user-line text-gray-600 dark:text-gray-300"></i>
</div>
<div class="w-10 h-10 flex items-center justify-center relative cursor-pointer" title="Notifications (Placeholder)">
<i class="ri-notification-3-line text-gray-600 dark:text-gray-300"></i>
<span class="absolute top-0 right-0 bg-red-500 text-white text-xs w-5 h-5 flex items-center justify-center rounded-full">3</span>
</div>
<!-- Mobile Menu Button (Placeholder) -->
<button class="md:hidden w-10 h-10 flex items-center justify-center" aria-label="Toggle Menu">
<i class="ri-menu-line text-gray-600 dark:text-gray-300 text-xl"></i>
</button>
</div>
</div>
</header>
<!-- Main Content Area -->
<main class="flex-grow">
<div class="container mx-auto px-4">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-8">
<!-- Input Column -->
<div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md border border-gray-100 dark:border-gray-700">
<h2 class="text-xl font-semibold text-gray-800 dark:text-white mb-4 border-b border-gray-200 dark:border-gray-600 pb-2">
<i class="ri-image-add-line mr-2 text-primary align-bottom"></i>
<span data-lang-en="Input Image" data-lang-hi="इनपुट छवि">Input Image</span>
</h2>
<p class="text-gray-600 dark:text-gray-400 text-sm mb-4" data-lang-en="Upload an image (PNG, JPG, JPEG) or select an example below." data-lang-hi="एक छवि (PNG, JPG, JPEG) अपलोड करें या नीचे दिए गए उदाहरण का चयन करें।">
Upload an image (PNG, JPG, JPEG) or select an example below.
</p>
<!-- File Input -->
<input type="file" id="imageUpload" accept="image/png, image/jpeg, image/jpg" class="hidden"/>
<div class="flex items-center mb-4">
<label for="imageUpload" class="bg-primary text-white px-4 py-2 rounded-button cursor-pointer hover:bg-blue-700 transition-colors text-sm inline-flex items-center mr-4 whitespace-nowrap">
<i class="ri-upload-2-line mr-2"></i>
<span data-lang-en="Choose File" data-lang-hi="फ़ाइल चुनें">Choose File</span>
</label>
<span id="fileName" class="text-gray-500 dark:text-gray-400 text-sm italic truncate" data-lang-en="No file chosen" data-lang-hi="कोई फ़ाइल नहीं चुनी गई">No file chosen</span>
</div>
<!-- Examples -->
<h3 class="text-md font-semibold text-gray-700 dark:text-gray-300 mb-2" data-lang-en="Examples" data-lang-hi="उदाहरण">Examples</h3>
<div id="examplesContainer" class="grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2 mb-4">
<div class="col-span-full">
<span class="text-gray-500 dark:text-gray-400 text-sm" data-lang-en="Loading examples..." data-lang-hi="उदाहरण लोड हो रहे हैं...">Loading examples...</span>
</div>
</div>
<!-- Preview -->
<div id="imagePreviewContainer" class="mt-4 pt-4 border-t border-gray-200 dark:border-gray-600 hidden">
<h3 class="text-md font-semibold text-gray-700 dark:text-gray-300 mb-2 text-center" data-lang-en="Preview" data-lang-hi="पूर्वावलोकन">Preview</h3>
<div class="flex justify-center">
<img id="imagePreview" src="#" alt="Image Preview" class="max-h-60 w-auto rounded border bg-gray-50 dark:bg-gray-700 dark:border-gray-600 p-1"/>
</div>
</div>
</div>
<!-- Output Column -->
<div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md border border-gray-100 dark:border-gray-700 flex flex-col items-center justify-center">
<h2 class="text-xl font-semibold text-gray-800 dark:text-white mb-4 border-b border-gray-200 dark:border-gray-600 pb-2 w-full text-center">
<i class="ri-text mr-2 text-primary align-bottom"></i>
<span data-lang-en="Recognition Result" data-lang-hi="पहचान परिणाम">Recognition Result</span>
</h2>
<!-- Recognize Button -->
<div class="my-4">
<button id="predictButton" class="bg-green-600 text-white px-6 py-3 rounded-button font-medium hover:bg-green-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-lg inline-flex items-center" disabled>
<i class="ri-search-line mr-2"></i>
<span data-lang-en="Recognize Word" data-lang-hi="शब्द पहचानें">Recognize Word</span>
</button>
</div>
<!-- Loading Indicator -->
<div id="loadingIndicator" class="flex items-center justify-center my-4 text-blue-600 dark:text-blue-400 hidden" style="min-height: 40px;">
<svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-blue-600 dark:text-blue-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span data-lang-en="Processing... Please wait." data-lang-hi="संसाधित हो रहा है... कृपया प्रतीक्षा करें।">Processing... Please wait.</span>
</div>
<!-- Result Display Area -->
<div id="resultDisplay" class="mt-4 p-4 bg-gray-100 dark:bg-gray-700 rounded-lg w-full text-center hidden" style="min-height: 100px;">
<h3 class="text-lg font-semibold text-gray-800 dark:text-white mb-3" data-lang-en="Predicted Text:" data-lang-hi="अनुमानित पाठ:">Predicted Text:</h3>
<p id="predictionText" class="text-4xl hindi-font font-bold text-gray-900 dark:text-white"></p>
<p id="probabilityText" class="text-gray-600 dark:text-gray-400 text-sm mt-2 mb-0"></p>
</div>
<!-- Error Display Area -->
<div id="errorDisplay" class="mt-4 p-3 bg-red-100 dark:bg-red-900 dark:bg-opacity-50 border border-red-300 dark:border-red-600 text-red-800 dark:text-red-200 rounded-lg w-full text-sm flex items-center hidden" role="alert">
<i class="ri-error-warning-fill mr-2 text-lg"></i>
<strong class="mr-1" data-lang-en="Error:" data-lang-hi="त्रुटि:">Error:</strong>
<span id="errorText"></span>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="bg-gray-900 text-gray-400 py-12"> <!-- Adjusted footer text color -->
<div class="container mx-auto px-4">
<div class="grid grid-cols-1 md:grid-cols-4 gap-8">
<div>
<!-- Add data-lang attributes to footer elements if needed -->
<a href="/" class="text-2xl font-['Pacifico'] text-white mb-4 inline-block" data-lang-en="HindiOCR" data-lang-hi="हिन्दी ओसीआर">HindiOCR</a>
<p class="mb-4 text-sm" data-lang-en="Transforming handwritten Hindi documents into digital text." data-lang-hi="हस्तलिखित हिंदी दस्तावेज़ों को डिजिटल टेक्स्ट में बदलना।">Transforming handwritten Hindi documents into digital text.</p>
<div class="flex space-x-4">
<a href="#" class="hover:text-white" title="GitHub (Placeholder)"><i class="ri-github-fill"></i></a>
<a href="#" class="hover:text-white" title="LinkedIn (Placeholder)"><i class="ri-linkedin-box-fill"></i></a>
</div>
</div>
<div>
<h3 class="text-lg font-medium text-white mb-4" data-lang-en="Quick Links" data-lang-hi="त्वरित लिंक्स">Quick Links</h3>
<ul class="space-y-2 text-sm">
<li><a href="/" class="hover:text-white" data-lang-en="Home" data-lang-hi="होम">Home</a></li>
<li><a href="/recognize" class="hover:text-white" data-lang-en="Recognize" data-lang-hi="पहचानें">Recognize</a></li>
<li><a href="/examples" class="hover:text-white" data-lang-en="Examples" data-lang-hi="उदाहरण">Examples</a></li>
<li><a href="/technology" class="hover:text-white" data-lang-en="Technology" data-lang-hi="तकनीक">Technology</a></li>
<li><a href="/about" class="hover:text-white" data-lang-en="About" data-lang-hi="बारे में">About</a></li>
</ul>
</div>
<div>
<h3 class="text-lg font-medium text-white mb-4" data-lang-en="Resources" data-lang-hi="संसाधन">Resources</h3>
<ul class="space-y-2 text-sm">
<li><a href="#" class="hover:text-white" data-lang-en="Documentation (TBD)" data-lang-hi="प्रलेखन (TBD)">Documentation (TBD)</a></li>
<li><a href="#" class="hover:text-white" data-lang-en="GitHub Repo (Link)" data-lang-hi="गिटहब रेपो (लिंक)">GitHub Repo (Link)</a></li>
<li><a href="#" class="hover:text-white" data-lang-en="Support (TBD)" data-lang-hi="समर्थन (TBD)">Support (TBD)</a></li>
</ul>
</div>
<div>
<h3 class="text-lg font-medium text-white mb-4" data-lang-en="Contact (Project)" data-lang-hi="संपर्क (परियोजना)">Contact (Project)</h3>
<ul class="space-y-2 text-sm">
<li class="flex items-start">
<i class="ri-mail-line mt-1 mr-2"></i>
<span>khansamayashaswini@gmail.com</span>
</li>
<li class="flex items-center">
<i class="ri-building-line mr-2"></i>
<span>MATS University,Raipur / NIC Durg</span>
</li>
</ul>
</div>
</div>
<!-- Copyright -->
<div class="border-t border-gray-700 mt-8 pt-8 text-center">
<p class="text-sm">© 2025 Yashaswini khansama | Final Year Project | NIC</p>
</div>
</div>
</footer>
<!-- Bootstrap JS Bundle (Not needed for Tailwind, can remove if not used elsewhere) -->
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> -->
<!-- Base Theme/Language Script -->
<script>
// --- Theme Toggle ---
const themeToggle = document.getElementById('themeToggle');
const htmlElement = document.documentElement; // Target <html> tag
// Function to apply theme based on preference
function applyTheme(isDark) {
if (isDark) {
htmlElement.classList.add('dark');
if(themeToggle) themeToggle.checked = true;
console.log("Theme applied: dark");
} else {
htmlElement.classList.remove('dark');
if(themeToggle) themeToggle.checked = false;
console.log("Theme applied: light");
}
}
// Check localStorage on load
const prefersDark = localStorage.getItem('theme') === 'dark' ||
(localStorage.getItem('theme') === null && window.matchMedia('(prefers-color-scheme: dark)').matches);
applyTheme(prefersDark);
// Add listener to toggle button
if(themeToggle){
themeToggle.addEventListener('change', (event) => {
const isDark = event.target.checked;
applyTheme(isDark);
// Save preference to localStorage
localStorage.setItem('theme', isDark ? 'dark' : 'light');
});
} else {
console.warn("Theme toggle button not found.");
}
// --- Language Toggle (Simple Version) ---
const languageToggle = document.getElementById('languageToggle');
const langElements = document.querySelectorAll('[data-lang-en]'); // Select elements with language data
// Function to apply language
function applyLanguage(lang) { // lang should be 'en' or 'hi'
console.log("Applying language:", lang);
htmlElement.setAttribute('lang', lang); // Set overall page lang
langElements.forEach(el => {
const text = el.getAttribute(`data-lang-${lang}`);
if (text) {
el.textContent = text; // Replace text content
}
});
// Update toggle state
if (languageToggle) languageToggle.checked = (lang === 'hi');
// Save preference
localStorage.setItem('language', lang);
}
// Check localStorage on load for language
const savedLang = localStorage.getItem('language') || 'en'; // Default to English
applyLanguage(savedLang);
// Add listener to language toggle button
if (languageToggle) {
languageToggle.addEventListener('change', (event) => {
const newLang = event.target.checked ? 'hi' : 'en';
applyLanguage(newLang);
});
} else {
console.warn("Language toggle button not found.");
}
</script>
<!-- Block for page-specific scripts -->
</body>
</html>