OMR-Scanner / README.md
Hujaifa01's picture
Upload folder using huggingface_hub
72ae56f verified
|
Raw History Blame Contribute Delete
3.09 kB
metadata
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:

pip install ./omr-blindnet-hf

Run directly from your terminal on any OMR PDF or image:

# 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

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:
    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:
    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!