Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Computer Vision Projects with OpenCV and Python 3
Computer Vision Projects with OpenCV and Python 3

Computer Vision Projects with OpenCV and Python 3: Six end-to-end projects built using machine learning with OpenCV, Python, and TensorFlow

eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Computer Vision Projects with OpenCV and Python 3

Image Captioning with TensorFlow

Primarily, this chapter will provide a brief overview of creating a detailed English language description of an image. Using the image captioning model based on TensorFlow, we will be able to replace a single word or compound words/phrases with detailed captions that perfectly describe the image. We will first use a pre-trained model for image captioning and then retrain the model from scratch to run on a set of images.

In this chapter, we will cover the following:

  • Image captioning introduction
  • Google Brain im2txt captioning model
  • Running our captioning code in Jupyter
  • Retraining the model

Technical requirements

Introduction to image captioning

Image captioning is a process in which textual description is generated based on an image. To better understand image captioning, we need to first differentiate it from image classification.

Difference between image classification and image captioning

Image classification is a relatively simple process that only tells us what is in an image. For example, if there is a boy on a bike, image classification will not give us a description; it will just provide the result as boy or bike. Image classification can tell us whether there is a woman or a dog in the image, or an action, such as snowboarding. This is not a desirable result as there is no description of what exactly is going on in the image...

Google Brain im2txt captioning model

Google Brain im2txt was used by Google in a paper 2015 MSCOCO Image Captioning Challenge, and will form the foundation of the image captioning code that we will implement in our project.

The Google's GitHub TensorFlow page can be found at https://github.com/tensorflow/models/tree/master/research/im2txt.

In the research directory, we will find the im2txt file, which was used by Google in the paper, 2015 MSCOCO Image Captioning Challenge, which is available for free at https://arxiv.org/abs/1609.06647. It covers RNNs, LSTM, and fundamental algorithms in detail.

We can check how CNNs are used for image classification and also learn how to use the LSTM RNNs for actually generating sequential caption outputs.

We can download the code from the GitHub link; however, it has not been set up to run easily as it does not include a pre-trained model...

Running the captioning code on Jupyter

Let's now run our own version of the code on a Jupyter Notebook. We can start up own own Jupyter Notebook and load the Section_1-Tensorflow_Image_Captioning.ipynb file from the GitHub repository (https://github.com/PacktPublishing/Computer-Vision-Projects-with-OpenCV-and-Python-3/blob/master/Chapter01/Section_1-Tensorflow_Image_Captioning.ipynb).

Once we load the file on a Jupyter Notebook, it will look something like this:

In the first part, we are going to load some essential libraries, including math, os, and tensorflow. We will also use our handy utility function, %pylab inline, to easily read and display images within the Notebook.

Select the first code block:

# load essential libraries
import math
import os

import tensorflow as tf

%pylab inline

When we hit Ctrl + Enter to execute the code in the cell, we will get the following output...

Retraining the captioning model

So, now that we have seen image captioning code in action, we are going to retrain the image captioner on our own desired data. However, we need to know that it will be very time consuming and will need over 100 GB of hard drive space for computations if we want it to process in a reasonable time. Even with a good GPU, it may take a few days or a week to complete the computation. Since we are inclined toward implementing it and have the resources, let's start retraining the model.

In the Notebook, the first step is to download the pre-trained Inception model. The webbrowser module will make it easy to open the URL and to download the file:

# First download pretrained Inception (v3) model

import webbrowser
webbrowser.open("http://download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz")

# Completely unzip tar.gz file to get inception_v3...

Summary

In this chapter, we were introduced to different image captioning methods. We learned about the Google Brain im2txt captioning model. While working on the project, we were able to run our pre-trained model on a Jupyter Notebook and analyze the model based on the results. In the last section of the chapter, we retrained our image captioning model from scratch.

In the next chapter, we will cover reading license plates with OpenCV.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Implement image classification and object detection using machine learning and deep learning
  • Perform image classification, object detection, image segmentation, and other Computer Vision tasks
  • Crisp content with a practical approach to solving real-world problems in Computer Vision

Description

Python is the ideal programming language for rapidly prototyping and developing production-grade codes for image processing and Computer Vision with its robust syntax and wealth of powerful libraries. This book will help you design and develop production-grade Computer Vision projects tackling real-world problems. With the help of this book, you will learn how to set up Anaconda and Python for the major OSes with cutting-edge third-party libraries for Computer Vision. You'll learn state-of-the-art techniques for classifying images, finding and identifying human postures, and detecting faces within videos. You will use powerful machine learning tools such as OpenCV, Dlib, and TensorFlow to build exciting projects such as classifying handwritten digits, detecting facial features,and much more. The book also covers some advanced projects, such as reading text from license plates from real-world images using Google’s Tesseract software, and tracking human body poses using DeeperCut within TensorFlow. By the end of this book, you will have the expertise required to build your own Computer Vision projects using Python and its associated libraries.

Who is this book for?

Python programmers and machine learning developers who wish to build exciting Computer Vision projects using the power of machine learning and OpenCV will find this book useful. The only prerequisite for this book is that you should have a sound knowledge of Python programming.

What you will learn

  • Install and run major Computer Vision packages within Python
  • Apply powerful support vector machines for simple digit classification
  • Understand deep learning with TensorFlow
  • Build a deep learning classifier for general images
  • Use LSTMs for automated image captioning
  • Read text from real-world images
  • Extract human pose data from images

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 28, 2018
Length: 182 pages
Edition : 1st
Language : English
ISBN-13 : 9781789954906
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Dec 28, 2018
Length: 182 pages
Edition : 1st
Language : English
ISBN-13 : 9781789954906
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 99.97
Hands-On Image Processing with Python
€37.99
Learn OpenCV 4 by Building Projects
€36.99
Computer Vision Projects with OpenCV and Python 3
€24.99
Total 99.97 Stars icon
Banner background image

Table of Contents

8 Chapters
Setting Up an Anaconda Environment Chevron down icon Chevron up icon
Image Captioning with TensorFlow Chevron down icon Chevron up icon
Reading License Plates with OpenCV Chevron down icon Chevron up icon
Human Pose Estimation with TensorFlow Chevron down icon Chevron up icon
Handwritten Digit Recognition with scikit-learn and TensorFlow Chevron down icon Chevron up icon
Facial Feature Tracking and Classification with dlib Chevron down icon Chevron up icon
Deep Learning Image Classification with TensorFlow Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
(1 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 100%
Mikhail Goncharov Apr 01, 2019
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Disclaimer: I have not finished this book.The content of this book is mostly code plus comments on what this code does. I wish there will be less code (that is available as a downloadable material) and more explanations why it's implemented this way and theory behind.Another major issue I personally had: is that instructions are not complete and I had to figure out how to obtain all files needed to train mococo model.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.