models icon indicating copy to clipboard operation
models copied to clipboard

Multi-Task Object Detection (Faster R-CNN)

Open oneTimePad opened this issue 8 years ago • 9 comments

I know this is not in the Faster R-CNN paper, but I was wondering if there was any interest in adding multi-task learning for Faster R-CNN, or R-FCN. This would allow a groundtruth to have multiple attributes for R-CNN to classify. This could be done by having multiple second stage classification networks with separate Softmax layers that would each learn to classify a different attribute for an object (i.e. you could find an animal in a picture, classify it as a cat, that is black).

Is there any interest in adding this feature? I have heard of it being done before, but not with Faster R-CNN. Although, the meta-architecture does already use Multi-Task learning.

I would assume that only one of the multi-task classes would contain the background class.

oneTimePad avatar Dec 31 '17 03:12 oneTimePad

@jch1 @tombstone @derekjchow @jesu9 @dreamdragon @afathi3, if any of you have a reaction or suggestions, they would be very helpful. Or even whether we should mark this feature request as "contributions welcome."

cy89 avatar Jan 09 '18 00:01 cy89

Just an update on this. I was able to get the Multi-Task feature working with SSD. However, there appears to be an issue with localization when one of the characteristics of the object of interest is embedded in the whole object. For example, if the two characteristics are animal and eye-color, the bounding box should be around the whole animal and not the animal's eyes. However, I have seen the bounding box regressor tighten the box as to miss the whole object and start creating the bounding box around the characteristic inside the whole object (the eyes), or a bounding box that is too small to fit the whole object of interest.

I could see this possibly being mitigated by training the classifier not associated with the bounding box regressor (i.e. the eyes in this example) separately from the animal classifier and bounding box regressor (in the example above).

Hopefully this makes sense, and I was wondering if anyone else has other suggestions on how to deal with this issue.

oneTimePad avatar Feb 09 '18 06:02 oneTimePad

@oneTimePad, I'm working on the similar thing with SSD. If you don't mind, could you please share your code? I also have similar issue since I'm trying to classify one "Entire" thing (i.e, a place like a room, playground, etc) given a whole image and one "Small" things (i,e, like a table, a cup, etc). I think the your suggestion makes sense. Do you have any update on this?

leejang avatar Mar 05 '18 18:03 leejang

@leejang Yes, I tried to train just the classifier not associated with the bounding boxes. I froze the feature extractor, and box predictor (localization and class associated with bounding boxes). It got the loss down to around 4~5 from 20. Whereas training altogether drops the loss to about .8, but as mentioned the localization accuracy is affected, even though the loss is low. I also added more conv layers before this classifier. However, it still struggled to get the loss down more. This was after training for around 12 hours. The number of classes was 26.

Here is a link to the code. Feel free to contribute! Not sure what else to do to fix this issue at the moment https://github.com/RUAIAA/models/tree/multi-ssd Let me know if you have any issues running it.

oneTimePad avatar Mar 05 '18 18:03 oneTimePad

@oneTimePad Great! Thank you so much for letting me know this update. I will share with you once I get some good news to fix the issue :)

leejang avatar Mar 05 '18 18:03 leejang

@oneTimePad, I just want to let you know small update on this. (sorry for this slow response). In my case, I was able to add one more task (a classification given a whole image) to the original object detection case, and there was no problem. I think my case is relatively easier than yours, since it is just adding classification task to the original task, so it does not affect the performance of object detector. I think your second task might still be related bounding boxes. For example, to classify the color (i.e, black) of the target object (i.e, a cat), I think that you still need bounding boxes. I think if your second task is not about the same object, but a small part of the object (i.e, eyes of cat), then it can cause the problem, but I'm not sure..

leejang avatar Mar 31 '18 22:03 leejang

Dear All, Thanks for your help!

I am also trying to add multi task to SSD. I am currently using https://github.com/balancap/SSD-Tensorflow

But I also tried object detection api here. I want to post here not only to share a possible task to add to SSD but also to get maybe some guidance or suggestions.

What I am doing is try use SSD to specifically detect face. Then also predict facial attributes.

Face detection is relatively easy to do. Mostly changing the training set to WIDERFace seemed good.

Then I want to predict a face's pitch. As a first attempt, I try use classification to get facial attribute:

if esti_pitch == 'down_10_5' : return 1 elif esti_pitch == 'down_15_10' : return 2 elif esti_pitch == 'down_20_15' : return 3 elif esti_pitch == 'down_25_20' : return 4 elif esti_pitch == 'down_30_25' : return 5 elif esti_pitch == 'down_5_0' : return 6 elif esti_pitch == 'down_over_30' : return 7 elif esti_pitch == 'up_0_5' : return 8 elif esti_pitch == 'up_10_15' : return 9 elif esti_pitch == 'up_15_20' : return 10 elif esti_pitch == 'up_20_25' : return 11 elif esti_pitch == 'up_25_30' : return 12 elif esti_pitch == 'up_5_10' : return 13 elif esti_pitch == 'up_over_30' : return 14 elif esti_pitch == 'NA' : return 15 else : return -999

However, I found that compared to classifying face-nonface, classifying 15 classes of faces degrades the detection accuracy. Some faces cannot be detected in my 15-classes-of-face model.

That's why I am trying another way. Tensorflow's object detection api seemed to have more layers of abstraction, so I chose to experiment with Balancap's implementation of SSD.

Right now I am trying to add a pitch estimation to ssd_multibox_layer.

https://github.com/balancap/SSD-Tensorflow/blob/master/nets/ssd_vgg_300.py def ssd_multibox_layer(inputs

This step seemed easy. Location prediction comes from convolute feature. At the same place, I made another convolution to get pitch.

And then comes the harder part I stuck with now:

Try to link ground truth pitch with the pitch prediction I just added. To do so, I have to modify tf_ssd_bboxes_encode_layer which determine the label corresponding to anchors.

BR, JimmyYS

speculaas avatar Nov 20 '18 06:11 speculaas

This issue has been robustly discussed and addressed. Thank you @leejang & @speculaas

msymp avatar Jan 05 '19 01:01 msymp

Hello, as a follow up, is there a way to do a combination of different classification heads using the current repository's Faster-RCNN meta-architecture(multi-task learning) ?

sp-ananth avatar Oct 23 '19 00:10 sp-ananth