# Kannada OCR Model (443 Classes) A deep learning model for Kannada character recognition using transfer learning with VGG16. ## Model Details - **Architecture**: VGG16-based transfer learning - **Classes**: 443 unique Kannada characters - **Input Size**: 128x128 RGB images - **Training Images**: 4,642 samples - **Validation Images**: 905 samples ## Performance - **Validation Accuracy**: 85.16% - **Top-5 Accuracy**: 98.21% - **Training Time**: ~3 hours 9 minutes on dual RTX 4090s ## Model Architecture ``` VGG16 (frozen weights) ├── BatchNormalization ├── Flatten ├── Dense(1024, relu) + L2 regularization ├── BatchNormalization + Dropout(0.5) ├── Dense(512, relu) + L2 regularization ├── BatchNormalization + Dropout(0.4) └── Dense(443, softmax) ``` ## Usage ### Download Model from Hugging Face ```python from huggingface_hub import hf_hub_download import tensorflow as tf import pandas as pd # Download model and class names model_path = hf_hub_download(repo_id="srikarthikv/kannada-ocr-443-classes", filename="kannada_model_full.h5") class_names_path = hf_hub_download(repo_id="srikarthikv/kannada-ocr-443-classes", filename="class_names.csv") # Load model model = tf.keras.models.load_model(model_path) # Load class names class_df = pd.read_csv(class_names_path) class_names = class_df['class_name'].tolist() ``` ### Prediction ```python import cv2 import numpy as np def preprocess_image(image_path): # Read and resize image img = cv2.imread(image_path) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = cv2.resize(img, (128, 128)) # Normalize and add batch dimension img = img.astype(np.float32) / 255.0 img = np.expand_dims(img, axis=0) return img # Make prediction image = preprocess_image("path/to/kannada_character.jpg") predictions = model.predict(image) # Get top prediction top_class_idx = np.argmax(predictions[0]) confidence = predictions[0][top_class_idx] predicted_character = class_names[top_class_idx] print(f"Predicted Character: {predicted_character}") print(f"Confidence: {confidence:.4f}") ``` ### Interactive UI Run the Streamlit UI for testing: ```bash pip install streamlit opencv-python streamlit run test_model_ui.py ``` ## Files - `kannada_model_full.h5` - Complete trained model (168 MB) - `class_names.csv` - Character class mappings - `test_model_ui.py` - Interactive Streamlit UI for testing ## Training Details - **Framework**: TensorFlow/Keras - **Base Model**: VGG16 (ImageNet weights, frozen) - **Optimizer**: Adam (lr=0.001) - **Loss**: Categorical Crossentropy - **Batch Size**: 64 - **Epochs**: 60 - **Data Augmentation**: Rotation, shift, shear, zoom, brightness - **Class Weights**: Balanced for imbalanced data ## Model Card | Metric | Value | |--------|-------| | Model Size | 168 MB | | Parameters | 17.3M total (2.6M trainable) | | Training Time | 3h 9m | | GPU Memory | ~12GB (dual RTX 4090) | | Inference Time | ~10ms per image | ## Hugging Face Repository 🤗 **Model**: [srikarthikv/kannada-ocr-443-classes](https://huggingface.co/srikarthikv/kannada-ocr-443-classes) ## License This model is released under MIT License for research and educational purposes. ## Citation ```bibtex @misc{kannada-ocr-443, title={Kannada OCR Model with 443 Character Classes}, author={Your Name}, year={2025}, url={https://huggingface.co/srikarthikv/kannada-ocr-443-classes} } ```