Data augmentation
Suppose you had a certain amount of image data for a given application – for example, images of weeds in grass for the weed detection task discussed above. Imagine if you used the data to train a CNN, then took part of the data, ‘messed around’ with it a bit, added the results to the original dataset and then used the new dataset to train a second CNN. How do you think the performances of the two CNNs would compare? This is data augmentation and as with transfer learning, you might expect that it would not provide a significant improvement in the learning and hence the network performance. But, you guessed it, it does. Data augmentation is often employed to artificially enlarge datasets being used by applying random transformations such as zooming or rotating the image. This can help to reduce the problems from overfitting that are often present when modelling small yet complex datasets. Commonly available software, such as Keras, TensorFlow, and Google Colab are free to access and provide useful tools for real-time image augmentation and CNN training. To give an example of how it is used, our weed-in-grass application mentioned above employed an augmentation regime that consists of the following: First the pixel values are scaled between zero and one; a process that yields slightly better training results. Next, the images are randomly rotated and shifted in both width and height. A random zoom is then applied. The final augmentation technique used is to randomly flip images horizontally and vertically. In the figure below, images are shown for just grass as well as grass with Rumex and grass with clover. Being able to differentiate between these plants being present in grass is, in fact, a very beneficial thing since, as mentioned, ingestion of dock is bad for animals, which is not the case for clover.
Original and augmented images of grass with Rumex present and clover present. (Images by the author.)
The presence of clover in grass is certainly a good thing seeing that it is good for grazing animals as well as providing valuable nutrition for the soil. However, up to now the treatments farmers give grazing grass for killing docks have generally involved blanket spraying of herbicides or ‘broadleaf’ weed killers which will, of course, kill clover along with the dock, as well as being more expensive and bad for the environment. Also, there can be little doubt that at some time soon the Government will ban the use of commonly used weed killers such as glyphosates. So, I am sure this kind of technology is going to become more important and widespread in the near future. Rumex is another name for dock weed – and to give it it’s full fancy name: Rumex obtusifolius .
By the way, giving plants common names and fancy names reminds me of Logan’s Run . In the film, Logan and Jessica go to the ruins of Washington D.C., where they meet Peter Ustinov playing a slightly crazy old man who keeps legions of cats and talks about them at length. As he rambles on, he claims all cats have three names: a regular name, a fancy name, and a name only the cat itself knows. I am not sure if this is true of plants, but if so, the names for the weed above are: bitter dock, Rumex obtusifolius, and a name only the plant itself knows.
One thing I do know is that dock weeds are taking over my garden, and any kind of weed control, automatic or otherwise, would be most welcome. Also, I will swear that Rumex obtusifolius manages to grow to a much bigger size in Somerset than it does in Scotland (where the farmer we were working with on this was based). If you have enough data to train a CNN from scratch, that will still give you the best possible performance, and when training a 26-layer CNN from scratch (with data that incorporated augmentation), for detection of docks in grass, we obtained 95.6% accuracy – which seemed impressive. However, perhaps even more amazing is the fact that when employing transfer learning we achieved a classification accuracy of 83.5% using a dataset of just 50 samples!
A picture containing text, book Description automatically generated
Logan and Jessica: “Are you all alone here?”
A close up Description automatically generated
Old Man: “Hardly, I’ve got all these cats.”
Scenes from the film Logan’s Run, with Michael York as Logan, Jenny Agutter as Jessica and Peter Ustinov as the old man they meet in a future Washington D.C. (Pen and ink drawing by the author.)
This represents higher accuracy results than previous non-deep learning techniques, while only requiring a training dataset that could be collected and processed by a single person in a day - clearly showing the advantages possible with these methods .