File size: 3,094 Bytes
72ae56f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | ---
license: mit
tags:
- omr
- optical-mark-recognition
- image-classification
- computer-vision
- onnx
- pytorch
- education
library_name: onnxruntime
pipeline_tag: image-classification
---
# OMR-BlindNet-v1 β Blind-Letter Deep Residual CNN for OMR Grading
**OMR-BlindNet-v1** is a lightweight, high-accuracy **4-Channel Residual Squeeze-and-Excitation Convolutional Neural Network** trained specifically for real-world MCQ OMR sheets (including red, maroon, blue, green, and black-and-white printed forms).
Instead of requiring students to shade 100% of every circle perfectly, **OMR-BlindNet-v1** detects whether the printed option letter (`A`, `B`, `C`, `D`, `E`) inside a bubble has been **blinded / occluded** by student ink β whether via full shading, partial center fill, hurried center dot, tick (`β`), cross (`Γ`), slanted scribble, or pencil shading β while cleanly ignoring unoccluded printed red/black letters, shadows, faint erasures, and tiny stray rim dots. **Double/multiple marks in one MCQ are automatically flagged as WRONG.**
## Architecture
- **Input**: `(batch, 4, 32, 32)` `float32` tensor:
- Channel `0`: Normalized Red (`R / 255`) β suppresses red/maroon printed OMR forms
- Channel `1`: Normalized Green (`G / 255`)
- Channel `2`: Normalized Blue (`B / 255`)
- Channel `3`: Local background-subtracted **Dark-Ink Occlusion Map** (`[0, 1]`)
- **Backbone**: Stem Conv (`4β32`) + 3 Residual Squeeze-Excitation stages (`32β64β128β192`) + Dual Avg/Max Pooling (`384β96β1`)
- **Size**: ~1.7 MB ONNX (`model.onnx`), runs 240 bubbles (~60 MCQs) in **~15 ms on CPU** (no PyTorch required at inference time!)
---
## Terminal Quickstart (For Any User)
Install the package locally or directly from your published repo:
```bash
pip install ./omr-blindnet-hf
```
Run directly from your terminal on any OMR PDF or image:
```bash
# Detect answers on a single OMR sheet image
omr-blindnet check student_sheet.jpg
# Grade a multi-page exam PDF against an Answer Key and export CSV
omr-blindnet check exam_batch.pdf --key "1:D,2:C,3:C,4:B,5:B" --out results.csv
# Load the model directly from Hugging Face Hub once published
omr-blindnet check exam_batch.pdf --model YOUR_USERNAME/omr-blindnet-v1 --key key.json
```
## Python API
```python
import cv2
from omr_blindnet import OMRBlindNetONNX
model = OMRBlindNetONNX.from_pretrained("YOUR_USERNAME/omr-blindnet-v1")
sheet = cv2.imread("student_sheet.jpg")
# List of (cx, cy, radius) bubble centers
probs = model.predict_bubbles_on_sheet(sheet, [(233, 650, 27), (299, 650, 27)])
print("Blinded probabilities:", probs)
```
---
## Publishing to Hugging Face Hub
1. Install Hugging Face CLI & login:
```bash
pip install huggingface_hub
huggingface-cli login
```
2. Create a repo (e.g., `YOUR_USERNAME/omr-blindnet-v1`) and upload this entire `omr-blindnet-hf/` directory:
```bash
huggingface-cli upload YOUR_USERNAME/omr-blindnet-v1 ./omr-blindnet-hf . --repo-type model
```
Anyone can then download and run `OMR-BlindNet-v1` directly from their terminal!
|