Image Recognition & Classification with Keras in R | TensorFlow for Machine Intelligence by Google

Sdílet
Vložit
  • čas přidán 8. 05. 2024
  • Provides steps for applying Image classification & recognition with easy to follow example.
    GitHub for R code: github.com/bkrai/DeepLearningR
    Data: goo.gl/To15db
    Machine Learning videos: goo.gl/WHHqWP
    To install EBimage package, you can run following 2 lines;
    install.packages("BiocManager")
    BiocManager::install("EBImage")
    Time stamps (provided by Caroline Mimeault):
    0:00 Load Packages
    0:29 Read Images
    4:08 Explore
    6:16 Resize
    7:23 Reshape
    8:45 Row Bind
    11:49 One Hot Encoding
    12:42 Create Model
    16:02 Compile
    16:38 Fit Model
    18:49 Evaluation and Prediction (train data)
    22:20 Evaluation and Prediction (test data)
    23:46 True or False questions
    Uses TensorFlow (by Google) as backend. Includes,
    - load keras and EBImage packages
    - read images
    - explore images and image data
    - resize and reshape images
    - one hot encoding
    - sequential model
    - compile model
    - fit model
    - evaluate model
    - prediction
    - confusion matrix
    Image Classification & Recognition with Keras is an important tool related to analyzing big data or working in data science field.
    R is a free software environment for statistical computing and graphics, and is widely used by both academia and industry. R software works on both Windows and Mac-OS. It was ranked no. 1 in a KDnuggets poll on top languages for analytics, data mining, and data science. RStudio is a user friendly environment for R that has become popular.
    For citation in a research paper, use:
    Rai BK, (2019). “Advanced Deep Learning with R: Become an expert at designing, building, and improving advanced neural network models using R”, Packt Publishing, ASIN: B07ZFN5MXN.

