Object detection with AutoKeras

Written by Richard

AutoKeras

AutoKeras is an open source version of Google Cloud AutoML. I was interested in trying this out to see first of all, how easy is it to use. Secondly, I wanted to know how it measured up to other comparable algorithms.

The installation process on a MacBook was a horrible experience. It took far, far longer than necessary to get it working.

My first mistake was to ‘pip install autokeras’ as described in the autokeras web page. That installed many packages but the application reported errors of missing packages. After several runs getting errors about missing modules, the end result was a mismatch of versions for numpy. Once numpy was upgraded to the correct version, Opencv was downgraded to version 3.4.1 from 3.4.4. At that point, ‘import cv2’ resulted in ‘module cv2 not found’ error.

I downloaded the AutoKeras project from github into my Eclipse workspace. A new Anaconda environment was made with Python 3.6 as indicated by the AutoKeras project. The project itself has a requirements.txt file but it is empty so there was no help there.

It was good that I used an Anaconda environment so I could start over and try again. Being interested in the object detection, I started with the example object detection python file. I would run the application to see what was missing and install the package since PyDev does not seem capable of identifying missing imports in Anaconda environments. Unfortunately, not all packages are available through Anaconda. Some had to be installed using pip. One after the other, as they appeared in the code, the missing packages were installed. When it came to opencv, I checked to make sure ‘import cv2’ worked in a python terminal. Everything seemed to be working well, until I had to install matplotlib. When that got installed, opencv got downgraded to version 3.4.1 and once again, ‘import cv2’ failed.

After much internet searching, I found references to installing opencv using ‘pip install python-opencv’. So, I uninstalled opencv with conda and installed python-opencv using pip. That made ‘import cv2’ work once again but matplotlib failed.

Again after much internet searching, I found a reference to using matplotlib.use(“TkAgg”). That fixed the issue but I didn't want to edit the source code so I used a matplotlibrc file to configure the backend of matplotlib. In my home directory is a .matplotlib folder. In that folder is a matplotlibrc file where I uncommented the backend entry to the following line:

backend      : TkAgg

That got matplotlib to work.

After a few more missing packages, finally the application ran to completion. Here is the result of the first run:

The test person image using AutoKeras

Ok. Fine. There is a person but there is also a dog that was not detected. Perhaps it cannot detect multiple objects. Let’s try another picture.

London traffic with AutoKeras

Well, there are multiple objects detected but a whole bunch of people and bikes were not detected, and a van was detected as both a car and a bus.

Let’s try another:

Street view with AutoKeras

Again, a few objects were detected but many others were not.

So how does this compare with another easy to use object detector like ImageAI? Let's find out.

Here are the detections for these last two pictures using ImageAI:

London traffic with ImageAI
Street view with ImageAI

ImageAI detects far more objects in images than does AutoKeras.

I was disappointed with AutoKeras. Perhaps it is not ready for prime time. I also need to look more at ImageAI. That is the subject for an other blog entry.

--

--

Emerging technologies & challenges

Thoughts about emerging technologies and some of the challenges related to them. The technology itself usually is not the problem (or the solution).