Performance of the slug detection was improved by disabling auto focus in the Logitech C290e camera and not using zoom as the zoom is digital rather than using lenses and dramatically reduces the pixel density. The detection results seem to be a lot better as shown in the video below:
The slugs are now house trained. 10605 images of slugs have created a fairly good slug detector although there could be improvements by adding blurred images to get the training to focus more on the overall shape of the animals, including their tentacles, or antennae. In deployment, there are quite a few false positives, not really shown on the video below, which was created on a leaf background:
The training shows obvious convergence, even though testing in real life does not pick up on the overall shape of the slugs, but more readily on the patterns on their bodies. Training on AWS Nvidia V100 GPU took about 13 hours to reach 500 epochs:
Training slugs has proved to be more difficult than the common European wasps, probably because the wasps have much more obvious features whereas the slug is more of an amorphous blob with antennae. At this stage, the project is very possibly finished as the limitations of the object detection algorithm has been successfully explored and the conclusion is that more obvious features need to be apparent for effective detection.
Future work would benefit from a better camera eg Logitech Brio 4K rather than Logitech C930e, which would give 4x the pixel density and HDR. Also, more images, possibly another 10,000 of them!
Deployment success! Not brilliant accuracy, but it's definitely working. Most inference is between 50 and 60 % accurate. Also detects snails, which is weird as I took all the snail images out of the image sets. Must be a relic of previous training as I always use a trained model from the previous AWS session (pre-trained network).
Looking at the graph, it seems that training has got quite a bit further to go as the top red line is still sloping downwards and the loss coverage is not diminishing as it should. I'll test the model that this session created, but I think throwing another 1,000 images at the network would be a good idea. I really needed this result to boost my enthusiasm!
It's worth thinking now about the next stage in a bit more detail - how to catch / destroy the slugs? I think a Google questionnaire form might be appropriate with questions to probe people's views on the morals / ethics of killing slugs and the possibility of more 'humane' alternative solutions?
I added another 1,000 images and text files of slugs and about 1,100 'dontcare' image sets and still no signs of convergence. I don't feel disheartened because I've already had good success with custom images of the common European wasp. Another difference between the data sets is that with the wasp images, there were often over 10 wasps in one single jpg and the wasps all looked pretty much identical, whereas the slugs are mostly one per image and there's about 10 different sprecies. Will the model converge or will I have to go back to YoloV3 to get a deployable model?
Even after adding another 600 images and associated text files, detectNet neural network failed to show any real signs of convergence, even after a couple of hours on AWS P100 GPU:
If detectNet fails to converge, I'm sure it's possible to run YOLOV3 on the Nano without too much trouble.
In my other project, the Ai Wasp sentry gun, I successfully managed to deploy a model on the Raspberry Pi using MobileNet SSD, although the results were admittedly pretty poor.
This time I thought I'd try YoloV3 as, theoretically, there is a complete software toolchain to take the Yolo model to the Pi. Training 1,000 annotated images of slugs on AWS seemed to be successful:
Training neural networks for detecting slugs requires hunting down slugs in the night time and photographing them under the light of a head torch with macro lens. Fortunately, they don't move too quickly, but photography is still challenging as the macro lens is very sensitive to movement so the aperture needs to be quite large which means getting focus correct is hard. An advantage is that the background gets blurred, especially when the slugs are silhouetted somewhat. A minimum of 2,500 photos are required and each one needs to be cropped, resized to 640 x 640 pixels, renamed and then labelled. I seem to be able to do an average of about 100 a day and have done 1,000 so far.
Slugs are amazing creatures and getting this close to them is quite revealing. I think most people would think of them as being pretty gross, but on close up they are truly beautiful animals. I think I identified about 10 different species, from the large black ones to the small dappled.