Komentáře • 309

  • @flamboyantperson5936
    @flamboyantperson5936 Před 6 lety +18

    Awesome tutorial sir, you are going deeper into R and I just love it. Please keep making videos we really need you. Thank you so much.

  • @InfinitesimallyInfinite
    @InfinitesimallyInfinite Před 6 lety +1

    FANTASTIC! Thanks for providing such stuff for free. Really appreciate.

  • @YueHanBaoLin
    @YueHanBaoLin Před 4 lety +1

    Thank you very much Dr. Rai for all the effort in creating these very helpful tutorials.

    • @bkrai
      @bkrai  Před 4 lety

      Thanks for your comments!

  • @liwenli7873
    @liwenli7873 Před 3 lety +1

    Thank you! Wish you and your family stay well through this calamity.

    • @bkrai
      @bkrai  Před 3 lety

      Thanks and best wishes to you and family too!

  • @meshackamimo1945
    @meshackamimo1945 Před 3 lety +6

    This prof made me love R..he made me understand machine learning in a very simplified way..I shall forever stay grateful

    • @bkrai
      @bkrai  Před 3 lety

      Thanks for your nice comments!

  • @meshackamimo1945
    @meshackamimo1945 Před 3 lety +1

    There r intimidating topics like deep learning that I never wanted to touch...today,thanks to you, I am a pro.

  • @valor36az
    @valor36az Před rokem +1

    Amazing tutorial. Thank you so much for making this available to us .

    • @bkrai
      @bkrai  Před rokem

      You're very welcome!

  • @aritrachatterjee8057
    @aritrachatterjee8057 Před 6 lety +8

    Nice Tutorial. Small Edit, you can read multiple files by the following command,
    pics

    • @bkrai
      @bkrai  Před 6 lety

      Thanks for the suggestion!

  • @IrinaMax
    @IrinaMax Před 5 lety +2

    Thank you so much for the tutorial, very good example.

    • @bkrai
      @bkrai  Před 5 lety

      Thanks for comments!

  • @carolinemimeault3668
    @carolinemimeault3668 Před 4 lety +3

    Thank you Dr. Rai for the video. Very helpful. :)
    I am going back and forth to the different sections, so I thought I would add the time stamps below.
    I hope you like it and it is also helpful to others.
    Load Packages at 0:02
    Read Images at 0:29
    Explore at 4:08
    Resize at 6:16
    Reshape at 7:23
    Row Bind at 8:45
    One Hot Encoding at 11:49
    Create Model at 12:42
    Compile at 16:02
    Fit Model at 16:38
    Evaluation and Prediction (train data) at 18:49
    Evaluation and Prediction (test data) at 22:20
    True or False questions at 23:46

    • @bkrai
      @bkrai  Před 4 lety +2

      Thanks Caroline! I've added it to description area below this video.

  • @revenez
    @revenez Před 5 lety +1

    Very useful and informative, sir. Thank you!

    • @bkrai
      @bkrai  Před 5 lety

      Thanks for comments!

  • @bulletkip
    @bulletkip Před 4 lety +1

    another great tutorial, thank you.

    • @bkrai
      @bkrai  Před 4 lety

      Thanks for comments!

  • @theforester_
    @theforester_ Před 2 lety +1

    thanks for the tutorial! greetints from brazil

    • @bkrai
      @bkrai  Před 2 lety

      You are welcome!

  • @statisticalworld1133
    @statisticalworld1133 Před 4 lety +1

    Good job. Really Appreciated.

    • @bkrai
      @bkrai  Před 4 lety

      Thanks for comments!

  • @user-bq9rg3rg4q
    @user-bq9rg3rg4q Před 10 měsíci +1

    thanku sir very good explaination ...plz make videos on NLP as well

    • @bkrai
      @bkrai  Před 10 měsíci

      For text data related videos, refer to:
      studio.czcams.com/users/playlistPL34t5iLfZddt0tt5GdDy3ny6X5RQvwrp6/edit

  • @phantasy2874
    @phantasy2874 Před rokem

    Thanks so much, Sir. Can you make videos about using R with U-Net for semantic segmentation?

  • @MD-ub9nt
    @MD-ub9nt Před 4 lety

    excellet tutorial. I was wondering how can you make a class activation map (heatmap) from the tutorial you just made.

  • @fafeabo8681
    @fafeabo8681 Před 6 lety +1

    Thank you very much it is a good tutorial

    • @bkrai
      @bkrai  Před 6 lety

      Thanks for comments!

  • @victorhenostroza1871
    @victorhenostroza1871 Před 3 lety +1

    Thanks for all ur effort. With this code u can get 100% accuracy Sir.
    # Compiling model
    model %>%
    keras::compile(loss = 'binary_crossentropy',
    optimizer = 'adam',
    metrics = 'accuracy')
    # Ajusting model
    history %
    fit(trainx,
    trainLabels,
    epochs = 15
    batch_size = 32,
    validation_split = 0.2)
    plot(history)

    • @bkrai
      @bkrai  Před 3 lety

      Yes, it is relatively small data.

  • @jozefsavel730
    @jozefsavel730 Před 5 lety

    Hi is there any possibility to use more than just one variable as output in this or other NN packages?

  • @hammao
    @hammao Před 4 lety +1

    @Bharatendra Rai, you succeeded in making CNN very cool... thanks for the video. I followed the example and trust me i watch all the video several times just to get a hang of it. I feel you're the only one that has gone to lenght to explains what is actually happening in the layers. thanks for this.
    I have set of images from geology (1325 in total) belonging to 102 classes (groups). i was wondering how to handle this because physically typing the labels and dividing into test and train would take me forever. I was wondering if can recommend an easy way to handle this large data and read them in.

    • @bkrai
      @bkrai  Před 4 lety

      Thanks for comments!
      For reading several images you can refer to this link where all files in a folder are read easily:
      czcams.com/video/5bso_5X7Zu4/video.html

  • @jean-francoisboulet570

    Thank you Dr Rai.
    I am a beginner with treatment of image. I have a problem with array-reshape. This function stop the execution of the line. I have charge TensorFlow, Keras KerasR, reticulate. I also try using aperm without success. Could you help me ?

  • @WahranRai
    @WahranRai Před 2 lety +1

    what about transforming the images with 3 channels into grey images : the length of flatten input is reduced and may be performance

  • @abemartin2002
    @abemartin2002 Před 4 lety +1

    Thank you Doctor!

    • @bkrai
      @bkrai  Před 4 lety

      Thanks for comments!

  • @sandeep3879
    @sandeep3879 Před 3 lety +1

    Your videos are very informative👍, you could have used list.files and any of the apply list of functions to import multiple files

    • @bkrai
      @bkrai  Před 3 lety +1

      Thanks for the suggestion! For importing multiple files you can also refer to:
      czcams.com/video/5bso_5X7Zu4/video.html

  • @richardsmith9399
    @richardsmith9399 Před 3 lety +1

    Great video

    • @bkrai
      @bkrai  Před 3 lety

      Thanks for comments!

  • @prathamsonar2131
    @prathamsonar2131 Před 8 měsíci +1

    sir tussi great ho!!!!

  • @99chintu
    @99chintu Před 5 lety +1

    Thanks great video.

    • @bkrai
      @bkrai  Před 5 lety

      Thanks for comments!

  • @ZzUJayC
    @ZzUJayC Před 4 lety +1

    Sweet stuff ;)

  • @faceprofesor
    @faceprofesor Před 2 lety +1

    Awesome !!! Can this be used to discern between two types of fish?

    • @bkrai
      @bkrai  Před 2 lety +1

      Yes, definitely

  • @aingchhengngunn7431
    @aingchhengngunn7431 Před 5 lety +1

    Any suggestion of visualizing convolutional neural networks filter and model graph based Keras in R Studop platform?

    • @bkrai
      @bkrai  Před 5 lety

      Thanks for bringing this up, I'll look into this.

  • @biswarana4491
    @biswarana4491 Před 5 lety +1

    i am facing trouble loading tensorflow
    any suggestions

  • @theREstd
    @theREstd Před 6 lety +1

    Hello Sir,
    Its a really nice tutorial. Can you please tell me what do we do for a multiple image classification problem??
    Thanks

    • @bkrai
      @bkrai  Před 5 lety

      This tutorial is for one image in a picture only.

  • @ashishkamboj009
    @ashishkamboj009 Před 5 lety

    I'm getting below error while reading the images-
    Error in readJPEG(x, ...) :
    JPEG decompression error: Not a JPEG file: starts with 0x89 0x50
    As I have all the images in JPEG format but when I used the image_read() function from the magick package, I found that some of the images having PNG format.
    So, How to find all those images where there is a change in extension? Also, how to convert these type of images in pixel format?

  • @hongquan9x
    @hongquan9x Před rokem

    Once completed with training and testing, how to predict a new image? is this corrected: model %>% predict_classes("link_newimage.jpg") ? Do we need to resize and reshape the new image before prediction? I faced several error regarding this step. i.e, Error in py_call_impl(callable, dots$args, dots$keywords)

  • @ekwallace10
    @ekwallace10 Před 4 lety +1

    Thank you so much for a great tutorial! I am currently working with a large dataset of images (around 30,000 images). How could I make a list like you did under 'pics' easily without listing all of the filenames? Thank you!

    • @bkrai
      @bkrai  Před 4 lety +3

      You can find an example here:
      czcams.com/video/5bso_5X7Zu4/video.html

  • @Benmoshe0
    @Benmoshe0 Před 6 lety +1

    Thx sir ! (use purrr ou lapply family for looping)

    • @bkrai
      @bkrai  Před 6 lety

      Thanks for the suggestion!

  • @Felixinhk08
    @Felixinhk08 Před 3 lety +2

    Thanks for the great tutorial. Can I use Keras for identifying tree species just using leaf? How do I separate the image of leaf from the background?

    • @bkrai
      @bkrai  Před 3 lety +2

      Yes, you can. Note that you will have to prepare images beforehand.

    • @Felixinhk08
      @Felixinhk08 Před 3 lety +1

      @@bkrai how to prepare those images using R? Is there a package that could seperate the background and the item that I want to identify? Thanks a lot.

    • @bkrai
      @bkrai  Před 3 lety +1

      I'll look into it.

  • @fowobajek
    @fowobajek Před 4 lety +2

    Excellent tutorial. Please i have issues installing EBImage package on my R 3.6.0 version. Any suggestions?

    • @bkrai
      @bkrai  Před 4 lety +2

      Try this:
      To install EBimage package, you can run following 2 lines;
      install.packages("BiocManager")
      BiocManager::install("EBImage")

  • @flamboyantperson5936
    @flamboyantperson5936 Před 6 lety +1

    Sir I have a request please do a video on Naive Bayes classifier on any data and please also teach little theory before the video so we can understand it and explain it to others. Thank you sir.

  • @sahingurol7510
    @sahingurol7510 Před 5 lety +1

    Hi Rai
    Can you also make a video about h2o package.. espacially for the automl function.. and share your comments about if it is succesfull or not

    • @bkrai
      @bkrai  Před 5 lety

      Thanks for the suggestion! I have added it to my list.

  • @MD-ub9nt
    @MD-ub9nt Před 4 lety +1

    thank you for your tutorial. It works perfectly, however, when I increase the resolution of the pictures you provided (50x50, 75x75, etc...) it doesnt seem to work. I have changes the resolution in both resize and reshape. When I use resolution similar to the one you provided (29x29 or 27x27) it does seem to work (it says the accurary is 0.5, flipping a coin, esencially). How is this possible?

    • @bkrai
      @bkrai  Před 4 lety

      Make sure training data do not have same type of images in a sequence.

  • @francisowino6985
    @francisowino6985 Před 4 lety +1

    please make a video on how to use the shiny package to develop an app for sentimental anaysis

    • @bkrai
      @bkrai  Před 4 lety +1

      Thanks for the suggestion, I've added it to my list.

  • @sugandhkumar3512
    @sugandhkumar3512 Před 4 lety +2

    Dear Sir, Can you prepare a tutorial on the whole slide image analysis. That will be more beneficial.

    • @bkrai
      @bkrai  Před 4 lety

      Thanks, I've added this to my list.

  • @njbuitragoa
    @njbuitragoa Před 6 lety

    Professor Bharatendra, I would like to inquire you how can I put another kind of metric, namely, log loss function or another one. This is due to metrics=c("categorical_accuracy") is not working very well and it seems that I obtained for a multiclass problem an imbalanced classes problem for a set of images with the same quantity of elements for each class. Thank you in advance for your answer.

    • @bkrai
      @bkrai  Před 6 lety

      Did you try: metrics = c('accuracy')

  • @cosimotuena6597
    @cosimotuena6597 Před 4 lety +1

    Dear Dr Rai
    Many thanks this is very helpful. However if when I tried to replicate your example I get error for the history object and consequently on the "evaluation and prediction" because there is an issue with py_call_impl(callable, dots$args, dors$keywords): input arrays should have the same number of samples as target arrays. Found 5 input samples and 10 target samples.
    Any cues to solve this?
    Thanks!

    • @bkrai
      @bkrai  Před 4 lety

      There is a mismatch between target values (10 data points) and input (5 data points).

    • @cosimotuena6597
      @cosimotuena6597 Před 4 lety

      Many thanks! I solved and I managed to run the script however sometimes I ve got issue with 1 0 coding. If I check the predicted actual matrix I gives me, apparently randomly, only one row(ie accuracy is 50% cause predict only one class). Any clues? Best Regards!

  • @saswatabiswas
    @saswatabiswas Před 6 lety +1

    An amazing tutorial sir. It was really helpful. Sir can I connect you on LinkedIn ?

  • @bankingnews862
    @bankingnews862 Před 5 lety

    Can u tell the code to read thousands of images using EBImage package instead of importing one by one? Thanks in advance sir.

  • @adarmawan5393
    @adarmawan5393 Před rokem +1

    Awesome tutorial Dr. Rai. Thank you. It was inspire me a lot. Today I have tried to follow, but I am still facing problem --> Error: Python module tensorflow.keras was not found. I have try to re-install tensorflow and karas, but still same.

    • @bkrai
      @bkrai  Před rokem

      If you are using Mac, try this:
      czcams.com/video/-IYYqdxdYXk/video.html

  • @RahulKumar-ld1io
    @RahulKumar-ld1io Před 4 lety +1

    Sir, after the command
    trainLabels

    • @bkrai
      @bkrai  Před 4 lety

      I don't see any error in this specific line. Probably error is somewhere earlier and the effect is seen here.

  • @saimohan4717
    @saimohan4717 Před 4 lety +1

    Sir, after the command
    trainLabels

    • @bkrai
      @bkrai  Před 4 lety

      I would suggest to download and install 64bit version of R.

  • @irfanshaik2301
    @irfanshaik2301 Před 6 lety

    Hii sir,
    display(mypic[[1]])
    Error in UseMethod("display", x) :
    no applicable method for 'display' applied to an object of class "c('Image', 'array', 'structure', 'vector')"

    • @bkrai
      @bkrai  Před 6 lety

      check if you ran EBImage library or not

  • @marcomichelini8444
    @marcomichelini8444 Před 4 lety +1

    Awesome tutorial! But I got stuck at min 12:31 because R tells me: Error in to_categorical(testy) : could not find function "to_categorical"

    • @bkrai
      @bkrai  Před 3 lety

      See if this helps:
      czcams.com/video/-IYYqdxdYXk/video.html

  • @ollycizilio1651
    @ollycizilio1651 Před 4 lety

    Error in py_call_impl(callable, dots$args, dots$keywords) :
    ValueError: A target array with shape (10, 1) was passed for an output of shape (None, 2) while using as loss `binary_crossentropy`. This loss expects targets to have the same shape as the output

  • @riyahedaoo2753
    @riyahedaoo2753 Před 2 lety +1

    Sir, why did you used 28 for resizing ? What other sizescan be used for best result? On what basis do we choose the size?

    • @bkrai
      @bkrai  Před 2 lety +1

      Since this is just for illustration, I used small size so that it runs faster. But there is no such requirement, you can use any other size.

    • @riyahedaoo2753
      @riyahedaoo2753 Před 2 lety +1

      @@bkrai Okay Thanks!

  • @mymessage11
    @mymessage11 Před 3 lety +1

    Thank you .
    Btw, If we have for example more than 12 pictures, ( consider 5000), then how we can assign them in pics?
    pics

    • @bkrai
      @bkrai  Před 3 lety

      You can refer to this for reading any number of image files from a folder:
      czcams.com/video/5bso_5X7Zu4/video.html

  • @Abhishek-wp9xu
    @Abhishek-wp9xu Před 5 lety +1

    sir while executing to_categorial function of keras library i am getting error as pythan module keras not found. but i have installed keras library in R already. so plz give me solution over it.

    • @bkrai
      @bkrai  Před 5 lety

      Make sure after installing you also run the library line.

  • @renjiisac2305
    @renjiisac2305 Před 5 lety +1

    When I try using #Reshape
    I get this error: Error in initialize_python(required_module, use_environment) :
    Installation of Python not found, Python bindings not loaded.

    • @drgones545
      @drgones545 Před 5 lety

      you must be install Anaconda and run rstudio form there. Check this link :github.com/rstudio/keras/issues/649

  • @gayathri.nagarajan
    @gayathri.nagarajan Před 3 lety +1

    to_categorical is throwing an error for me "Error in install_tensorflow() :
    could not find function "install_tensorflow". Can you let me know how to proceed ?

    • @bkrai
      @bkrai  Před 3 lety

      You can try this:
      czcams.com/video/-IYYqdxdYXk/video.html

  • @BogdanAnastasiei
    @BogdanAnastasiei Před 3 lety +1

    Does mypic need to be a list? Can we define it as a data frame as well? Thanks.

    • @bkrai
      @bkrai  Před 3 lety +1

      I've not tried, but see if it works.

  • @wandanoviana2949
    @wandanoviana2949 Před 4 lety +1

    I do not understand the section on how to create populations for cars and planes 1 through 6 and then stored in what form so that when called "setwd" runs. Please help sir,thank you...

    • @bkrai
      @bkrai  Před 4 lety

      See if this link helps answer your question where we read several image files:
      czcams.com/video/5bso_5X7Zu4/video.html

  • @gayathri.nagarajan
    @gayathri.nagarajan Před 3 lety +1

    Sir, Iam getting an error when fitting model (16:38) " ValueError: Dimensions must be equal, but are 4 and 2 for '{{node binary_crossentropy/mul}} ". Iam using this for a data set of say 5 records . 3 training and 2 testng records where variable to be predicted is binary ( has values 0 to 4). ANy insights on which dimensions could be incorrect?

    • @bkrai
      @bkrai  Před 3 lety

      If your response has values from 0 to 4, it will be incorrect to use binary. Binary is for response with only 2 values.

    • @gayathri.nagarajan
      @gayathri.nagarajan Před 3 lety +1

      Oh I see...then how do we perform model and classification for this kind sir?

    • @bkrai
      @bkrai  Před 3 lety

      For more than 2 classes you can refer to this:
      czcams.com/video/5bso_5X7Zu4/video.html

    • @gayathri.nagarajan
      @gayathri.nagarajan Před 3 lety

      @@bkrai Thank you Sir..I will use this for my images and check

    • @bkrai
      @bkrai  Před 3 lety

      Thanks for the update!

  • @maddy14390
    @maddy14390 Před 5 lety +1

    how can this code be modified to classify more than 2 categories of images? Like, I have 6 classes of images and need to classify any new image to be among any 1 of the 6 categories.
    Also, I am not able to use the keras package as it is showing me "Error: Python module keras was not found." whereas I have it installed in my python environment.
    Can you help me in this as i need to understand this code and work on my thesis?
    Thankyou

    • @bkrai
      @bkrai  Před 5 lety

      You can try this link:
      czcams.com/video/LxTDLEdetmI/video.html

    • @bkrai
      @bkrai  Před 5 lety

      In addition for more complete coverage, you can use following playlist:
      czcams.com/play/PL34t5iLfZddtC6LqEfalIBhQGSZX77bOn.html

    • @maddy14390
      @maddy14390 Před 5 lety +1

      Thank you Sir. Glad to study through your videos. Neural networks look like a piece of cake now.

    • @bkrai
      @bkrai  Před 5 lety

      Thanks for your comments!

  • @BogdanAnastasiei
    @BogdanAnastasiei Před 3 lety +1

    Hello... I'm back with a serious problem. I cannot use the array_reshape function. First, I had to install the retculate package, because the program told me that this function is part of the reticulate package, not keras (??). But even after installing reticulate, I got the following error for when executed the array_reshape function:
    Error in py_call_impl(callable, dots$args, dots$keywords) :
    Evaluation error: Required version of NumPy not available: numpy.core.multiarray failed to import.
    What could that be? Thank you very much!

    • @bkrai
      @bkrai  Před 3 lety

      Probably try this:
      czcams.com/video/-IYYqdxdYXk/video.html

  • @sonalikapanda8398
    @sonalikapanda8398 Před 6 lety +1

    Hello Sir.EBImage Package is not getting installed for 3.4.3R Version.Kindly suggest.

    • @bkrai
      @bkrai  Před 6 lety

      If you not installed EBImage package yet, then you can make use of following link:
      czcams.com/video/dKgEDAUUtoo/video.html

    • @muditsingh4468
      @muditsingh4468 Před 6 lety

      use this code:
      source("bioconductor.org/biocLite.R")
      biocLite()
      biocLite(c("GenomicFeatures", "AnnotationDbi"))
      biocLite("EBImage")
      library(EBImage)

  • @stefanus_christian
    @stefanus_christian Před 5 lety +1

    Thankyou so much for the tutorial. It really help me understand about Keras in R. But, while i'm trying to practicing the code, i got an error on fit model. The error is " Error in py_call_impl(callable, dots$args, dots$keywords) :
    ValueError: Error when checking target: expected dense_3 to have shape (2,) but got array with shape (1,)" can you help me to understand the problem? Thanyou so much!

    • @bkrai
      @bkrai  Před 5 lety

      I saw your message now. I hope by now you figured it out.

  • @cinderellameilani6261
    @cinderellameilani6261 Před 4 lety +1

    i've problem with tensorflow, how to install tensorflow in R on macbook? Thank you sir

    • @bkrai
      @bkrai  Před 4 lety

      You can use following code:
      install.packages("tensorflow")
      library(tensorflow)
      install_tensorflow()

  • @shivadarshans3409
    @shivadarshans3409 Před 4 lety +1

    Hii sir.
    I understood everything u said in this vedio thank u nice vedio sir
    But how can we update this for multi class image classification
    Once again thank u

    • @bkrai
      @bkrai  Před 4 lety

      You can refer to this link for multi class:
      czcams.com/video/5bso_5X7Zu4/video.html

    • @shivadarshans3409
      @shivadarshans3409 Před 4 lety +1

      @@bkrai thank u sir

    • @bkrai
      @bkrai  Před 4 lety

      Welcome!

  • @ubelyildmar2368
    @ubelyildmar2368 Před 3 lety

    Awesome video, Thank you. I still cannot install EBImage :(
    Package which is only available in source form, and may need
    compilation of C/C++/Fortran: ‘EBImage’

    • @bkrai
      @bkrai  Před 3 lety +2

      To install EBimage package, you can run following 2 lines;
      install.packages("BiocManager")
      BiocManager::install("EBImage")

    • @ubelyildmar2368
      @ubelyildmar2368 Před 3 lety

      @@bkrai thank you so much. These two lines gave me the error above.

  • @badrinathkrish4661
    @badrinathkrish4661 Před 5 lety

    need help I cannot run the library keras and EbImage.... Is there any other requirements for this?

    • @bkrai
      @bkrai  Před 5 lety

      For installing keras, refer to this link:
      czcams.com/video/hd81EH1g1bE/video.html

  • @2coolge
    @2coolge Před 6 lety

    running that code "for(i in 1:12) {mypic[[i]]

    • @bkrai
      @bkrai  Před 6 lety

      Make sure you run library(keras) after installing keras package.

    • @2coolge
      @2coolge Před 6 lety +1

      getting this error now , Error in py_module_import(module, convert = convert) :
      ModuleNotFoundError: No module named 'numpy

  • @venustat
    @venustat Před 6 lety +1

    Good One..
    trainLabels< to_categorical(trainy)
    Error: object 'trainLabels' not found.. How to solve this

  • @chriss7771
    @chriss7771 Před 5 lety

    Any idea why I am getting Error in transpose(y) : object is NULL when running for loop readImage(pics[i])

    • @Abhishek-wp9xu
      @Abhishek-wp9xu Před 5 lety

      either u have not installed EBimage package or just execute library(EBimage) line before executing for loop.

  • @Felixinhk08
    @Felixinhk08 Před 3 lety +1

    Instead of using binary, I got multiple categories, which loss function should I use?

    • @bkrai
      @bkrai  Před 3 lety +1

      You can refer to this where we have 10 categories:
      czcams.com/video/5bso_5X7Zu4/video.html

  • @selvavigneshm6266
    @selvavigneshm6266 Před 4 lety +1

    Sir the EBImage package is not coming for version 3.6..pls help me

    • @bkrai
      @bkrai  Před 4 lety

      To install EBimage package, you can run following 2 lines;
      install.packages("BiocManager")
      BiocManager::install("EBImage")

  • @MAbdullah47
    @MAbdullah47 Před 6 lety +1

    Thank you, sir, for this video I did it based on your code but it gives me 50% accuracy with exactly the same code you post in the video, how this coming? how can we re-modify the model to reach the best accuracy?

    • @woutertwo
      @woutertwo Před 6 lety +2

      Use [sigmoid] instead of [softmax] in output layer. Worked for me.

    • @99chintu
      @99chintu Před 5 lety

      @@woutertwo thanks sigmoid worked for me

  • @hapvideolar7957
    @hapvideolar7957 Před 2 lety

    Thanx for share Sir,
    I am getting
    "Error in unique.default(x, nmax = nmax) :
    unique() applies only to vectors
    "
    What could be a solution for me sir?

    • @uchekalu7725
      @uchekalu7725 Před 2 lety +2

      Use pipe operator to add as.numeric() to k_argmax
      As in
      k_argmax %>% as.numeric()

    • @hapvideolar7957
      @hapvideolar7957 Před 2 lety

      @@uchekalu7725 Hello, thanks for help. Here is my related code:
      "
      #evaluation & prediction -traindata
      model %>% evaluate(trainx, trainLabels)
      pred % predict(trainx) %>% k_argmax() #pred % predict(trainx)
      pred
      table(Predicted = pred, Actual = trainy)
      prob % predict(trainx)#prob % predict_proba(trainx) #prob % predict()
      prob
      cbind(prob, Prected = pred, Actual= trainy)
      " could you write the correct code?

    • @uchekalu7725
      @uchekalu7725 Před 2 lety +2

      @@hapvideolar7957
      #Evaluation: model %>% evaluate(trainx, trainLabels)
      #Prediction: pred % predict(trainx) %>% k_argmax() %>% as.numeric()
      #ConfusionMatrix: table(Predicted = pred, Actual = trainy)
      prob % predict(trainx)
      cbind(prob, Predicted = pred, Actual = trainy)
      Hope this helps.

    • @hapvideolar7957
      @hapvideolar7957 Před 2 lety

      @@uchekalu7725 yes, thx. I had already solved thx 2 u that day you replied first.

    • @hapvideolar7957
      @hapvideolar7957 Před 2 lety

      It works out

  • @tulsipatro4662
    @tulsipatro4662 Před 4 lety +2

    Sir..I am getting an error in the function "to_categorical" saying that it could not find the function

    • @BilalHussain-md2ch
      @BilalHussain-md2ch Před 4 lety +2

      Try this, worked for me. :)
      -- Install these:
      install.packages("BiocManager")
      BiocManager::install("EBImage") #EBImage isn't supported in latest R, so this...
      install.packages("keras")
      install.packages("tensorflow")
      library("EBImage")
      library("keras")
      library("tensorflow")
      install_tensorflow() #install for to_categorical()
      -- After installation is complete, it shows restarting session and gets stuck there... Manually restart RStudio, load those three libraries and run the rest of the code.
      Also, alternatives to to_categorical:
      Package CatEncoders, OneHotEncoder (same as Python scikit-learn).
      Package caret, function dummyVars.

    • @bkrai
      @bkrai  Před 4 lety +1

      Thanks for the update!

    • @Felixinhk08
      @Felixinhk08 Před 3 lety

      @@BilalHussain-md2ch I have tried your method but it still doesn't work:
      Error: Python module tensorflow.keras was not found.
      Detected Python configuration:
      python: C:/Users/b145065/AppData/Local/r-miniconda/envs/r-reticulate/python.exe
      libpython: C:/Users/b145065/AppData/Local/r-miniconda/envs/r-reticulate/python36.dll
      pythonhome: C:/Users/b145065/AppData/Local/r-miniconda/envs/r-reticulate
      version: 3.6.12 |Anaconda, Inc.| (default, Sep 9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)]
      Architecture: 64bit
      numpy: C:/Users/b145065/AppData/Local/r-miniconda/envs/r-reticulate/Lib/site-packages/numpy
      numpy_version: 1.19.1

    • @robertt396
      @robertt396 Před 3 lety

      @@Felixinhk08 You need to run this line and then restart R, then take the line out and try it :) :
      install_tensorflow()

  • @arzumkizilelma3150
    @arzumkizilelma3150 Před 3 lety +1

    what can i use as a binary_crossentropy? I have 4 response variables. It's urgent please help.

    • @bkrai
      @bkrai  Před 3 lety

      categorical_crossentropy()

    • @bkrai
      @bkrai  Před 3 lety

      You can also refer to this:
      czcams.com/video/5bso_5X7Zu4/video.html

  • @me3jab1
    @me3jab1 Před 4 lety +1

    Sir , PLease I have one question : deep Learning Process in r I mean if you want to case study whats it the process , step by step

    • @bkrai
      @bkrai  Před 4 lety +1

      You can find some case studies here:
      czcams.com/play/PL34t5iLfZddtC6LqEfalIBhQGSZX77bOn.html

    • @me3jab1
      @me3jab1 Před 4 lety +1

      @@bkrai yes I already followed your videos as I understand :
      1-Load Data.
      2-Define Keras Model.
      3-Compile Keras Model.
      4-Fit Keras Model.
      5-Evaluate Keras Model.
      6-Tie It All Together.
      7-Make Predictions

    • @bkrai
      @bkrai  Před 4 lety +1

      Perfect!

  • @jodiewarren
    @jodiewarren Před 3 lety +1

    Hello, first of all thank you for making this tutorial! I am very new to R and machine learning, and this tutorial has really helped me to understand each of the steps. I am however coming up against an error regarding the input, and wondered if you had and suggestions?
    when I use:
    history %
    fit(trainx,
    trainLabels,
    epochs = 30,
    batch_size = 32,
    validation_split = 0.2)
    I get this error:
    ValueError: Input 0 of layer sequential_10 is incompatible with the layer: expected axis -1 of input shape to have value 2352 but received input with shape [None, 20, 1]
    *'sequential_10' is the name of the model in Kaggle I believe
    For some reason I wasn't able to get tensorflow to work in R on my laptop (despite trying lots of different methods for 2 weeks), and so I am using a combination of R and a Kaggle Notebook using R script. I am doing the first steps (importing images, reshaping, binding) in R, then exporting 'trainx' and 'testx' as csv files, then loading those into Kaggle... is this where I am going wrong? I am using planes vs cars images, and I don't see any errors in the previous lines of code. Searching this error online hasn't proved to solve the situation yet either

    • @bkrai
      @bkrai  Před 3 lety

      The main issue is "expected input shape to have value 2352 but received input with shape [None, 20, 1]"
      You need to fix this.

    • @jodiewarren
      @jodiewarren Před 3 lety +1

      @@bkrai Hi, I have solved this, thank you!

    • @bkrai
      @bkrai  Před 3 lety

      Thanks for the update!

    • @jodiewarren
      @jodiewarren Před 3 lety

      @@bkrai Hello again! Would you please be able to tell me if this is a feedforward or feedback/recurrent NN?

  • @Mohib283
    @Mohib283 Před 6 lety

    when i use: trainLabels

    • @bkrai
      @bkrai  Před 6 lety

      keras package that I used in the video is version 2.1.2. The one you installed is version 1.2.0 which is too old. I would suggest you install it again.

  • @hamadsaeed1481
    @hamadsaeed1481 Před 5 lety

    I got a problem with array_reshape, it tell me getting error Error in initialize_python(required_module, use_environment) :
    Installation of Python not found, Python bindings not loaded.
    I run keras and I run EBImage but the problem is still there
    im trying to reach you and send you my codes, but I couldn't find ur contact.

    • @bkrai
      @bkrai  Před 5 lety

      Probably issue with keras installation. Try this link before image recognition video:
      czcams.com/video/hd81EH1g1bE/video.html

  • @Yadofficial
    @Yadofficial Před 4 lety +1

    Sir i am get an error
    Error: object 'trainLabels' not found

    • @bkrai
      @bkrai  Před 4 lety

      Probably you missed running a previous line

  • @vjysri2756
    @vjysri2756 Před 4 lety +1

    I would like to train images against matrices as respponse variables, can you please help with the code

    • @bkrai
      @bkrai  Před 4 lety

      What kind of matrices are these?

    • @vjysri2756
      @vjysri2756 Před 4 lety

      A matrix containing single row and 6 columns.

    • @vjysri2756
      @vjysri2756 Před 4 lety

      Or can we train matirx against another matrix with both matrices containing [1 row * 6 columns]. Thanks

  • @yatharththakur6858
    @yatharththakur6858 Před 5 lety

    Bharatendra Rai error in one hot encoding
    Error in modules$keras.utils$to_categorical(y = int32(y), num_classes = num_classes) :
    attempt to apply non-function
    > testLabels

  • @BogdanAnastasiei
    @BogdanAnastasiei Před 3 lety +1

    Unfortunately, it does not work. The keras_model_sequential function does not work. It gives an error: the module keras.tensorflow was not found. I have tried everything: the functions install_keras(), instal_tensorflow() and so on - no result. Please tell me, there are some technical conditions that you don't specify in the video? Do you need to have installed Anaconda, Python?... Which versions? I have installed Anaconda, tried to activate the environment etc. etc. but useless. it seems that I cannot make keras work on my machine. Could someone help? Thanks.

    • @bkrai
      @bkrai  Před 3 lety

      Check this link:
      czcams.com/video/-IYYqdxdYXk/video.html

  • @Felixinhk08
    @Felixinhk08 Před 3 lety +1

    I don't understand why the batch size is 32? What does it mean?

    • @bkrai
      @bkrai  Před 3 lety

      Here the data is too small. If the batch size specified is larger than the data size, essentially all samples in the data will be used.

  • @krissawoodring1750
    @krissawoodring1750 Před 4 lety +1

    Great tutorial.. but having a lot of issues with memory. After trying to train the model I get 'Error in py_call_impl(callable, dots$args, dots$keywords): ResourceExhaustedError: OOM when allocating tensor...' Anyone else have this issue or know how to solve it?

    • @bkrai
      @bkrai  Před 4 lety

      If you already have any data or similar file open that you are not using, I would suggest close it and try again.

  • @viewbeforevisit6824
    @viewbeforevisit6824 Před 5 lety +2

    Sir Iam getting the error at encoding that is Error in to_categorical(trainy):could not find function to_categorical

    • @bkrai
      @bkrai  Před 5 lety

      Make sure you have run library(keras).

    • @viewbeforevisit6824
      @viewbeforevisit6824 Před 5 lety

      @@bkrai sir I have runned keras in separate sessionR also,but it again showing Python.keras not found nd sometime it showing to_categorical function not found

    • @bkrai
      @bkrai  Před 5 lety

      That means keras is not installed.

    • @viewbeforevisit6824
      @viewbeforevisit6824 Před 5 lety

      @@bkrai k tq sir..I want small information sir..is there any package to open our webcam?.how to take pics and then compare it in r language ..

  • @ankurpatel1809
    @ankurpatel1809 Před 4 lety +2

    can i resize the images without naming them manually? i need to resize 400 images)

    • @bkrai
      @bkrai  Před 4 lety

      This link provides steps to read any number of images from a directory.

  • @viewbeforevisit6824
    @viewbeforevisit6824 Před 5 lety

    Sir Iam getting an error while reading pics to my pic at the line for(i in 1:12){my pic[[i]]

    • @bkrai
      @bkrai  Před 5 lety

      Check the folder where you have pictures and make sure it only has pictures.

    • @viewbeforevisit6824
      @viewbeforevisit6824 Před 5 lety

      @@bkrai tq sir it solved ..I have not mention file format for the pic names ..tq sir

  • @user-nj7vr6ps4f
    @user-nj7vr6ps4f Před 5 lety

    when i run the code, the following error occur.
    > model %>%
    + layer_dense(units = 256, activation = 'relu', input_shape = c(2352)) %>%
    +
    + layer_dense(units = 128, activation = 'relu') %>%
    +
    + layer_dense(units = 2, activation = 'softmax')
    Error in eval(lhs, parent, parent) : object 'model' not found
    > summary(model)
    Error in summary(model) : object 'model' not found
    can you help me?

    • @99chintu
      @99chintu Před 5 lety

      have you declared the model object i.e model

  • @ajaysingh-gj2eo
    @ajaysingh-gj2eo Před 5 lety +1

    Sir I want to know more about binary_ cross entropy??

    • @bkrai
      @bkrai  Před 5 lety

      Try this for a good explanation: goo.gl/8CeqaR

  • @joeltharian
    @joeltharian Před 5 lety

    @bharatendra rai sir, I am getting an error: > history %
    + fit(trainx,
    + trainLabels,
    + epochs = 30,
    + batch_size = 32,
    + validation_split = 0.2)
    Error in py_call_impl(callable, dots$args, dots$keywords) :
    ValueError: Input arrays should have the same number of samples as target arrays. Found 5 input samples and 10 target samples.

    • @bkrai
      @bkrai  Před 5 lety

      It says "Found 5 input samples and 10 target samples." Make sure to use proper number of units.

    • @joeltharian
      @joeltharian Před 5 lety

      @@bkrai proper number of units where exactly sir?

    • @bkrai
      @bkrai  Před 5 lety

      What codes have you used under # Model and # Compile?

    • @joeltharian
      @joeltharian Před 5 lety

      @@bkrai # Model
      model %
      layer_dense(units = 256, activation = "relu", input_shape = c(2352)) %>%
      layer_dense(units = 128, activation = 'relu') %>%
      layer_dense(units = 2, activation = "softmax")
      summary(model)
      # Compile
      model %>%
      compile(loss = "binary_crossentropy",
      optimizer = optimizer_rmsprop(),
      metrics = c('accuracy'))

    • @bkrai
      @bkrai  Před 5 lety

      This also looks right.
      Next I would suggest check line-27 from the video. Note that first I read 1 to 5 pictures and then from 7 to 11. This way there were totally "10 input samples".

  • @coolghoul9
    @coolghoul9 Před měsícem +1

    any chance of updated version of this

    • @bkrai
      @bkrai  Před měsícem

      I'm exploring updating this and other deep learning videos. Hopefully I'll be able to start later this month.

  • @muhammadaqil5432
    @muhammadaqil5432 Před 2 lety

    i have just follow your tutrial amd retrain your data but i got error on fitting model...as follows
    Error in py_call_impl(callable, dots$args, dots$keywords) :
    ValueError: in user code:
    File "C:\Users\LENOVO\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\keras\engine\training.py", line 1021, in train_function *
    return step_function(self, iterator)
    please help me to complete my trial...thanks

  • @ohvenky
    @ohvenky Před 5 lety

    Suppose I want to load 10000 images then what to do and for that 10k images how can I give 1 & 0 codes

    • @bulletkip
      @bulletkip Před 4 lety

      you would have to have your pictures already identified as one thing or the other so the model can train on it. there are probably some datasets on the web!

  • @yatharththakur6858
    @yatharththakur6858 Před 5 lety

    error in one hot encoding
    Error in modules$keras.utils$to_categorical(y = int32(y), num_classes = num_classes) :
    attempt to apply non-function
    > testLabels

  • @Neerajkumar-tv4yo
    @Neerajkumar-tv4yo Před 5 lety

    sir can you tell version of your r in which you did this code