AI Pipeline for Pipelines

Industrial fluid leaks can happen due to a variety of factors, such as equipment failure, human error, or natural disasters. These leaks can result in the release of toxic chemicals and pollutants into the environment, which can have serious consequences for human health. Exposure to chemicals present in industrial fluids, such as pesticides, heavy metals, and carcinogens, can lead to a wide range of health problems, including cancer, neurological disorders, and respiratory issues.

In addition to the impact on human health, industrial fluid leaks also have a significant impact on the environment. These leaks can contaminate water sources, leading to the death of fish and other aquatic life, and can also harm terrestrial wildlife and plant life. Furthermore, the release of pollutants into the environment can lead to air pollution, which gives rise to additional hazards.

Industrial fluid leaks also result in significant costs to industry. In addition to the substantial costs associated with cleaning up the leak and any damage caused, companies may also face fines and penalties for violating environmental regulations. Insurance claims and potential legal action can also add to the cost for the company.

Seeed Wio Terminal

To mitigate the negative impacts of industrial fluid leaks, it is essential for companies to take proactive measures to prevent them from occurring in the first place. This includes regular maintenance and inspections of equipment, however, pipelines for fluid transportation can be very large, sometimes traversing hundreds or even thousands of miles. Needless to say, keeping close watch over such an expansive system is both challenging and costly, which all too often leads to leaks wreaking havoc well before they are even detected.

An engineer by the name of Shebin Jose Jacob has recently described a proof of concept device that he constructed to address the problem of industrial fluid leaks. Rather than relying on costly and error-prone manual inspections, his system uses an intelligent algorithm developed with Edge Impulse Studio that can automatically monitor a fluid transport pipeline and detect leaks the moment they occur. Jacob’s inexpensive solution has the potential to notify appropriate personnel instantly so that pipeline repairs and environmental remediation efforts can begin without delay.

To get the project off the ground quickly, a Seeed Studio Wio Terminal was selected for the hardware platform. The Wio Terminal has a powerful SAM D51-based microcontroller running at 120 MHz and 192 KB of RAM to run machine learning models that have been highly optimized by Edge Impulse for resource-constrained devices. It also has a 2.4” LCD display, Bluetooth and Wi-Fi wireless connectivity, and a slew of on-board sensors — just about anything you might need in a single package. This was paired with a water flow sensor to capture information about the flow of fluids through pipes.

System testing setup

Jacob’s plan was to feed the measurements from the water flow sensor into a machine learning classifier that has been trained to recognize three conditions — normal fluid flow, no fluid flow, and fluid leak. In order to do that, labeled sample data from the flow sensor would be needed to train the model. A test rig, consisting of some lengths of pipe and the water flow sensor, was created, and the Wio Terminal was configured to collect the sensor measurements. A hole, which could be uncovered as needed, was made in a section of pipe to simulate leaks. This setup was then used to collect sensor data for all three conditions of interest, with the help of a few simple scripts that were created for that purpose.

The scripts saved the measurements as CSV files, which were then uploaded to a project in Edge Impulse Studio using the data acquisition tool. Using this tool, the input data was assigned labels, split into six second segments, and divided into separate training and testing datasets. There are also options to visualize the data so that one can get a sense of how well the different classes may be differentiated from one another.

Visualizing the training data in Edge Impulse Studio

Once the data was ready, the stage was set for designing the impulse that analyzes sensor data with a machine learning algorithm. In this case, Jacob added a preprocessing step that segments input data into one second lengths, then forwards that raw data into a neural network classifier that can predict which class any given set of input data belongs to. After making a few small tweaks to the model’s hyperparameters, the training process was initiated.

After a short time, model training was complete, and a confusion matrix was presented to eliminate any confusion about how well the model was performing its job. The average classification accuracy was reported as being 100%, which is excellent, but can also be indicative of a model that is overfit to the training data. To check for that possibility, the model testing tool was utilized. This is a more stringent test that checks the model’s performance on a set of data that was held out of the training process. The test also revealed an average accuracy of 100%, so there was nothing left to fine-tune.

The results of the model testing tool

Next, Jacob used the deployment tool so that the model can run directly on the Wio Terminal hardware. This eliminates the need for cloud connectivity, as well as any privacy concerns that can come with transmitting sensor data to a remote location. The Arduino library option was selected, which provides a lot of flexibility. This choice allows one to insert their own logic into the code to, for example, trigger specific actions based on the inferences made by the model.

The prototype device continually analyzes data from the water flow meter and displays the status of the fluid flow through it in real-time on the screen of the Wio Terminal. It would be fairly trivial to also wirelessly transmit that status to a remote cloud dashboard, or even as a text message in the case of a leak, to allow for remote management of a distributed network of leak detectors.

You don’t want to see this one!

Lots more detail is available in the project documentation over at Edge Impulse, and Jacob has made his Arduino sketches available on GitHub. If an automated fluid leak detector is exactly what you have been looking for, you can create your own in a jiffy by cloning the public Edge Impulse Studio project.

Want to see Edge Impulse in action? Schedule a demo today.


Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter