Random thoughts - MystiCons/AIScouts GitHub Wiki

What should be done differently

  • All image editing on raspberry pi should be done with Pillow instead of Opencv 2. Installing Opencv 2 (Python 3+) is quite painful. You need to compile the project from scratch, which on raspberry takes 3-4 hours with one core, 1 hour with 4 cores (make -j 4).

  • picamera should be optimized somehow, currently capturing one image takes 0.4 seconds, which is about 70% of the loops processing time. (Raspberry version of parking detection)

  • The current dataset contains a lot of too similiar images of the cars, which makes the balance of park and car images even worse. Make a new dataset and take maximum one image each hour from a parking slot

  • Delete incorrent images (images with a car) from empty park dataset

  • Normalize all images between -1 and 1. Currently all images are 0-255 uint8

  • Use cPython to optimize raspberry code to make it work in realtime.

  • Take random crops of cars to augment the car dataset. This could improve detecting wrongly parked cars.

  • Simply take more images of cars from different parking places, The current version wont detect cars from different angles and altitudes.

  • Use opencv 2 for image manipulation on a desktop pc. Opencv 2 can use a numpy array as an image and simply has a lot of good functions when it comes to image manipulation compared to Pillow

Why Tflearn

Tflearn makes neural network prototyping a lot faster and easier when compared to pure Tensorflow. 20 lines of code can become 5 lines of code. Tflearn can also be used with Tensorflow and it extends Tensorflow in some small cases which weren't used in this project.

Why not Opencv 2?

Opencv 2 is good choice when the computer has to recognize an image which doesn't have many variations. There are simply too many car types to use opencv 2.
Neural networks can recognize even a untaught version of a car. A pretrained model can also be used to predict an image in 0.05 seconds on raspberry pi, which is quite fast compared to manipulating the image several times to find the contours from an image so that you can use opencv 2 to recognize it.

Tflearn + Opencv 2

Tflearn and opencv 2 can still be used together, opencv is really amazing image manipulation tool and if the object is to recognize moving objects, opencv 2 and tflearn can do this together really well. But if there is no need to manipulate the images heavily, you should probably use Pillow instead of Opencv. Opencv is a really bloated tool and if you are using python 3+ you need to compile it from source code, which on raspberry pi could take up to 4 hours.

Alternatives for tflearn

Deep convolutional generative adversarial network (DCGAN)

The project also has an implementation of DCGAN, which was done in couple of days. The implementation uses a lot of the guidelines found here.
The guidelines have proved themselves to be quite good, except for "LeakyReLU = good (in both G and D)" which broke the whole system. LeakyReLU doesn't seem to be such a good idea in Discriminator, but could work in Generator. But our implementation used normal ReLU as an activation function for convolutional layers.