Object detection using YOLO v4 and pre trained model | Deep Learning Tutorial 32 (Tensorflow)

codebasics · Beginner ·👁️ Computer Vision ·5y ago

Key Takeaways

This video demonstrates object detection using YOLO v4 and pre-trained models with Tensorflow, utilizing the COCO dataset and pre-trained weights for detection.

Full Transcript

in the last video we looked at some theory behind yolo algorithm in this video we will do real object detection using yolo now we'll go over some history behind yellow the different versions version one two three four as of january 2021 there are total five versions of yellow so we'll go over that whole history and then we will use pre-trained weights for doing object detection so we are not taking any custom object image data set and then doing object detection in that instead we are using cocoa data set using pre-trained weights and doing object detection for those cocoa data set labels in future we'll have a separate video on how you can train your own classifier or not not the classifier but the object detector you know and run yolo on the custom data set in 2016 the first version of yolo was invented by joseph redman santos diwala rose gershik and ali farhadi i'm going to provide a link of this research paper in the video description below you can just google it and you can find what they proposed in this particular research paper then in 2017 they came up with yellow version 2 mainly josef and ali for hadi where they improved the speed you you see that they have speeds which supports the rate of 67 frame per second so this algorithm detects the objects at a very very fast rate so if you have a video playing at certain of frame rate it can detect the objects really fast and this could be useful in lesser autonomous cars in 2018 a yolo version 3 was created and again joseph and ellie was the pioneer in in this incremental improvement so they kept on improving the original yolo framework tell version 3 and then at some point joseph redman stopped working on it because of some concern some conflict that he had with his personal values and the use of this in military in 2020 yolo version 4 was created now the reason i have this in different color was because joseph redwater redmond was not part of it alexei boko waski created a fork of uh his github repository and he created this separate uh branch of this version 4 algorithm now nowadays there is yolo version 5 as well but there is some controversy going on with it so i'm not going to cover that we will be doing coding using yolo version 4. you need to go to google and search for yolo v4 github lxcab and you will find a repository by alex ab that has yolo v4 core and this is the repo name is dark knight it is four prom pj ready so this this one is if you look at this repository this is the original repository by joe redman and he stopped development of yolo after version three so then alex cab forked his repository and he built this yolo version for now yolo is not available as like you can't do like paper install your something like that you have to get clone this repository and follow certain steps in order to use it now once you are on this repository you will find this particular section where it says how to compile this on windows if you are on linux there are instruction on doing this linux so this was built originally for linux so building this on linux is straightforward on windows you have to follow certain steps it's not very very straightforward so first what you need to do is git clone this vc package and vc package is needed to compile the dark net project so what i have done is here open a powershell so when you open a powershell windows powershot click on this and you get this windows command prompt this is like powershell is a new version of old windows command prompt and here i made a temporary directory okay so if i do cd tmp and see this is an empty directory which i made so now i need to do git clone and you can copy and if you mouse right click it will copy that so this will copy the vc package microsoft project once it is copied see you're just doing copy paste so you go to that directory you set some environment variable this is just setting some windows environment variable and then you are compiling your bootstrapping that vc package will might take time okay so after a few seconds this step is done now i'm just see this will install the whole darknet version i want to install only the one for x64 windows so this will save you a lot of time if you try to install the whole version it will take hours and hours so here uh i think i did not copy the whole thing so okay so what you need to do is this install darknet opencv cnn okay so now again it will take some time for this tip to finish so it is installing the cu dn and all these dependencies i forgot to mention one thing is before you do all these steps you need to perform these three steps where you need to install either visual studio 2017 or 2019 the community edition okay community edition is free so that is microsoft ide and we need that for compilation process you might be wondering why are we installing visual studio well it is needed for the compilation process so install that then you install cuda kuda is nvidia's library for gpu and machine learning so install that make sure you enable vs integration okay so cuda is not really machine learning it is gpu library you know it allows you to access gpu for faster computation but when you're installing that make sure you are doing vs integration so see when you do cuda installation so basically when you do put installation just go to custom step and make sure you install everything they will have express tab but don't use express tab go to custom and install everything including vs integration when i was following these steps i was facing horrible issues with coda because i had cuda 11 point some 11.0 or 11.1 and it was giving me a lot of trouble because it was not compatible with the rest of the software i have on my machine so i had to install cuda 10.2 okay so if you are facing any errors at any step let's say at this step when you're compiling darknet if you face the error make sure that you look at the error properly if it is saying that the error is in this particular file path open that file and try to see the error most likely it might be incompatible cuda version so try to resolve that again following these steps it might be easier or it might not be easier based on what kind of system software you have so you have to have a patience look at errors carefully do google search and try to install the things which are needed this still downloading looks like this is slow now that step is done without any errors so we are ready to move on to the next step which is go out of this directory so you'll see that right now this so c code damn directory so if you see code temp this has only vc package so see this is vc package now you're coming out and you're doing git clone the dark net repository so once you do git clone you will have that particular directory here so if you do dir see you have now darknet repository here and then you do 3d darknet and then now this command doesn't quite work well like we can try it so see some authorization issue it is giving so we will be running a different command which i have given in the video description below so this is the command that will run again it's available in the video description below so check it out so now this is building the dark net repository and it will take some time for it to build it took me long time around 40 minutes for this to finish so make sure you have enough patience this process the compilation of darknet is going to take long time now when i look at my tmp directory here in the dark net folder i will see a thing called darknet.exe using this you can do object detection and also here there are a couple of files for example there will be this image yellow v4 dot asset so if you open that here this has a command to detect the uh objects basically so if you look at data directory here data directory dog.jpg so see there is this image where there is dock bicycle car and so on and we want to do object detection on that so it draws the boundaries around this so when you do this command here just copy paste this command okay so this will run the detection and now see here it says the yolo v4 dot weights couldn't find so we missed one step which was to download yellow weights from this particular folder so let's go back to the directory here and if you do yolo dot yolo for or just do weights see use this link when you use this link you will be able to download those weights so when i do this see it is downloading this now so i copied that file into darknet directory so yolo v4 waits that you just downloaded copy it in this dark net directory and then run the same command again see now it detected those objects you see that so there's a truck there is a bicycle this these are like scores you know 0.96 percent this is matching with a dog bicycle truck so you can see that when you have driverless car type of application this kind of object detection can be really useful i have one more image where i'm trying to break my computer okay so let's detect objects in this particular image so the name of the image is laptop.jpg you can put any of your image so here i will just say laptop dot jpg see it is detecting some of the images right but for this hammer it is saying toothbrush the reason is that the cocoa data set probably doesn't have this hammer as a label or maybe or maybe it did not detect it fine so let's look at our cocoa data set labels so in the previous video i talked about different data sets such as cocoa image net so what that video if you don't know what coco data set is but it's an image data set which with all the annotations pixel segmentation and so on and this uh and the weights that we will be downloaded where train on that cocoa data set and if you look at this website this has all the labels of cocoa data set so the link of this website is in the video description below you can see that it has around let's see around 91 labels and like 91 classes which it can detect so whatever output you get will be one of these classes and this probably doesn't have a hammer so you know but it has toothbrush so it is trying to do detect toothbrush so any image you take which has any of these objects uh it will do the object detection all right so this was on the coco data set if you want to train yolo on your own images there are instructions here we are not going to go into those details in today's video maybe in future we'll cover that but just follow these instructions uh to train your own custom object detection model uh in the future video i want to cover a recurrent neural network and that's the reason uh we don't want to spend too much time in these videos so we will be starting a recurrent neural network and nlp tutorials pretty soon i hope you like this video if you do please give it a thumbs up check video description it has all the necessary information and the links that you need thank you

