Search…

Responsible CV: Privacy, Fairness, Security, Governance

In this series (30 parts)
  1. Computer Vision Roadmap: From Basics to Real Projects
  2. What is Computer Vision? From Pixels to Decisions
  3. A Short History of Computer Vision: 1545 to Now
  4. Math for CV Beginners: Vectors, Matrices, Convolutions
  5. Image Fundamentals: Color, Histograms, Noise, Filtering
  6. How Images and Video Are Stored: Colour, JPEG, Frames
  7. OpenCV Setup + First 10 Tasks in Python
  8. Vision Metrics: Accuracy, Precision, Recall, mAP, IoU
  9. CV Project Workflow: Dataset, Baseline, Error Iteration
  10. Intensity Transforms and Frequency-Domain Filtering
  11. Edge Detection and Thresholding That Actually Work
  12. Morphology, Contours, and Shape Analysis for Real Images
  13. Feature Matching (SIFT/ORB) and Image Stitching
  14. Camera Calibration and Perspective Correction
  15. Epipolar Geometry, Stereo Vision, and Depth Estimation
  16. Optical Flow and Motion Tracking in Video
  17. HOG, HOF and MBH: Descriptors Before Deep Learning
  18. Your First Image Classifier (PyTorch + Transfer Learning)
  19. Data Pipelines and Augmentation for Vision Models
  20. CNN Architectures Explained: From LeNet to ResNet
  21. YOLO Detection Pipeline: Data to Inference
  22. Semantic and Instance Segmentation: U-Net to Mask R-CNN
  23. Vision Transformers (ViT) and When to Use Them
  24. CV Explainability: Grad-CAM, Failures, Bias Checks
  25. 3D Vision Basics: SfM, Point Clouds, and Pose Estimation
  26. Multimodal Vision: CLIP, Embeddings, and Retrieval Systems
  27. Video Understanding: Flow Networks, Interpolation, Stabilisation
  28. Real-Time CV Systems: Tracking, Latency, Streaming
  29. Deploying CV Models: ONNX, TensorRT, Edge, and APIs
  30. Responsible CV: Privacy, Fairness, Security, Governance

The traffic counting system works. It also has eight cameras pointed at a public street, storing footage of everyone who walks past, and a pedestrian detector whose recall nobody has checked across different groups of people. None of that shows up in the mAP.

Prerequisites: Model explainability and bias checks and deploying computer vision models.

Four questions, all measurable

# Question Concretely Measured by
1 Does it work equally well? Recall by group Slice metrics + confidence intervals
2 What are we storing? Bytes retained, and for how long Data inventory
3 Can it be attacked? Accuracy under perturbation Adversarial evaluation
4 Who is accountable? Named owner, documented limits Model card + release checklist

None of these are philosophical. All four produce a number or a name.

Fairness, computed

fairness gap A difference in a model's performance between groups of people, measured with the same metric on comparable data.

The pedestrian detector, evaluated on a held-out set split by apparent skin tone using the Fitzpatrick scale:

# Group N Detected Recall target FPR
1 Fitzpatrick 1–3 (lighter) 1840 1641 0.8918 0.041
2 Fitzpatrick 4–6 (darker) 1210 1022 0.8446 0.048

Recall by group on the pedestrian detector.

Equal opportunity difference — the gap in recall:

Δ=0.89180.8446=0.0472\Delta = 0.8918 - 0.8446 = 0.0472

Disparate impact ratio — the ratio of the lower to the higher:

ratio=0.84460.8918=0.9471\text{ratio} = \frac{0.8446}{0.8918} = 0.9471

four-fifths rule A rule of thumb from US employment law: if the ratio between groups falls below 0.8, the disparity is treated as significant enough to require justification.

At 0.947 this passes. But before acting on either number, check whether they are real.

The confidence interval that decides whether the gap exists

Recall is a proportion, so the standard error is:

SE=p(1p)nSE = \sqrt{\frac{p(1-p)}{n}}

