Workshop #2

Classification & Color

Appalachian A. I. Corps @ UTK

Lesson Objective


In this lesson, you will learn about and apply ideas around image classification, neural nets, color, as well as how they can be used to monitor water quality.

Materials Needed:

  • 💻 A computer with a webcam
  • A web browser (Chrome, Firefox, or Safari)

Workshop Structure


💻 Navigate to:

https://tinyurl.com/aaic-wq-2


Review


Last workshop we learned:

  • Forms of Nitrogen in Water
    • Nitrate
    • Nitrite
  • EPA Limits?

Review


Last workshop we learned:

  • Roles of Nitrogen in Water:
    • Nutrient
    • Pollutant
      • 🐄 Waste runoff
      • 🌧️ Acid rain
      • 🌼 Fertilizer

Review


Last workshop we learned:

  • Using Python to store, summarize, and visualize data
    • Store data in a list
    • Useful functions:
      • len()
      • min()
      • max()

Review


Last workshop we learned:

  • Using Statistics to Summarize Data
    • Measures of Center
      • Mean
      • Median
    • Measures of Spread
      • Range

Meet the Buoy!

Meet the Buoy!


Later this semester, we will be deploying these Smokey Buoys!

🎥 Buoy In Action!


The Buoy: Test Strips


  • Smokey Buoy also uses test strips to monitor nitrate concentrations in water
    • Like we did in the first workshop!
    • The buoy’s strips are just made a bit differently…

The Buoy: Test Strips


Start with the same test strips

The Buoy: Test Strips


Remove the pads and adhere onto a long strip of material

The Buoy: Test Strips


Roll up strip inside canister

The Buoy: Test Strips


Strip dispenses out of the canister to be fed through the roller

The Buoy: Other Parts!


The Buoy: Container for Test Strip Roll


Container for Test Strip Roll

The canister stores the rolled-up test strip and feeds it out as the motor and rollers advances it.

The Buoy: Water Contact


Water Contact

There is an opening in a chamber of the canister, allowing the strip to contact the water.

The Buoy: Test Strip


Test Strip

The test strip feeds up from the canister and through the rollers.

The Buoy: Test Strip Pad


Test Strip Pad

The reactive pad on the strip changes color when exposed to nitrates in water.

The Buoy: Rollers


Rollers

The rollers grip the test strip and advance it.

The Buoy: Motor


Motor

The motor drives the rollers, which grip and advance the test strip.

The Buoy: Camera


Camera

The camera acts like the “eyes” of the buoy. It watches for a pad to come into frame and, when it does, also takes a photo.

🗣️ Discuss: In Your Group


Thinking back to the nitrates activity from last week…

- What are the benefits to using a computerized buoy to conduct water quality tests?

- What are the drawbacks?

Intro to Classification

Intro to Classification


🎯 Checkpoint 2. a: Which banana(s) would you eat?

Source: US Department of Agriculture

Intro to Classification


  • People make decisions about ripeness daily: grocery shoppers & farmers alike.
  • These decisions—judging if a fruit/vegetable is ripe—are called classification.
  • Classification = sorting items into groups based on appearance or behavior.

Use of Classification in Agriculture


  • AI can help make classification decisions, saving time and labor for farmers
  • Example: At University of Maryland, AI is used to identify ripe crops in fields

Source: Liu, T., Chopra, N., & Samtani, J. (2022). Information system for detecting strawberry fruit locations and ripeness conditions in a farm. Biology and Life Science Forum, 16 (1), https://doi.org/10.3390/IECHo2022-12488

Use of Classification in Agriculture


🎯 Checkpoint 2. b: Review the figure below. In image (b), what do you think the yellow represents? The green?

Binary Classification


Two possible Outcomes:



Not Ripe Ripe



Types of Classification


Classification of Strawberries

  • Binary Classification: Two possible outcomes (e.g., Ripe vs. Not Ripe)
  • Multiclass Classification: More than two possible outcomes (e.g., Underripe, Ripe, Overripe)

Multiclass Classification


More than Two Outcomes:



Underripe Ripe Molded



Multiclass Classification Example 1