Original Description

In this video we will use YOLO V4 and use pretrained weights to detect object boundaries in an image. The model was trained on COCO dataset using YOLO V4. Watch this to understand how yolo algorithm works: https://www.youtube.com/watch?v=ag3DLKsl2vk Windows setup instructions: https://github.com/AlexeyAB/darknet#how-to-compile-on-windows-using-cmake Above, I was getting errors when I used .\build.ps1 command but using following command instead worked: powershell -ExecutionPolicy Bypass -File .\build.ps1 Make sure you are installing a compatible version of CUDA. For me it was CUDA 10.1, when I installed 11.x version I was getting all kind of errors so had to downgrade it to 10.1 Based on your system you might have to use a different version download yolov4.weights from https://github.com/AlexeyAB/darknet#how-to-evaluate-ap-of-yolov4-on-the-ms-coco-evaluation-server COCO labels: https://tech.amikelive.com/node-718/what-object-categories-labels-are-in-coco-dataset/ YOLO research papers YOLO v1: https://arxiv.org/abs/1506.02640 YOLO v2: https://arxiv.org/abs/1612.08242 YOLO v3: https://arxiv.org/abs/1804.02767 Do you want to learn technology from me? Check https://codebasics.io/?utm_source=description&utm_medium=yt&utm_campaign=description&utm_id=description for my affordable video courses. #objectdetectionusingyolo #yoloobjectdetection #yolov4objectdetection #yoloalgorithm #yolov4 #yolodeeplearning 🌎 My Website For Video Courses: https://codebasics.io/?utm_source=description&utm_medium=yt&utm_campaign=description&utm_id=description Need help building software or data analytics and AI solutions? My company https://www.atliq.com/ can help. Click on the Contact button on that website. #️⃣ Social Media #️⃣ 🔗 Discord: https://discord.gg/r42Kbuk 📸 Dhaval's Personal Instagram: https://www.instagram.com/dhavalsays/ 📸 Instagram: https://www.instagram.com/codebasicshub/ 🔊 Facebook: https://www.facebook.com/codebasicshub 📱 Twitter: https://twitter.com/codebas
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from codebasics · codebasics · 0 of 60