For the darker-skinned group at n=1210n = 1210:

SE=0.8446×0.15541210=0.131251210=0.00010847=0.01041SE = \sqrt{\frac{0.8446 \times 0.1554}{1210}} = \sqrt{\frac{0.13125}{1210}} = \sqrt{0.00010847} = 0.01041

95% CI=0.8446±1.96(0.01041)=0.8446±0.0204=[0.824,  0.865]\text{95\% CI} = 0.8446 \pm 1.96(0.01041) = 0.8446 \pm 0.0204 = [0.824,\; 0.865]

The lighter group’s interval is [0.878,  0.906][0.878,\; 0.906]. They do not overlap, so the 4.7-point gap is real.

Now suppose the slice had only 120 samples:

SE=0.13125120=0.0010937=0.03307SE = \sqrt{\frac{0.13125}{120}} = \sqrt{0.0010937} = 0.03307 95% CI=0.8446±0.0648=[0.780,  0.909]\text{95\% CI} = 0.8446 \pm 0.0648 = [0.780,\; 0.909]

That interval comfortably contains the other group’s recall. The same 4.7-point gap would be indistinguishable from noise.

# Slice size n SE 95% CI half-width target Smallest detectable gap
1 60 0.0468 ±0.092 ~18 points
2 120 0.0331 ±0.065 ~13 points
3 300 0.0209 ±0.041 ~8 points
4 1210 0.0104 ±0.020 ~4 points
5 5000 0.0051 ±0.010 ~2 points

At recall 0.845. A slice of 60 cannot detect anything under about 18 points, which is a catastrophic gap.

Where the gap comes from, and what to do

# Cause How to check Fix Typical gain target
1 Training data under-represents the group Count examples per group Collect more, or reweight the loss large
2 Low-light performance differs Slice by time of day as well Add night data, improve exposure handling large
3 Annotation quality differs Re-adjudicate a sample from each group Fix labels, retrain moderate
4 One global threshold suits one group Plot PR curves per group Per-group thresholds (check legality first) moderate
5 Genuine visual difficulty Expert review of the errors Usually needs a model or sensor change small

Diagnose before fixing. The first two explain most gaps and are the cheapest to address.

Slicing by two variables at once is usually the revealing step. The gap above was 4.7 points overall — but 1.9 points in daylight and 11.3 points after dark. That is not a fairness problem in the abstract; it is a low-light problem that lands unevenly, and the fix is exposure handling and night-time training data.

Privacy through not collecting things

data minimisation Collecting and keeping only the data needed for the stated purpose, for only as long as it is needed.

The traffic system’s purpose is counting vehicles. Compare what that requires with what a default installation stores:

# What is stored Per year (8 cameras) target Re-identifies people? Needed for counting?
1 Raw 1080p footage, 30-day rolling 10.4 TB at any time yes no
2 Cropped detections ~180 GB yes no
3 Blurred frames ~126 TB harder, not impossible no
4 Bounding boxes + class + timestamp ~4 GB movement patterns only no
5 Per-minute aggregate counts 26 MB no yes

Five levels of retention for the same system. Only the last is required.

The ratio is the argument. Aggregate counts are 400,000 times smaller than the footage and answer the question completely. Everything above them is stored for reasons nobody wrote down — usually “in case we need it later”, which is exactly the reasoning that fails a data protection review.

The default path never writes a frame anywhere. The retention path exists but requires a specific request, and it expires by itself.

# Technique Protects against Cost Limitation
1 Process on device, never transmit Interception, cloud breach edge hardware Harder to debug remotely
2 Blur faces and plates before storing Casual re-identification ~3 ms/frame Gait and clothing still identify
3 Store aggregates only Almost everything none Cannot investigate incidents
4 Short automatic retention Long-term profiling none Needs enforcement, not policy
5 Encryption at rest and in transit Theft, interception minimal Not against authorised misuse
6 Access logging and approval Insider misuse process overhead Detects after the fact

