Loading
0xE0Lesson 15 of 16

Build computer vision responsibly

Measure performance across groups, and weigh privacy and misuse before deploying vision systems.

18 min 6-question quiz 1 code exercise
By the end of this lesson you can
  • Explain how a vision model can work worse for some groups
  • Measure accuracy per group instead of only overall
  • Recognize privacy and misuse risks in vision applications

Vision systems decide who unlocks a phone, which X-rays a doctor looks at first, and who gets stopped at a border. When they fail, the failures are rarely spread evenly - they cluster on the people and situations the training data covered least.

Look past the overall number

An overall accuracy averages over everyone, so a large group the model handles well can hide a small group it fails. Always report results per subgroup - by skin tone, age, lighting, camera type, region - and check that the test data includes enough examples of each to trust the numbers.

per_group.py
1results = {"group A": [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], "group B": [1, 0, 1, 0]}
2all_results = [result for outcomes in results.values() for result in outcomes]
3print("overall", round(sum(all_results) / len(all_results), 2))
4for group, outcomes in results.items():
5    print(group, round(sum(outcomes) / len(outcomes), 2))
Output
overall 0.79
group A 0.9
group B 0.5

Try it

What is the risk?

Each scenario carries a main risk. Sort them.

0 of 5 sortedScore 0/0
  • “A skin-condition app trained almost only on light skin”

  • “A store identifies every shopper’s face without telling them”

  • “A realistic generated photo of a politician at a fake event”

  • “A pedestrian detector tested only on daytime, sunny streets”

  • “Street-view photos that show readable license plates and house numbers”

Key takeaways

  • Vision models fail most on what their training data covered least - often already disadvantaged groups.

  • Report accuracy per subgroup; an overall number can hide large gaps.

  • Consider privacy (faces are biometric data) and misuse (realistic fakes) before you deploy.

Lesson quiz

6 questions · pass with 5 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: apply computer vision with Python

Use small pixel arrays to explore vision concepts, run your code against sample images, and connect each result to the larger computer vision idea.

Exercise 1

Measure accuracy per group

+25 XP

The first line is N. Each of the next N lines is group outcome, where the outcome is 1 (correct) or 0 (wrong). Print group: accuracy for each group in alphabetical order (accuracy rounded to 2 decimals), then gap: G - the largest group accuracy minus the smallest, rounded to 2 decimals.

  • A big gap
  • Even
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Did you like the lesson? 😆👍
Consider a donation to support our work: