158 - Convolutional filters + Random Forest for image classification.

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ก.ย. 2024
  • Deep learning is far superior to traditional machine learning with loads of training data. But, for limited training data traditional machine learning (e.g. Random Forest or SVM) may outperform deep learning. For image processing applications features need to be extracted / engineered for improved accuracy. Alternatively, features can be extracted from convolutional filters that are part of convolutional neural networks.
    This video goes through the process of extracting features using convolutional filters and using them as inputs to a traditional Random Forest classifier to develop an image classification solution. This approach is specifically designed for image classification of custom datasets.
    Code generated in the video can be downloaded from here:
    github.com/bns...

ความคิดเห็น • 117

  • @ssshukla26
    @ssshukla26 3 ปีที่แล้ว +5

    You never know who is watching the videos. Exactly the kind of attitude every professor should have when they start explaining stuff which gets really confusing because one doesn't know small things needed to know. Thank you sir for the video. Subscribed.

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว

      Like I tweeted a few days ago - A good teacher educates by meeting students at least 80% into their space of understanding.

    • @ssshukla26
      @ssshukla26 3 ปีที่แล้ว

      @@DigitalSreeni what's your Tweeter handle? I will like to follow you.

    • @ssshukla26
      @ssshukla26 3 ปีที่แล้ว +1

      @@DigitalSreeni ok it's by same name. Got it. Following.

  • @iamtherealankitroy
    @iamtherealankitroy 4 ปีที่แล้ว +25

    These videos have been an extremely valuable resource for me. Thanks for constantly providing high value content!

  • @ghaliahmed
    @ghaliahmed 2 ปีที่แล้ว

    For the first time, i find a person who can realy make a good explanation for all the time !!!!!!

  • @Fransphoenix
    @Fransphoenix 7 หลายเดือนก่อน +2

    Amazing content. Underrated channel. Though I suspect all of us here are the ones truly embracing ML and AI, haha!

  • @adoniasandarge6008
    @adoniasandarge6008 3 ปีที่แล้ว

    I am Adonias Andarge from Ethiopia. I am so impressed by your everything. I am working on mammography image classification. And I found your tutorial very useful... thankyou so much sir...

  • @AmrikKrishnakumar-q4e
    @AmrikKrishnakumar-q4e 27 วันที่ผ่านมา

    Exactly what I needed as a beginner in ML!

  • @naveenfernando1852
    @naveenfernando1852 3 ปีที่แล้ว

    Hi sir,
    I use this approach for one of my projects. Thanks to you i was able to achieve 98% of accuracy.
    once i created the model i save random forest model using the following code
    import dill
    save_model = dill.dump(RF_model, open(directory_name + ".obj","wb"))
    Once i completed the model i open a new notebook and load the CNN_RF_model using the following code
    load_model = dill.load(open(directory_name + ".obj","rb"))
    After load the RF_CNN_model i tried to predict some images using the following code
    input_img = np.expand_dims(image, axis=0) #Expand dims so the input is (num images, x, y, c)
    input_img_features=feature_extractor.predict(input_img)
    prediction_RF = RF_CNN_model.predict(input_img_features)[0]
    prediction_RF = le.inverse_transform([prediction_RF])
    Since now i am in a new notebook i dont have feature_extraction variable that i used to build the RF_CNN_model.
    so my problem is how can load the feature_extractor variable data for the RF prediction?
    What i had done was I rerun the feature_extraction part that we use to create the model again in my new notebook.
    Everytime my CNN+RF model gives different results. maybe the feature_extraction variable changes everytime. How can i fix this issue sir?
    In conclude, when using the random forest model which created with CNN features .. how can i get the feature_extracted part for the prediction.. is there a method to save the CNN features
    Thanks and best regards.

  • @shalombentenzingnamchyo9384
    @shalombentenzingnamchyo9384 2 ปีที่แล้ว

    Wow thank you so much. I wish I found you sooner. You deserver to be on top of the search results for CNN tutorials.

  • @swethanandyala
    @swethanandyala 6 หลายเดือนก่อน

    Most amazing content for deep learning...am learning lot from u sir...thank you

  • @nikhilkethu5202
    @nikhilkethu5202 ปีที่แล้ว

    These video sloved lot of doubhts which i had and got me distinction in my main masters project. Thank you keep going....

  • @inhibited44
    @inhibited44 2 หลายเดือนก่อน

    been trying to use this for an app similar to finding a ordinary dog and a dog that's all white and a dog that has spots on it . I get low accuracy, but I also have only a hundred photos. I like how I was able to incorporate a confusion matrix to see how my 27 test images thus far compare to the actual images. I guess I will continue to collect images online. Thanks for uploading the video

  • @iguyblr
    @iguyblr 2 ปีที่แล้ว

    Wow Sreeni , Just bumped into your videos , its pretty impressive now need to catch up on others .. Thanks for sharing

  • @inhibited44
    @inhibited44 2 หลายเดือนก่อน

    on to_categorical(y_train, num_classes=3) to_categorical(y_test, num_classes=3) include num_classes = 3 to adjust if you have only 3 selections instead of four.

  • @saivarun7298
    @saivarun7298 2 ปีที่แล้ว

    Thanks sir, my mini project is done just because of you.

  • @AIdAssist
    @AIdAssist 9 หลายเดือนก่อน

    Thank you so so much! These videos are so helpful!!!!!!

    • @DigitalSreeni
      @DigitalSreeni  9 หลายเดือนก่อน

      You're so welcome!

  • @madchemist199
    @madchemist199 3 ปีที่แล้ว

    Thanks a ton for making the video extremely useful for me!

  • @Hoxle-87
    @Hoxle-87 3 ปีที่แล้ว +1

    Great tutorial. For few samples you should use bootstrapping

  • @資工系日常
    @資工系日常 3 ปีที่แล้ว

    really helpful video! clear explanation! thank you a lot and this Vedio helps me a lot as a student majoring in CS

  • @kuipan5968
    @kuipan5968 4 ปีที่แล้ว +1

    Great content! One quick question: since you trained feature_extractor first during fitting CNN model, that basically means the Random forest model's performance is dependent on the CNN model training process. I am wondering how did you decide how many layers to be used for the feature_extractor?

    • @DigitalSreeni
      @DigitalSreeni  4 ปีที่แล้ว +2

      Please watch the follow up video 158b which may answer your questions.

  • @rayhanuthama-5917
    @rayhanuthama-5917 2 ปีที่แล้ว

    so i try this and set dense 2, activation = sigmoid (2 class) and why my confussion matrix append 4x4 table?

  • @qsxzae12
    @qsxzae12 2 ปีที่แล้ว

    Extremely helpful. Thanks for sharing.

  • @shilashm5691
    @shilashm5691 2 ปีที่แล้ว

    You can also work with labelencoding in deep learning by setting loss function as sparse_categorical_crossentropy

  • @RAZZKIRAN
    @RAZZKIRAN 2 ปีที่แล้ว

    super, excellent , thank u sir

  • @holthuizenoemoet591
    @holthuizenoemoet591 2 ปีที่แล้ว

    How do you apply the one hot encoding for pixel segmentation? An how can you flatten the convolutional layers, so they match the flattened input image?

    • @DigitalSreeni
      @DigitalSreeni  2 ปีที่แล้ว

      I did that in many of my videos. Just search for multiclass segmentation videos on my channel. Here is the link to one such tutorial: th-cam.com/video/XyX5HNuv-xE/w-d-xo.html

  • @ravimehta714
    @ravimehta714 2 ปีที่แล้ว

    by Compiling
    history = cnn_model.fit(x_train, y_train_one_hot, epochs=50, validation_data = (x_test, y_test_one_hot))
    I am getting error....Please suggest

  • @fatizulfiqar
    @fatizulfiqar 3 ปีที่แล้ว

    Thank you for detailed and very informative tutorial. However I have one question that is you have extracted features from convolutional base, flatten it and passed into the random forest. My query is can I also add a few dense layers on top of features from convolutional base and use that feature descriptor to be fed into the svc or any other sklearn model?. I hope my query is clear

  • @dr.aravindacvnmamit3770
    @dr.aravindacvnmamit3770 3 ปีที่แล้ว +2

    Dear sir I cleared the error. I should use accuracy instead of acc😉😉😉

  • @shitshow_1
    @shitshow_1 2 ปีที่แล้ว

    Thank you, such an amazing video. Really Helpful 👍🏼

  • @minhaoling3056
    @minhaoling3056 2 ปีที่แล้ว

    Hi Sir , do you know a feature extractor in computer vision called Krawtchouk moment ? Do you think it will be helpful if I convert the image into Krawtchuok moment image before putting them into the CNN feature extractor?

    • @DigitalSreeni
      @DigitalSreeni  2 ปีที่แล้ว

      No need to preprocess images for deep learning based approach. Usually they should learn from raw data.

  • @AlgoTribes
    @AlgoTribes 4 ปีที่แล้ว

    that was really insightful..thanks for the content ..it really made me content..

  • @MrMikael1337
    @MrMikael1337 3 ปีที่แล้ว

    Hi Sreeni, thank you for this amazing video.
    I have a question on how to interpret what the random forest is doing. In another video you posted, the decision trees were using nodes based on histogram values and texture . There it was very clear what nodes the tree can be built upon. But when we have like in this case, just a very long flattened column vector, how can the nodes be represented from this vector?

  • @htissolutions7960
    @htissolutions7960 2 ปีที่แล้ว

    Also my cnn model does not show number trainning samples and validation samples

  • @RadomName3457
    @RadomName3457 2 ปีที่แล้ว

    Thanks for your ammazing video sir. But i have a question, how can i save the weights and architecture of the feature extractor (not the whole model) built from convolutional layers for later use?

  • @lakshyavaibhavdatta9098
    @lakshyavaibhavdatta9098 2 ปีที่แล้ว

    @DigitalSreeni There's a huge problem with this code. Even directly copying it into google colab, and creating the directory structure with a train and validation folder produces a seemingly irresolvable error in the line "X_for_RF = feature_extractor.predict(train_images)" :
    WARNING:tensorflow:Model was constructed with shape (None, 100, 100, 3) for input KerasTensor(type_spec=TensorSpec(shape=(None, 100, 100, 3), dtype=tf.float32, name='conv2d_37_input'), name='conv2d_37_input', description="created by layer 'conv2d_37_input'"), but it was called on an input with incompatible shape (32,)
    Is there any way around this? Because otherwise the logic of merging the predict function will never work even in our own implementations. Thank you :)

    • @DigitalSreeni
      @DigitalSreeni  2 ปีที่แล้ว

      You need to keep track of array dimensions as they go through various layers. The dimensions depend on your input images so you have to customize that part.

  • @TheMishupo
    @TheMishupo 2 ปีที่แล้ว

    Great video, thank you!

  • @rv0_0
    @rv0_0 2 ปีที่แล้ว

    If you get the error "cannot import name 'BatchNormalization' from 'keras.layers.normalization' (C:\Users\RAVI\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\layers
    ormalization\__init__.py)"
    then use from tensorflow.keras.layers import BatchNormalization
    then use "from tensorflow.keras.layers import BatchNormalization" instead

    • @inhibited44
      @inhibited44 8 หลายเดือนก่อน

      thanks

  • @talhaabbasjalvi9572
    @talhaabbasjalvi9572 3 ปีที่แล้ว

    His sir amazing video by the way I have question which software or IDE you are usingb here

  • @refreshyourlife3099
    @refreshyourlife3099 2 ปีที่แล้ว

    great course, thank you sir

  • @NehadHirmiz
    @NehadHirmiz 4 ปีที่แล้ว

    Excellent Tutorial. Thank you very much

    • @DigitalSreeni
      @DigitalSreeni  4 ปีที่แล้ว +1

      You are welcome!

    • @NehadHirmiz
      @NehadHirmiz 4 ปีที่แล้ว

      @@DigitalSreeni Please keep making those great videos :)

  • @ismailaslan287
    @ismailaslan287 2 ปีที่แล้ว

    Is it similar to getting node embeddings with Convolutional filters and then passing the node embeddings to the random forest? Thanks for the great video.

  • @danielyoo5897
    @danielyoo5897 ปีที่แล้ว

    Hi! Your video is so helpful! I would like to ask you one question about the code. On line 58 where you make X_for_RF, why does it have to be feature_extractor.predict(x_train) instead of feature_extractor.output like NN?
    Also, can you make a video to demonstrate how to add additional features like tabular data to your model please? For example, feature_extractor to extract features, then add tabular features (age, sex, etc..), then perform random forest for final!

  • @samarafroz9644
    @samarafroz9644 4 ปีที่แล้ว

    Awesome tutorial like always sir.

  • @saivarun7298
    @saivarun7298 2 ปีที่แล้ว

    At x= dense i am not able to use dropout. its showing keyword error. any solution

  • @mohammadareeb4826
    @mohammadareeb4826 3 ปีที่แล้ว

    Sir can we not do one hot encoding and use sparse_categorical_crossentropy as the loss function?

  • @umairsabir6686
    @umairsabir6686 3 ปีที่แล้ว

    Hi Sreeni, great presentation of the topic. In real world scenarios most problems are novelty detection related. Where we only have data for normal case but not abnormal case. Is there any possibility of extracting features from convolutional filters and then use one class svm, isolation forest of LOC for novelty detection ? I want to know about tuning of those parameters in one class segmentation problems to get novelties. Thanks

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว

      For data sets where you only have normal case images you need to look for algorithms that detect anomalies. This is where you train it on normal and anything not normal is anomaly. Autoencoders can be good architectures for this application.

    • @umairsabir6686
      @umairsabir6686 3 ปีที่แล้ว

      @@DigitalSreeni I tried autoencoders. But the problem with autoencoders is that they are also reconstructing the defected part of the images which they should not construct. They learned normal data but they also learned to construct abnormal part as well. This is where Variational autocnecoders comes in. Is it possible to tweat parameters in autoencoders or variational autoencoders to have control on the model so that it learns limited features ?

  • @htissolutions7960
    @htissolutions7960 2 ปีที่แล้ว

    I found this video very interesting. Good job. But I have small issue that i want you to help me with. I have 790 train images, but when CNN trained, it reduced to 25 from the Epoch.
    And yours remain 320 images even during the training.
    kindly help me out

  • @abderrahmaneherbadji5478
    @abderrahmaneherbadji5478 4 ปีที่แล้ว

    Hello Sreeni,
    Plesae how can we determine Accuracy Top-5 of the RF classifer

  • @MohamedAbomokh
    @MohamedAbomokh 4 ปีที่แล้ว

    Hey Sreeni ,
    I really enjoy watching your videos and love the effort you put into each video and they are helpful ,
    Also I wanted to ask if you did a video about how to use the watershed algorithm or something similar for edge detection in cells or fractography in order to creat masks for a CNN model ? If yes which one cause I can find it , if not would you kindly recommend something?

    • @DigitalSreeni
      @DigitalSreeni  4 ปีที่แล้ว +1

      I did videos on Grain and cell segmentation where I used traditional watershed to separate connected components. Please watch videos 33, 34, and 35.

    • @MohamedAbomokh
      @MohamedAbomokh 4 ปีที่แล้ว

      @@DigitalSreeni thank you :)

  • @dr.aravindacvnmamit3770
    @dr.aravindacvnmamit3770 3 ปีที่แล้ว

    Dear Sir I have taken 5 folders of images each folder consists of 1214 samples. But am getting this error?"ValueError: zero-size array to reduction operation maximum which has no identity"

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +1

      Zero size array mean it is not reading your files and has an empty array. Please do these one step at a time so you can troubleshoot easily. Please make sure the path is correct from the location where you are executing the python file.

  • @thomasjefferson6225
    @thomasjefferson6225 ปีที่แล้ว

    Can i use this with deepsurv on a random survival forest?

  • @bhargavireddy604
    @bhargavireddy604 4 ปีที่แล้ว

    Sir how to slove this error " return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
    " y_train_one_hot = to_categorical(y_train)
    ValueError: zero-size array to reduction operation maximum which has no identity

    • @DigitalSreeni
      @DigitalSreeni  4 ปีที่แล้ว

      It says zero-size array. Please make sure you have information your arrays, may be the files are not being read into python correctly.

  • @abderrahmaneherbadji5478
    @abderrahmaneherbadji5478 4 ปีที่แล้ว

    Hi Sreeni,
    Many thanks for your efforts.
    Please can you record a video about fine-tuning procedure of pretrained models.

    • @DigitalSreeni
      @DigitalSreeni  4 ปีที่แล้ว

      Fine tuning to do what? Do you mean transfer learning where you want t use pre-trained models?

  • @michaelmanuel1676
    @michaelmanuel1676 3 ปีที่แล้ว

    Thank you!!

  • @joaosacadura6097
    @joaosacadura6097 4 ปีที่แล้ว

    Thanks so much for your videos! So i'm currently using U-net for multi class classification on o
    orthophotos, and i see that u used other methods like this one with the add of random forest. From your
    experience in the subject what is best model for multi class?
    Keep up with the videos!

    • @DigitalSreeni
      @DigitalSreeni  4 ปีที่แล้ว +1

      If you have enough labeled images please use one of the pre-trained models (e.g. VGG16) and attach your own dense layers to customize the prediction for your images. Continue training on your images. I think this works best for multiclass problems.

  • @saivarun7298
    @saivarun7298 3 ปีที่แล้ว

    Sir, in this video the accuracy you got for cnn is for entire cnn model right?

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว

      Accuracy is for the trained model in classifying test data.

  • @abhisheksrivastava3700
    @abhisheksrivastava3700 3 ปีที่แล้ว

    Hi
    What is your tensorflow and keras library version , because to_categorical() function giving error.
    Thank in advance .

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว

      If you are working with tensorflow2.x, do not import keras or its libraries directly. I do that mistake all the time. Please import keras from tensorflow.
      For example: from tensorflow.keras.utils import to_categorical

  • @dr.aravindacvnmamit3770
    @dr.aravindacvnmamit3770 3 ปีที่แล้ว

    Dear Sir I have solved my previous error thank you. But am facing this Error-acc = history.history['acc'] ??? Can you tell me Why.
    I saw the cnn_model.compile(optimizer='rmsprop',loss = 'categorical_crossentropy', metrics = ['accuracy'])

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +1

      Looks like you solved this error but in general if you define metrics as 'acc' then it is stored as 'acc' in history. In the new version of keras you cannot mix 'acc' and 'accuracy'.

  • @iraqfree9509
    @iraqfree9509 2 ปีที่แล้ว

    thank you,how can i find the class labels for these features?

  • @mohit6847
    @mohit6847 3 ปีที่แล้ว

    Sir is it possible if we use 3 pretrained models(ResNet, DensNet, Inception) with random forest for image classification if yes then how to do that.
    (newbie to ML)

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +1

      Yes it is possible. You need to perform classification individually and then combine the predictions. Please watch my video 213 to find out how to ensemble. I used deep learning approach for classification but the ensembling part should be the same. th-cam.com/video/-ix_Mjzu8BU/w-d-xo.html

    • @mohit6847
      @mohit6847 3 ปีที่แล้ว

      @@DigitalSreeni Sir with weighted average I got u and tried. But main problem where I confused to merge all 3 models using Random Forest like in this video u had fitted a single model, like that I want to merge all 3 models

  • @pechaaloler
    @pechaaloler 3 ปีที่แล้ว

    Hey, I really like your video!
    Do you know some papers about deep image feature extraction by any chance?
    I searched for an eternity but did not find interesting papers or an overview on this topic.
    I would really appreciate it if you could name a few papers or blogs on this topic!

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว

      Sorry No. I am not sure if the topic is worth publishing a paper so I am not surprised you haven't found any papers. I am also not aware of any blogs. If you haven't found anything doing a Google search then it must not exist :)

  • @abhukk
    @abhukk 3 ปีที่แล้ว

    this is amazing

  • @pareedhijain5295
    @pareedhijain5295 6 หลายเดือนก่อน

    can we use CNN for numerical datasets

    • @DigitalSreeni
      @DigitalSreeni  6 หลายเดือนก่อน

      Yes, but I wouldn't recommend it. There are much better approaches for structured data.

  • @kannanv9304
    @kannanv9304 3 ปีที่แล้ว +1

    @4.06......Why not live on the edge?........My take away......

  • @meriemketfi4923
    @meriemketfi4923 2 ปีที่แล้ว

    thank you for this veideo. please can you help me why my RF_accuracy =00

  • @QGISTutorial
    @QGISTutorial 2 ปีที่แล้ว

    Please tell me how to get the image data.

  • @mohamedtouati9663
    @mohamedtouati9663 3 ปีที่แล้ว

    I need help Sir !!! :O how can i use this model to classifier diabetic retinopathy images?

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว

      This will work for diabetic retinopathy images but I recommend using fully deep learning for better accuracy. You may find this paper useful: arxiv.org/pdf/2003.02261.pdf

  • @Antonio-lu2vo
    @Antonio-lu2vo 3 ปีที่แล้ว

    the code crash after read only the first two for? why?

  • @rv0_0
    @rv0_0 2 ปีที่แล้ว

    Title should be "DigitalSreeni trying to built build a crappy neural network model but failed"

  • @anirudhank6337
    @anirudhank6337 3 ปีที่แล้ว

    "I think Random Forests did a better job than a Human in classification " LOL..XD 25:37

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +1

      Machines are always better than humans at boring jobs. We tend to get bored after a while and get sloppy at our job.

    • @anirudhank6337
      @anirudhank6337 3 ปีที่แล้ว

      @@DigitalSreeni agreed .. 👍

  • @centralprocessingunit7431
    @centralprocessingunit7431 2 ปีที่แล้ว

    the title is quite misleading.
    this is convolutional neural network and random forest,
    not convolution and random forest as suggested by the title.

    • @DigitalSreeni
      @DigitalSreeni  2 ปีที่แล้ว

      Can you please let me know what exactly is misleading so i can correct it? I do not see the confusion so trying to understand how others can misinterpret my intentions. Also, the title screen should help summarize the topic, hopefully.

    • @centralprocessingunit7431
      @centralprocessingunit7431 2 ปีที่แล้ว

      @@DigitalSreeni
      the title is misleading as convolution is an independent topic to neural networks.
      so i got the sense that the only machine learning model going to be used in the video is random forest,
      but adding the neural network just makes it completely different.
      from the video title, one could expect the structure to be
      convolution + random forest --> random forest
      instead of
      convolution + neural network --> random forest

  • @ebrahimahmedal-rahawe3161
    @ebrahimahmedal-rahawe3161 3 ปีที่แล้ว

    Great effort sir,thanks a lot..
    My question is: can we plot ROC for such multiclasses? If so, how? Otherwise, what is the metrics applicable rather than acc?!
    Thanks a lot sir..

  • @yoyomcg
    @yoyomcg 3 ปีที่แล้ว

    my nigga sreeni makes good ass shit

  • @inhibited44
    @inhibited44 2 หลายเดือนก่อน

    I've got tensorflow 2.9.0 and I get an error on this line -> x = feature_extractor.output

    • @inhibited44
      @inhibited44 2 หลายเดือนก่อน

      "The layer has never been called and thus has no defined output ". I didn't find the solution. I chose another method to do the job. Couldn't find a solution on stack overflow quickly

    • @inhibited44
      @inhibited44 2 หลายเดือนก่อน

      at some point I installed another version of tensorflow. Not sure if I deprecated, but got by the error