glyphcnn.py
Completed

GlyphCNN

A CNN that classifies heavily-degraded letter glyphs

  1. 1// GlyphCNN
  2. 2export const project = {
  3. 3 status: "completed",
  4. 4 timeline: "2025",
  5. 5 role: "Solo",
  6. 6 language: "Python",
  7. 7 stack: [
  8. 8 "Python",
  9. 9 "PyTorch",
  10. 10 "CNNs",
  11. 11 "pytest",
  12. 12 "GitHub Actions",
  13. 13 ],
  14. 14};

Pretrained model hits 93.4% accuracy / 0.929 macro-F1; the whole pipeline is reproducible, tested, and CI-checked.

  • 93.4% accuracy, 0.929 macro-F1 (pretrained)
  • Config-driven, installable, pytest + CI
  • Dataset recovered from lost source via rendering

Overview

GlyphCNN classifies heavily-degraded 32×32 binary images of capital letters (21 classes: the alphabet minus D, H, K, X, Z) under random orientation, salt-and-pepper noise and out-of-range pixels. It is a full revamp of one of my first ML projects. The original was a single flat script with hard-coded paths, no tests and no reproducibility; this rebuild is a modular, tested, installable package with a config dataclass describing every run.

The pretrained model scores 93.4% accuracy / 0.929 macro-F1 on recovered glyphs. Because the original raw pixel files were lost, a reconstruction script recovers the 32×32 arrays from 151 surviving matplotlib renders, a convention validated empirically by the pretrained model's score. A single self-contained HTML dashboard renders hero metrics, class gallery, training curves, confusion matrix and every classified sample.

Key features

  • 3-conv-block CNN with FC head
  • Stratified split, augmentation, early stopping
  • Empirically-validated dataset reconstruction
  • Single-file interactive results dashboard

Notes

/**
* @importance Why it matters

Shows the jump from 'a script that runs' to real ML engineering: reproducibility, testing, packaging and honest reporting.

*/
/**
* @technicality The hard parts

A PyTorch CNN with a config-dataclass pipeline, plus a non-trivial dataset-recovery step that reconstructs the inputs from rendered images.

*/
/**
* @clarity How it's organised

An installable package with clear modules (config, data, model, engine, metrics) and legacy code preserved untouched for comparison.

*/
Completed
Python Repo