69 - Image classification using Bag of Visual Words (BOVW)

Ғылым және технология

Bag of words (BOW) model is used in natural language processing for document classification where the frequency of each word is used as a feature to train a classifier. This approach can be extended to classify images by treating each feature in the image as a word, bag of visual words (BOVW).
For BOVW approach, the features from image can be extracted using one of many feature extractors such as SIFT, HOG, SURF, and ORB. The extracted features can then be clustered into various bins using a clustering algorithm such as k-means. Finally, the features can be used to train a classifier such as Random Forest or SVM.
This tutorial explains the Python approach for BOVW based image classification.
The code from this video is available at: github.com/bnsreenu/python_fo...
Malaria cell data set: www.kaggle.com/datasets/iarun...

Пікірлер: 48

  • @nabaa.h4566
    @nabaa.h45664 жыл бұрын

    Awesome and so useful thanks so much 👏🏻🙏🏼

  • @alialmalki1294
    @alialmalki12942 жыл бұрын

    very nice , good help from you to every one *free help is rare in these days

  • @zakariaabderrahmanesadelao3048
    @zakariaabderrahmanesadelao30484 жыл бұрын

    Very clear explanation. thank you sir.

  • @DigitalSreeni

    @DigitalSreeni

    4 жыл бұрын

    Glad it helped

  • @zistiqb1815
    @zistiqb18152 жыл бұрын

    excellent work ...

  • @DigitalSreeni

    @DigitalSreeni

    2 жыл бұрын

    Thank you! Cheers!

  • @zakariaabderrahmanesadelao3048
    @zakariaabderrahmanesadelao30484 жыл бұрын

    what was TF-IDF used for, you computed them but they were not used in the machine learning phase

  • @abdelrahmanamr6752

    @abdelrahmanamr6752

    2 жыл бұрын

    trying to figure the same here

  • @AbdulQayyum-kd3gf
    @AbdulQayyum-kd3gf4 жыл бұрын

    Excellent work. Can I use these features extractor for segmentation images as explained to you in previous videos?

  • @DigitalSreeni

    @DigitalSreeni

    4 жыл бұрын

    You are only limited by your creativity on how to use feature extractors :)

  • @vanetoj
    @vanetoj4 жыл бұрын

    i m just using it as a guide for BOW to lead to VLAD . but i m getting the same error as the others about dimenssion. is len(image_paths) supposed to be the number of images ?

  • @dinooliuduwarage4659
    @dinooliuduwarage46593 жыл бұрын

    Could you kindly show how to implement a texton library similarly this research paper: Automatic Detection of Globules, Streaks and Pigment Network Based on Texture and Color Analysis in Dermoscopic Images. Your videos are absolutely effective and useful ! Thank you !

  • @vishalgowda6755
    @vishalgowda67553 жыл бұрын

    hey can we use this concept for face authentication/recognition using SIFT /SURF.

  • @rachanasolanke9832
    @rachanasolanke98323 жыл бұрын

    I have tried this classification but while prediction i got error, list index out of range , please help me out sir.

  • @hiankun
    @hiankun2 жыл бұрын

    Just a minor reminder: This video is not listed in your comprehensive "Python tutorials from basics to deep learning (with code)" playlist.

  • @merihunnega
    @merihunnega3 жыл бұрын

    sir, thanks your clear explanation, but i encountered the error such as: "error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-i1s8y2i1\opencv\modules\imgproc\src esize.cpp:4051: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'" kpts, des = brisk.detectAndCompute(im, None)

  • @hedgehog1962
    @hedgehog19622 жыл бұрын

    Now SIFT is available in openCV, right?

  • @c-techtube3634
    @c-techtube36342 жыл бұрын

    Sir kindly briefly explain the difference between sklearn kmeans and scipy kmeans. it would be better and i will be thankfull if you apply the sklearn kmeans in this code and share it in the replay box I will be wait for your kind response thanks

  • @felip6180
    @felip61804 жыл бұрын

    Mr. Sreeni, I've done this lesson of yours, but as I could not get the images you used for training, I searched for the ones I used. My model result was not good, got a bad classification (20% score 2/10). I've done some code review here, but the code is like yours, so no error found. As I was watching the second part of this video, the one you talk about malarial cells, one thing I noticed was that you use standardized cells: same length and black blackground. With this, it came to me to review my images for training and the images were not very good because they contained some relevant background,which the feature detector would get. So, I changed for a new dataset (train and test), one with no background at all and retrained my algorithm and got a poor result, 11% score (1/9 of total images) what would you sugest me to do ?

  • @felip6180

    @felip6180

    4 жыл бұрын

    note: I've done the code with the malaria cells (the pics you provided in your github). the sizes were: 30 train, 10 test and the model proved to be a good fit, with 8/10 righ for the SVM and 6/10 for the RFC

  • @DigitalSreeni

    @DigitalSreeni

    4 жыл бұрын

    Unfortunately (but understandably) GitHub does not allow users to upload lots of data. But, for most examples you should be able to generate your own data by downloading images from Google search or find public repositories.

  • @rohithkarthikeya2686
    @rohithkarthikeya26863 жыл бұрын

    Sir for training and testing how can we split it dynamically in code?

  • @DigitalSreeni

    @DigitalSreeni

    3 жыл бұрын

    Use sklearn to split your data to train and test. You can watch this video: kzread.info/dash/bejne/dHWdr617oqnUpMY.html

  • @hamadouousmanou7307
    @hamadouousmanou73074 жыл бұрын

    well done please i want to know if you have done the same series with MATLAB

  • @DigitalSreeni

    @DigitalSreeni

    4 жыл бұрын

    No, I do not have access to MATLAB. Moreover, I believe people are moving from MATLAB to Python so no point in trying to do it MATLAB.

  • @dinooliuduwarage4659
    @dinooliuduwarage46593 жыл бұрын

    Can you please show us how to extract or identify features with supervised classification manner?😔 We are trying to classify skin lesions images. Appreciate your help with these valuable videos.. 💐

  • @DigitalSreeni

    @DigitalSreeni

    3 жыл бұрын

    Skin Lesion classification (for example to detect melanoma or benign) falls into image classification category. It is a rather easy topic to handle, depending on the features. Please follow my videos on the topic of image classification. I recommend watching my video 158b where I combined Deep learning based feature extractors with traditional Random Forest classifier for image classification. It may work well for your case. You can even replace Random Forest with deep learning if you want. kzread.info/dash/bejne/e6mjp8uenaTbebw.html

  • @dinooliuduwarage4659

    @dinooliuduwarage4659

    3 жыл бұрын

    @@DigitalSreeni Thank you very much for your comment.

  • @achinvincible
    @achinvincible4 жыл бұрын

    get a error saying that "ValueError: observation and code should have same number of dimensions" in the line 'words,distance = vq(desc_list[i][i],voc)" I was going over the documentation that they need to have same number of dimensions. My desc_list is a 2d list and so is the voc which is also 2d. I used sift for the feature extraction by the way I need to submit a project using the same code tomorrow morning and am trying to figure out where i have gone wrong with this implementation. Please help thanks

  • @DigitalSreeni

    @DigitalSreeni

    4 жыл бұрын

    Looks like the dimensions are wrong. Up on quick look of the code snippet I see that you got it as desc_list[i][i]. I have it as desc_list[i][1] in my code. Please check your code if it is supposed to be indeed i or 1.

  • @vanetoj

    @vanetoj

    4 жыл бұрын

    i got the same. did you ever resolve it? how long is len(image_paths) supposed to be? the number of images or ?

  • @vanetoj

    @vanetoj

    4 жыл бұрын

    @@DigitalSreeni i used

  • @mohalemolefe
    @mohalemolefe4 жыл бұрын

    Sir, great tutorial thank you, been using DCNN but i wanted to give traditional methods a try as well. I followed all the steps here, but I am getting this error. when using np.vstack "all the input array dimensions except for the concatenation axis must match exactly" Any idea how to rectify this??

  • @DigitalSreeni

    @DigitalSreeni

    4 жыл бұрын

    As the error suggests, please check if the dimensions match. You are trying to concatenate two arrays, so it must have same dimensions.

  • @mohalemolefe

    @mohalemolefe

    4 жыл бұрын

    @@DigitalSreeni I noted the issue could be because of the X-ray images I am using, my descriptor returns nonetype object with size 1. The code works fine for the dataset you used with here.

  • @KomalKumari2894

    @KomalKumari2894

    4 жыл бұрын

    @@mohalemolefe How did you deal with this.. I am getting the same error

  • @KomalKumari2894

    @KomalKumari2894

    4 жыл бұрын

    @@DigitalSreeni How to handle predictors of different length?

  • @mohalemolefe

    @mohalemolefe

    4 жыл бұрын

    @@KomalKumari2894 I ended up using matlab

  • @musabejeanbosco6902
    @musabejeanbosco69023 жыл бұрын

    thank you for your explanation, i am using python3.7 and i had an error for sklearn, ImportError: cannot import name 'joblib' from 'sklearn.externals' (C:\Users\bosulus\AppData\Local\conda\conda\envs\py3env-gpu\lib\site-packages\sklearn\externals\__init__.py), which scikit-learn version fitted py3.7

  • @DigitalSreeni

    @DigitalSreeni

    3 жыл бұрын

    You can directly use joblib rather than importing it from sklearn.externals. import joblib joblib.readthedocs.io/en/latest/

  • @taherehmehrjerdy4411
    @taherehmehrjerdy44113 жыл бұрын

    I am using BOVW but it takes a long time about 1 hour (I have a big database) . How can I run my program faster? fore example using t-SNE instead of PCA

  • @DigitalSreeni

    @DigitalSreeni

    3 жыл бұрын

    I haven't tried t-SEN and not sure if it would make the process any faster. Please let me and others know if t-SNE is indeed faster. In general this approach is not optimized for speed during the training process. I like mixing CNN feature extraction with Random Forest / SVM to classify images. Please wait a couple of days for my new video on this topic.

  • @m_fadhln
    @m_fadhln3 жыл бұрын

    Trump representation of BoW is brilliant

  • @ajaykharat8832
    @ajaykharat8832 Жыл бұрын

    ftp://lhcftp.nlm.nih.gov/Open-Access-Datasets/Malaria/cell_images.zip need username ?

  • @DigitalSreeni

    @DigitalSreeni

    Жыл бұрын

    You can download the malaria dataset from here: www.kaggle.com/datasets/iarunava/cell-images-for-detecting-malaria

Келесі