Getting the Gaussian model weight - c++

I am wondering how to get single model weight from several Gaussian mixture models in OpenCV. For
For instance, if the number of models is five for GMM I want to get the weight of the second or third model.
Could someone help me on this? Another saying, I want to know which model is the mostly used one among these five?

Related

Comparison of Two 3D Models to Determine Orientation Difference

I am working on a project where I am trying to compare a 3D reconstructed model with a predefined 3D model of the same object to find the orientation shift between them. An example of these types of models can be seen here: example models.
I was thinking about maybe trying to use Kabsch's algorithm to compare them but I'm not completely sure that will work because they don't have the same number of vertices and I'm not sure if there's a good way to make that happen. Also, I don't know the correspondence information - which point in set 1 represents which point in set 2.
Regardless, I have the model's PLY files which contains the coordinates of each vertex so I'm looking for some way to compare them that will match up the different features in each object together. Here is a GitHub repo with both PLY files just in case that would be useful.
Thanks in advance for any help, I've been struck trying to figure out this problem for a while!

when does model diverged? and what is the next step

I'm using the detectron2 with cascade rcnn.
I'm predicting 4 different classes. and dataset with around 6000 object boxes with training.
I used resnet 50 for backbone and got around 80 accuracy.
then I try it with resnet 101 back bone and it diverged with first iteration.
1. small dataset and big model easily diverged at the first iteration?
2. what heppen to small dataset and big back bone
3. And for my case augmentation + resnet50 backbone decrease the result why?
4. How should I fix this diverged problem?(what is the step next)
As we can see in the detectron2 model zoo for Cascade R-CNN, their pre-trained models only use ResNet50 as backbone (config 1 and config 2).
So the most likely reason your model diverges is that most of the parameters will need to be trained from scratch (which is much more difficult and will require more data) as there is no pre-trained ResNet101.
Please also note that using a larger model increases the risk of overfitting.

How to calculate the distance between two GMMs in OpenCV?

I am training two GMMs in OpenCV, each with 4 components. One GMM is trained using all points from the foreground of an image and another is trained using all points in the background. I want to find out how close are the two GMMs to each other in order to get an idea on how close are the background colours to the foreground colours.
Any ideas on how I can go about this problem? The popular distance measures I see (KL, Mahalanobis etc.) are for single variable normal distributions. How can I extend this to GMMs trained on RGB values of each pixel?
Because gaussian mixture model consists of a set of weighted gaussians, you can find distance between centers of nearest gaussuans of two models. But this is not absolutely correct approach, because of probabilistic nature of model. It'll be much better to look at probabilities of both models for given value.

What is class_weight parameter does in scikit-learn SGD

I am a frequent user of scikit-learn, I want some insights about the “class_ weight ” parameter with SGD.
I was able to figure out till the function call
plain_sgd(coef, intercept, est.loss_function,
penalty_type, alpha, C, est.l1_ratio,
dataset, n_iter, int(est.fit_intercept),
int(est.verbose), int(est.shuffle), est.random_state,
pos_weight, neg_weight,
learning_rate_type, est.eta0,
est.power_t, est.t_, intercept_decay)
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/linear_model/stochastic_gradient.py
After this it goes to sgd_fast and I am not very good with cpython. Can you give some celerity on these questions.
I am having a class biased in the dev set where positive class is somewhere 15k and negative class is 36k. does the class_weight will resolve this problem. Or doing undersampling will be a better idea. I am getting better numbers but it’s hard to explain.
If yes then how it actually does it. I mean is it applied on the features penalization or is it a weight to the optimization function. How I can explain this to layman ?
class_weight can indeed help increasing the ROC AUC or f1-score of a classification model trained on imbalanced data.
You can try class_weight="auto" to select weights that are inversely proportional to class frequencies. You can also try to pass your own weights has a python dictionary with class label as keys and weights as values.
Tuning the weights can be achieved via grid search with cross-validation.
Internally this is done by deriving sample_weight from the class_weight (depending on the class label of each sample). Sample weights are then used to scale the contribution of individual samples to the loss function used to trained the linear classification model with Stochastic Gradient Descent.
The feature penalization is controlled independently via the penalty and alpha hyperparameters. sample_weight / class_weight have no impact on it.

Object Detection: Training Requried or No Training Required?

This question is related to Object detection, and basically, detecting any "known" object. For an example, imagine I have the below objects.
Table
Bottle.
Camera
Car
I will take 4 photos from all of these individual object. One from left, another from right, and other 2 from up and down. I originally thought it is possible to recognize these objects with these 4 photos per each, because you have the photos in all 4 angles, no matter how you see the object you can detect it.
But I got confused with someones idea about training the engine with thousands of positive and negative images from each object. I really don't think this is required.
So simply speaking, my question is, in order to identify an object, do I need these thousands of positive and negative objects? Or else simply 4 photos from 4 angles is enough?
I am expecting to use OpenCV for this.
Update
Actually the main thing is something like this.. Imagine that I have 2 laptops. One is Dell and the other one is HP. Both are laptops but you know, they have clearly visible differences including the Logo. Can we do this using Feature Description? If not, how "hard" the "training" process? How many pics needed?
Update 2
I need to detect "specific" objects. Not all the cars, all the bottles etc. For an example, the "Maruti Car Model 123" and "Ferrari Car Model 234" are both cars but different. Imagine I have the pictures of Maruti and Ferrari of above mentioned models, then I need to detect them. I don't have to worry about other cars or vehicles, or even other models of Maruti and Ferrari. But the above mentioned "Maruti Car Model 123" should be identified as "Maruti Car Model 123" and above mentioned "Ferrari Car Model 234"should be identified as "Ferrari Car Model 234". How many pictures do I need for this?
Answers:
If you want to detect a specific object and you don't need to account for view point changes, you can use 2D features:
http://docs.opencv.org/doc/tutorials/features2d/feature_homography/feature_homography.html
To distinguish between 2 logos, you'll probably need to build a detector for each logo which will be trained on a set of images. For example, you can train a Haar cascade classifier.
To distinguish between different models of cars, you'll probably need to train a classifier using training images of each car. However, I encountered an application which does that using a nearest neighbor approach - it just extracts features from the given test image and compares it to a know set of images of difference car models.
Also, I can recommend some approaches and packages if you'll explain more on the application.
To answer the question you asked in the title, if you want to be able to determine what the object in the picture is you need a supervised algorithm (a.k.a. trained). Otherwise you would be able to determine, in some cases, the edges or the presence of an object, but not what kind of an object it is. In order to tell what the object is you need a labelled training set.
Regarding the contents of the question, the number of possible angles in a picture of an object is infinite. If you just have four pictures in your training set, the test example could be taken in an angle that falls halfway between training example A and training example B, making it hard to recognize for your algorithm. The larger the training set the higher the probability of recognizing the object. Be careful: you never reach the absolute certainty that your algorithm will recognize the object. It just becomes more likely.