Bag of words training samples
Asked Answered
M

1

3

I have implemented Bag Of Words, everything is working smoothly. But, I'm confused about some steps and how to implement it.

I could create the bow descriptors as the last step in Bag of words to create the samples, as it shown here bowDE.compute(img, keypoints, bow_descriptor); .. The things is that i'm confused about the next steps.

I know that in BOW that I have to train and test a class (car) with non-class (cola), what I created in bow_descriptor vector is only for the class car, so I have vector for samples that belong only to the car. here are the questions that I have for training my system and test it.

1- Shall I make the vector of bow_descriptor half of it for the class(cola) and the rest for non-class(cola) , or I have to create a new bow_descriptor for the non-class(cola) ?

2- I need to do multi-class classification, after finishing the first system for class (car), and I need to train a new class (Buses+trains and so on), shall I create a new training model for each of them, or it is possible to do the training procedure with the previous training (i.e. training class BUS,train with the class car in the same system)?

Metaplasm answered 25/4, 2013 at 12:34 Comment(0)
F
1

It does not matter whether you create one object for all classes or one object for each class, as long as you use the same dictionary for all classes. Creating only one object might be more economical. But the extracted image descriptors should be the same.

Regarding multiclass SVMs:

You used the SVM tag. So I assume you want to use SVM. There do exist ways to do multiclass classifications explicitly with SVMs it is more common to train several binary SVMs and combine them to get a multiclass results.

You can either use the 1-vs-1 setting, where you train one SVM per class pair. For testing you evaluate your test example on each SVM. The class which wins those duels the most often then becomes your final result.

The other popular approach is 1-vs-all SVMs. Here you train one SVM per class where samples from the current class are labeled positive and all other samples negative. During testing the class with the highest score wins.

So if you want to use the 1-vs-1 setting you might be able to reuse some binary SVMs when you add new classes. It is not possible for the 1-vs-All setting, as you need to add the new class to the negative samples for each SVM.

Fluorite answered 25/4, 2013 at 14:15 Comment(7)
hey @sietschie, so you mean the bow_descriptor can contain all the 4 classes or only 2 classes(pos. and neg.)? the other question, in my SVM how will I train them? to be honest I got a bit confused now? What should I train and what should I test?Metaplasm
Sure. All it does is to count the occurrences of each word in each image. It does not matter whether you do it for all images at once or per class.Fluorite
Usually in classification you split your data in a training and a test set. The training set is used to compute the SVMs. The test set is only used to evaluate the performance of your system. Does this answer your question?Fluorite
@sitchie, Now I got the point how to create the dictionary which is the bow_descriptor (which is for all the images includes the negative of them).. What about the next step, I mean how to train and test, can you guide for specific steps ?Metaplasm
This answer gives a nice overview. Or do you mean specifics on how to use OpenCVs SVM?Fluorite
Thank you so much, but what I meant exactly, now I have collected the histogram for car, bus and train. let's say that I want to classify a new images contain cars and see the percentage for them and then for all them together, how to do these stepsMetaplasm
let us continue this discussion in chatFluorite

© 2022 - 2024 — McMap. All rights reserved.