Git Product home page Git Product logo

bag-of-words's People

Contributors

bikz05 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bag-of-words's Issues

'LinearSVC' object has no attribute 'classes_'

I get this error when trying to run getClass.py with the args -t dataset/test --visualize.
I think this is an issue with LinearSVC and not my end, but I wanted to make sure.

predictions = [classes_names[i] for i in clf.predict(test_features)] File "C:\Python27\lib\site-packages\sklearn\linear_model\base.py", line 228, in predict return self._classes_[indices] AttributeError: 'LinearSVC' object has no attribute 'classes_'

Anyone having this issue?

issue while trainig the data

I got this error while training the data, please help!!

File "findFeatures.py", line 50, in
descriptors = np.vstack((descriptors, descriptor))
File "/usr/lib/python2.7/dist-packages/numpy/core/shape_base.py", line 228, in vstack
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
ValueError: all the input array dimensions except for the concatenation axis must match exactly

core dumped

When i am excecuting

python findFeatures.py -t dataset/train/
it shows -
Segmentation fault (core dumped)

plz help.

TypeError: type other than float or double not supported

Hi.
I am using ORB features instead of SIFT features.

I am facing an issue while performing clustering on the images.
Please find the code snippet.

``

Create feature extraction and keypoint detector objects

orb = cv2.ORB()

List where all the descriptors are stored

des_list = []

for image_path in image_paths:
im = cv2.imread(image_path)
is_cv3 = cv2.version.startswith("3.")
if(is_cv3):
detector = cv2.ORB_create()
else:
detector = cv2.ORB()
kpts = detector.detect(im)
kpts, des = detector.compute(im,kpts)
img_temp = np.zeros((1,1))
img_four = cv2.drawKeypoints(im,kpts,img_temp,color = (0,255,0), flags = 0)
des_list.append((image_path, des))

Stack all the descriptors vertically in a numpy array

descriptors = des_list[0][1]
for image_path, descriptor in des_list[1:]:
descriptors = np.vstack((descriptors, descriptor))

Perform k-means clustering

k = 100
voc, variance = kmeans(descriptors, k, 1)

Calculate the histogram of features

im_features = np.zeros((len(image_paths), k), "float32")
for i in xrange(len(image_paths)):
words, distance = vq(des_list[i][1],voc)
for w in words:
im_features[i][w] += 1

I am facing the following error:-

Traceback (most recent call last):
File "findFeatures.py", line 133, in
words, distance = vq(des_list[i][1],y_kmeans[:500,])
File "/usr/local/lib/python3.5/dist-packages/scipy/cluster/vq.py", line 211, in vq
return _vq.vq(c_obs, c_code_book)
File "_vq.pyx", line 211, in scipy.cluster._vq.vq
ValueError: observation and code should have same number of dimensions.

Please provide me with the solution to the problem.

Evaluation

Can you please let us know how to evaluate the trained model? I mean the confusion matrix and classfication_report functions in scikit-learn.

'xrange' not not defined

Error appears while training:

Traceback (most recent call last):
File "findFeatures.py", line 56, in
for i in xrange(len(image_paths)):
NameError: name 'xrange' is not defined

A problem for stacking all the descriptors vertically in a numpy array

Hi, bikz05

There is another problem in findFeatures.py. The code:

# Stack all the descriptors vertically in a numpy array
descriptors = des_list[0][1]
for image_path, descriptor in des_list[0:]:
    descriptors = np.vstack((descriptors, descriptor))  

I think it's should be as follows:

# Stack all the descriptors vertically in a numpy array
descriptors = des_list[0][1]
for image_path, descriptor in des_list[1:]:
    descriptors = np.vstack((descriptors, descriptor))  

Training Error

Hi,

I've got some error after ruuning the training with python findFeatures.py -t dataset/train/ which states

Traceback (most recent call last):
File "findFeatures.py", line 35, in
fea_det = cv2.FeatureDetector_create("SIFT")
AttributeError: module 'cv2' has no attribute 'FeatureDetector_create'

Could you publish the packages version you have used for this build so I'll check if I'm using the same opencv version?

Thanks,
Shahar

realtime

Thanks for your work. Really great job. I have modified the code by removing the arguments and to run the code from python idle. For a single image. Can i make it real time by using a webcam?
findFeatures.txt
getClass.txt

Regards
Rahul

vstack issue

Hi,

First thanks the script seems quite nice.
I try to run it with 103 classes, so i basically replaced the folder in train directory by new folders, named after my classes, and containing 50 images each.
So, as guessed, it take 45/50min to run... but then i always get that error : "ValueError: all the input array dimensions except for the concatenation axis must match exactly" the error comes from ligne 50 when stacking the descriptors...

My folders are as the picture... any idea what is wrong??

capture d ecran 2015-06-01 a 00 59 07

ps : when using your code "out of the box" it runs perfectly

PS2 : solved it

ISSUE WHILE TRAINING AND TESTING

after running the code in anaconda (spyder) we are getting Systemexit : 0 with no errors and no output (while running both training and testing)

below are the screenshots of what i have done :
screenshot 124
screenshot 125

Something about the idf

Hi, bikz05
It seems you don't make use of the computed idf

# Perform Tf-Idf vectorization
nbr_occurences = np.sum( (im_features > 0) * 1, axis = 0)
idf = np.array(np.log((1.0*len(image_paths)+1) / (1.0*nbr_occurences + 1)), 'float32')

# Scaling the words
stdSlr = StandardScaler().fit(im_features)
im_features = stdSlr.transform(im_features)

I think for each im_features[i] it should multiply the idf to make full use of it, that is:

im_features = im_features*idf

Don't you think so?

Accuracy

Please tell me how to find accuracy of the model.

error

i have this error:

Traceback (most recent call last):
File "findFeatures.py", line 35, in
fea_det = cv2.FeatureDetector_create("SIFT")
AttributeError: 'module' object has no attribute 'FeatureDetector_create'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.