CSC3104 · Module 9 of 9

Deployment & Responsible Vision

Package, benchmark & explain limitations

~56 min to study properly

A model in a notebook helps no one. Deployment means running it on real hardware — phones, edge cameras, cloud GPUs — within limits on latency, memory and power.

Checkpoint · the examiner asks

How does Grad-CAM produce an interpretable visual explanation of a CNN prediction? And how do you audit a vision model for demographic bias?

In one minute

Deployment means meeting latency, memory and power budgets on real hardware: quantise (FP32 → INT8 is 4× smaller), prune, and export to runtimes like ONNX, TensorRT or TFLite, then benchmark on the target device. Explain predictions with Grad-CAM and audit fairness with disaggregated per-group metrics, model cards and robustness tests.

Traps examiners look for
  • Benchmarking on your laptop instead of the target device.
  • Reporting one overall accuracy number and hiding subgroup failures.
  • Confusing latency (time per request) with throughput (requests per second).
Read

Study notes

01Deployment constraints

A vision model is only useful when it runs where it's needed — a phone, an edge camera at a junction, a hospital server, a cloud GPU — within that device's limits:

  • Latency — time for one prediction (a safety system may need < 30 ms).
  • Throughput — predictions per second (a video stream at 30 fps).
  • Memory — RAM / VRAM for weights and activations.
  • Power and cost — battery life, energy bills, cloud spend.

Latency and throughput are different: batching improves throughput but increases each request's latency. Always benchmark on the target device, with realistic inputs, after a warm-up, reporting p50 and p99.

02Making models smaller and faster

  • Quantisation — store weights (and often activations) as INT8 instead of FP32: 4× smaller and faster on hardware with integer acceleration. Post-training quantisation needs a small calibration set; quantisation-aware training recovers more accuracy.
  • Pruning — remove weights or whole channels that contribute little; structured pruning gives real speed-ups.
  • Knowledge distillation — train a small "student" to mimic a large "teacher's" outputs.
  • Efficient architectures — MobileNet, EfficientNet, small YOLO variants.

Then export to an inference runtime: ONNX as the common exchange format; TensorRT for NVIDIA GPUs; OpenVINO for Intel CPUs; TFLite or Core ML for phones. Re-validate accuracy after every step.

03Explaining predictions with Grad-CAM

Grad-CAM shows which image regions drove a CNN's prediction:

  1. Run the image forward and pick the class score y_c.
  2. Compute the gradient of y_c with respect to the last convolutional feature maps A^k.
  3. Global-average-pool each gradient map to get a weight α_k per channel ("how important is this channel for class c").
  4. Heatmap = ReLU(Σ_k α_k A^k), upsampled to the image size and overlaid.

ReLU keeps only regions that increase the class score. Grad-CAM is how you catch shortcut learning — e.g. a pneumonia model that actually looks at the hospital's text marker in the corner, or a "husky" detector that looks at snow.

04Responsible vision — fairness, documentation, robustness

A single overall accuracy can hide who the model fails. The Gender Shades study found commercial gender classifiers with error rates up to 34.7% for darker-skinned women versus 0.8% for lighter-skinned men.

Practices to know:

  • Disaggregated evaluation — report metrics per subgroup (skin tone, age, region, camera type), and fix gaps with better data.
  • Model cards — document intended use, out-of-scope uses, training data, per-group performance, limitations and ethical considerations.
  • Robustness testing — small adversarial perturbations or physical patches/stickers can flip predictions; test against noise, blur, lighting and distribution shift.
  • Privacy — faces and licence plates are personal data; minimise retention, blur where possible, and follow data-protection law (e.g. Uganda's Data Protection and Privacy Act 2019).
Watch it done

Worked examples

Worked example 1

Fitting a model on a phone

A 25 M-parameter detector must fit in 40 MB on a phone. Does FP32 fit? FP16? INT8?

    Worked example 2

    Disaggregated evaluation

    A face-verification model has 96% overall accuracy on 10,000 test images: 8,000 of group A at 98% and 2,000 of group B. What is group B's accuracy, and what should you report?

      Vocabulary

      Key terms

      Stickers that fool stop signs

      Eykholt et al. (CVPR 2018) put a few black-and-white stickers on a real stop sign; a road-sign classifier then read it as ‘Speed Limit 45’ in most test frames, from different distances and angles. Physical adversarial robustness is now part of safety testing for automotive vision.

      Practise

      Quick check

      0 of 8 correct so far. Wrong answers come with an explanation — and the buddy can unpack them.

      Q1A 25M-parameter model in FP32 is about 100 MB. After INT8 quantisation?

      Q2A Grad-CAM heatmap for ‘husky’ highlights snow, not the dog. This suggests…

      Q3Batching more requests together usually…

      Q4Which runtime targets NVIDIA GPUs?

      Q5In Grad-CAM, what are the channel weights α_k?

      Q6Why apply ReLU in Grad-CAM?

      Q7What does a model card document?

      Q8Knowledge distillation trains…

      Exam-style

      Written practice

      Short answer6 marks

      How does Grad-CAM produce a heatmap, and how can it reveal shortcut learning?

      Short answer5 marks

      How would you audit a vision model for bias? Refer to Gender Shades.

      Long answer15 marks

      You must deploy a skin-lesion classifier as an offline app on mid-range Android phones used by community health workers in rural Uganda. Describe how you would make it fit and run fast, how you would verify it is accurate and fair, how you would explain its outputs, and what you would document.

      Watch

      Videos

      Fresh picks are chosen by AI every day.
      Hands-on

      Quantisation & model size

      4 guided tasks: predict, experiment, explain — then challenge yourself. Plus 2 coding exercises you run right in the browser.

      Start the lab