When a large group of people come together, they inevitably have all sorts of ideas and it can be hard to get everyone to agree on much of anything. But one thing that everyone can agree on is that litter should not be strewn along our city streets. Not only does litter look terrible, but hazardous chemicals can leach out of the trash and enter nearby soil and bodies of water. When that happens, it can lead to health problems for both humans and animals.
Litter is a huge problem, with billions of tons of trash being inappropriately discarded each year. Over 11 billion dollars of taxpayer money is spent each year in the United States to clean up litter, but because these efforts are not always very efficient, even that large sum is insufficient to solve the issue. Engineer Nathaniel Felleke has a good deal of experience in working with machine learning, so he thought about ways that he might put it to work to help to solve this problem. What he came up with is quite interesting and may just help to make litter cleanup more efficient in the future. He built a vehicle-mounted litter detection system that records the GPS coordinates of any trash that it finds, and displays that information as a heatmap overlaid on a map.
Felleke was able to create this device using inexpensive and easy to use hardware. A Raspberry Pi 4 was chosen to run the machine learning algorithms.Since the device is operating while moving, the power of the Raspberry Pi was needed to run machine learning inferences very quickly so that accurate positioning information can be recorded. This was paired with a Blues Wireless Notecard to supply GPS coordinates, and to report findings to the cloud via cellular networks. A Logitech C270 HD webcam was used to capture roadside images.
The plan was to classify those roadside images with a neural network, so the next step in making this project a reality was to collect training data. This consisted of 764 images from the pLitter dataset, as well as images that Felleke took while driving around San Diego. The images were all assigned to one of two classes — trash or no trash. After completing data collection, it was uploaded to Edge Impulse Studio for further analysis.
An impulse was created to preprocess the image data and feed it into a neural network with just a few clicks. The network was then trained using a portion of the previously uploaded dataset. On completion of training, the model was tested against another portion of the uploaded data that was held back from the training process. This test showed that the model, even with such a small training set, had achieved an average classification accuracy of 87.5%. As previously mentioned, this model needs to run as fast as possible to record accurate positioning information, so Edge Impulse’s EON Tuner was enabled to optimize the model for use on edge computing devices.
The final step was to deploy the trained model to the Raspberry Pi so that it could run locally and with minimal latency. This was done by using Edge Impulse’s Linux Python SDK, which made deployment a breeze. Now that the Raspberry Pi was capable of classifying images of trash, Felleke only needed to create a few simple Python scripts to contain the logic for working with the Blues Wireless Notecard and transmitting reports of detected trash to the cloud.
The device now being complete, Felleke mounted the camera on his car’s window and went for a drive around town. The Edge Impulse model located pockets of trash by the side of the road and reported it to a cloud service over cellular networks. The result could then be viewed in a web page powered by the Google Maps API, which showed the distribution of litter. This map is exactly the type of resource that clean up crews need to be more efficient and more effective.
Felleke noted that the model performed very well, but in some cases it would give a false positive in a parking garage. There is no doubt that this problem could be solved by supplying the model with a bit more training data. With a few small tweaks like this, there may one day be a fleet of vehicles equipped with Felleke invention to make cities cleaner and healthier places.
You do not want to miss this one, check out the full project details to learn how you might transform your own community with ML.
Want to see Edge Impulse in action? Schedule a demo today.