Image Classification with Neural Networks in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ค. 2020
  • In this tutorial we are going to use neural networks in order to classify images and recognize what they are representing.
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    💻 The Algorithm Bible Book: www.neuralnine.com/books/
    🐍 The Python Bible Book: www.neuralnine.com/books/
    👕 Programming Merch: www.neuralnine.com/shop
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine.com/
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/NeuralNine
    🖥️ My Coding Setup 🖥️
    ⌨️ Keyboard: hyperurl.co/neuralkeyboard
    🖱️ Mouse: hyperurl.co/neuralmouse
    🖥️ Monitor: hyperurl.co/neuralmonitor
    🎙️ Microphone: hyperurl.co/neuralmicrophone
    ✏️ Drawing Tablet: hyperurl.co/neuraldraw
    🎵 Outro Music From: www.bensound.com/
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @victoriawagman7183
    @victoriawagman7183 3 ปีที่แล้ว +2

    Lovely tutorial, thank you! 👍🏽

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

    I was working on a CNN for image classification but I couldn't wrap my head around after training the model, how to actually get the specific image classification on a random image from online. I was stuck on this issue for hours until your step-by-step video explained it perfectly and I finally got my model to output image labels after classifying. Thank you so much for this video!

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

      Plz send me the code

    • @Khubaiblj
      @Khubaiblj 6 หลายเดือนก่อน +1

      Do u have the video m

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

    Very well explained the use of keras library.

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

    Thanks for helping me with my thesis !

  • @fantasmy7129
    @fantasmy7129 3 ปีที่แล้ว +2

    Hello! Thanks for the tutorial, it's really cool.
    Nevermind, fixed it hahaha
    Thanks!

  • @SHREYASPATEL-wh1ki
    @SHREYASPATEL-wh1ki 8 หลายเดือนก่อน

    Hello sir actually I wanted to know that is there any another method for pattern recognition from image except cnn , if yes then please tell me how many algorithms are there?

  • @aymenbenrhouma4678
    @aymenbenrhouma4678 3 ปีที่แล้ว +17

    sir thank u for this tutirial but would u do a video how to create your own model classifier by adding your own images

  • @KaijaKFanpages
    @KaijaKFanpages 18 วันที่ผ่านมา +1

    I think this was an EXCELLENT tutorial and I definitely will use the treasures that you gave on this difficult topic!
    I wish you had gone over the data that you were using I little bit more in detail and stated how you have to adjust the convoluted2D layers, because of the size difference of the images. In your example you used 32 pixel x 32 pixel Cifar10 dataset, but how does this change, if your input_shape is more complex ie. trying to classify whether there is an apartment building OR a detached house in a certain address => even my thumbnails that I am trying to classify are more complex 400 pixels x 400 pixels pictures and I do not want to make them smaller, because I am afraid that I would lose some features that make them more recognizable (although a very quick rule of a thumb would be the amount of asphalt and grass; lot of asphalt > an apartment building, lot of grass a detached house with its own garden).
    So evidently I am increasing my input_shape to match the size of my images, but how does that reflect the size of the convoluted 2D layers, do I need one that is exactly the size of my image 400 and three that are twice as large 800?

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

    Great tutorial!

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

    Clearly explained!

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

    Best-One!! Amazing :)

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

    Awesome tutorial

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

    This is great, but how can we do opposite, like feeding name to the trained model and it will generate a random image for us , just like MidJourney.
    Any suggestions?

  • @woonie3134
    @woonie3134 3 ปีที่แล้ว +2

    How can u extract the label of a classified image when working with a large dataset? I would like to classify food image and recommend recipes based on the label identified but I am not understanding how to do this. I WOULD kindly ask a tutorial on this matter. There is barely information on food related projects plz

  • @SwarupMazumder
    @SwarupMazumder 3 ปีที่แล้ว +13

    Thank you. If the dataset isn't inside of Keras, in other words, if my dataset is in my local drive how can I import the training_images?

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

      from keras.datasets import cifar10

  • @RomIlay
    @RomIlay 3 ปีที่แล้ว +2

    Is there a way to add an anomaly case to such classifications?

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

    Great video but how do I label the images if i don't know the order of images? How to identify the label name from label number value?

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

    thank you for this tutorial, really helpful but i was wondering how long does it take to run this code?

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

    i hope you do the same for text, for example try to check if a book translated Ok by raining the model on good translation of the same book. Kind of correcting the second translation

  • @pranaytiwari9204
    @pranaytiwari9204 4 ปีที่แล้ว +10

    Awesome tutorial, you explains so awesome, can you make a tutorial to create a chatbot using nlp

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

      Its on my list! Thank you! :)

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

      @@NeuralNine i will wait.🙏🙏😊😊

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

      @@NeuralNine hello dear friend
      Can i use camera to identify the object in thiscode.but the predict() function cant work within a while loop

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

    先赞后看!!!thank you!!

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

    Sir can we see something like NN in native python IDKY but making this in tensorflow doesnt satisfy me IDKY

  • @photogyulai
    @photogyulai 5 หลายเดือนก่อน +4

    Thanks. Your videos, topics are relevant, your teaching style is great. But please dont torture your viewers, with this low contrast and small text !

  • @magesticmushroomgarden6914
    @magesticmushroomgarden6914 วันที่ผ่านมา

    i think it would have helped if you had showed us all packages and their versions in your virtual env
    because i am getting a lot of dependency errors

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

    Activate main didn't work. It's not found , what should i do?
    C:\WINDOWS\system32>activate main
    Could not find conda environment: main
    You can list all discoverable environments with `conda info --envs`.

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

    can you tell me how to do like this with python:
    detect an image on an application and if the image is not there search for the image again
    and if it's there then do something.

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

    great educator

  • @nonamenoname-sh1uk
    @nonamenoname-sh1uk 3 ปีที่แล้ว +1

    please when i give it an image of a another thing like a flower it classifies it is it normal how to correct it

  • @victoriawagman7183
    @victoriawagman7183 3 ปีที่แล้ว +2

    Question: Did you make any changes to your code before training your model?
    The output at the bottom of your screen at 31:52 in the video is very different from mine.
    I'm also getting:
    loss: 14.550795555114746
    accuracy: 0.09724999964237213
    What is your setup?
    Which OS are you using?

    • @Nobody-qw4qm
      @Nobody-qw4qm ปีที่แล้ว

      He's using Windows OS And his setup in in the disc

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

    Hey 👋 bud can you make an script for example i have thousands of images alright i.e mix photos of animals. But i need only 1 specific image so Image Recognized Software can find those img which is i want to copy once from my all images folder.

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

    this is really quality video and enhance our skills too.

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

      It is an awesome video.

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

    Hi, first of all, great tutorial! When I'm Training my Model, I only get 1563 'images', when using 'training_images = training_images[:20000]', to scale it down, it gets scaled down to around 600 images. Did TensorFlow change the size of the training models? And why are almost 100 images being removed when 'cutting' the array?

    • @al.d9592
      @al.d9592 2 ปีที่แล้ว +1

      Same here, its 625, which is exactly 1/32th of 20k. trying to figure out why...

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

      @@al.d9592 Any luck? 10 epochs of 625...

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

      @@al.d9592 could you figure it out?

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

      @@al.d9592 you have to specify the batch_size:
      model.fit(training_images, training_labels, batch_size = 1, epochs = .........
      otherwise, the default batch_size will be taken, so 32 ... 20000 / 32 = 1563

    • @Ambient_Life
      @Ambient_Life 11 หลายเดือนก่อน +1

      @@benjaminwendel9175 yeah, the default batch size is kept 32, really helpful tip

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

    can you do a video that you show to cam a picture and soft reconize that picture tell you all you need to know of the thing in picture?

  • @TheMuffinMan
    @TheMuffinMan 2 ปีที่แล้ว +1

    Mans is Nacho from Better Call Saul. Seriously though good video.

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

    Thanks for the great video. I was wondering how we can classify the color of a person (black, white, asian, etc) from a large set of pictures of humans?
    I

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

      Great question. To answer, practically if you are trying to distinguish a human on say, a security camera. Though difficult, you could have it take a picture of the moments when a person is in view, using the neural network to detect people. Then process the images to only keep the person in the shot(difficult) then distinguish all the shades of color of the 'person' and provide a result based on what the program perceives as a 'Human color' and sifting out colors that likely are not like pink(Likely to mess up due to clothes color) Then pray, I mean pray it gets close.
      I'm very sorry but with the tech of today tech like that that can be considered even 50 percent accurate would be a dream, but alas.
      However, if this is for facial recognition then instead of one singular image of a car or plane, use thousands of pictures of people with "distinct" facial features, like Asian, or European. Then have separate neural networks entirely check to avoid the error:
      Is black or white. (White)
      Is European or Asian. Etc.
      This could work fairly well, but with apparent limitations like needing the image to only include the user's face, like to the degree that you may see on a license. All I can say is if you can somehow make this. You are a brilliant mind on par with Thomas Edison or Albert Einstein.
      Jokes aside though it was a great question, and I do hope you the honest best on your project.
      Regards,
      Link-Start.

  • @cs_076_parinitsinha9
    @cs_076_parinitsinha9 26 วันที่ผ่านมา

    i'm getting an error like -
    File format not supported: filepath=image_classifier.model. Keras 3 only supports V3 `.keras` files and legacy H5 format files (`.h5` extension). Note that the legacy SavedModel format is not supported by `load_model()` in Keras 3. In order to reload a TensorFlow SavedModel as an inference-only layer in Keras 3, use `keras.layers.TFSMLayer(image_classifier.model, call_endpoint='serving_default')` (note that your `call_endpoint` might have a different name).
    Please help
    @NueralNine

  • @luissandoval2517
    @luissandoval2517 7 หลายเดือนก่อน +1

    Hi, i'm using a dataset that i downloaded from github. It has a .json archive with the labels and a file with the images but i dont know how to import it to my python project. Someone can help me pls?

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

    When training the model i get this: WARNING:absl:Found untraced functions such as _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op while saving (showing 3 of 3). These functions will not be directly callable after loading.
    Can someone help me?

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

      just a warning. wont be fatal to the code, you will have to wait for tensorflow to fix it if you dont want to see the warning.

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

    Thank you!
    where can i find the full code of it?

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

      import cv2 as cv
      import numpy as np
      import matplotlib.pyplot as plt
      from tensorflow.keras import datasets, layers, models
      (training_images, training_labels), (testing_images, testing_labels) = datasets.cifar10.load_data()
      training_images, testing_images = training_images / 255, testing_images / 255
      class_names = ['Plane', 'Car', 'Bird', 'Cat', 'Deer', 'Dog', 'Frog', 'Horse', 'Ship', 'Truck']
      for i in range(16):
      plt.subplot(4,4,i+1)
      plt.xticks([])
      plt.yticks([])
      plt.imshow(training_images[i], cmap=plt.cm.binary)
      plt.xlabel(class_names[training_labels[i][0]])
      training_images = training_images[:20000]
      training_labels = training_labels[:20000]
      testing_images = testing_images[:4000]
      testing_labels = testing_labels[:4000]
      model = models.Sequential()
      model.add(layers.Conv2D(32, (3,3), activation='relu', input_shape=(32,32,3)))
      model.add(layers.MaxPooling2D((2,2)))
      model.add(layers.Conv2D(64, (3,3), activation='relu'))
      model.add(layers.MaxPooling2D((2,2)))
      model.add(layers.Conv2D(64, (3,3), activation='relu'))
      model.add(layers.Flatten())
      model.add(layers.Dense(64, activation='relu'))
      model.add(layers.Dense(10, activation='softmax'))
      model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
      model.fit(training_images, training_labels, epochs=10, validation_data=(testing_images, testing_labels))
      loss, accuracy = model.evaluate(testing_images, testing_labels)
      print(f'Loss: {loss}')
      print(f'Accuracy: {accuracy}')
      model.save('image_classifier.model')

  • @daniela8375
    @daniela8375 12 วันที่ผ่านมา

    I used Open Cv's resize() function to resize any image i need for me since when I tried resizing manually i got black borders around the image which caused problems. Not only did this fix that issue it also helped save me time.
    img = cv.resize(img, (32, 32))
    img = cv.cvtColor(img, cv.COLOR_BGR2RGB)
    super easy

  • @arjunbasandrai7487
    @arjunbasandrai7487 3 ปีที่แล้ว +53

    How do i use my own images for training the model?

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

      yea

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

      @@brucedickie9394How do I do that.

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

      @@RawCuriosity imported cv2 and numpy as np libraries, had all the images I wanted in a folder, added them to a list:
      pic = cv2.imread(os.path.join(path, img))
      pic = cv2.cvtColor(pic, cv2.COLOR_BGR2RGB)
      pic = cv2.resize(pic, (80, 80))
      image_list.append(pic)
      np.save("training_images", np.array(training_images))

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

      @@brucedickie9394 Tysm

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

      @@brucedickie9394
      Thanks a lot for the lines of code. Very useful.
      How would you proceed regarding the training labels?

  • @sinep6060
    @sinep6060 11 หลายเดือนก่อน

    what version are you using my project is gettin errros

  • @niinaaaalami9763
    @niinaaaalami9763 11 หลายเดือนก่อน

    Perfect

  • @jophamming6929
    @jophamming6929 4 หลายเดือนก่อน

    lovely!

  • @peschebichsu
    @peschebichsu 3 ปีที่แล้ว +2

    Great video! Would be nice to know, how to automate the scaling part in python somehow

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

      I've done it with opencv:
      img = cv.imread(path, cv.IMREAD_UNCHANGED)
      resized = cv.resize(img, (32, 32), interpolation = cv.INTER_AREA)

  • @Warrior-qz5ip
    @Warrior-qz5ip 8 หลายเดือนก่อน

    Молодець!

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

    cool stuff

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

    5:55 horse and truck appear similar XD

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

    ValueError: `labels.shape` must equal `logits.shape` except for the last dimension. Received: labels.shape=(32,) and logits.shape=(512, 10)
    Getting this error when compiling the CNN model. Any Help?

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

    How do I link it on my website?

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

    cifar10 not in datasets also i had to use from keras import datasets, layers, models
    becaus keras was not in tensorflow how to fix?

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

      import cv2 as cv
      import numpy as np
      import matplotlib.pyplot as plt
      from tensorflow.python.keras import layers, models
      from keras import datasets
      this worked for me

  • @yashsharma-td6ii
    @yashsharma-td6ii หลายเดือนก่อน

    Have you applied Alex Net Model ??

  • @BrainWave-07
    @BrainWave-07 3 ปีที่แล้ว +1

    Can i get flowchart of this program... Please !! Fast

  • @Mard3s
    @Mard3s 2 ปีที่แล้ว +1

    Why when I train the model use only 1563 cases even if I pass the entire Vector of 50000 elements?

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

      you have to specify the batch_size:
      model.fit(training_images, training_labels, batch_size = 1, epochs = ...............
      Otherwise, the default batch size will be 32, so 20000 / 32 = 1563. And you have to delete / comment out the part where we only take the first 20000 test images, otherwise it will still be limited to 20000 instead of 50000 images

  • @elbertmkizy7086
    @elbertmkizy7086 4 หลายเดือนก่อน

    how to correct the model when prediction is wrong?

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

    plt.imshow is not working for me.. i get an error that I is out of range.. any suggestions
    plt.xlabel(class_names[training_labels[i][0]])
    IndexError: list index out of range

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

      Hello, I have the same issue, did you find a solution? Thanks

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

      Could you copy and paste your code?

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

      you can try this plt.xlabel(class_names[list(training_labels[i])[0]])

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

    Can i copy code plz?

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

    Sir can you please give me code for animal identification using ML algorithms and in Python code in crop protection

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

    Does anyone know why we add dense layers

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

      They just help the AI get better results, basically it adds more variables that it can mess around with to get the outcome it wants

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

    im only on the 4th line and i have 4 errors and 6 warnings... anyone else having problems?

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

      yes

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

      'keras.datasets' has no attribute 'cifar10'

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

      @@CoderKai same

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

      need to replace the tensor flow import with these two lines:
      from tensorflow import keras
      from keras import datasets, layers, models

  • @PepeBote11a
    @PepeBote11a 5 หลายเดือนก่อน

    Where is the source code he had use?

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

    can you zoom-in when you code

  • @ahmedmagdy2251
    @ahmedmagdy2251 3 หลายเดือนก่อน

    please source code

  • @TheRilwen
    @TheRilwen 11 หลายเดือนก่อน

    If I correctly understand that your test set is a subset of the training set, that’s a rookie mistake.

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

      does it take too much from one classification? classifcations wont be balanced?

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

    It doesnt work. It just says "Deer", even when I predict with the first 16 test images. Bullshit.

  • @jophamming6929
    @jophamming6929 4 หลายเดือนก่อน

    ♥♥♥lets mix our code (if you know what I mean 😜)

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

    I did not benifit anything in this video
    You just read what you are writting. You did not explain anythinh

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

    The tutorial is fake. I get an error with the line plt.xticks([]) - TypeError: 'list' object is not callable. How can you call a list???

    • @-caio-
      @-caio- ปีที่แล้ว +1

      😐