you have the pictures of barns and landscapes. If you were trying to distinguish between a person with freckles and the same person without freckles , is the detail too small for ML to pick it up?
I am wondering how you deploy this on a website if you want to classify an image from your iphone? I can save an h5 file using video 158 , but don't see how to save it on this vgg program.
Dear thank you very much for this video. I have implemented the same codes on brain tumor dataset but getting the accuracy result of 0, what should I do ? Also I have 4 class labels but confison matrix shows 7 labels. Could you please help me ?
For petrografic semantic segmentation for multiclass classification, im having a problem while fitting the model. As the VGG16 output is of shape (None, 8, 8, 512), i cant fit it to my y_train values, of shape (None, 256, 256, 6). What should i do?
Thsnk you for this video ...I want to ask if I can extract features from 960 image using HOG and then concatenate with cnn features to obtain features vector to use it for classifying images using svm .please give us example about this idea
This code part is giving an error that 'int' object has no attribute 'assign' pliz assist #Now, let us use features from convolutional network for RF feature_extractor=VGG_model.predict(x_train) features = feature_extractor.reshape(feature_extractor.shape[0], -1) X_for_training = features #This is our X input to RF
why can't we just add a flatten layer at the end of the VGG model? Then add a dense layer with softmax activation and desired number of classes and train the model with these trainable layers only. I have tried it and it gives almost same validation accuracy. Am I missing something?
May be you are are missing something. The approach you mentioned is deep learning approach which works great if you have large amount of training data. With limited training data, you will get higher accuracies with feature engineering and traditional machine learning (e.g., Random Forest). You can engineer your features by adding a bunch of filters or filter banks using Gabor. Or you can use pretrained CNN (e.g., VGG on imagenet) as feature extractor, which is what I described in this video. In summary, this approach may yield better results with only a handful of training images and masks.
Hello Sreeni, Thanks for your great efforts. Please let me know how one can use SVM instead of Random Forest. Also, I think feature vectors are of higher dimensions, so how can we implement PCA to reduce dimensions. Best regards.
hi, i have been reading a paper and it say this "We noticed that randomly selecting few dimensions is more efficient that a classic Principal Component Analysis (PCA) algorithm [30]. This simple random dimensionality reduction significantly decreases the complexity of our model for both training and testing time while maintaining the state-of-the-art performance." Maybe can help u
I have followed this process of coding, but can you please mention how many epochs you have used, and is there any way to change the epoch number in the program?
Sir, this code part is giving an error that "Unexpected result of `predict_function` (Empty batch_outputs)" #Now, let us use features from convolutional network for RF feature_extractor=VGG_model.predict(x_train) Kindly clarify my doubt
@@DigitalSreeni thanks a lot, Sir. But I have another question. In transfer learning we see that we can do the augmentation manually by using ImageDataGenerator of keras during running the model. But is their any way to do augmentation manually in hybrid model like this u given in this video??? If it can be done, then how?? Can u please tell us??
hi i am using this code for a 4 class dataset and i am getting the accuracy as 0 and the confusion matrix also has 8 indices (i.e. from 0 to 7) instead of 4. if you could please help me out with this it'd be great!
Hello sir ..i had one query..what is the use of random forest classifier or any other classifier to be applied after deep learning...like vgg19 or vgg16...because the deep learning model can give us classification results as well???
It's for imbalanced data, cnn models are really biased towards the majority class however random forest models aren't, so we are leveraging the feature extraction quality of cnn to classify the class by random forest
It depends on whether you define the problem as multiclass with 2 classes or binary. If you define it as multiclass and using softmax activation then you need to encode your labels and convert to categorical. If you are defining it as binary and using sigmoid activation, you do not need to convert to categorical, just encoding to 0 and 1 would do.
i am trying it on two classes of vegetable one is fresh_vegetable and other is stale_vegetable, using the same code , but i am getting accuracy as zero
sir after feature_extractor=VGG_model.predict(x_train) UnboundLocalError: local variable 'batch_outputs' referenced before assignment Please give solution
May be an issue with keras.... instead of from keras.models import ..... from keras.layers import ...... try... from tensorflow.python.keras.layers import .... from tensorflow.python.keras.models import .... But, please be consistent. Do not mix some modules from keras and some from tensorflow.keras.
you shared extremely really valuable videos.Thank you very much. I wonder if can we use fine-tuned CNN models for feature extraction (that you used all trainable layers=false) and is it enough just like: (for layer in ResNet_model.layers[:xy]: layer.trainable = False for layer in ResNet_model.layers[zx:]: layer.trainable = True) And will we use cnn model's features after all epoch finished or just like you shared like layer.trainable = False.
When we say we want to use pretrained models as feature extractors we will set trainable=False because we want to use pre-trained weights as kernels that define the feature extractor. If you do the training, running through epochs, you are adjusting the weights and fitting a model. This is not the goal when you only want to use the model for feature extraction. Think of it as training a model on a bunch of data and now you are using the trained model for prediction. Except, we are not predicting and only extracting features because the original network was trained for a different purpose.
Amazing video!! I was wandering if I can save my trained model so I can call it one more time without rerunning it and how to do so. I'm actually trying to classify 3 classes with a limited number of features and I'm getting an 0.59 in accuracy, I've tried data augmentation with ImageDataGenerator but the accuracy has become 0.58. What should I do to increase it. Thank you
To save and load sklearn models you can use Pickle. import pickle #Save the trained model as pickle string to disk for future use filename = "sandstone_model" pickle.dump(model, open(filename, 'wb')) #To test the model on future datasets loaded_model = pickle.load(open(filename, 'rb')) result = loaded_model.predict(X) If you accuracy is not improving, play with the classifier parameters. If that doesn't help, you need more training data. You cannot augment your way to better accuracy.
I don't see why there should be an issue with 2 class classification. It just reads the folder name and assigns it as a label. It does not matter how many folders you have. Please make sure the folder names do not have any spaces, that can lead to issues.
@@DigitalSreeni no sir no spaces in folder names... Just changed the folder path as I am running this on colab...just troubled with the accuracy..is it because I am using xray images?. Plz have a look..
Just replace the Random Forest part in this video with SVM or other classifier. I am not sure if it requires a new video for each classifier in this process.
@@DigitalSreeni I have a doubt on this here we are giving input size 256, but the default size of the vgg16 is (224,224) based on this only the convolutional layers are structured and got 92 % accuracy on imagenet competition. Here we are changing input shape will it affect the performance of the model?
I got so many ideas watching you walk through transfer learning step-by-step. 🙏🙏
Thorough explanation! Really helpful and informative. Thanks 🙏
Its amazing....... helped alottttttt!!!!!!! Thanks alot it saved uss🙏
trueeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Yess!!
You're damn great sir best tutorial on RUclips
Awesome thankyou so much keep making more videos
😊😊😊😊😊😊😊
Thanks
Thank you very much.
Thank you so much for the amazing tutorial!! It was very informative and helpful!!
Glad it was helpful!
Kindly tell us how to do the feature selection using the MRI IMAGE DATASET
you have the pictures of barns and landscapes. If you were trying to distinguish between a person with freckles and the same person without freckles , is the detail too small for ML to pick it up?
No detail is too small for deep learning; chances are if you can see them the algorithm can also see them.
Why do you perform on-hot encoding if you will not use it in the rest of the code?
I am wondering how you deploy this on a website if you want to classify an image from your iphone? I can save an h5 file using video 158 , but don't see how to save it on this vgg program.
I actually bumped into your lesson 268 and I am reviewing it. Thanks
Dear thank you very much for this video. I have implemented the same codes on brain tumor dataset but getting the accuracy result of 0, what should I do ? Also I have 4 class labels but confison matrix shows 7 labels. Could you please help me ?
should nt u change test_labels in line 121 change to test_labels_encoded?????
For petrografic semantic segmentation for multiclass classification, im having a problem while fitting the model.
As the VGG16 output is of shape (None, 8, 8, 512), i cant fit it to my y_train values, of shape (None, 256, 256, 6).
What should i do?
looking forward to viewing and trying this on my own data. I haven't enough data to classify the images and the images are unusual.
Sir, using a large dataset my program gets crashed, because of the RAM isn't sufficient enough. What should I do?
Note: I'm using Colab
Why its still labeling a data out of 4 classes if i give it some random image. ?
Hello sir, how can this method be used for videos instead of images
Hi, sir. 28 number line, print (label). What is the output of this line? Same as directory_path?
Hello Sir How to apply Transfer Learning for numerical data? using 1dCNN?
Thsnk you for this video ...I want to ask if I can extract features from 960 image using HOG and then concatenate with cnn features to obtain features vector to use it for classifying images using svm .please give us example about this idea
Hello,
Thank you for this video, but i can't find the dataset ??
How can we use yolo for localizing and alexnet for final identification purpose
Is there video of you explains the process of using pretrained weights (VGG16) as feature extractors for MLP?
sir your code run but give accuracy 0.0 what problem and how to solve please answer
I wish you'd make a version of this with data augmentation (giving the input to random forest)
line number 72,73,74 getting error
ValueError: zero-size array to reduction operation maximum which has no identity
This code part is giving an error that 'int' object has no attribute 'assign' pliz assist
#Now, let us use features from convolutional network for RF
feature_extractor=VGG_model.predict(x_train)
features = feature_extractor.reshape(feature_extractor.shape[0], -1)
X_for_training = features #This is our X input to RF
hello sir! when i run this code, the one hot encoding runs into error everytime. its not working properly
why can't we just add a flatten layer at the end of the VGG model? Then add a dense layer with softmax activation and desired number of classes and train the model with these trainable layers only. I have tried it and it gives almost same validation accuracy. Am I missing something?
May be you are are missing something. The approach you mentioned is deep learning approach which works great if you have large amount of training data. With limited training data, you will get higher accuracies with feature engineering and traditional machine learning (e.g., Random Forest). You can engineer your features by adding a bunch of filters or filter banks using Gabor. Or you can use pretrained CNN (e.g., VGG on imagenet) as feature extractor, which is what I described in this video. In summary, this approach may yield better results with only a handful of training images and masks.
Hello Sreeni,
Thanks for your great efforts.
Please let me know how one can use SVM instead of Random Forest.
Also, I think feature vectors are of higher dimensions, so how can we implement PCA to reduce dimensions.
Best regards.
Just switch the line where we have Random Forest to SVM.
I will try to do a video on the topic of PCA.
@@DigitalSreeni looking forward to the video
hi, i have been reading a paper and it say this "We noticed that
randomly selecting few dimensions is more efficient that a classic Principal Component Analysis (PCA) algorithm [30].
This simple random dimensionality reduction significantly decreases the complexity of our model for both training and testing time while maintaining the state-of-the-art performance." Maybe can help u
I have followed this process of coding, but can you please mention how many epochs you have used, and is there any way to change the epoch number in the program?
Very nice explanation...but while I am trying this code for my classification problem, it gives more number of classes for a.3 class problem statement
Awesome video sir! I What if we have a big dataset? SVM from sklearn dont support generators or partial_fit
Well, that is why you have neural networks, try SGD classifier. If you want to stick with SVM try using PCA to reduce dimensions.
@@DigitalSreeni Thank you for your reply!
sir how to generate roc curve..? i am getting error
You are really great Sir!
Would love to apply this same method but using random forest for segmentation
Sir, this code part is giving an error that "Unexpected result of `predict_function` (Empty batch_outputs)"
#Now, let us use features from convolutional network for RF
feature_extractor=VGG_model.predict(x_train)
Kindly clarify my doubt
Sir, please make a tutorial video on GAN using your own data set..can transfer learning is used in GAN also
Sir when i run this code for two class problem its not working.Getting a confusion matrix of 4X4.Kindly tell me
to me its showing 0.0 accuracy in two class problem
hi sir, how can i run it for n trails ?
Can I use the same process for other models like EfficientNet to combine EfficientNet with SVM and Random Forrest??
Sure. You can use output from trained models as features for your traditional classification algorithms such as SVM or RF or Gradient boost.
@@DigitalSreeni thanks a lot, Sir. But I have another question. In transfer learning we see that we can do the augmentation manually by using ImageDataGenerator of keras during running the model. But is their any way to do augmentation manually in hybrid model like this u given in this video??? If it can be done, then how?? Can u please tell us??
@@DigitalSreeni did you get any luck trying the SVM?
in my case, i am running the code on cat dog sample dataset. but it is showing 0.0 accuracy. please help
I have the same problem,plz if you had resolved it tell me
Dear Sreeni, please share the code for practice purpose
Another great video, thanks!
My pleasure!
sir how can we save final model for further use?
hi i am using this code for a 4 class dataset and i am getting the accuracy as 0
and the confusion matrix also has 8 indices (i.e. from 0 to 7) instead of 4.
if you could please help me out with this it'd be great!
Hi can you solve this problem ?
Hello sir ..i had one query..what is the use of random forest classifier or any other classifier to be applied after deep learning...like vgg19 or vgg16...because the deep learning model can give us classification results as well???
It's for imbalanced data, cnn models are really biased towards the majority class however random forest models aren't, so we are leveraging the feature extraction quality of cnn to classify the class by random forest
Sir, aren't we supposed not to rescale the test images ?
Very useful. Thank you!
Glad to hear that!
if I only have 2 classes, should I use label encoder?
It depends on whether you define the problem as multiclass with 2 classes or binary. If you define it as multiclass and using softmax activation then you need to encode your labels and convert to categorical. If you are defining it as binary and using sigmoid activation, you do not need to convert to categorical, just encoding to 0 and 1 would do.
@@DigitalSreeni thankyou so much, your video helps me a lot
i am trying it on two classes of vegetable one is fresh_vegetable and other is stale_vegetable, using the same code , but i am getting accuracy as zero
same here...how did u resolve the issue???
hello sreeni
can you make a vedio to classify covid -19 ct scan image with using the grad-cam please
sir after
feature_extractor=VGG_model.predict(x_train)
UnboundLocalError: local variable 'batch_outputs' referenced before assignment
Please give solution
May be an issue with keras.... instead of
from keras.models import .....
from keras.layers import ......
try...
from tensorflow.python.keras.layers import ....
from tensorflow.python.keras.models import ....
But, please be consistent. Do not mix some modules from keras and some from tensorflow.keras.
Thank you so much sir
Sir,can we give binary images as input to vgg16?
Yes
Hi thanks for the tutorial
Can you make a tutorial on transfer learning for multi label classification
I need same issue
you shared extremely really valuable videos.Thank you very much.
I wonder if can we use fine-tuned CNN models for feature extraction (that you used all trainable layers=false) and
is it enough just like:
(for layer in ResNet_model.layers[:xy]: layer.trainable = False for layer in ResNet_model.layers[zx:]: layer.trainable = True)
And will we use cnn model's features after all epoch finished or just like you shared like layer.trainable = False.
When we say we want to use pretrained models as feature extractors we will set trainable=False because we want to use pre-trained weights as kernels that define the feature extractor. If you do the training, running through epochs, you are adjusting the weights and fitting a model. This is not the goal when you only want to use the model for feature extraction. Think of it as training a model on a bunch of data and now you are using the trained model for prediction. Except, we are not predicting and only extracting features because the original network was trained for a different purpose.
@@DigitalSreeni thank you for this valuable help and contributions
Sir!
Your task for 4 classes! It can work for 30 classes?
Yes, no reason why it wouldn't work for 30 classes.
sir please make a video on style transfer and pixtopix neural networks.
Amazing video!!
I was wandering if I can save my trained model so I can call it one more time without rerunning it and how to do so.
I'm actually trying to classify 3 classes with a limited number of features and I'm getting an 0.59 in accuracy, I've tried data augmentation with ImageDataGenerator but the accuracy has become 0.58.
What should I do to increase it.
Thank you
To save and load sklearn models you can use Pickle.
import pickle
#Save the trained model as pickle string to disk for future use
filename = "sandstone_model"
pickle.dump(model, open(filename, 'wb'))
#To test the model on future datasets
loaded_model = pickle.load(open(filename, 'rb'))
result = loaded_model.predict(X)
If you accuracy is not improving, play with the classifier parameters. If that doesn't help, you need more training data. You cannot augment your way to better accuracy.
Nice work, keep going!
Thanks a lot!
sir, it is my request to make a video on a combination of Unet and GAN as GAN-Unet network for segmentation purpose
I second this, transfer learning from Unet to random forest for image segmentation would be amazing
why are u not normalizing extracted features before giving it to random forest
For a couple of reasons, primary reason being Random Forest is a tree-based model so it does not require feature scaling.
Sir your videos are damn amazing. Tried it with a different dataset, but stuck with 0.0 accuracy as mine is a 2 class classification.. Pls guide us..
I don't see why there should be an issue with 2 class classification. It just reads the folder name and assigns it as a label. It does not matter how many folders you have. Please make sure the folder names do not have any spaces, that can lead to issues.
@@DigitalSreeni no sir no spaces in folder names... Just changed the folder path as I am running this on colab...just troubled with the accuracy..is it because I am using xray images?. Plz have a look..
I have the 3problem ,plz if you had resolved it tell me
@@anupriya3741 i also got 0.0 accuracy with 10 class dataset...what can be done??
@@DigitalSreeni i also got 0.0 accuracy with 10 class dataset...what can be done??pls rply sir....m stuck
Please a video for VGG16 with SVM and VGG16 with KNN
Just replace the Random Forest part in this video with SVM or other classifier. I am not sure if it requires a new video for each classifier in this process.
@@DigitalSreeni Thanks. I was able to do it. Please post a video with pretrained AlexNet.
@@ameentendolkar4430 what did u replace in the code to use SVM as I'm trying to do the same
Amazing content as usual, well done :)
Great, Thank you
You are welcome!
@@DigitalSreeni I have a doubt on this here we are giving input size 256, but the default size of the vgg16 is (224,224) based on this only the convolutional layers are structured and got 92 % accuracy on imagenet competition. Here we are changing input shape will it affect the performance of the model?
Thank you sir
Welcome
Merci !
Thank you very much.
Great
Any body intrested in my project.. im working on a density map estimatatin
from tensorflow.keras.layers import BatchNormalization
Use this import statement for BatchNormalization
after feature extraction, can i use the optimization like gridsearchcv or GA with tpot for the classifier?
sir i am getting error while implementing this on another dataset " zero-size array to reduction operation maximum which has no identity"