← Previous Next →
1 Python Tutorial - 1. Install python on windows
Python Tutorial - 1. Install python on windows
codebasics
2 Python Tutorial - 2. Variables
Python Tutorial - 2. Variables
codebasics
3 Python Tutorial - 3. Numbers
Python Tutorial - 3. Numbers
codebasics
4 Python Tutorial - 4. Strings
Python Tutorial - 4. Strings
codebasics
5 Python Tutorial - 5. Lists
Python Tutorial - 5. Lists
codebasics
6 Python Tutorial - 6. Install PyCharm on Windows
Python Tutorial - 6. Install PyCharm on Windows
codebasics
7 PyCharm Tutorial - 7. Debug python code using PyCharm
PyCharm Tutorial - 7. Debug python code using PyCharm
codebasics
8 Python Tutorial -  8. If Statement
Python Tutorial - 8. If Statement
codebasics
9 Python Tutorial - 9. For loop
Python Tutorial - 9. For loop
codebasics
10 Python Tutorial -  10. Functions
Python Tutorial - 10. Functions
codebasics
11 Python Tutorial - 11. Dictionaries and Tuples
Python Tutorial - 11. Dictionaries and Tuples
codebasics
12 Python Tutorial - 12. Modules
Python Tutorial - 12. Modules
codebasics
13 Python Tutorial - 13. Reading/Writing Files
Python Tutorial - 13. Reading/Writing Files
codebasics
14 How to install Julia on Windows
How to install Julia on Windows
codebasics
15 Python Tutorial - 14. Working With JSON
Python Tutorial - 14. Working With JSON
codebasics
16 Julia Tutorial - 1. Variables
Julia Tutorial - 1. Variables
codebasics
17 Julia Tutorial - 2. Numbers
Julia Tutorial - 2. Numbers
codebasics
18 Python Tutorial - 15. if __name__ == "__main__"
Python Tutorial - 15. if __name__ == "__main__"
codebasics
19 Julia Tutorial - Why Should I Learn Julia Programming Language
Julia Tutorial - Why Should I Learn Julia Programming Language
codebasics
20 Python Tutorial  - 16. Exception Handling
Python Tutorial - 16. Exception Handling
codebasics
21 Julia Tutorial - 3. Complex and Rational Numbers
Julia Tutorial - 3. Complex and Rational Numbers
codebasics
22 Julia Tutorial - 4. Strings
Julia Tutorial - 4. Strings
codebasics
23 Python Tutorial -  17. Class and Objects
Python Tutorial - 17. Class and Objects
codebasics
24 Julia Tutorial - 5. Functions
Julia Tutorial - 5. Functions
codebasics
25 Julia Tutorial - 6. If Statement and Ternary Operator
Julia Tutorial - 6. If Statement and Ternary Operator
codebasics
26 Julia Tutorial - 7. For While Loop
Julia Tutorial - 7. For While Loop
codebasics
27 Python Tutorial  - 18. Inheritance
Python Tutorial - 18. Inheritance
codebasics
28 Julia Tutorial - 8. begin and (;) Compound Expressions
Julia Tutorial - 8. begin and (;) Compound Expressions
codebasics
29 Python Tutorial - 12.1 - Install Python Module (using pip)
Python Tutorial - 12.1 - Install Python Module (using pip)
codebasics
30 Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
codebasics
31 Julia Tutorial - 10. Exception Handling
Julia Tutorial - 10. Exception Handling
codebasics
32 Python Tutorial  - 19. Multiple Inheritance
Python Tutorial - 19. Multiple Inheritance
codebasics
33 Python Tutorial - 20. Raise Exception And Finally
Python Tutorial - 20. Raise Exception And Finally
codebasics
34 Python Tutorial - 21. Iterators
Python Tutorial - 21. Iterators
codebasics
35 Python Tutorial - 22. Generators
Python Tutorial - 22. Generators
codebasics
36 Python Tutorial - 23. List Set Dict Comprehensions
Python Tutorial - 23. List Set Dict Comprehensions
codebasics
37 Python Tutorial - 24. Sets and Frozen Sets
Python Tutorial - 24. Sets and Frozen Sets
codebasics
38 Python Tutorial - 25. Command line argument processing using argparse
Python Tutorial - 25. Command line argument processing using argparse
codebasics
39 Debugging Tips - What is bug and debugging?
Debugging Tips - What is bug and debugging?
codebasics
40 Debugging Tips - Conditional Breakpoint
Debugging Tips - Conditional Breakpoint
codebasics
41 Debugging Tips - Watches and Call Stack
Debugging Tips - Watches and Call Stack
codebasics
42 Python Tutorial - 26. Multithreading - Introduction
Python Tutorial - 26. Multithreading - Introduction
codebasics
43 Git Tutorial 3:  How To Install Git
Git Tutorial 3: How To Install Git
codebasics
44 Git Tutorial 1: What is git / What is version control system?
Git Tutorial 1: What is git / What is version control system?
codebasics
45 Git Tutorial 2 : What is Github? | github tutorial
Git Tutorial 2 : What is Github? | github tutorial
codebasics
46 Git Tutorial 4: Basic Commands: add, commit, push
Git Tutorial 4: Basic Commands: add, commit, push
codebasics
47 Git Tutorial 5: Undoing/Reverting/Resetting code changes
Git Tutorial 5: Undoing/Reverting/Resetting code changes
codebasics
48 Git Tutorial 6: Branches (Create, Merge, Delete a branch)
Git Tutorial 6: Branches (Create, Merge, Delete a branch)
codebasics
49 Git Github Tutorial 10: What is Pull Request?
Git Github Tutorial 10: What is Pull Request?
codebasics
50 Git Tutorial 7: What is HEAD?
Git Tutorial 7: What is HEAD?
codebasics
51 Git Tutorial 9: Diff and Merge using meld
Git Tutorial 9: Diff and Merge using meld
codebasics
52 Difference between Multiprocessing and Multithreading
Difference between Multiprocessing and Multithreading
codebasics
53 Python Tutorial - 27. Multiprocessing Introduction
Python Tutorial - 27. Multiprocessing Introduction
codebasics
54 Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
codebasics
55 Git Tutorial 8 - .gitignore file
Git Tutorial 8 - .gitignore file
codebasics
56 Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
codebasics
57 Python Tutorial - 30. Multiprocessing Lock
Python Tutorial - 30. Multiprocessing Lock
codebasics
58 Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
codebasics
59 What is code?
What is code?
codebasics
60 Python unit testing - pytest introduction
Python unit testing - pytest introduction
codebasics

This video teaches object detection using YOLO v4 and pre-trained models with Tensorflow, and demonstrates how to use pre-trained weights for detection on the COCO dataset. The video provides a step-by-step guide on how to set up the environment and use YOLO v4 for object detection.

Key Takeaways
  1. Create a temporary directory
  2. Open a PowerShell window
  3. Copy and paste the VC package
  4. Set environment variables
  5. Compile the Dark Net project
  6. Install Visual Studio 2017 or 2019 Community Edition
  7. Install CUDA
  8. Install cuDNN and dependencies
  9. Compile Darknet version for x64 Windows
  10. Use Darknet.exe for object detection
💡 YOLO v4 is a real-time object detection system that can detect objects in images and videos, and pre-trained models can be used for object detection on the COCO dataset.

Related Reads

Up next
9-Phase Computer Vision Roadmap 2026 | AI & Deep Learning | #shorts
SCALER
Watch →