Weed recognition results
Finding the weeds in the photos with a neural-net classifier (NNC).

Why?

Because a weeding robot needs to know where the weeds are to disrupt them.

The task

  • 273 pictures were taken of grass with a mobile phone camera. Some of these contain just grass. Some contained weeds and grass. Some contained just weeds. Some even contained part of my gum-boots.
  • The images were each cut into 6x4=24 tiles, producing 6552 images (which are here for the interested masochist).
  • All of these were classified by a human into one of three categories:
    • grass Contains only grass - no weeds
    • weeds Contains weeds which could be sprayed in the centre
    • reject Contains weeds, but the picture doesn't contain the centres, and hence may confuse the NNC.
    This produced a CSV file.
  • The grass and weeds photos were placed in so-named directories, with a small number taken aside to be test images.
  • The trainer was run for the { weeds, grass } set, and the results from the test images are shown below.

Human classification

Classifying 6552 images manually wasn't nearly as gruesome as expected. Anyone who has done any serious spot-spraying or weeding has already programmed their wet-ware neurons to be triggered by the sight of weeds. (Spend an entire afternoon digging out weeds, and you will see them in your dreams, I guarantee. This is your brain hard-wiring your lizard-brain as a weed trigger). A very quick glance at an image is generally enough to allow a '1' (kill!) or '0' (ignore!) to be typed in by your pre-programmed lizard brain. (I even managed to binge-watch Netflix's 'The Final Kingdom' at the same time, though I did kind of lose track of why Æthelred's evil adviser suddenly changes sides, and alerts Æthelflæd that her hubby is trying to kill her, but that was a small price to pay. For me that it is, not for Æthelred).

.. anyway, the point is that human classification is not actually that onerous. They say the average human only uses 10% of their brain, and in this case that's certainly not an overstatement. Human classification is quite feasible even with medium sized data sets. Just find something else to do at the same time.

Classification of the resultant tiles

These are images, pulled out of the original training set before training was done, then classified by the NNC.

 grass 54% ;weeds 45%

 grass 84% ;weeds 15%

 grass 62% ;weeds 37%

 weeds 90% ;grass 09%

 grass 76% ;weeds 23%

 weeds 97% ;grass 02%

 weeds 98% ;grass 01%

 weeds 99% ;grass 00%

 grass 79% ;weeds 20%

 weeds 97% ;grass 02%

 weeds 99% ;grass 00%

 weeds 96% ;grass 03%

 grass 92% ;weeds 07%

 weeds 99% ;grass 00%

 grass 97% ;weeds 02%

 grass 92% ;weeds 07%

 grass 95% ;weeds 04%

 grass 87% ;weeds 12%

 weeds 82% ;grass 17%

 grass 66% ;weeds 33%

 grass 51% ;weeds 48%

 weeds 52% ;grass 47%

 grass 90% ;weeds 09%

 grass 91% ;weeds 08%

 grass 97% ;weeds 02%

 grass 77% ;weeds 22%

 grass 77% ;weeds 22%

 grass 78% ;weeds 21%

 grass 94% ;weeds 05%

 grass 95% ;weeds 04%

 weeds 98% ;grass 01%

 weeds 82% ;grass 17%

 weeds 99% ;grass 00%

 weeds 89% ;grass 10%

 weeds 98% ;grass 01%

 grass 60% ;weeds 39%

 grass 80% ;weeds 19%

 grass 94% ;weeds 05%

 grass 84% ;weeds 15%

 weeds 77% ;grass 23%

 weeds 50% ;grass 49%

 weeds 99% ;grass 00%

 weeds 81% ;grass 19%

 weeds 67% ;grass 32%

 grass 81% ;weeds 18%

 grass 82% ;weeds 17%

 grass 88% ;weeds 11%

 grass 86% ;weeds 13%

 grass 60% ;weeds 39%

 weeds 92% ;grass 07%

 grass 61% ;weeds 38%

 grass 87% ;weeds 12%

 grass 97% ;weeds 02%

 grass 97% ;weeds 02%

 grass 58% ;weeds 41%

 weeds 68% ;grass 31%

 weeds 61% ;grass 38%

Conclusion

It works. Kind of. Not as well as the Kangarrecogniser, but pretty well.

Discussion

A few points

    The real test of 'does this work?' is the equivalent of 'would I actually be prepared to put herbicide on all the positive matches?'. Any of these photos with a 'weeds' probability of more than 90% probably qualifies. Success.
    There are a few odd results - weeds are opportunists, and grow less well in healthy thick grass, so the training photos containing only very thin vegetation are more likely to contain weeds, so the classifier is likely to be skewed this way.
    Some of the weeds in these photos are clearly water-stressed, making the classifier's job harder (ie it has to recognise both healthy and water-stressed weeds). This is actually a good thing to do to .
    Because weeds are non-oriented, I could have improved the training by distorting, flipping and rotating the images.

Leave a comment

Something I'm doing wrong? Solved my problems? Got a better idea? Got a similar problem?
Think I might have solved your problem? Ninety-nine problems, but your robot ain't one? Say so ..