Many industries have the need to identify current and past weather conditions. The data helps them plan, organize, and/or optimize their operations. For example, farmers might look at the current weather to decide if the sprinklers should be turned on or off. Ski resort operators might choose to enable snowmaking machines based on varying weather conditions across the mountain. Construction workers might plan out the supplies and rain gear they'll need for a remote job site.
Currently, making such decisions can require manually looking at video feeds from remote cameras, relying on weather forecasts, or simply looking out the window.
Using machine learning (ML) offers the potential to automate this by providing a digital eye. More specifically, if an image recognition ML model could be built to identify conditions by simply looking at images of the weather, it could be deployed in scenarios like those described above. For example, a camera feed on a farm could be processed by an ML model deployed on an IoT device at the edge (e.g., on a smart camera). That model can then be used to automatically determine the current weather conditions and enable or disable sprinkler valves accordingly.
To demonstrate this use case, we built a model in PerceptiLabs trained to classify four different types of weather. We used 1,123 images from the Multi-class Weather Dataset for Image Classification1: cloudy, shine, sunrise, and rain.
We pre-processed the images to resize each of them into a resolution of 224x224 pixels and created a .csv file to map the images to their respective classification enumerations. Below is a partial example of how the .csv file looks:
Example of a .csv file to load data into PerceptiLabs where 0 is cloudy, 1 is rain, 2 is shine, and 3 is sunrise.
Our model was built with just three Components:
|Component 1: ResNet50||include_top=No, input_shape=(224,224)|
|Component 2: Dense||Activation=ReLU, Neurons=128|
|Component 3: Dense||Activation=Softmax, Neurons=10|
Training and Results
With a training time of around four minutes, we were able to achieve a training accuracy of 99.4% and a validation accuracy of 95.9%. In the following screenshot from PerceptiLabs, you can see how the accuracy ramped up to these percentages over the 10 epochs, with much of the increase occurring within just the first three epochs:
At the same time, loss decreased the most during the first five to six epochs:
The ability to automatically identify current weather conditions using image recognition, can play a key role in industrial IoT (IIoT) applications ranging from agriculture to oil and gas and beyond. Companies can use it to control resources, save energy, and optimize their operations.
The model itself could also be used as the basis for transfer learning to create more advanced models that detect other weather conditions or even analyze a given environment.
This use case is a simple example of how ML can be used to identify weather conditions using image recognition. If you want to build a deep learning model similar to this in just minutes, run PerceptiLabs and grab a copy of our pre-processed dataset from GitHub.
1 Dataset Credits: Ajayi, Gbeminiyi (2018), “Multi-class Weather Dataset for Image Classification”, Mendeley Data, V1, doi: 10.17632/4drtyfjtfy.1