Image Segmentation And Object Detection Using 5 Lines Of Code Using PixelLib

Krish Naik · Intermediate ·👁️ Computer Vision ·5y ago

Key Takeaways

Demonstrates image segmentation and object detection using PixelLib with just 5 lines of code

Full Transcript

hello all my name is krishna and welcome to my youtube channel so guys this will be an amazing video for every one of you because in this particular video we are going to discuss about image segmentation and how you can implement it with just writing five lines of code right so initially if you have this kind of image or probably you have this kind of image then you will be able to convert it something like this okay now here you can see that how the segmentation is basically done it so object detection is also there you can see over here traffic light person everything is there apart from that the segmentation you know it is being able to do this kind of segmentation where with different different colors uh you'll you'll be able to see each and every objects and into this right not only this suppose if i have this specific image if i apply this kind of segmentation then finally you'll be able to get something like this right and this is all possible just by this file lines of code right so we'll try to see what it is and the library that we are going to use is pixel lip so what is pixel lip over here you can see um the pixel leave is a library for performing segmentation of objects in images and videos so it both supports button images and videos right now in this particular video we'll focus on images you know and then in the upcoming videos we'll see in videos how we can do it right it'll be pretty much amazing i tried it with both and trust me with the approach that we used to follow before and with the approach of this you'll be able to do it very very easily and here you can also do custom training which i will be showing you as we go ahead okay so for this first thing is that what are libraries you're actually requiring require tensorflow you require tensorflow gpu any of them and there is also some dependencies of libraries that are required okay and you can also check out this entire github page so let's proceed and let's see first of all i'm just going to create my requirement.txt file so here you can see uh these are my requirement.txt files uh which you actually require okay one is opencv python skykit image pillow pixel lib okay so this all libraries you actually required and one more which i forgot to write over here is tensorflow gpu right so this all libraries you actually require and this is the dependencies for this pixel lib library okay at the end of the day we are going to use pixel lib because there are techniques over here which will actually help you to do the image segmentation both in images and videos right so please make sure that you keep this requirement.txt file and then go to the terminal and just write pip install pip install minus r requirement.txt so you just have to write like this pip install minus r requirement requirements dot txt that's it right so automatically all the requirements will be installed okay i don't want to do it again because i have already done it okay so let's go to the next step now the next step is that i will go to my app.py and in this particular uh code what we are actually going to do is that we are going to import the pixel lab we are going to import pixel lab dot instance import instance segmentation so fine guys we have actually imported both this library and we are going to use this instant segmentation for doing the segmentation and for this we also required a library probably like rcnn and all so that it will be able to do the object detection and based on that it will also be able to show the boxes to us right so for that we are going to use this h5 file and where did i get this h55 because it is already given away if i go down you'll be able to see all the examples over here and they have released what all different different types of models are there one is deep level and one is mast rcnn which they have actually used and uh remember guys the the the you know the inference part is very very quick uh if you are also using this so just go over here okay and uh you can download this mass rcnn coco.h5 right so this rcnn is basically trained on the coco data set so what you have to do go over here there is have there is something called as tutorial on back background editing and videos and here you can actually see the uh the note is there which says deep lab and mars rcn are available in the release of this repository so once you click this you'll be able to go over here and you'll be able to select this okay so again let me just go and click it so you'll be getting this page and then go down right go down and just click this okay so mask rcn and for this particular purpose we are going to use marks rcnn okay now after we use this after i download it if i click this i'll get downloaded and here you can see that i'll be able to find this h55 so i've actually uploaded this in my same working location perfect then what i'm going to do i'm going to use this segment image first of all we are going to initialize with the help of instance segmentation this will be an object and then we are going to load this particular h5 file for the object detection purpose and along with that we'll try to also do the segment image so this is both object detection and image segmentation okay so here in the segment image the first image is basically your input image and then there will be a parameter which is called as show pb uh b boxes is equal to true you have to set it as true otherwise you will be able to not be able to see the boxes and after taking this image after performing the image segmentation and object detection you will be able to get the output name something like this right so let's quickly run right now i'm giving hangover.jpg i hope everybody has seen the hangover image right i saw this particular movie hangover part one i hope many people have seen it so let's see how we are going to get an output once then output is basically created you'll be able to get output1.jpg okay so let's go and run it and here we go and make sure that you have all the libraries installed perfectly guys then only things will work okay so i'm now executing this uh you'll be able to see all the image segmentation will be done and it will actually create an image called as output one so here you can see processed image saved successfully in the current working directory and this is my output one and if i want to show you the image this is how it looks like yes it has been detecting this building as tv but person is detected person is defected and refrigerated because this looks like a refrigerator itself but amazing accuracy let's try some other one so here i'm going to give you this image okay cycle.jpg let's see so i'm just going to try this one cycle.jpg and probably give my image as output dot or i'll say output2.jpg okay and probably i'll run it so probably this will also take some time to run it and again uh it depends on your system also based on the inferences that you are actually getting okay so quickly quickly let's let's see yes it is saved what is my file name output 2 so initially i had this specific image and now i'm able to get this specific image and you can see how accurately everything is there you can see this petted plant you can see person cars this this everything is there amazingly right it is being able to even traffic light is given over here right so this is my second example third example i can also take something like this this is my test.gpg you'll be able to see input.jpg over here let's see this one football i can see that it is not that clear but let me try this one also so here i can say football.jpg okay football dot jpg and here i'm just going to say output three so just with this three line of code and in the upcoming videos i'll also show you how to do this in videos okay it will be pretty much amazing in live streams also i'll i'll be able to show you how these things work because i've been exploring with respect to image segmentation trust me the older approach that we used to do and you may be thinking krish how to do custom training don't worry about that that also i'll try to show custom training of different images and all also you can actually do so this is my output three now here you can see that yes within this also it is being properly determined person and all but here you can see the tennis is basically determined this was not tennis actually yes some some amount of error is there definitely uh not 100 accuracy but yes a good accuracy altogether right uh let's see one more so i have this football one dot jpg let's see this also if i'm able to get in a proper way and i have output four perfect and let me run it so here you will be able to see now i think it will work perfectly fine and i'm just giving my input and output image by just using this rcnn model and i think it will work so it is get saved now let me see my output 4 so here you can see right this was my initial image sorry this was my initial image now after doing the segmentation doll i'm actually getting something like this and here clearly everything is basically getting determined even stop sign also so i hope you like this particular video please do subscribe the channel if you're not already subscribed and i'll put all this particular thing in my github so that you can actually work it out right i'll see y'all in the next video have a great day thank you and all bye

