Using AI for Food Contamination

Bernice Lien
Everyday Analytics
Published in
5 min readJan 17, 2021
Source: Scott Warman Unsplash

A staggering 600 million peoplealmost 1 in 10 people in the world, became ill after ingesting contaminated food. Of those, 420,000 people die every single year. Just alone in America, there are 48 million cases of foodborne illnesses annually — tantamount to 1 in 6 Americans getting sick every year.

I’m sure the main concern for many of you reading this article right now is if the food you are going to eat for your next year will kill you. But for many people in the world, that is their reality.

So what’s the solution?

Hyperspectral Imaging.

“It collects hundreds of images at different wavelengths for the same spatial area. While the human eye has only three color receptors in the blue, green and red, hyperspectral imaging measures the continuous spectrum of the light for each pixel of the scene with fine wavelength resolution, not only in the visible but also in the near-infrared.” — Nireos

Source: Nireos

Don’t get me wrong, our eyes and mobile cameras surely do an amazing job of capturing colorful and vivid art pieces. But, there are still limitations to what our human eyes can perceive and details our RGB cameras can capture. Here’s when Hyperspectral Imaging enters the game. Hyperspectral Imaging is an analytical technique that is based on spectroscopy.

It analyzes a broad spectrum of light rather than assigning primary colors (red, green, blue) to each pixel.

Essentially, this form of imaging aims to obtain the spectrum for each pixel in the image. This allows us to find objects, detect processes, identify materials we couldn’t have with our conventional microscopes, cameras, or our very eyes.

Source: Wikipedia

How does this tie in with food?

Well, hyperspectral imaging can be implemented to detect foodborne pathogens. Traditional methods for the detection and identification of pathogens are merely cumbersome. In the picture below, you can see pathogens such as E. coli and Salmonella being detected.

Not only can hyperspectral imaging be used for food safety but also the assessment of food quality. It allows us to determine the freshness of meat, vegetable, and fruit products. Which, in turn, accurately calculates the shelf life of the products.

Hyperspectral imaging is also used in other industries such as precision agriculture, biotechnology, environmental monitoring, and much more.

Source: Kangjin Lee ResearchGate

But… There’s a HUGE caveat…

The hyperspectral cameras (aka image spectrometer) ARE SOO EXPENSIVE! The cost ranges from $28k to well over $1M! Fortunately, scientists have been working on reducing the cost of these cameras to around $800. However, there is still another way to produce hyperspectral images using …

Artificial Intelligence.

Photo by Michael Dziedzic on Unsplash

Artificial Intelligence x Hyperspectral Imaging

There are several ways you can produce hyperspectral images from AI. In this article, I will focus on generative adversarial networks (GAN) based on the Pix2Pix model as they are computationally less expensive and have a lower training/validation loss than the other methods.

The Pix2Pix GAN is an approach to train a deep convolutional neural network for image-image conversions. Now in a GAN model, there is a generator and a discriminator.

The generator's role is to generate a hyperspectral image from a ‘random input’, the RGB image. Once the ‘fake’ hyperspectral image is created, it runs through the discriminator.

There are two inputs to the discriminator: A real hyperspectral image and the generated hyperspectral image. The role of the discriminator is to discriminate between which image is the ‘real’ hyperspectral image.

Let’s break down generative adversarial networks to a simple analogy …

So Bob (the generator) is pretty broke, so he decided to start making counterfeit money. He goes to the store and tries to pay with his counterfeit bill. Now the cashier (the discriminator) can differentiate between Bob’s counterfeit and a real bill. The cashier declines the bill.

Bob is amazing at drawing.

So Bob tried again. And got rejected.

He tried again and got rejected 100 times. At this point, both the generator (Bob) and the discriminator (the cashier) are getting better and better at making fake bills and differentiating bills.

Photo by Ystallonne Alves on Unsplash

Finally, Bob becomes very good at making money and tricks the cashier.

Success!

The same notion is applied to creating hyperspectral images. The generator creates the images, and the discriminator receives two inputs: the actual hyperspectral image taken on a hyperspectral camera and the generated hyperspectral image. Both of the networks get trained. The generator gets better and better at making hyperspectral images.

There are many different applications for this, such as checking if a fruit is ripe or how long you can leave it on your shelf before it rots. Hopefully, in the future, this can be implemented to prevent deaths and hospitalization from food-borne diseases.

hehe, I made this

Summary

  • You can use hyperspectral images to assess food quality, freshness, and if it was ever contaminated using hyperspectral imaging.
  • Hyperspectral imaging: An analytical technique that is based on spectroscopy
  • Hyperspectral cameras are expensive, so a possible cost-effective way to make these images would be through artificial intelligence.
  • There are different way to make this AI; one is through generative adversarial networks (GAN)

If you liked this article, follow me on medium :) Also, feel free to connect with me on LinkedIn.

More resources!

What is hyperspectral imaging?

--

--

Bernice Lien
Everyday Analytics

Hey everyone! I’m Bernice and I’m a high school student who loves to learn about technology. Follow me to get notified for my articles :)