I am working on an online image feature recognition program(BOW histograms) that gets objects in a live cam and extracts the SIFT features. After getting a bunch of pictures, I get the kmeans of the batch and create a global cluster. Next, I repeat the step all over and get more pics to create a new separate batch of clusters. Ideally though, I want to limit the number of clusters that I have and clusters all images at once, but this is impossible since there is an infinite amount of new data coming in. I'm not quite sure how to approach this.

Here is how my code works right now:

1.Image is taken from live video feed, once enough pictures are saved, get kmeans of sift features.(get 200 clusters)

2.Repeat step 1, a new batch of live feed pictures, get kmeans again. Combine the kmeans vectors with the previous kmeans like :[A B],(total 400 clusters)

You can see that this is bad, because I quickly get too much clusters, and each batch of clusters will definitely have overlaps with another batch.

What I want:

1.Image taken from live video feed, once pics are saved, get kmeans(200 clusters)

2.Repeat step 1, get kmeans again, which updates the the previous clusters. (still 200 clusters, but some clusters have been updated or changed)

Nothing that I've seen could accommodate that, unless I'm just not understanding them correctly. many implementations, such as data-streaming, seemingly only allows you to make the cluster in one go. After all the data are streamed, it doesn't seem so easy to update the existing cluster. I would assume though that this should be possible, but none of the code I found seems to back that up. I would appreciate any help on clearing this up.

Thanks!

some updates, I'm starting to look into dirichlet process. Here is something that looks like it could work: http://www.cc.gatech.edu/~jeisenst/software.html#dpmm

but what's the advantage of kmeans over this however? since kmeans seems to be a de facto standard in the BOW methodology.

asked Aug 17 '12 at 00:52

mugetsu's gravatar image

mugetsu
233212431

edited Aug 17 '12 at 12:05


2 Answers:

I think you want an algorithm that looks roughly like this:

var globalMeans = new List[Vector]()
val threshold = ...
// For each batch of images you want to cluster, iterate.
for (dataset <- gather_batch_of_pictures()) {
    // Run K-Means on that batch with however many clusters you want.
    val means = kmeans(dataset, k=200)
    // For each local mean found, try to associate it with a global mean.
    for (localMean <- means) {
        // Find the closest global mean.
        var bestGlobalMean = null
        var bestGlobalSim = 0
        for (globalMean <- globalMeans) {
            val sim = similarity(globalMean, localMean)
            if (sim > bestGlobalSim) {
                 bestGlobalSim = sim
                 bestGlobalMean = globalMean
            }
        }
        // If the nearest global mean is too dissimilar, add the local mean as a new global mean
        if (bestGlobalSim < threshold)
            globalMeans += localMean
        // Otherwise add the local mean to the nearest global mean.
        else
            bestGlobalMean += localMean
    }
}

This let's you use any batch algorithm you want for the small batches you're gathering and then try to associate the local means found for the batch with global means. The global means will be created on the fly as they are needed. So at first there will be no global means and likely (if k-means did it's job right) all the local means for the first batch become global means. For the second batch, there'll likely be some clusters with local means that existed in the previous dataset. So you'll compare each local mean to existing global means, find the most similar one, and combine the local mean into that best global mean as long as their similarity is above some threshold. Setting the threshold is the hard part. You'll likely have to play around a bit to find one that works well. But with a good threshold, this will much better than just concatenating the list of local means together and over time you should see fewer and fewer global means be added as long as your dataset new distributions of features aren't dynamically being added to the dataset.

answered Aug 17 '12 at 03:16

Keith%20Stevens's gravatar image

Keith Stevens
62161327

I actually am doing something somewhat similar right now. Instead of a straight concat, I use vl_ubcmatch to get squared euclidean dist between each local means with the global means. Given a set threshold, similar clusters are simply removed. It does help a little but I still get pretty huge vocab after a few hundred images. Maybe your method will work a little better, but I would really rather the clusters rearrange themselves instead of being forced together by similarity. I think that would be more robust.

(Aug 17 '12 at 11:58) mugetsu

Some solutions come to mind:

  1. You could just initialize the second run (or third, or etc) of the K-Means with the most recent K-Means batch you have in memory, that way you force the new SIFT features to fit in the existen clusters.
  2. If you are expecting new instance or clusters being formed as you get data, you could use Dirichlet Processes instead of K-Means, with Dirichlet Processes, as you get more data, you get to create new clusters if needed.
  3. Instead of using a batch approach of K-Means, use an online approach, that is, train the clusters little by little as you get new data. There must be some papers on online K-means.
  4. You could look into Self Organizing Maps, which also create clusters on the go, but are kinda shady and unreliable.

answered Aug 17 '12 at 02:20

Leon%20Palafox's gravatar image

Leon Palafox ♦
40857194128

I can't go with 1, since i expect some clusters to be merged and new clusters form. That means that only 2 and 3 are viable. The problem that I've had with online k-means is that I have really had a hard time finding anything about it. Would online k-means work better than Dirichlet process?

(Aug 17 '12 at 11:52) mugetsu

I've always been confused by the terminologies online/sequential/incremental/streaming kmeans that gets thrown around. Would online kmeans be something as described here ?

(Aug 17 '12 at 12:02) mugetsu
Your answer
toggle preview

powered by OSQA

User submitted content is under Creative Commons: Attribution - Share Alike; Other things copyright (C) 2010, MetaOptimize LLC.