How to do object detection using CNN's features in tensorflow? - python

I am trying to make an end to end unified model that detects(localizes) the object in an image. The object itself can be of many types, like "text in the wild", but the surrounding features of the object should determine where the region of interest is.
Like detecting a human face, without considering the features of the face itself. i.e its some rage distance about the neck.
I'm expecting the output to be coordinates of the object, or like the image-net format to generate bounding boxes like : [xmin , ymin , xmax, ymax]
I have a data-set of 500 images. Are there any examples of object detection in tensorflow based on surrounding features. i.e the feature maps from conv1 or conv2. ?

There is Tensorflow based framework for object detection/localization that you can check out:
https://github.com/Russell91/TensorBox
Though, I am not sure that 500 images would be enough to successfully retrain provided model(s).

Object detection using deep learning is broadly classified in to one-stage detectors (Yolo,SSD) and two stage detectors like Faster RCNN. Google's repo[1] contains pre-trained models for various detection architectures.
You could pick up a pre-trained model and then train it on your dataset. The two-stage model is modular and you have a choice of different feature extractors depending on whether speed/accuracy is crucial for you.
[1] Google's object detection repository

Related

Object Detection - Mask RCNN

I have a project in which I need firstly to detect if the image is fake or not and if it is fake to detect the object. For the first part, I am using ELA and CNN in order to detect if the image is forged or not, but for the object detection I need to use Mask R-CNN, but unfortunately I have a problem understanding how to use it. I am using the CASIA v2 dataset and I have the ground truth masks for all the forged images.
I saw that every model online is using the model COCO for the mask RCNN, but I need the model to be trained on my dataset. Also, I saw that I need a list of labels, but for my project I only need to display fake on the detected object, is it alright if in the label.txt I will only write "Fake"?
Also, I am a little bit new to Deep Learning, so any help is useful.

Can I use DeepSORT without deep learning detection such as YOLO?

I am new to computer vision, and I still didn't try any kind of neural network detections such as yolo, however, I am wishing to do object tracking before entering the field of detection. I started reading about deep sort and all the projects use deep learning detections that needs training. My question is, can I give an ROI result to my deep SORT tracker instead of detections using YOLO and it continues tracking the object selected with ROI.
Here is a link that i found information about the code of DeepSORT.DeepSORT: Deep Learning to Track Custom Objects in a Video
In DeepSORT, you need to have detection in order to perform tracking. It is a tracking-by-detection method. The detection results are input to the Kalman filter component of DeepSORT. The filter generates tracking predictions. Also, the bounding boxes from detection are used to extract crops of RoI from the input image. These image crops are used by the trained Siamese model for feature extraction. The feature extraction by the Siamese model helps in reducing ID Switch.
If you are only interested in doing tracking and ID switch in case of occlusion is not your concern then you can have look at CenterTrack. It does joint detection and tracking in a single model. In this case, you can avoid model training from scratch. The authors provide pre-trained models for tracking both pedestrians and vehicles. As compared to DeepSORT the CenterTrack is pretty fast. 
[Sorry for the late reply] I think you should try Siamese Network for tracking by selecting the ROI region. You can find many variants in this given link.
https://github.com/HonglinChu/SiamTrackers.

How to train Tensorflow Object Detection images that do not contain objects?

I am training an object detection network using Tensorflow's object detection,
https://github.com/tensorflow/models/tree/master/research/object_detection
I can successfully train a network based on my own images and labels.
However, I have a large dataset of images that do not contain any of my labeled objects, and I want to be able to train the network to not detect anything in these images.
From what I understand with Tensorflow object detection, I need to give it a set of images and corresponding XML files that box and label the objects in the image. The scripts convert the XML to CSV and then to another format for the training, and do not allow XML files that have no objects.
How to give an image and XML files that have no objects?
Or, how does the network learn what is not an object?
For example if you want to detect "hot dogs" you can train it with a set of images with hot dogs. But how to train it what is not a hot dog?
An Object Detection CNN can learn what is not an object, simply by letting it see examples of images without any labels.
There are two main architecture types:
two-stages, with first stage object/region proposal (RPN), and second - classification and bounding box fine-tuning;
one-stage, which directly classifies and regresses BB based on the feature vector corresponding to a certain cell in the feature map.
In any case, there's a part which is responsible to decide what is an object and what's not. In RPN you have "objectness" score, and in one-stages there's the confidence of classification, where you usually a background class (i.e. everything which is not the supported classes).
So in both cases, in case a specific example in an image doesn't have any supported class, you teach the CNN to decrease the objectness score or increase the background confidence correspondingly.
You might want to take a look at this solution.
For for the tensorflow object detection API to include your negative examples, you need to add the negative examples to the csv file you have created from the xml, either by modifying the script that generates the csv file or by adding the examples afterwards.
For generating xml-files without class labels using LabelImg, you can do this by pressing "Verify Image".

Does inception model label multiple object in one image?

I used retrain.py to train tensorflow with my own dataset of traffic sign but it seems it doesn't capture multi-object in one image.I am using the label_image.py to detect the object in my image. I have an image of two road sign which exists in my dataset but i get only one sign with high accuracy. It doesn't detect other sign.
You have misunderstood what a classification CNN does. Inception is built and trained to classify an image. Not objects in an image. For this reason you will only get a single result from label_image.py as it is using softmax to generate a confidence that an image is of a certain class.
It does not identify individual objects as I explained to you on another question here: Save Image of Detected object from image using Tensor-flow
If you are trying to detect multiple signs then you will need to use object detection models.

How to create bounding boxes around the ROIs using TensorFlow

I'm using inception v3 and tensorflow to identify some objects within the image.
However, it just create a list of possible objects and I need it to inform their position in the image.
I'm following the flowers tutorial: https://www.tensorflow.org/versions/r0.9/how_tos/image_retraining/index.html
bazel-bin/tensorflow/examples/image_retraining/retrain --image_dir
~/flower_photos
Inception is a classification network, not a localization network.
You need another architecture to predict the bounding boxes, like R-CNN and its newer (and faster) variants (Fast R-CNN, Faster R-CNN).
Optionally, if you want to use inception and you have a train set annotated with class and bounding box coordinates, you can add a regression head to inception, and make the network learn to regress the bounding box coordinates.
It's the same thing of transfer learning, but you just use the last convolutional layer output as a feature extractor, and train this new head to regress 4 coordinates + 1 class for every bounding box in your training set.
By default inception does not output coordinates. There are specific tools for that like Faster R-CNN available for Caffe.
If you want to stick with tensorflow, you can retrain the inception to output the coordinates if you have the human annotated images.
Putting bounding boxes around objects is usually called detection in the lingo of the field, and there is a whole category of networks designed for it. There's a separate category in the PASCAL VOC competition for detection, and that's a good place to find good detection networks
My favorite detection network (which is the currently leader for the 2012 PASCAL VOC dataset) is YOLO, which starts with a typical classifier, but then has some extra layers to support bounding boxes. Instead of just returning a class, it produces downsampled version of the original image, where each pixel has its own class. Then it has a regression layer that predicts the exact position and size of the bounding boxes. You can start with a pre-trained classifier, and then modify it into a YOLO network and retrain it. The procedure is described in the the original paper about YOLO
I like YOLO because it has a simple structure, compared to other detection networks, it allows you to use transfer learning from classification networks (which makes it easier to train), and the detection speed is very fast. It was actually developed for real-time detection in video.
There is an implementation of YOLO in TensorFlow, if you would like to avoid using the custom darknet framework used by the authors of YOLO.

Categories