Тёмный
No video :(

Tutorial on CNN implementation for own data set in keras(TF & Theano backend)-part-2 

Anuj shah
Подписаться 8 тыс.
Просмотров 16 тыс.
50% 1

This is the second part of tutorial for Implementing your own CNN on custom data. the first part: • Tutorial on CNN implem...
The code: github.com/anujshah1003/own_d...
It explains viewing your model configuration and keras callback function such as early stopping, saving the logs in a csv file and adding a model checkpoint to save the best weights during training.
You can support me on Paypal : www.paypal.me/anujshah645

Опубликовано:

 

17 май 2017

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 125   
@anujshah645
@anujshah645 4 года назад
if from sklearn.cross_validation import train_test_split gives error then use from sklearn.model_selection import train_test_split
@UniqueTech0098
@UniqueTech0098 3 года назад
can I have your contact number plz
@anujshah645
@anujshah645 3 года назад
@@UniqueTech0098 you can reach me in mail - anujonline645@gmail.com
@aratikushwaha1936
@aratikushwaha1936 3 года назад
Good Job!! very well explained and easily understandable. Thanks a lot!
@shailavijay1
@shailavijay1 5 лет назад
Thanks , its very good video for CNN with code.
@waridhasan37
@waridhasan37 4 года назад
Thanks a lot. I 100% understand everything. You save 30 days in my life. Thank you bro. Good Luck
@RnFChannelJr
@RnFChannelJr 4 года назад
thanks for detail explanation 'bout CNN , i appreciate u sir
@naifalshammari3265
@naifalshammari3265 6 лет назад
It's a very nice tutorial, thanks a lot Anuj Shah.
@prarthana1122
@prarthana1122 7 лет назад
It's so easy to understand. Thanks for the video tutorial.
@anujshah645
@anujshah645 7 лет назад
Good luck
@michaelkonstantinovsky2184
@michaelkonstantinovsky2184 6 лет назад
Great JOB!!!!! very easy to understand, learned a lot from you. Waiting for additional videos. Thanks a lot!
@underpowerjet
@underpowerjet 7 лет назад
Hey man I seriously want to thank you! I watched your Keras/Theano setup video a year ago and it really helped me set it all up! I was new to CNN and that video really helped me out! Thank you!
@anujshah645
@anujshah645 7 лет назад
Thanks. I am glad my videos are useful
@WKhan-jl3fv
@WKhan-jl3fv 6 лет назад
Hello Anuj shah! When I run the bwlow section, i got an error that: File "", line 2, in img_list=os.listdir(data_path+'/'+ dataset) NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\Admin\\data/custom_data_cnn.py' Please comment. for dataset in data_dir_list: img_list=os.listdir(data_path+'/'+ dataset)
@rohitsethi2085
@rohitsethi2085 6 лет назад
Thank you so much for the video.... Nice explanation
@RnFChannelJr
@RnFChannelJr 4 года назад
hello sir, can you tell me how to test loaded weight ?
@anujshah645
@anujshah645 4 года назад
Its already mentioned - model.load_weights('weight_file_name')
@dintakurthinvvssaikumar4755
@dintakurthinvvssaikumar4755 5 лет назад
sir im getting this error please help me sir" OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'"
@randomvideos8856
@randomvideos8856 6 лет назад
So nice n clear
@xueqing6824
@xueqing6824 4 года назад
Hi, can I use this code for multi-label in an image?? and it is in csv file
@anujshah645
@anujshah645 4 года назад
Not exactly, this code is for single label
@shreyasumare1443
@shreyasumare1443 4 года назад
ValueError Traceback (most recent call last) in () 1 img_data = np.array(img_data_list) ----> 2 img_data = img_data.astype('float32') 3 img_data /= 255 4 print (img_data.shape) ValueError: setting an array element with a sequence. how do i resolve it
@shivadarshans3409
@shivadarshans3409 4 года назад
Sir is there is a need of opencv for preprocessing if we r using keras Please reply
@anujshah645
@anujshah645 4 года назад
Keras has a preprocessing module for few standard architecture s but with opencv you have more options and flexibility.
@puremarijuana
@puremarijuana 6 лет назад
Anuj you're the man bro! This explains CNN so very well. Thanks man...keep em' coming :) Could you do more videos on Tensorflow and TFLearn?
@anujshah645
@anujshah645 6 лет назад
yes sure
@dkishore599
@dkishore599 4 года назад
Hi Anuj, it is great explanation, i just wondering about one thing here i seen some videos they used MobileNet of Keras on image classification , so what is the difference b/w your code and MobileNet code ? can we do Dog & cat classification by using MobileNet ? please help me about my doubt.
@anujshah645
@anujshah645 4 года назад
ues you can do. Mobilenet is a lightr weight model
@dkishore599
@dkishore599 4 года назад
@@anujshah645 from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D from keras.layers import Activation ,Dropout,Flatten,Dense from keras import backend as K import tensorflow.compat.v1 as tf import numpy as np from keras.preprocessing import image from __future__ import generator_stop img_width,img_height=150,150 train_data_dir='data/train' validation_data_dir='data/validation' nb_train_samples=1000 nb_validation_samples=100 epochs=50 batch_size=20 if K.image_data_format()=='channels_first': input_shape=(3,img_width,img_height) else: input_shape=(img_width,img_height,3) train_datagen=ImageDataGenerator( rescale=1./255, shear_range=0.2, zoom_range=0.2, horizontal_flip=True) test_datagen=ImageDataGenerator(rescale=1./255) train_generator=train_datagen.flow_from_directory( train_data_dir, target_size=(img_width,img_height), batch_size=batch_size, class_mode='binary') validation_generator=test_datagen.flow_from_directory( validation_data_dir, target_size=(img_width,img_height), batch_size=batch_size, class_mode='binary' ) model=Sequential() model.add(Conv2D(32,(3,3),input_shape=input_shape)) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2,2))) model.summary() model.add(Conv2D(32,(3,3))) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Conv2D(64,(3,3))) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Flatten()) model.add(Dense(64)) model.add(Activation('relu')) model.add(Dropout(0.5)) model.add(Dense(1)) model.add(Activation('sigmoid')) model.summary() model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy']) model.fit_generator( train_generator, steps_per_epoch=nb_train_samples // batch_size, epochs=epochs, validation_data=validation_generator, validation_steps=nb_validation_samples // batch_size) i used above code but getting error RuntimeError: generator raised StopIteration , Can you help me ?
@maruthivaraprasadparakati5241
@maruthivaraprasadparakati5241 5 лет назад
Hi Anuj,I want to get draw bounding box around the object can you please help to predict bounding boxes for my own dataset
@ManjeetKaur-hm4jt
@ManjeetKaur-hm4jt 5 лет назад
Hey Anuj...Thank you for your informative videos. I was trying to run your code with the same dataset but it is giving the following error: ValueError: Error when checking input: expected conv2d_27_input to have 4 dimensions, but got array with shape (646, 128, 128). I think it's in line 126. Please reply
@anujshah645
@anujshah645 5 лет назад
Hi Manjeet, The input to CNN is of shape - (num_samples,num_rows,num_cols,num_channels). If you are using gray image then image shape is usually say (128,128). It does not show you the channel. but yo u have to feed the channel info as well i.e (128,128,1). so your input_array shape should be (646,128,128,1) for gray images and (646,128,128,3) for coloured images. in you can do an expands dims function on 4th axis and a 1 will be added at the end. you can use this command x=np.expand_dims(x, axis=0)
@ManjeetKaur-hm4jt
@ManjeetKaur-hm4jt 5 лет назад
Thanks Anuj for the reply. Waiting for more videos (GAN's , Ensemble methods etc.)
@RnFChannelJr
@RnFChannelJr 4 года назад
@@anujshah645 where i can plot that code x=np.expand_dims(x, axis=0)
@RnFChannelJr
@RnFChannelJr 4 года назад
@@ManjeetKaur-hm4jt where i can plot that code x=np.expand_dims(x, axis=0)
@ngyj807
@ngyj807 5 лет назад
hi, I used your code to train my cnn, however this error observed and I search through google still cant find any solution, can you help on this? ValueError: Error when checking input: expected conv2d_171_input to have 4 dimensions, but got array with shape (3, 128, 128)
@anujshah645
@anujshah645 5 лет назад
in which line is the error being generated, is it during testing?
@soumyakumar8898
@soumyakumar8898 5 лет назад
I'm getting the same error, any solution to this?
@melesezekiwos1252
@melesezekiwos1252 4 года назад
Thanks very much...could you show me how to convert this for colored(RGB) image classification please?
@kirankumarsoni009
@kirankumarsoni009 6 лет назад
Hi Anuj, Thanks for this amazing vedio. I have created my own hdf5 file with my own database. But how to use this data base in real time video input to detect object and how to access hdf5 and predict output (0,1,2..) with live video stream, Please do let me know.
@pz2519
@pz2519 6 лет назад
Hello Anuj, I am using Keras 2.1.1 . While the Evaluation time i am getting the error as below? What changes shall i do? TypeError: evaluate() got an unexpected keyword argument 'show_accuracy'
@anujshah645
@anujshah645 6 лет назад
+Poonam Zagade I guess in keras 2 we don't need the show accuracy argument
@anujshah645
@anujshah645 6 лет назад
just use model.evaluate(X_test, Y_test, verbose=0)
@vigneshviggs100
@vigneshviggs100 6 лет назад
Anuj shah can I use this code to build a biometric ear recognition model with a dataset having 125 subjects, atleast 5 samples in each?
@denisadrian9765
@denisadrian9765 3 года назад
i am getting this error when running the code help please TypeError: must be str, not list
@anujshah645
@anujshah645 3 года назад
well the error says for itself
@denisadrian9765
@denisadrian9765 3 года назад
Solved thanks
@munmiandnilotpal9854
@munmiandnilotpal9854 5 лет назад
Thank you. Its a very good tutorial. Great work. Can you please help me....is it applicable to apply a new sample data set to a already trained model CNN (of my own data set) without training the model again. (For e.g. Suppose I have created a train model for 3 types of samples and later I want to add a new sample for classification to the model without doing the training again)
@ransfordtetteh3070
@ransfordtetteh3070 6 лет назад
This is an awesome video, clearly explained and easy to follow. I have one question, how do I import the created dataset into a model for real-time detection? I tried to use the created file "weights-Test-CNN.hdf5" but couldn't get a way. Can you please guide? Thanks
@dkishore599
@dkishore599 4 года назад
i have taken one image from google and tried to Predict it , but it is giving wrong out put, Why ?
@anujshah645
@anujshah645 4 года назад
The model is not a perfect model, it was just a demo, you need to take better model, train it in a better way
@aseelsami.6322
@aseelsami.6322 4 года назад
@@anujshah645 why you say that I need your tetegram please
@shamoonmohammad5230
@shamoonmohammad5230 6 лет назад
cannot able to import name np_utils any suggestion
@ahmedhusham7728
@ahmedhusham7728 4 года назад
I tried to run your code but I faced some issues, I fixed them until I got an error that I could not exceed it. Could you please assist me to handle it?
@anujshah645
@anujshah645 4 года назад
Can you post the issue
@ahmedhusham7728
@ahmedhusham7728 4 года назад
@@anujshah645 can I sent it via email?
@ahmedhusham7728
@ahmedhusham7728 4 года назад
@@anujshah645 the problem occurred when I executed this code: hist = model.fit(X_train, y_train, batch_size=16, epochs=num_epoch, verbose=1, validation_data=(X_test, y_test)) The error message is: "ValueError: Calling `Model.fit` in graph mode is not supported when the `Model` instance was constructed with eager mode enabled. Please construct your `Model` instance in graph mode or call `Model.fit` with eager mode enabled".
@saikumar-gc2yh
@saikumar-gc2yh 5 лет назад
Name error:model not found this one also coming sir plzz help mee sir
@visheshtanwar1710
@visheshtanwar1710 7 лет назад
Hey Anuj, I ran this code on my terminal instead of Spyder and am getting the error in the line " plt.plot(xc,train_loss) " that " raise ValueError("x and y must have same first dimension") ValueError: x and y must have same first dimension " I have tried the same way as you change num_epochs to 5 but even than it's not working. Can you help me to fix this problem? Thanks
@anujshah645
@anujshah645 7 лет назад
well you have to see the number of epoch that you selected for training and number of epoch that you gave during plotting
@visheshtanwar1710
@visheshtanwar1710 7 лет назад
Thanks Anuj, It solved my bug..
@sokhibtukhtaev9693
@sokhibtukhtaev9693 6 лет назад
I have a dataset of gestures that contains 10 types of 1400 black/white gestures (140 sample images for each gesture). what model in Keras do you recommend? Can someone please help build that model (such as how many conv layer, activation layers or maxpooling, etc)?
@anujshah645
@anujshah645 6 лет назад
that should be based on trial and error you can start with simple network first and see how it performs
@sokhibtukhtaev9693
@sokhibtukhtaev9693 6 лет назад
thank you mister!
@bharatbargujar3071
@bharatbargujar3071 6 лет назад
Thank you for the video Anuj it is very informative. Do you have any plan to similar video for object detection using Faster-R-CNN or SSD with Keras framework?
@swamiswami2580
@swamiswami2580 7 лет назад
Hi, If I run the the code for the same dataset multiple times, the accuracy and the loss changes. Is it possible to save the best training model? If yes, how?
@anujshah645
@anujshah645 7 лет назад
yes you can save the best model during training using callback function. i have explained it in this video
@khadijaamouri6041
@khadijaamouri6041 6 лет назад
thank you so much ! i have a problem with this command : Y = np_utils.to_categorical(labels, num_classes) because i have 40 classes what shall i do please ?
@anujshah645
@anujshah645 6 лет назад
make your num_classes=40, the command will create one-hot encoding for it
@khadijaamouri6041
@khadijaamouri6041 6 лет назад
thank you it works
@AbhishekGupta92
@AbhishekGupta92 7 лет назад
Hi Anuj, I am new to CNN and keras. While implementation I have encountered this error: TypeError: A Message class can only inherit from Message in __module__ = 'google.protobuf.descriptor_pb2' . I couldn't find anything relevant to this error. could you please help me out with this?
@anujshah645
@anujshah645 7 лет назад
well I am also not very sure about this error but you may check your protobuf installation, which tensorflow you are using and on which environment
@AbhishekGupta92
@AbhishekGupta92 7 лет назад
Thanks Anuj. I don't know the exact problem as there is some problem within libraries [from their github discussion]. But, as soon as I restart the kernel of Spyder IDE, It worked fine.
@anujshah645
@anujshah645 7 лет назад
Thats great. Good Luck!
@junfenggao5403
@junfenggao5403 7 лет назад
Hi, Anuj. How to calculate the number of parameters for each layer. for example, the convolutional2d-1 why the parameters is 320. I have no idea. Thanks
@anujshah645
@anujshah645 7 лет назад
There is some command to get the number of parameters for each layer in keras. I don't exactly remember that but you can get it online
@junfenggao5403
@junfenggao5403 7 лет назад
OKay, Thanks for your reply.
@WKhan-jl3fv
@WKhan-jl3fv 6 лет назад
Hello Anuj! Thanks for the video. How can I give another folder to test my accuracy. I mean, in this code we just select training and validation and testing from the same data. What I train my system on this data. But for testing I want to some other images to predict?
@anujshah645
@anujshah645 6 лет назад
+Wasif Khan similar like data folder you can make a test folder and load test data from there
@WKhan-jl3fv
@WKhan-jl3fv 6 лет назад
thanks for the reply, but when I load test data. Should do all process the same you did for the training data? Because for testing data we dont need labels. Can you post some links to follow? thanks
@prativadas4794
@prativadas4794 5 лет назад
ValueError: Error when checking input: expected conv2d_4_input to have 4 dimensions, but got array with shape (646, 128, 128) this error is coming while training. please help
@ManjeetKaur-hm4jt
@ManjeetKaur-hm4jt 5 лет назад
Hi Prativa...Please add this command before splitting the input data (line 70 in the code) x=np.expand_dims(x, axis=1) I hope it will resolve the issue.
@RnFChannelJr
@RnFChannelJr 4 года назад
@@ManjeetKaur-hm4jt hi , i get ValueError: Input 0 is incompatible with layer conv2d_54: expected ndim=4, found ndim=5 after input x=np.expand_dims(x, axis=1) (line 70 in the code )
@RnFChannelJr
@RnFChannelJr 4 года назад
@@ManjeetKaur-hm4jt thankksss it's work for me
@shikhagupta2130
@shikhagupta2130 3 года назад
RnF Channel how did you solve it I am still getting the same error
@mrinalsubash8358
@mrinalsubash8358 6 лет назад
Hi Anuj. If i change every 'th' to 'tf', will it take in tensorflow commands because I have installed tensorflow and I need to use that for multiclassification.
@anujshah645
@anujshah645 6 лет назад
change the backend from theano to tf in keras.json file. the code should work
@mrinalsubash8358
@mrinalsubash8358 6 лет назад
Where is the keras.json file? Unable to get it
@anujshah645
@anujshah645 6 лет назад
it should be in your home directory in .keras folder
@mrinalsubash8358
@mrinalsubash8358 6 лет назад
Thankyou anuj I did that.Now, when I am running the testing line it says THEANO requires BLAS whereas I have changed my backend to tf and that prevents me from running the epoch.
@anujshah645
@anujshah645 6 лет назад
check carefully or google to see how to change the backend
@pz2519
@pz2519 6 лет назад
How shall I use this code for 3D images?
@anujshah645
@anujshah645 6 лет назад
+Poonam Zagade what do you exactly mean by 3 D images. If you are referring to depth then we can use the depth as NUM o channel in the code above
@poornachandrasandur3340
@poornachandrasandur3340 7 лет назад
Hi , Anuj both the videos are informative,thanks for uploading. If I want to put all the images into a single .h5 file, can I do it.
@anujshah645
@anujshah645 7 лет назад
I haven't tried but i guess you can
@priyanshuupadhyay7095
@priyanshuupadhyay7095 6 лет назад
in line no. 74 of ur code I get the following error error:(-215) scn ==3 || scn==4 in function cvtcolor. do help and thanku for Amazing work
@anujshah645
@anujshah645 6 лет назад
Check whether the images are RGB or gray already , you can check by computing their dim len(img.shape)
@thegaganmodi
@thegaganmodi 6 лет назад
Hi Anuj, You explained it very easy way. Thank you for the videos. I have 2 question can you please explain me if I need to predict the image with its name instead of integer encoded, how can I do that and second question is your Paypal account still active I would love to support you . Thank you
@anujshah645
@anujshah645 6 лет назад
the prediction will always be in integer , as each image is mapped to a label. if you want to display name then simply use a if loop if predicted_label==0: name='cat' elif predicted_label==1: name = 'horse' and so on... yes my paypal is active: www.paypal.me/anujshah645
@anongeorge2504
@anongeorge2504 6 лет назад
Nice work. Please improve the voice quality. Thank you.
@mehmetelmac9394
@mehmetelmac9394 7 лет назад
Hi Anuj, This videos are very good, thanks for all of them. I have four classes and each class has 10.000 pictures . I trained networks but I couldnt succes its testing :( . after training there are .hdf5 files but I don't know how can I use them ?
@anujshah645
@anujshah645 7 лет назад
it is shown in the video , how to test any image after the model is trained using model.predict
@amirlasry8426
@amirlasry8426 6 лет назад
can you explain how to predict continuous output using CNN?
@anujshah645
@anujshah645 6 лет назад
Do you mean continuous output of predicted class from say webcam feeds. If so you can watch this video I have shown here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-G9qiGuZKjLs.html
@amirlasry8426
@amirlasry8426 6 лет назад
I mean that the output instead of being classes will be continuous value, for example - I have images and I want to measure size of an object(of course I have training data)
@anujshah645
@anujshah645 6 лет назад
oh I got it. you can treat as a regression problem , at the last layer instead of softmax you can just have linear activation layer
@amirlasry8426
@amirlasry8426 6 лет назад
yes, I think this is the direction but I get dimensions error.. can we talk privately?
@poornachandrasandur3340
@poornachandrasandur3340 7 лет назад
Hi Anuj , I am working on BRATS dataset for Brain Tumor Segmentation. I have to read the .nii.gz images, which has 4 modalities for a single patient residing in folders and sub folders. I want to know how to read these files which are in subfolders. Can I get your email
@poornachandrasandur3340
@poornachandrasandur3340 7 лет назад
can I get ur email id...
@anujshah645
@anujshah645 7 лет назад
i have explained it in the first video how to read the sub folders in the first video
@anujshah645
@anujshah645 7 лет назад
anujonline645@gmail.com
@poornachandrasandur3340
@poornachandrasandur3340 7 лет назад
Anuj shah thank you I will send u an email
@AkshayKumar-zr1gs
@AkshayKumar-zr1gs 5 лет назад
Error when checking input: expected conv2d_1_input to have 4 dimensions, but got array with shape (4141, 256, 256) please tell me how to remove this error and what and where can i do to remove the error ?
@anujshah645
@anujshah645 5 лет назад
the inpu should have shape - (num_samples, num_channels, num_rows, num_cols) for theano backend and (num_samples, num_rows, num_cols, num_channels) for tensorflow backend. In your case the num_channels dimension is missing , it should be 1 for gray image and 3 for colored image
@AkshayKumar-zr1gs
@AkshayKumar-zr1gs 5 лет назад
@@anujshah645 thank you Sir
@sokhibtukhtaev9693
@sokhibtukhtaev9693 6 лет назад
Could you please let me know your email address? I remember I have seen it somewhere along but now I can't find it.
Далее
🎙ПЕСНИ ВЖИВУЮ от КВАШЕНОЙ🌇
3:16:26
How I'd Learn AI (If I Had to Start Over)
15:04
Просмотров 763 тыс.
Mask R-CNN
12:22
Просмотров 104 тыс.
The moment we stopped understanding AI [AlexNet]
17:38
Просмотров 832 тыс.