AI Lab 10: Handwritten Digit Recognition with AI

Lab Overview

In this lab, you will build a complete, end-to-end deep learning application that recognizes handwritten digits. You will train a Convolutional Neural Network (CNN) on the classic MNIST dataset, evaluate how well it performs, and then connect the trained model to a live webcam so it can recognize digits you write on paper in real time.

The entire workflow runs on Windows 11 inside a Jupyter Notebook, using a dedicated conda environment and VS Code as the editor. No GPU is required — the model is small enough to train on the CPU in a few minutes.

Item Detail
Goal Train a CNN on MNIST and perform real-time digit recognition from a camera
Platform Windows 11 + Miniconda + VS Code + Jupyter Notebook
Framework TensorFlow / Keras (CPU)
Estimated time 3–4 hours (across environment setup, training, and inference)
Difficulty Beginner to intermediate (first AI / deep-learning lab)
Work mode Individual (may be done in pairs at the instructor's discretion)

By the end of the lab, you will understand the full supervised-learning pipeline: from raw data, to a trained model, to predictions on images the model has never seen before.


Learning Objectives

After completing this lab, you will be able to:

  1. Describe the supervised-learning pipeline — data → model → training → inference — and explain the role of each stage.
  2. Prepare image data for training by applying normalization and reshaping so that it matches the input a neural network expects.
  3. Build a Convolutional Neural Network for image classification using
  4. the Keras high-level API.
  5. Train a model and interpret its loss and accuracy curves to
  6. judge whether learning is progressing and whether overfitting is
  7. occurring.
    Evaluate a trained model on a held-out test set using accuracy and
    a confusion matrix.
    Integrate a trained model with OpenCV to perform real-time
    inference on a live camera feed.
    Analyze why a model that scores highly on MNIST may perform worse on
    real-world camera images, and propose preprocessing improvements.

None

© 2026 Air Supply Information Center (Air Supply BBS)