Privacy controls. The cheapest one — not storing it — is also the strongest.

Security

Three distinct threats, often conflated.

ThreatWhat the attacker doesWhen it happensMain defence
EvasionPerturbs the input to avoid detectionat inferenceAdversarial training, input checks
PoisoningCorrupts the training dataat trainingData provenance, review of new labels
Model extractionQueries the API to clone the modelat inferenceRate limits, coarse outputs
InversionReconstructs training data from the modelat inferenceDifferential privacy, limit output detail
Four attack types on a deployed vision model.

Evasion, with numbers

The standard demonstration adds a small perturbation in the direction that most increases the loss:

xadv=x+ϵsign ⁣(xL(x,y))x_{\text{adv}} = x + \epsilon \cdot \text{sign}\!\left(\nabla_x \mathcal{L}(x, y)\right)

With ϵ=8/255=0.0314\epsilon = 8/255 = 0.0314, every pixel moves by at most 8 of 255 levels — under the threshold at which a person notices anything.

# ε (of 255) Max pixel change Visible to a person? Model accuracy target
1 0 0 94.2%
2 2 0.008 no 61.3%
3 4 0.016 no 28.7%
4 8 0.031 barely 10.9%
5 16 0.063 faint texture 3.1%

FGSM on an undefended classifier. At ε=8/255 the image looks unchanged and accuracy has collapsed.

Physical attacks exist too — printed patches that stop a person being detected, and stickers that change a sign’s classification. They are less transferable than the digital versions, but they need no access to anything.

Whether to care depends entirely on the threat model. A traffic counter has no motivated adversary and adversarial training would cost 7 points of clean accuracy for nothing. A system controlling access to a building does, and the trade looks completely different.

Governance you can actually run

model card A short document recording what a model does, what data it was trained on, how it performs across groups, and where it should not be used.
# Section What goes in it Length
1 Intended use The specific task and setting 2–3 lines
2 Out of scope Uses that are explicitly not supported 3–5 lines
3 Training data Source, size, dates, known gaps a short paragraph
4 Performance Overall metrics plus every slice, with n a table
5 Known failure modes What breaks it, from error analysis a list
6 Owner A named person and a review date 1 line

A model card fits on one page. The out-of-scope section is the one people skip and the one that matters.

The out-of-scope section is where a counting model gets stopped from becoming an enforcement model. Writing “this system is not validated for identifying individuals and must not be used for enforcement” before launch is a two-minute job. Writing it after someone has asked for that feature is a negotiation.

A release checklist

# Check Passes when Blocks release?
1 Slice metrics computed Every slice has n and a CI reported yes
2 No slice ratio below 0.8 Or the gap is documented and justified yes
3 Explainability spot-check Grad-CAM on 20 errors shows no shortcut yes
4 Calibration measured ECE reported; thresholds set on calibrated scores if a threshold gates a decision
5 Data retention enforced in code Automatic deletion job exists and is tested yes
6 Model card written Including the out-of-scope section yes
7 Failure path defined System degrades safely, does not fail open yes
8 Monitoring live Drift, drop rate, and detection-rate alerts firing yes
9 Rollback tested Previous version restorable in under 10 minutes yes
10 Named owner and review date A person, and a date within 12 months yes

Ten checks. Most are half a day of work in total, and each one has caught a real problem in some deployment.

Even in the exempt cases, slice the metrics. It costs an hour and it is the check that finds real bugs, not just governance ones.

Practice task

Use any classifier or detector with metadata available.

  1. Pick two or more slices. Compute the metric for each, with n.
  2. Compute the standard error and 95% CI for each slice. Do the intervals overlap?
  3. Compute the disparity ratio. Compare against 0.8.
  4. Re-slice on two variables at once — group and lighting, or group and time of day.
  5. Write down every piece of data your system stores and how long it keeps it. Cross out what is not needed.
  6. Implement FGSM at ε of 2, 4, 8, 16 of 255. Plot accuracy. Look at the ε=8 image.
  7. Write a one-page model card, including the out-of-scope section.
  8. Run the ten-item release checklist honestly. Note which items you cannot currently pass.

