How to extract multiple categories per image?


I’ve just finished the first class and I’d like to know if there is a way to use vgg16 to extract multiple categories from an image. Is it called keyword extraction?

How should be my training directory? Should I copy the images to multiple folders (one folder per tag)?


I think you’re referring to multi-label classification? The output would use Sigmoid and select all categories with a probability score above some fixed threshold.

In that case, the one-directory-per-class approach will break down. You will need to have all image files in the same directory and use some alternative lookup scheme, perhaps with a CSV file:

Here is an example with categories delimited by spaces:

image_id, categories
1, forest water road
2, water
3, habitation road

This design was used in the recent planet competition and you should be able to find sample Keras code for loading this files:

If you’re open to using Pytorch, here is an example we wrote while working on the competition

It uses something called a FileDataset which simply takes a list of file paths and a target (one-hot encoded) numpy array.


Thank you! Learning a lot from you!