Pros of Using AI for Classification


  • Using AI has advantages and disadvantages

Pros:

  • Handles millions of items quickly
  • Makes classification decisions quickly
  • Spots tiny differences humans miss

Cons of Using AI for Classification


Cons:

  • Needs tons of examples to train the computer
  • Bad examples = bad decisions (e.g., train only on sunny photos, it fails on cloudy days).

🗣️ Discuss: In Your Group


🎯 Checkpoint 2. c:

If farmers use a certain company to train and decide when to pluck or harvest fruits/veggies, who gets to own that data?

Why?

🗣️ Discuss: In Your Group


🎯 Checkpoint 2. d:

Let’s say the company becomes better at identifying ripe fruits because they used data from your farm. Now, they want to up their subscription fees for farmers (including you) to use their model.

Is that fair?

Do you have any suggestions or solutions?

💻 Classification: Your Turn!

Classification Activity - Train


  • Fruit Assortment
    • 🍎 🍏 Apples, 🍊 Orange, 🔴 Ball
  • 💻 Device
  • Lab sheet


💻 Teachable Machine


  • Uses Python in the background
  • Helps users build classification models


🚀 Let’s Go


💻 Go to Teachable Machine at:

tinyurl.com/google-tm



*** We’ll walk through this together!

Evaluate Your Model!

Evaluate Your Classifier


  • Some models can be very accurate, while others might struggle
  • Let’s put your model to the test!

Evaluate Your Classifier


Use the “Preview” pane on the right side of the Teachable Machine screen

📝 Now test your model!

  • Hold up each of your objects on your handout to the camera
  • Record the results
  • Does your model correctly classify each object?
  • With what confidence?

🗣️ Discuss: In Your Group


  • How did your model perform?
  • Were any objects classified incorrectly?
  • Were any objects classified with low confidence (< 80%)?

Classification in Smokey Buoy


Neural Networks

How Does Your Model Work?


  • Under the hood of a classification model is a Convolutional Neural Net (CNN)
  • CNNs are trained to recognize patterns in images

How Does Your Model Work?


Prioritize understanding big picture over math

How Does Your Model Work?


🗣️ Discuss: How Does Your Model Work?


🎯 Checkpoint 5. a

Contrast how each layer type works in a neural net:
- the input layer
- the hidden layers, and
- the output layer

What might each layer do if your model is trying to classify whether or not an image is a cow? 🐮

Computers & Color

Understanding RGB


An image is a combination of millions of little squares called pixels

Understanding RGB


Each pixel has a color

Understanding RGB


Each color is a combination of three values:

  • Red = 252
  • Green = 148
  • Blue = 43

🎨 Computers & Color Activity (Pt. 1)

Color –> RGB Values


🎯 Checkpoint 6. a: Exploring color and RGB Values

Materials Needed:

  • 💻 APPLET
  • 🍎🍊🍏 Fruit from previous activity
  • 📝 Handout

Color –> RGB Values


  • Use the applet and follow the instructions on the handout.

  • We will do the first together!

Colors –> RGB Values


  • We learned every pixel has a value for Red (R), Green (G), and Blue (B)
  • Each value can range from 0 to 255

🎨 Computers & Color Activity (Pt. 2)

RGB Values –> Color


🎯 Checkpoint 7. a: Using RGB Values to Create Color

Materials Needed:

  • 💻 Slider Tool on Pg. 7
  • 📝 Handout

Using RGB Values to Create Color


  • Use the slider tool below to convert the RGB values to colors
  • Record your answers on the handout
  • We’ll do one together!

Slide the R, G, or B to see how it affects the color of the square!

R:
128
G:
128
B:
128

Using RGB Values to Create Color


🎯 Checkpoint 7. b: Use the slider tool!

What color does this RGB value represent? (110, 164, 212)

Just like the computer, predict what fruit this could be from!

🎟️
Exit Ticket

🎟️ Exit Ticket





🎉 Great job! You’ve learned so much!

Share what you’ve learned on the Exit Ticket.

🧠
Exercises

🧠 Exercises





Want to practice what we’ve learned?

Try the Exercises.

(Ask Your Teacher For the Link.)