Step 8 is the one that finds things. Most systems fail three or four items on the first pass, and the failures are usually the easy ones — no enforced deletion, no named owner, no tested rollback.

Summary

Fairness is measurable. The pedestrian detector had recall 0.8918 and 0.8446 across two groups: a gap of 0.0472 and a ratio of 0.9471, which passes the four-fifths rule. At n=1210n = 1210 the confidence intervals were ±0.020 and did not overlap, so the gap was real — at n=120n = 120 the margin would have been ±0.065 and the same gap would have been invisible. Re-slicing by time of day showed 1.9 points in daylight and 11.3 after dark, which turns a vague fairness concern into a specific low-light fix.

Privacy is mostly about not collecting. Aggregate counts are 26 MB a year against 10.4 TB of rolling footage, and they answer the question completely.

Security depends on the threat model. FGSM at ε = 8/255 took accuracy from 94.2% to 10.9% with no visible change to the image, and adversarial training recovered it to 64.2% at a cost of 7 points on clean data. Only worth it if someone is actually attacking you.

Governance is a one-page model card and ten checks. The out-of-scope section is the one that matters most and takes the least time.

Where this leaves you

That is the series. You started with a pixel grid and a rule about dark fractions, and worked through image formation, filtering, edges, contours, features, calibration, stereo, motion, classification, detection, segmentation, transformers, explainability, 3D, retrieval, real-time systems, deployment, and now the checks that decide whether any of it should ship.

The series roadmap has the full map if you want to revisit a track. The most useful next step is not another topic — it is one project end to end: collect a small dataset, work the project loop, get something running, and slice its metrics before you tell anyone it works.

Test your understanding
You audit a model across four groups and find no statistically significant differences. Three slices have between 40 and 70 samples. What should you conclude?
Test your understanding
Your traffic counting system only needs vehicle counts, but the default installation records 30 days of 1080p footage. What is the strongest argument for changing it?

Frequently asked questions

Which fairness metric should I use?
It depends on which error hurts. Equal opportunity compares recall and is right when missing someone is the harm, as in pedestrian detection. Predictive parity compares precision and is right when a false positive is the harm, as in flagging someone for review. Demographic parity compares selection rates regardless of correctness and is rarely appropriate for detection. You cannot satisfy all of them at once when base rates differ, so pick the one that matches the actual harm and say which you picked.
What if I do not have demographic labels?
Use proxies that do not require them. Slice by time of day, weather, camera, lighting, image quality, and object size — these correlate with many real disparities and need no protected attributes. The low-light gap in this post was found that way. Collecting demographic labels specifically for auditing is itself a privacy decision, and in many jurisdictions it needs a lawful basis of its own.
How often should I re-audit?
On every model update, and on a schedule regardless — quarterly is a reasonable default for a deployed outdoor system. Data drifts even when nothing changes: seasons shift lighting, road layouts change, cameras get nudged. A model that was fair in June can develop a gap by December without a single line of code changing, and only a scheduled re-audit catches that.
Is edge processing enough for privacy compliance?
It helps a great deal and it is not sufficient on its own. Processing on device means raw footage never traverses a network or lands in a data centre, which removes the largest category of risk. But you still need a lawful basis for the processing, signage where required, a retention policy for anything that is stored, and access controls on the device. Talk to whoever owns data protection at your organisation rather than treating architecture as the whole answer.
Where do I start if all of this is new?
Slice your metrics. It costs about an hour, needs no new tooling, and finds genuine bugs rather than just governance gaps — the underexposed-image slice in the explainability post was 17 points below average and completely invisible in the headline number. Then write the one-page model card, because filling in the out-of-scope section forces the conversation about what the system is for while it is still easy to have.
Start typing to search across all content
navigate Enter open Esc close