Image Classification with Neural Networks in Python

Ғылым және технология

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/

Пікірлер: 113

  • @victoriawagman7183
    @victoriawagman71833 жыл бұрын

    Lovely tutorial, thank you! 👍🏽

  • @hugokidd
    @hugokidd3 ай бұрын

    Thanks for helping me with my thesis !

  • @nwang03
    @nwang0311 ай бұрын

    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

    10 ай бұрын

    Plz send me the code

  • @Khubaiblj

    @Khubaiblj

    8 ай бұрын

    Do u have the video m

  • @tranjeeeet
    @tranjeeeet3 жыл бұрын

    Very well explained the use of keras library.

  • @pawankushwah4992
    @pawankushwah49923 жыл бұрын

    Awesome tutorial

  • @akritworanithiphong
    @akritworanithiphong2 жыл бұрын

    Clearly explained!

  • @szymonduranowski4510
    @szymonduranowski45103 жыл бұрын

    Great tutorial!

  • @fantasmy7129
    @fantasmy71293 жыл бұрын

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

  • @ajayspatil
    @ajayspatil3 жыл бұрын

    Best-One!! Amazing :)

  • @abdullahghumaricom
    @abdullahghumaricom Жыл бұрын

    great educator

  • @qianzhang2031
    @qianzhang20314 жыл бұрын

    先赞后看!!!thank you!!

  • @aymenbenrhouma4678
    @aymenbenrhouma46783 жыл бұрын

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

  • @swarupmazumder
    @swarupmazumder3 жыл бұрын

    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

    Жыл бұрын

    from keras.datasets import cifar10

  • @KaijaKFanpages
    @KaijaKFanpages2 ай бұрын

    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?

  • @RomIlay
    @RomIlay3 жыл бұрын

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

  • @kusumrohra5861
    @kusumrohra5861 Жыл бұрын

    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?

  • @pranaytiwari9204
    @pranaytiwari92044 жыл бұрын

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

  • @NeuralNine

    @NeuralNine

    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

  • @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

  • @woonie3134
    @woonie31343 жыл бұрын

    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

  • @jophamming6929
    @jophamming69295 ай бұрын

    lovely!

  • @photogyulai
    @photogyulai7 ай бұрын

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

  • @niinaaaalami9763
    @niinaaaalami9763 Жыл бұрын

    Perfect

  • @tcgvsocg1458
    @tcgvsocg14582 жыл бұрын

    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?

  • @codefix40
    @codefix40 Жыл бұрын

    this is really quality video and enhance our skills too.

  • @ajarivas72

    @ajarivas72

    Жыл бұрын

    It is an awesome video.

  • @heliakhiabani
    @heliakhiabani3 ай бұрын

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

  • @daniela8375
    @daniela8375Ай бұрын

    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

  • @nonamenoname-sh1uk
    @nonamenoname-sh1uk3 жыл бұрын

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

  • @nagisafurukawa8864
    @nagisafurukawa88643 жыл бұрын

    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`.

  • @aimalkhan3313
    @aimalkhan33132 жыл бұрын

    cool stuff

  • @saurabhkalra3042
    @saurabhkalra30423 жыл бұрын

    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.

  • @Extorc
    @Extorc3 жыл бұрын

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

  • @SHREYASPATEL-wh1ki
    @SHREYASPATEL-wh1ki10 ай бұрын

    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?

  • @SuperHovik
    @SuperHovikАй бұрын

    what do i need to do to make it read notes written by people and be able to classify them to which one is who's? please help

  • @Extorc
    @Extorc3 жыл бұрын

    5:55 horse and truck appear similar XD

  • @TheMuffinMan
    @TheMuffinMan2 жыл бұрын

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

  • @NeuralNine

    @NeuralNine

    2 жыл бұрын

    Thank you L

  • @arjunbasandrai7487
    @arjunbasandrai74873 жыл бұрын

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

  • @xavxavierm

    @xavxavierm

    3 жыл бұрын

    yea

  • @RawCuriosity

    @RawCuriosity

    Жыл бұрын

    @@brucedickie9394How do I do that.

  • @brucedickie9394

    @brucedickie9394

    Жыл бұрын

    @@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?

  • @luissandoval2517
    @luissandoval25178 ай бұрын

    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?

  • @sinep6060
    @sinep6060 Жыл бұрын

    what version are you using my project is gettin errros

  • @peschebichsu
    @peschebichsu3 жыл бұрын

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

  • @itunsicherheit

    @itunsicherheit

    Жыл бұрын

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

  • @yashsharma-td6ii
    @yashsharma-td6ii3 ай бұрын

    Have you applied Alex Net Model ??

  • @victoriawagman7183
    @victoriawagman71833 жыл бұрын

    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.

  • @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

  • @christianmarklaurio9604
    @christianmarklaurio96043 жыл бұрын

    How do I link it on my website?

  • @arjabdhakal3599
    @arjabdhakal35993 жыл бұрын

    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

    3 жыл бұрын

    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.

  • @nadavmoyal
    @nadavmoyal Жыл бұрын

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

  • @adamtoth7679

    @adamtoth7679

    11 ай бұрын

    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')

  • @Warrior-qz5ip
    @Warrior-qz5ip9 ай бұрын

    Молодець!

  • @xanderthedev
    @xanderthedev Жыл бұрын

    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

    11 ай бұрын

    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.

  • @BrainWave-07
    @BrainWave-073 жыл бұрын

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

  • @ReazerDev
    @ReazerDev3 жыл бұрын

    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 жыл бұрын

    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

    Жыл бұрын

    @@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

    Жыл бұрын

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

  • @Mard3s
    @Mard3s2 жыл бұрын

    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
    @elbertmkizy70865 ай бұрын

    how to correct the model when prediction is wrong?

  • @bejaminog
    @bejaminog3 жыл бұрын

    Can i copy code plz?

  • @jayantbarthwal4470
    @jayantbarthwal4470 Жыл бұрын

    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?

  • @alialavizadeh2775
    @alialavizadeh27753 жыл бұрын

    can you zoom-in when you code

  • @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

    Жыл бұрын

    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

  • @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

  • @cs_076_parinitsinha9
    @cs_076_parinitsinha92 ай бұрын

    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

  • @chiragbaid7275

    @chiragbaid7275

    15 күн бұрын

    Bro i am getting the same error, u got its solution on how to resolve it ??

  • @kaustab03
    @kaustab033 ай бұрын

    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?

  • @PepeBote11a
    @PepeBote11a7 ай бұрын

    Where is the source code he had use?

  • @afolabiowoloye804
    @afolabiowoloye804Ай бұрын

    Nice lecture, thanks. Please how do I contact you?

  • @nagisafurukawa8864
    @nagisafurukawa88643 жыл бұрын

    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]])

  • @boxeriain
    @boxeriain Жыл бұрын

    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_

    Жыл бұрын

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

  • @ullascr391
    @ullascr3913 жыл бұрын

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

  • @TheRilwen
    @TheRilwen Жыл бұрын

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

  • @pesk8801

    @pesk8801

    11 ай бұрын

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

  • @ahmedmagdy2251
    @ahmedmagdy22514 ай бұрын

    please source code

  • @jophamming6929
    @jophamming69295 ай бұрын

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

  • @technik1572
    @technik15728 ай бұрын

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

  • @zaidbaarab552
    @zaidbaarab5527 ай бұрын

    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-

    Жыл бұрын

    😐

Келесі