How to obtain the weights for SVM in OpenCV 2.4.6 for Python 2.7.5?
I need this to calculate the primal form of my cv2.SVM() to feed it to a cv2.HOGDescriptor().setSVMDetector.
Found this and this SOF useful, but it seems like SVM.decision_func is protected and I cannot access this variable to obtain the weights.
Are there any other ways to do this in Python+OpenCV?
You can use Save method to save SVM to hard drive.
If you need only weights then I think you need to modify code or look closer at format in which opencv svm saved.
here some info
OpenCv SVM output file format
Related
I learn object detection on windows 10 with tensorflow object detection.
I download ssd_mobilenet_v1_coco_2018_01_28.tar.gz from https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
After I unzipped the ssd_mobilenet_v1_coco_2018_01_28.tar.gz file, I didn't find the pbtxt file.
Where can I find the related pbtxt file of ssd_mobilenet_v1_coco?
I know that there some pbtxt files in models-master\research\object_detection\data folder, but which file is related to ssd_mobilenet_v1_coco?
The label map is not specific to an architecture, but rather to a dataset (which classes you support, and accordingly you should set the number of channels of the classification layer).
Therefore, you simply need the label map which corresponds to coco, which is object_detection/data/mscoco_label_map.pbtxt.
Dataset is implemented in the model. Model is delivered by tar.gz or .zip. If you use pretrained basic model, then label map can be found code tree githup object_detection/data/mscoco_label_map.pbtxt as netanel-sam explains.
But if you start to train your pretrained model and add items to be detected to your dataset and start to deliver your modified model, then your must offer your label map also and there is no better way than include it to the .tar.gz or .zip. Same situation is with lite-model, because conversion from trainable model to lite often loses items from dataset. Lite-model uses also other format to labelmap than basic model. Confusing?
Does anyone know if I am able to open a pickled sklearn Python algorithm in R? Or if I can save a trained model in sklearn in a different way that can be opened and used in R? Specifically, I am looking at a gradient boosting model. Thanks!
I don't recommend doing what you are doing. It's a lot of extra work that you don't need.
However, in case you find yourself obliged to do that, I would think of saving my model in the binary format. This your best option.
This is possible for Xgboost see link here.
Read this answer on how to save xgboost as a binary file: link
You may want to take a look at the Reticulate package, it will allow you to call python code from R.
https://rstudio.github.io/reticulate/
I have once created and trained a GeneralizedLinearModel in Matlab, then saved it to my drive. Regularly I load this model in Matlab and use the '.predict' on some data. Now I would like to load the saved model (with its specific coefficients) into Python and run the'.predic' the same as in Matlab.
Does anyone know how to do that or alternatively how to implement the prediction given the coefficients?
I'm having trouble figuring out how to use a support vector machine trained on Weka for real time processing with python.
For example when you train a back propagation algorithm on Matlab, you can extract the weights and biases and use them to replicate the network on other programs (e.g python) in feed-forward.
Thanks for your suggestions.
Assuming you want to continue using Python and Weka, the easiest way is to just call the Weka command line using subprocess (see https://docs.python.org/2/library/subprocess.html). You can then train and save your models and use them as needed. See this reference: https://weka.wikispaces.com/Saving+and+loading+models
In matlab I have this function
function psi = encodeImage(encoder, im)
This function takes
im which is list of names of images
encoder which is bovw.mat I have this file as encoder
This function does bag of visual words encoding and returns the spatial histograms of images.
I use this histograms for training in SVM classifier.
I am doing this task in python and I don't want to implement the bag of visual words encoding as my main task is to implement SVM. Is there a built in function in python that does bag of visual words encoding and returns spatial histograms so I can train SVM classifier on histograms.
Are you doing something similar to this?
http://www.robots.ox.ac.uk/~vgg/practicals/category-recognition/index.html
There is a computer vision library called Vlfeat. It's Matlab version is in active development state. However there exists a Python interface as well.
Supports all major image processing features:
Scale-Invariant Feature Transform (SIFT)
Dense SIFT (DSIFT)
Integer k-means (IKM)
Hierarchical Integer k-means (HIKM)
Maximally Stable Extremal Regions (MSER)
Quick shift image segmentation
I am not sure whether Pyvlfeat will be sufficient or not. In fact, I was trying to do the same. Couldn't figure out. If it works, awesome, mention the trick in comment. If you have figured out some other method, please mention that too.