Original Description

github:https://github.com/krishnaik06/Image-Segmentation-Using-Pixellib Documentation Page: https://github.com/ayoolaolafenwa/PixelLib Complete DL Playlist: https://www.youtube.com/watch?v=YFNKnUhm_-s&list=PLZoTAELRMXVPGU70ZGsckrMdr0FteeRUi -------------------------------------------------------------------------------------------------------------------------- Subscribe my vlogging channel https://www.youtube.com/channel/UCjWY5hREA6FFYrthD0rZNIw Please donate if you want to support the channel through GPay UPID, Gpay: krishnaik06@okicici Telegram link: https://t.me/joinchat/N77M7xRvYUd403DgfE4TWw Please join as a member in my channel to get additional benefits like materials in Data Science, live streaming for Members and many more https://www.youtube.com/channel/UCNU_lfiiWBdtULKOw6X0Dig/join ----------------------------------------------------------------------------------------------------------------------------------------------------- Connect with me here: Twitter: https://twitter.com/Krishnaik06 Facebook: https://www.facebook.com/krishnaik06 instagram: https://www.instagram.com/krishnaik06
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Krish Naik · Krish Naik · 0 of 60

← Previous Next →
1 Natural Language Processing|Stemming
Natural Language Processing|Stemming
Krish Naik
2 Natural Language Processing|BagofWords
Natural Language Processing|BagofWords
Krish Naik
3 Gaussian distribution or Normal Distribution in statisctics
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
4 Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
5 Log Normal Distribution in Statistics
Log Normal Distribution in Statistics
Krish Naik
6 Covariance in Statistics
Covariance in Statistics
Krish Naik
7 Confusion matrix, Precision, Recall| Data Science Interview questions
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
8 Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
9 Implementing a Spam classifier in python| Natural Language Processing
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
10 Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
11 Face Recognition using open CV and VGG 16 Transfer Learning
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
12 Pedestrian Detection using OpenCV from Videos
Pedestrian Detection using OpenCV from Videos
Krish Naik
13 Face and Eye Detection from Videos using HAAR Cascade Classifier
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
14 Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
15 OpenCV Installation | OpenCV tutorial
OpenCV Installation | OpenCV tutorial
Krish Naik
16 Face and Eye Detection from Images using HAAR Cascade Classifier
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
17 Car Detection using HAAR Cascade and Opencv from Videos.
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
18 Using OpenFace for Face recognition in Keras
Using OpenFace for Face recognition in Keras
Krish Naik
19 OpenPose Tutorial with Tensorflow
OpenPose Tutorial with Tensorflow
Krish Naik
20 Multiple Linear Regression using python and sklearn
Multiple Linear Regression using python and sklearn
Krish Naik
21 Dimensional Reduction| Principal Component Analysis
Dimensional Reduction| Principal Component Analysis
Krish Naik
22 Movie Recommender System using Python
Movie Recommender System using Python
Krish Naik
23 TPR,FPR,FNR,TNR, Confusion Matrix
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
24 Precision, Recall and F1-Score
Precision, Recall and F1-Score
Krish Naik
25 Artificial Neural Network for Customer's Exit Prediction from Bank
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
26 GridSearchCV- Select the best hyperparameter for any Classification Model
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
27 RandomizedSearchCV- Select the best hyperparameter for any Classification Model
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
28 K Nearest Neighbor classification with Intuition and practical solution
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
29 K Means Clustering Intuition
K Means Clustering Intuition
Krish Naik
30 Create custom Alexa Skill- Lambda function- Part2
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
31 Hierarchical Clustering intuition
Hierarchical Clustering intuition
Krish Naik
32 Implement Transfer Learning with a generic Code Template
Implement Transfer Learning with a generic Code Template
Krish Naik
33 Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
34 Unlock Your Application With Your Face using OpenCV
Unlock Your Application With Your Face using OpenCV
Krish Naik
35 Draw rectangle from webcam and sketch process it on a live feed
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
36 Complete Life Cycle of a Data Science Project
Complete Life Cycle of a Data Science Project
Krish Naik
37 How we can apply Machine Learning in Finance
How we can apply Machine Learning in Finance
Krish Naik
38 Deep Learning in Medical Science
Deep Learning in Medical Science
Krish Naik
39 How to switch your career to Data Science.
How to switch your career to Data Science.
Krish Naik
40 Linear Regression Mathematical Intuition
Linear Regression Mathematical Intuition
Krish Naik
41 Handle Categorical features using Python
Handle Categorical features using Python
Krish Naik
42 Machine Learning Algorithm- Which one to choose for your Problem?
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
43 DBSCAN Clustering Easily Explained with Implementation
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
44 Curse of Dimensionality Easily explained| Machine Learning
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
45 Feature Selection Techniques Easily Explained | Machine Learning
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
46 Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
47 Cross Validation using sklearn and python | Machine Learning
Cross Validation using sklearn and python | Machine Learning
Krish Naik
48 Handling Missing Data Easily Explained| Machine Learning
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
49 Deploy Machine Learning Model using Flask
Deploy Machine Learning Model using Flask
Krish Naik
50 Deployment of Deep Learning Model using Flask
Deployment of Deep Learning Model using Flask
Krish Naik
51 How to Visualize Multiple Linear Regression in python
How to Visualize Multiple Linear Regression in python
Krish Naik
52 K Nearest Neighbour Easily Explained with Implementation
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
53 Predicting Heart Disease using Machine Learning
Predicting Heart Disease using Machine Learning
Krish Naik
54 Predicting Lungs Disease using Deep Learning
Predicting Lungs Disease using Deep Learning
Krish Naik
55 Stock Sentiment Analysis using News Headlines
Stock Sentiment Analysis using News Headlines
Krish Naik
56 Random Forest(Bootstrap Aggregation) Easily Explained
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
57 Voting Classifier(Hard Voting and Soft Voting Classifier)
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
58 Credit Card Fraud Detection using Machine Learning from Kaggle
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
59 Hyperparameter Optimization for Xgboost
Hyperparameter Optimization for Xgboost
Krish Naik
60 Tutorial 45-Handling imbalanced Dataset  using python- Part 1
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik

Related Reads

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