Practical Machine Learning and Image Processing: For Facial Recognition, Object Detection, and Pattern Recognition Using Python
()
About this ebook
The next section looks at advanced machine learning and deep learning methods for image processing and classification. You’ll work with concepts such as pulse coupled neural networks, AdaBoost, XG boost, and convolutional neural networks for image-specific applications. Later you’ll explore how models are made in real time and then deployed using various DevOps tools.
All the conceptsin Practical Machine Learning and Image Processing are explained using real-life scenarios. After reading this book you will be able to apply image processing techniques and make machine learning models for customized application.
What You Will Learn
- Discover image-processing algorithms and their applications using Python
- Explore image processing using the OpenCV library
- Use TensorFlow, scikit-learn, NumPy, and other libraries
- Work with machine learning and deep learning algorithms for image processing
- Apply image-processing techniques to five real-time projects
Who This Book Is For
Data scientists and software developers interested in image processing and computer vision.
Read more from Himanshu Singh
Practical Machine Learning with AWS: Process, Build, Deploy, and Productionize Your Models Using AWS Rating: 0 out of 5 stars0 ratingsDeep Neuro-Fuzzy Systems with Python: With Case Studies and Applications from the Industry Rating: 0 out of 5 stars0 ratings
Related to Practical Machine Learning and Image Processing
Related ebooks
Advanced Machine Learning with Python Rating: 0 out of 5 stars0 ratingsPractical Machine Learning with Python: A Problem-Solver's Guide to Building Real-World Intelligent Systems Rating: 0 out of 5 stars0 ratingsLearn R for Applied Statistics: With Data Visualizations, Regressions, and Statistics Rating: 0 out of 5 stars0 ratingsData Science with Jupyter: Master Data Science skills with easy-to-follow Python examples Rating: 0 out of 5 stars0 ratingsLearn PySpark: Build Python-based Machine Learning and Deep Learning Models Rating: 0 out of 5 stars0 ratingsPractical Python Data Visualization: A Fast Track Approach To Learning Data Visualization With Python Rating: 4 out of 5 stars4/5Applied Machine Learning Solutions with Python: SOLUTIONS FOR PYTHON, #1 Rating: 0 out of 5 stars0 ratingsHands-on Supervised Learning with Python Rating: 0 out of 5 stars0 ratingsDeep Learning with TensorFlow Rating: 5 out of 5 stars5/5Deep Learning with Azure: Building and Deploying Artificial Intelligence Solutions on the Microsoft AI Platform Rating: 0 out of 5 stars0 ratingsMastering jQuery Mobile Rating: 0 out of 5 stars0 ratingsPractical Machine Learning for Streaming Data with Python: Design, Develop, and Validate Online Learning Models Rating: 0 out of 5 stars0 ratingsPyTorch Recipes: A Problem-Solution Approach Rating: 0 out of 5 stars0 ratingsPro Machine Learning Algorithms: A Hands-On Approach to Implementing Algorithms in Python and R Rating: 0 out of 5 stars0 ratingsInternet of Things (IoT) A Quick Start Guide: A to Z of IoT Essentials Rating: 0 out of 5 stars0 ratingsPractical hapi: Build Your Own hapi Apps and Learn from Industry Case Studies Rating: 0 out of 5 stars0 ratingsAdvanced Data Analytics Using Python: With Machine Learning, Deep Learning and NLP Examples Rating: 0 out of 5 stars0 ratingsDeep Learning for Natural Language Processing: Creating Neural Networks with Python Rating: 0 out of 5 stars0 ratingsMachine Learning for Beginners: Learn to Build Machine Learning Systems Using Python (English Edition) Rating: 0 out of 5 stars0 ratingsMastering Machine Learning with Python in Six Steps: A Practical Implementation Guide to Predictive Data Analytics Using Python Rating: 0 out of 5 stars0 ratingsBeginning Machine Learning in the Browser: Quick-start Guide to Gait Analysis with JavaScript and TensorFlow.js Rating: 0 out of 5 stars0 ratings
Intelligence (AI) & Semantics For You
Midjourney Mastery - The Ultimate Handbook of Prompts Rating: 5 out of 5 stars5/5AI for Educators: AI for Educators Rating: 5 out of 5 stars5/5101 Midjourney Prompt Secrets Rating: 3 out of 5 stars3/5Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 5 out of 5 stars5/5Mastering ChatGPT: Unlock the Power of AI for Enhanced Communication and Relationships: English Rating: 0 out of 5 stars0 ratingsCreating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5ChatGPT For Fiction Writing: AI for Authors Rating: 5 out of 5 stars5/5Dancing with Qubits: How quantum computing works and how it can change the world Rating: 5 out of 5 stars5/5ChatGPT For Dummies Rating: 0 out of 5 stars0 ratingsArtificial Intelligence: A Guide for Thinking Humans Rating: 4 out of 5 stars4/5A Quickstart Guide To Becoming A ChatGPT Millionaire: The ChatGPT Book For Beginners (Lazy Money Series®) Rating: 4 out of 5 stars4/5Discovery Writing with ChatGPT: AI-Powered Storytelling: Three Story Method, #6 Rating: 0 out of 5 stars0 ratingsThe Secrets of ChatGPT Prompt Engineering for Non-Developers Rating: 5 out of 5 stars5/5What Makes Us Human: An Artificial Intelligence Answers Life's Biggest Questions Rating: 5 out of 5 stars5/5ChatGPT Rating: 1 out of 5 stars1/5Chat-GPT Income Ideas: Pioneering Monetization Concepts Utilizing Conversational AI for Profitable Ventures Rating: 4 out of 5 stars4/5ChatGPT Ultimate User Guide - How to Make Money Online Faster and More Precise Using AI Technology Rating: 0 out of 5 stars0 ratingsTensorFlow in 1 Day: Make your own Neural Network Rating: 4 out of 5 stars4/5ChatGPT for Marketing: A Practical Guide Rating: 3 out of 5 stars3/5THE CHATGPT MILLIONAIRE'S HANDBOOK: UNLOCKING WEALTH THROUGH AI AUTOMATION Rating: 5 out of 5 stars5/5The Business Case for AI: A Leader's Guide to AI Strategies, Best Practices & Real-World Applications Rating: 0 out of 5 stars0 ratingsDark Aeon: Transhumanism and the War Against Humanity Rating: 5 out of 5 stars5/5
Reviews for Practical Machine Learning and Image Processing
0 ratings0 reviews
Book preview
Practical Machine Learning and Image Processing - Himanshu Singh
© Himanshu Singh 2019
Himanshu SinghPractical Machine Learning and Image Processinghttps://doi.org/10.1007/978-1-4842-4149-3_1
1. Setup Environment
Himanshu Singh¹
(1)
Allahabad, Uttar Pradesh, India
In this chapter we prepare our system to run the code included in this book. Let’s look at how to install the following:
Anaconda
OpenCV
Keras
Aside from the last two packages in the list, most of what we need comes preinstalled with Anaconda. Let’s start with Anaconda, then follow with OpenCV and Keras.
Install Anaconda
The Anaconda installation page proclaims it is The Most Popular Python Data Science Platform.
Using Anaconda, installing supporting software, setting up virtual environments, and so on, are all quite easy, and the package comes with one of the best integrated development environments (IDEs) for Python data science: Jupyter Notebook. Jupyter not only helps you write Python code, but also it makes your code look beautiful and presentable. So, let’s get started with the Anaconda installation.
Windows
If you are using Windows, here’s the process:
1.
Go to www.anaconda.com.
2.
On the top right side of the screen, is the button Downloads. Click it.
3.
Scroll down and you will see two versions of Anaconda: Python version 3.7 and Python version 2.7. In the Python 3.7 version box, select 64-Bit Graphical Installer (select the 32-bit option, if your system is a 32-bit system).
4.
Wait for the download to finish, then double-click the installation file.
5.
Finish the installation and restart your system.
6.
Now, open the Start menu, search for the Anaconda prompt, and select it. A shell named Anaconda Prompt appears. Type Jupyter Notebook inside the shell and you will see a screen like the one displayed in Figure 1-1.
../images/471189_1_En_1_Chapter/471189_1_En_1_Fig1_HTML.jpgFigure 1-1
Opening screen
7.
In the top right corner of the Files tab, you’ll see the drop-down New. Click the downward-pointing arrow and Select Python 3. Now you’re ready to code (Figure 1-2)!
../images/471189_1_En_1_Chapter/471189_1_En_1_Fig2_HTML.jpgFigure 1-2
A new Python script
macOS
If you are using macOS, here is the Anaconda installation process:
1.
Download Anaconda for macOS as you would for Windows.
2.
Double-click the .pkg file and follow the installation procedures.
3.
Open your terminal and type Jupyter Notebook. You will see the same screen shown in Figure 1-1.
Ubuntu
The process for downloading Anaconda in Ubuntu is as follows:
1.
Download Anaconda for Linux as you did for Windows.
2.
Go to the installation folder and type bash Anaconda-latest-Linux-x86_64.sh.
3.
Follow the installation procedures, open your terminal, and type Jupyter Notebook. You will see the same screen shown in Figure 1-1.
Install OpenCV
Now that we have installed Anaconda and Jupyter Notebook. The next thing to do is to install its supporting software. For OpenCV, do the following:
1.
Open the Anaconda Prompt.
2.
Type conda install -c conda-forge opencv.
3.
You could also type conda install -c conda-forge/label/broken opencv.
4.
After a few minutes, OpenCV will be installed in your environment.
Install Keras
To install Keras, follow these procedures:
1.
Open the Anaconda Prompt.
Type conda install -c conda-forge keras.
2.
After a few minutes, Keras will be installed in your environment.
Test the Installations
Before going further, you need to test the installations as follows:
1.
Open Jupyter Notebook.
2.
Open a new Python 3 notebook.
3.
Type import cv2. If you do not receive an error, then OpenCV has been installed perfectly. If an error comes, either you did something wrong during the installation, or there may be a compatibility issue. For rectification, either restart the process of installation, or refer to OpenCV documentation page.
4.
Type import keras. If you do not receive an error, then Keras has been installed perfectly. If an error comes, either you did something wrong during the installation, or there may be a compatibility issue. For rectification, either restart the process of installation, or refer to Keras documentation page.
Virtual Environments
Now that we have installed the software we need, let’s take a look at virtual environments. Virtual environments are very important when you want to develop multiple projects. What should we do if we are developing a product using Python 3, but we want to create another project using Python 2.7? If we do it directly, we may encounter problems because different versions of Python are installed. Or, we could create a virtual environment, install Python 2.7, and develop the product inside that environment. Regardless of what you develop inside a virtual environment, it never influences any code outside the environment. Let’s see how we can create a virtual environment:
1.
Type conda create -n environment_name python=version anaconda. In place of environment_name, type any name you wish to give to your environment. In place of version, type any version of Python that you wish to use (for example, 2.7, 3.5, 3.6, and so on).
2.
Now that we have created the environment, we have to activate it. We do this by typing source activate environment_name.
3.
We can now open Jupyter Notebook and start working in this environment.
4.
To deactivate the environment, type source deactivate.
© Himanshu Singh 2019
Himanshu SinghPractical Machine Learning and Image Processinghttps://doi.org/10.1007/978-1-4842-4149-3_2
2. Introduction to Image Processing
Himanshu Singh¹
(1)
Allahabad, Uttar Pradesh, India
In this chapter we examine exactly what an image is, and its related properties. By the end of the chapter, you should have an understanding of the following concepts:
Images
Pixels
Image resolution
Pixels per inch (PPI) and dots per inch (DPI)
Bitmap images
Lossless compression and lossy compression
Different image file formats
Different types of color spaces
Advanced image concepts
Images
Visual representation of a real-life object (a person or any other object) in a two-dimensional form is called an image. An image is nothing but a collection of pixels in different color spaces. Figure 2-1 is an example of a normal image .
../images/471189_1_En_2_Chapter/471189_1_En_2_Fig1_HTML.jpgFigure 2-1
Normal Image
Pixels
You might think of a complete image as a set that consists of small samples. These samples are called pixels. They are the smallest elements in any digital image. Have you ever zoomed in on an image to such an extent that you see small squares? Those are pixels. So, pixels are subsamples of an image that, when get combined, give us the complete image. Figure 2-2 shows how pixels, with various colors, may