🧔 Hello World

My name is Emil. I am a programmer, passionate by coding, music, video and photography

Install Object Detection in 5 minutes on Ubuntu 18.10

Nowadays Image Recognition became a realy easy task, thanks to some Open Source Libraries like YoloV3 or TensorFlow. In five minutes it is possible to install and use such a library, if your project requires it as feature.

I recently tested YoloV2, YoloV3 and TensorFlow on Ubuntu 18.10, both ideal for classifying images and must say, both are working out of the box, without any special installation requirements and are enough fast even without GPU power.


Yolo Installation


For Yolo Installation is required to clone the git repo and to compile it after.



# Install Yolo Package

git clone https://github.com/pjreddie/darknet.git
cd darknet
make

# Download weights files
wget https://pjreddie.com/media/files/yolov3.weights
wget https://pjreddie.com/media/files/yolo.weights
wget https://pjreddie.com/media/files/yolov2.weights
wget https://pjreddie.com/media/files/yolo-tiny.weights


# Run script Using A Pre-Trained Model
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg -out prediction
./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/dog.jpg

The gist file:
https://gist.github.com/maranemil/0886b01126130fcd3a41870e9cd10e9e



Tensorflow Installation


For Tensorflow, before starting the clone part, be sure that you have php or pip3 installed.




# Install Dependency Packages

sudo apt install python3-pip -y
pip3 install tensorflow
pip3 install numpy
pip3 install pandas

# Clone Models Repo
git clone https://github.com/tensorflow/models

# Run script
cd models/tutorials/image/imagenet


The gist file:
https://gist.github.com/maranemil/8eccb0d85b962e6e3e0f7f0f078f3611


Conclusion:



Performance is strong related with the size of input. If you use big pictures than it will take longer for the detection process. My recommnedation is to batch all pictures to a low resolution, something like 320x240 or something similar, if the amount of pictures is really huge. For a 1280x720 image it would take 15 seconds with Yolo2 to detect objects on Intel i5 460M Processor with 4 threads. Probably on GPU works faster.

The pre-trained models are good for general purpose, Tensorflow models are better than Yolo models, but for fun you can use both of them and combine the results of both in a word matrix. If you need somethings special to detect, than you have to train your own model for that.




Resources:

TensorFlow (C++, Python)
https://www.tensorflow.org/tutorials/image_recognition
https://github.com/tensorflow
https://github.com/tensorflow/models


YoloV3 (C and CUDA)
https://pjreddie.com/darknet/yolo/
https://github.com/pjreddie/darknet/