Add support for multiple labels to be specified in the image_data_layer#3653
Add support for multiple labels to be specified in the image_data_layer#3653elezar wants to merge 3 commits intoBVLC:masterfrom
Conversation
3c3ff57 to
5dfbc9e
Compare
|
This is exactly what I need. Have you test it on PASCAL VOC dataset? |
|
I have, and have been working on a simple tutorial. I will push it soon. |
0afa9a5 to
3cef9db
Compare
|
@shenyunhang Please see the latest push. I have included an example that uses the PASCAL VOC dataset with the multi-label image data layer. The example can be run as both an iPython notebook, from the script. The format of the iPython notebook is "borrowed" from @beijbom's PR #3471 (I will update it further once that PR has been accepted and merged). |
|
@elezar Thank you very much. I am trying on it. filename ;ignore1 ignore2 Here I can't make sure what labels are associated with the data line. |
|
@shenyunhang I will look at adding a unit test for your example you tomorrow. There should not be a specific reason that this does not work, but I may have missed something in the implementation. You are also welcome to submit a pull request to the feature branch at zalando/caffe is you get it working before then. |
|
@shenyunhang were you able to get the layer working for you? If so, do you mind sharing your changes with me? |
cfdddeb to
4c4f3f0
Compare
|
@shenyunhang I have updated the image data layer to support ignore labels when no labels have been specified. |
…data_layer. This adds support for lines in the image_data_layer with the following format: filename label1 label2 label3;ignore1 ignore2 Here multiple labels (label 1, 2, and 3) are associated with the data line and labels to ignore (e.g. not take into account when calculating loss or accuracy) can also be specified. The separator for the two label lists can be specified by the user, as can the separator for the individual labels. By default, labels to be ignored are assigned a value of -1, but this can be specified. The SigmoidCrossEntropy layer has also been changed to allow for a particular label to be ignored when calculating the loss, or back propagating the diff. A PASCAL VOC2012 Example has been included to show the use of the code.
b31cb70 to
02868e1
Compare
|
@beijbom Since you worked on the Python implementation of the example, would you mind looking at notebook that I have included in this PR? @shelhamer This also contains a prototxt version of the network which could be used to address some of the TODOs mentioned in #3471 (comment) |
|
hey @elezar , I think the notebook could use some more explanation & comments, but it's getting there! :). It will be very useful to have multi-label support in the image data-layer, as this is a very common user-case, and the python data-layers are slow for production stuff. cheers |
|
@beijbom Thanks. I have tried to improve the notebook (once again using your notebook as reference) and pushed the changes. |
|
@shelhamer could you perhaps have a look at this PR and let me know what work is still required? |
|
@elezar |
|
Closing this PR as stale. |
Although there are a number of pull requests pending where mulit-label support has been discussed, many of them seem to have been abandoned.
For reference for example: #523 #3268
The latter may still be active (last updated in December 2015), but they also deal with the loss or accuracy layers, and not with the data layers themselves.
This pull requests adds the ability to specify multiple labels in a text file directly e.g.:
instead of having to maintain separate labels and data sets.
It is also possible to specify a list of labels to ignore following the labels per item:
Ignoring a label equates to setting the entries in the label top blob to some predefined value (
-1). In the same way that multiple labels could be specified, multiple ignore labels could also be specified as a list. Here a semi-colon (;) has been chosen as the label and ignore list separator.The following points should be noted:
(N,1)dimensional blob, with the entries equal to the label of the image.(N, K)dimensional blob, withK=max_label + 1. In this case the entries in the blob are zero if the label is not present in the line, or 1 if this is the case.max_labelis determined when reading the file for the first time.Some extensions that I would like to add:
I would also like to look at adapting #3471 to use the new data layer.
Thoughts and comments would be welcome.
Note, I had to add
std::endloutputs to the unit tests. I assume that this makes more sense in any case.