Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shape Detection - TensorFlow

I'm trying to train a model to detect the basic shapes like Circle, Square, Rectangle, etc. using Tensorflow. What would be the best input data set? To load the shapes directly or to find the edge of the image using OpenCV and load only the edge image.

We can detect shapes using OpenCV too. What would be the added advantage to use Machine Learning.

Sample images given for training the model.

Circle Detected using OpenCV Square detection

like image 911
OpenCV User Avatar asked Jun 19 '17 05:06

OpenCV User


People also ask

Is TensorFlow good for object detection?

Object Detection using Tensorflow is a computer vision technique. As the name suggests, it helps us in detecting, locating, and tracing an object from an image or a video.

Which is better Yolo or TensorFlow?

Obviously the OpenCV & Tensorlfow/Keras methods allow for far more in-depth customisation, but if you are looking for a quick and easy, and relatively simple adaptation of an object detection/recognition, then yolo will get you there faster.


2 Answers

You may want to checkout objective detection in tensorflow. https://github.com/tensorflow/models/tree/master/research/object_detection There is a pre-trained model here http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_11_06_2017.tar.gz

One potential advantage of using neural nets to do the detection is that it can reduce the cpu cycles to calculate. This is useful on mobile devices. For example - the Hough transform https://en.wikipedia.org/wiki/Hough_transform is too expensive to calculate / but if a convolutional neural net was used instead - more possibilities open up for real time image processing.

To actually train a new model - see here https://www.tensorflow.org/tutorials/deep_cnn

like image 183
johndpope Avatar answered Oct 01 '22 00:10

johndpope


I would recommend starting with this guide for doing classification, not object detection: https://kiosk-dot-codelabs-site.appspot.com/codelabs/tensorflow-for-poets/#0

Classification is for one unique tag for one picture (99% square, 1%circle). Object Detection is for classification of several objects within the picture (x_min=3,y_min=8,x_max=20,y_max30, 99% square). Your case looks more like a classification problem.

You don't need the full Docker installation as in the guide. If you have Python 3.6 on your system, you can just do:

pip install tensorflow

And then jump to "4. Retrieving the images"

I had to try it out myself, so I downloaded the first 100 pictures of squares and circles from Google with the add-on "fatkun batch download image" from Chrome Web Store.

On my first 10 tests I get accuracy between 92,0% (0.992..) and 99,58%. If your examples are more uniform than a lot of different pictures from Google, you will probably get better results.

like image 23
Punnerud Avatar answered Sep 30 '22 23:09

Punnerud