Bird Species Identification Using Deep Learning
Bird Species Identification Using Deep Learning
1.1Problem statement :
Basically bird identification is done visually or acoustically. The main visual
components comprise of bird’s shape, its wings, size, pose, color, etc. However, while
considering the parameters time of year must be taken into consideration because
bird’s wings changes according to their growth. The acoustics components comprise
the songs and call that birds make [7]. The marks that distinguish one bird from
another are also useful, such as breast spots, wing bars which are described as thin
lines along the wings, eye rings, crowns, eyebrows. The shape of the beak is often an
important aspect as a bird can recognized uniquely.
Motivation:
BIRD behavior and population trends have become an important issue now a days.
Birds help us to detect other organisms in the environment (e.g. insects they feed on)
easily as they respond quickly to the environmental changes [2]. But, gathering and
collecting information about birds requires huge human effort as well as becomes a
very costlier method. In such case, a reliable system that will provide large scale
processing of information about birds and will serve as a valuable tool for researchers,
governmental agencies, etc. is required...
1.2Objective:
Bird species identification means predicting the bird species belongs to which
category by using an image. The identification can be done through image, audio or
video. An audio processing technique makes it possible to identify by capturing the
audio signal of birds. But, due to the mixed sounds in environment such as insects,
objects from real world, etc. processing of such information becomes more
complicated. Usually, human beings find images more effective than audios or videos.
1.3.1 Proposed System:
In this paper author is describing concept to identify species of birds by using python
TENSORFLOW and Deep Learning algorithm. Earlier technique were using birds
voice or videos to predict it species but this technique will not give accurate result as
audio may contains background or other animal voices. So images can be best option
to identify species of birds.
To implement this technique we need to train all birds species and generate a model
1
and then by uploading any image deep learning algorithm will convert uploaded
image into gray scale format and apply that image on train model to predict best
match species name for uploaded image.
Advantages
To train bird species we are using ‘Caltech-UCSD Birds 200(CUB-200-2011)’ dataset
which contains 200 species or categories of birds. Model will be built using that
dataset and tensor flow deep learning algorithm.
So the main aim of this project is to identify species of birds.
2
CHAPTER 2
TECHNOLOGIES LEARNT
What is Python :-
Below are some facts about Python.
Advantages of Python :-
1. Extensive Libraries
Python downloads with an extensive library and it contain code for various purposes
like regular expressions, documentation-generation, unit-testing, web browsers,
threading, databases, CGI, email, image manipulation, and more. So, we don’t have
to write the complete code for that manually.
3
2. Extensible
As we have seen earlier, Python can be extended to other languages. You can write
some of your code in languages like C++ or C. This comes in handy, especially in
projects.
3. Embeddable
Since Python forms the basis of new platforms like Raspberry Pi, it finds the future
bright for the Internet Of Things. This is a way to connect the language with the real
world.
When working with Java, you may have to create a class to print ‘Hello World’. But
in Python, just a print statement will do. It is also quite easy to learn, understand,
and code. This is why when people pick up Python, they have a hard time adjusting to
other more verbose languages like Java.
7. Readable
Because it is not such a verbose language, reading Python is much like reading
English. This is the reason why it is so easy to learn, understand, and code. It also
does not need curly braces to define blocks, and indentation is mandatory. This
further aids the readability of the code.
8. Object-Oriented
4
model the real world. A class allows the encapsulation of data and functions into
one.
9. Free and Open-Source
Like we said earlier, Python is freely available. But not only can you download
Python for free, but you can also download its source code, make changes to it, and
even distribute it. It downloads with an extensive collection of libraries to help you
with your tasks.
10. Portable
When you code your project in a language like C++, you may need to make some
changes to it if you want to run it on another platform. But it isn’t the same with
Python. Here, you need to code only once, and you can run it anywhere. This is
called Write Once Run Anywhere (WORA). However, you need to be careful
enough not to include any system-dependent features.
11. Interpreted
Lastly, we will say that it is an interpreted language. Since statements are executed
one by one, debugging is easier than in compiled languages.
Any doubts till now in the advantages of Python? Mention in the comment section.
1. Less Coding
Almost all of the tasks done in Python requires less coding when the same task is
done in other languages. Python also has an awesome standard library support, so you
don’t have to search for any third-party libraries to get your job done. This is the
reason that many people suggest learning Python to beginners.
2. Affordable
The 2019 Github annual survey showed us that Python has overtaken Java in
the most popular programming language category.
5
3. Python is for Everyone
Python code can run on any machine whether it is Linux, Mac or Windows.
Programmers need to learn different languages for different jobs but with Python, you
can professionally build web apps, perform data analysis and machine learning,
automate things, do web scraping and also build games and powerful visualizations. It
is an all-rounder programming language.
Disadvantages of Python
So far, we’ve seen why Python is a great choice for your project. But if you choose it,
you should be aware of its consequences as well. Let’s now see the downsides of
choosing Python over another language.
1. Speed Limitations
We have seen that Python code is executed line by line. But since Python is
interpreted, it often results in slow execution. This, however, isn’t a problem unless
speed is a focal point for the project. In other words, unless high speed is a
requirement, the benefits offered by Python are enough to distract us from its speed
limitations.
2. Weak in Mobile Computing and Browsers
3. Design Restrictions
As you know, Python is dynamically-typed. This means that you don’t need to
declare the type of variable while writing the code. It uses duck-typing. But wait,
what’s that? Well, it just means that if it looks like a duck, it must be a duck. While
this is easy on the programmers during coding, it can raise run-time errors.
6
4. Underdeveloped Database Access Layers
No, we’re not kidding. Python’s simplicity can indeed be a problem. Take my
example. I don’t do Java, I’m more of a Python person. To me, its syntax is so simple
that the verbosity of Java code seems unnecessary.
This was all about the Advantages and Disadvantages of Python Programming
Language.
History of Python : -
What do the alphabet and the programming language Python have in common?
Right, both start with ABC. If we are talking about ABC in the Python context, it's
clear that the programming language ABC is meant. ABC is a general-purpose
programming language and programming environment, which had been developed in
the Netherlands, Amsterdam, at the CWI (Centrum Wiskunde & Informatica). The
greatest achievement of ABC was to influence the design of Python. Python was
conceptualized in the late 1980s. Guido van Rossum worked that time in a project at
the CWI, called Amoeba, a distributed operating system. In an interview with Bill
Venners1, Guido van Rossum said: "In the early 1980s, I worked as an implementer
on a team building a language called ABC at Centrum voor Wiskunde en Informatica
(CWI). I don't know how well people know ABC's influence on Python. I try to
mention ABC's influence because I'm indebted to everything I learned during that
project and to the people who worked on it." Later on in the same Interview, Guido
van Rossum continued: "I remembered all my experience and some of my frustration
with ABC. I decided to try to design a simple scripting language that possessed some
of ABC's better properties, but without its problems. So I started typing. I created a
simple virtual machine, a simple parser, and a simple runtime. I made my own
version of the various ABC parts that I liked. I created a basic syntax, used
7
indentation for statement grouping instead of curly braces or begin-end blocks, and
developed a small number of powerful data types: a hash table (or dictionary, as we
call it), a list, strings, and numbers."
What is Machine Learning : -
Before we take a look at the details of various machine learning methods, let's start by
looking at what machine learning is, and what it isn't. Machine learning is often
categorized as a subfield of artificial intelligence, but I find that categorization can
often be misleading at first brush. The study of machine learning certainly arose from
research in this context, but in the data science application of machine learning
methods, it's more helpful to think of machine learning as a means of building models
of data.
At the most fundamental level, machine learning can be categorized into two main
types: supervised learning and unsupervised learning.
8
Unsupervised learning involves modeling the features of a dataset without reference
to any label, and is often described as "letting the dataset speak for itself." These
models include tasks such as clustering and dimensionality reduction. Clustering
algorithms identify distinct groups of data, while dimensionality reduction algorithms
search for more succinct representations of the data. We will see examples of both
types of unsupervised learning in the following section.
Human beings, at this moment, are the most intelligent and advanced species on earth
because they can think, evaluate and solve complex problems. On the other side, AI is
still in its initial stage and haven’t surpassed human intelligence in many aspects.
Then the question is that what is the need to make machine learn? The most suitable
reason for doing this is, “to make decisions, based on data, with efficiency and scale”.
Quality of data − Having good-quality data for ML algorithms is one of the biggest
challenges. Use of low-quality data leads to the problems related to data
preprocessing and feature extraction.
9
Time-Consuming task − Another challenge faced by ML models is the consumption
of time especially for data acquisition, feature extraction and retrieval.
Emotion analysis
Sentiment analysis
Speech synthesis
Speech recognition
Customer segmentation
Object recognition
10
Fraud detection
Fraud prevention
This is a rough roadmap you can follow on your way to becoming an insanely
talented Machine Learning Engineer. Of course, you can always modify the steps
according to your needs to reach your desired end-goal!
In case you are a genius, you could start ML directly but normally, there are some
prerequisites that you need to know which include Linear Algebra, Multivariate
Calculus, Statistics, and Python. And if you don’t know these, never fear! You don’t
need a Ph.D. degree in these topics to get started but you do need a basic
understanding.
11
(a) Learn Linear Algebra and Multivariate Calculus
Both Linear Algebra and Multivariate Calculus are important in Machine Learning.
However, the extent to which you need them depends on your role as a data scientist.
If you are more focused on application heavy machine learning, then you will not be
that heavily focused on maths as there are many common libraries available. But if
you want to focus on R&D in Machine Learning, then mastery of Linear Algebra and
Multivariate Calculus is very important as you will have to implement many ML
algorithms from scratch.
Data plays a huge role in Machine Learning. In fact, around 80% of your time as an
ML expert will be spent collecting and cleaning data. And statistics is a field that
handles the collection, analysis, and presentation of data. So it is no surprise that you
need to learn it!!!
Some of the key concepts in statistics that are important are Statistical Significance,
Probability Distributions, Hypothesis Testing, Regression, etc. Also, Bayesian
Thinking is also a very important part of ML which deals with various concepts like
Conditional Probability, Priors, and Posteriors, Maximum Likelihood, etc.
Some people prefer to skip Linear Algebra, Multivariate Calculus and Statistics and
learn them as they go along with trial and error. But the one thing that you absolutely
cannot skip is Python! While there are other languages you can use for Machine
Learning like R, Scala, etc. Python is currently the most popular language for ML. In
fact, there are many Python libraries that are specifically useful for Artificial
Intelligence and Machine Learning such as Keras, TensorFlow, Scikit-learn, etc.
So if you want to learn ML, it’s best if you learn Python! You can do that using
various online resources and courses such as Fork Python available Free on
GeeksforGeeks.
12
Step 2 – Learn Various ML Concepts
Now that you are done with the prerequisites, you can move on to actually learning
ML (Which is the fun part!!!) It’s best to start with the basics and then move on to the
more complicated stuff. Some of the basic concepts in ML are:
13
Semi-supervised Learning – This involves using unlabelled data like Unsupervised
Learning with a small amount of labeled data. Using labeled data vastly increases the
learning accuracy and is also more cost-effective than Supervised Learning.
Reinforcement Learning – This involves learning optimal actions through trial and
error. So the next action is decided by learning behaviors that are based on the current
state and that will maximize the reward in the future.
Advantages of Machine learning :-
Machine Learning can review large volumes of data and discover specific trends and
patterns that would not be apparent to humans. For instance, for an e-commerce
website like Amazon, it serves to understand the browsing behaviors and purchase
histories of its users to help cater to the right products, deals, and reminders relevant
to them. It uses the results to reveal relevant advertisements to them.
2. No human intervention needed (automation)
With ML, you don’t need to babysit your project every step of the way. Since it
means giving machines the ability to learn, it lets them make predictions and also
improve the algorithms on their own. A common example of this is anti-virus
softwares; they learn to filter new threats as they are recognized. ML is also good at
recognizing spam.
3. Continuous Improvement
Machine Learning algorithms are good at handling data that are multi-dimensional
and multi-variety, and they can do this in dynamic or uncertain environments.
5. Wide Applications
You could be an e-tailer or a healthcare provider and make ML work for you. Where
it does apply, it holds the capability to help deliver a much more personal experience
14
to customers while also targeting the right customers.
Disadvantages of Machine Learning :-
1. Data Acquisition
Machine Learning requires massive data sets to train on, and these should be
inclusive/unbiased, and of good quality. There can also be times where they must
wait for new data to be generated.
2. Time and Resources
ML needs enough time to let the algorithms learn and develop enough to fulfill their
purpose with a considerable amount of accuracy and relevancy. It also needs massive
resources to function. This can mean additional requirements of computer power for
you.
3. Interpretation of Results
Another major challenge is the ability to accurately interpret results generated by the
algorithms. You must also carefully choose the algorithms for your purpose.
4. High error-susceptibility
Machine Learning is autonomous but highly susceptible to errors. Suppose you train
an algorithm with data sets small enough to not be inclusive. You end up with biased
predictions coming from a biased training set. This leads to irrelevant advertisements
being displayed to customers. In the case of ML, such blunders can set off a chain of
errors that can go undetected for long periods of time. And when they do get noticed,
it takes quite some time to recognize the source of the issue, and even longer to
correct it.
15
which Guido Van Rossum never liked. Six and a half years later in October 2000,
Python 2.0 was introduced. This release included list comprehensions, a full garbage
collector and it was supporting unicode. Python flourished for another 8 years in the
versions 2.x before the next major release as Python 3.0 (also known as "Python
3000" and "Py3K") was released. Python 3 is not backwards compatible with Python
2.x. The emphasis in Python 3 had been on the removal of duplicate programming
constructs and modules, thus fulfilling or coming close to fulfilling the 13th law of
the Zen of Python: "There should be one -- and preferably only one -- obvious way to
do it." Some changes in Python 7.3:
Purpose :-
We demonstrated that our approach enables successful segmentation of intra-retinal
layers—even with low-quality images containing speckle noise, low contrast, and
different intensity ranges throughout—with the assistance of the ANIS feature.
Python
16
Python is Interpreted − Python is processed at runtime by the interpreter. You do not
need to compile your program before executing it. This is similar to PERL and PHP.
Python is Interactive − you can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.
Python also acknowledges that speed of development is important. Readable and terse
code is part of this, and so is access to powerful constructs that avoid tedious
repetition of code. Maintainability also ties into this may be an all but useless metric,
but it does say something about how much code you have to scan, read and/or
understand to troubleshoot problems or tweak behaviors. This speed of development,
the ease with which a programmer of other languages can pick up basic Python skills
and the huge standard library is key to another area where Python excels. All its tools
have been quick to implement, saved a lot of time, and several of them have later
been patched and updated by people with no Python background - without breaking.
Tensorflow
TensorFlow was developed by the Google Brain team for internal Google use. It was
released under the Apache 2.0 open-source license on November 9, 2015.
Numpy
17
Useful linear algebra, Fourier transform, and random number capabilities
Besides its obvious scientific uses, Numpy can also be used as an efficient multi-
dimensional container of generic data. Arbitrary data-types can be defined using
Numpy which allows Numpy to seamlessly and speedily integrate with a wide variety
of databases.
Pandas
Matplotlib
Scikit – learn
18
commercial use. Python
19
There have been several updates in the Python version over the years. The question is
how to install Python? It might be confusing for the beginner who is willing to start
learning Python but this tutorial will solve your query. The latest or the newest version
of Python is version 3.7.4 or in other words, it is Python 3.
Note: The python version 3.7.4 cannot be used on Windows XP or earlier devices.
Before you start with the installation process of Python. First, you need to know about
your System Requirements. Based on your system type i.e. operating system and based
processor, you must download the python version. My system type is a Windows 64-bit
operating system. So the steps below are to install python version 3.7.4 on Windows 7
device or to install Python 3. Download the Python Cheatsheet here.The steps on how
to install Python on Windows 10, 8 and 7 are divided into 4 parts to help understand
better.
Step 1: Go to the official site to download and install python using Google
Chrome or any other web browser. OR Click on the following
link: https://www.python.org
20
Now, check for the latest and the correct version for your operating system.
Step 3: You can either select the Download Python for windows 3.7.4 button in
Yellow Color or you can scroll further down and click on download with respective
to their version. Here, we are downloading the most recent python version for
windows 3.7.4
Step 4: Scroll down the page until you find the Files option.
Step 5: Here you see a different version of python along with the operating system.
21
To download Windows 32-bit python, you can select any one from the three
options: Windows x86 embeddable zip file, Windows x86 executable installer or
Windows x86 web-based installer.
To download Windows 64-bit python, you can select any one from the three
options: Windows x86-64 embeddable zip file, Windows x86-64 executable installer
or Windows x86-64 web-based installer.
Here we will install Windows x86-64 web-based installer. Here your first part regarding
which version of python is to be downloaded is completed. Now we move ahead with
the second part in installing python i.e. Installation
Note: To know the changes or updates that are made in the version you can click on the
Release Note Option.
Installation of Python
Step 1: Go to Download and Open the downloaded python version to carry out the
installation process.
22
Step 2: Before you click on Install Now, Make sure to put a tick on Add
Python 3.7 to PATH.
23
With these above three steps on python installation, you have successfully and
correctly installed Python. Now is the time to verify the installation.
Note: The installation process might take a couple of minutes.
24
Step 3: Open the Command prompt option.
Step 4: Let us test whether the python is correctly installed. Type python –V and
press Enter.
25
Step 3: Click on IDLE (Python 3.7 64-bit) and launch the program
Step 4: To go ahead with working in IDLE you must first save the file. Click on
File > Click on Save
Step 5: Name the file and save as type should be Python files. Click on SAVE. Here
I have named the files as Hey World.
Step 6: Now for e.g. enter print (“Hey World”) and Press Enter.
26
You will see that the command given is launched. With this, we end our tutorial on how
to install Python. You have learned how to download python for windows into your
respective operating system.
Note: Unlike Java, Python doesn’t need semicolons at the end of the statements
otherwise it won’t work.
This stack that includes:
world.
27
Advantages of Django
Here are few advantages of using Django which can be listed out here −
As you already know, Django is a Python web framework. And like most modern
framework, Django supports the MVC pattern. First let's see what is the Model-View-
Controller (MVC) pattern, and then we will look at Django’s specificity for the
Model-View-Template (MVT) pattern.
MVC Pattern
When talking about applications that provides UI (web or desktop), we usually talk
about MVC architecture. And as the name suggests, MVC pattern is based on three
components: Model, View, and Controller. Check our MVC tutorial here to know
more.
The Model-View-Template (MVT) is slightly different from MVC. In fact the main
difference between the two patterns is that Django itself takes care of the Controller
part (Software Code that controls the interactions between the Model and View),
leaving us with the template. The template is a HTML file mixed with Django
Template Language (DTL).
28
The following diagram illustrates how each of the components of the MVT pattern
interacts with each other to serve a user request −
The developer provides the Model, the view and the template then just maps it to a
URL and Django does the magic to serve it to the user.
Jupyter Notebook
The Jupyter Notebook is an open source web application that you can use to create
and share documents that contain live code, equations, visualizations, and text.
Jupyter Notebook is maintained by the people at Project Jupyter.
Jupyter Notebooks are a spin-off project from the IPython project, which used to have
an IPython Notebook project itself. The name, Jupyter, comes from the core
supported programming languages that it supports: Julia, Python, and R. Jupyter ships
with the IPython kernel, which allows you to write your programs in Python, but
there are currently over 100 other kernels that you can also use.
Anaconda :-
29
Together with a list of Python packages, tools like editors, Python distributions
include the Python interpreter. Anaconda is one of several Python distributions.
Anaconda is a new distribution of the Python and R data science package. It
was formerly known as Continuum Analytics. Anaconda has more than 100
new packages.
The released version 5.0.1 addresses some minor bugs and adds useful features,
such as updated R language support. All of these features weren’t available in
the original 5.0.0 release.
30
31
CHAPTER 3 SYSTEM DESIGN
3.1 System Architecture
32
K – nearest neighbor:
In k-NN regression, the output is the property value for the object. This
value is the average of the values of k nearest neighbors.
The neighbors are taken from a set of objects for which the class (for k-NN
classification) or the object property value (for k-NN regression) is known.
This can be thought of as the training set for the algorithm, though no explicit
training step is required.
Bagging classifier:
33
A Bagging classifier is an ensemble meta-estimator that fits base classifiers each on
random subsets of the original dataset and then aggregate their individual predictions
(either by voting or by averaging) to form a final prediction. Such a meta-estimator
can typically be used as a way to reduce the variance of a black-box estimator (e.g., a
decision tree), by introducing randomization into its construction procedure and then
making an ensemble out of it.
Each base classifier is trained in parallel with a training set which is generated by
randomly drawing, with replacement, N examples (or data) from the original training
dataset – where N is the size of the original training set. Training set for each of the
base classifiers is independent of each other. Many of the original data may be
repeated in the resulting training set while others may be left out.
Bagging reduces over fitting (variance) by averaging or voting, however, this leads to
an increase in bias, which is compensated by the reduction in variance though.
AdaBoost:
Every learning algorithm tends to suit some problem types better than others, and
typically has many different parameters and configurations to adjust before it achieves
optimal performance on a dataset, AdaBoost is often referred to as the best out-of-
the-box classifier.[2] When used with decision tree learning, information gathered at
each stage of the AdaBoost algorithm about the relative 'hardness' of each training
sample is fed into the tree growing algorithm such that later trees tend to focus on
harder-to-classify examples.
34
Multilayer perceptron (MLP):
An MLP consists of at least three layers of nodes: an input layer, a hidden layer and
an output layer. Except for the input nodes, each node is a neuron that uses a
nonlinear activation function. MLP utilizes a supervised learning technique
called back propagation for training. Its multiple layers and non-linear activation
distinguish MLP from a linear perceptron. It can distinguish data that is not linearly
separable.
ANNs are considered nonlinear statistical data modelling tools where the complex
relationships between inputs and outputs are modelled or patterns are found.
An ANN has several advantages but one of the most recognized of these is the fact
that it can actually learn from observing data sets. In this way, ANN is used as a
random function approximation tool. These types of tools help estimate the most cost-
effective and ideal methods for arriving at solutions while defining computing
functions or distributions. ANN takes data samples rather than entire data sets to
arrive at solutions, which saves both time and money. ANNs are considered fairly
35
simple mathematical models to enhance existing data analysis technologies.
ANNs have three layers that are interconnected. The first layer consists of input
neurons. Those neurons send data on to the second layer, which in turn sends the
output neurons to the third layer.
Training an artificial neural network involves choosing from allowed models for
which there are several associated algorithms.
3.3System Specification
2. The data should be accessible through any devices connected to the Internet;
3. The service should be capable to synchronize the user’s data between multiple
devices (notebooks, smart phones, etc.);
4. The service should preserve all historical changes (versioning);
7. The service should be interoperable with other cloud storage services, enabling
data migration from one CSP to another.
• Operating System: Windows
• Script:
• Database :
36
• Processor - Pentium –III
• Hard Disk - 20 GB
UML is an acronym that stands for Unified Modeling Language. Simply put, UML
is a modern approach to modeling and documenting software. In fact, it’s one of the
most popular business process modeling techniques.
UML was created as a result of the chaos revolving around software development and
documentation. In the 1990s, there were several different ways to represent and
document software systems. The need arose for a more unified way to visually
represent those systems and as a result, in 1994-1996, the UML was developed by
three software engineers working at Rational Software. It was later adopted as the
standard in 1997 and has remained the standard ever since, receiving only a few
updates.
GOALS:
1. Provide users a ready-to-use, expressive visual modeling Language so that they can
37
develop and exchange meaningful models.
2. Provide extendibility and specialization mechanisms to extend the core concepts.
upload image
User
38
ii. SEQUENCE DIAGRAM:
user Database
upload image
Choose image()
Upload Image()
Run DCNN Algorithm()
view identified species()
View Score card()
Database
Data flow diagrams are used to graphically represent the flow of data in a business
information system. DFD describes the processes that are involved in a system to
transfer data from the input to the file storage and reports generation.
Data flow diagrams can be divided into logical and physical. The logical data flow
diagram describes flow of data through a system to perform certain functionality of
a business. The physical data flow diagram describes the implementation of the
logical data flow..
import argparse
import collections
from datetime import datetime
import hashlib
import os.path
import random
import re
import sys
import tarfile
import numpy as np
from six.moves import urllib
import tensorflow as tf
def create_model_graph(model_info):
with tf.Graph().as_default() as graph:
model_path = os.path.join(FLAGS.model_dir, model_info['model_file_name'])
with gfile.FastGFile(model_path, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
bottleneck_tensor, resized_input_tensor = (tf.import_graph_def(
graph_def,
name='',
return_elements=[
model_info['bottleneck_tensor_name'],
model_info['resized_input_tensor_name'],
]))
return graph, bottleneck_tensor, resized_input_tensor
def maybe_download_and_extract(data_url):
dest_directory = FLAGS.model_dir
if not os.path.exists(dest_directory):
os.makedirs(dest_directory)
filename = data_url.split('/')[-1]
filepath = os.path.join(dest_directory, filename)
if not os.path.exists(filepath):
def ensure_dir_exists(dir_name):
if not os.path.exists(dir_name):
os.makedirs(dir_name)
bottleneck_path_2_bottleneck_values = {}
how_many_bottlenecks += 1
if how_many_bottlenecks % 100 == 0:
tf.logging.info(
str(how_many_bottlenecks) + ' bottleneck files created.')
def get_random_distorted_bottlenecks(
sess, image_lists, how_many, category, image_dir, input_jpeg_tensor,
distorted_image, resized_input_tensor, bottleneck_tensor):
class_count = len(image_lists.keys())
bottlenecks = []
ground_truths = []
for unused_i in range(how_many):
label_index = random.randrange(class_count)
label_name = list(image_lists.keys())[label_index]
image_index = random.randrange(MAX_NUM_IMAGES_PER_CLASS + 1)
image_path = get_image_path(image_lists, label_name, image_index, image_dir,
category)
if not gfile.Exists(image_path):
tf.logging.fatal('File does not exist %s', image_path)
jpeg_data = gfile.FastGFile(image_path, 'rb').read()
distorted_image_data = sess.run(distorted_image,
{input_jpeg_tensor: jpeg_data})
bottleneck_values = sess.run(bottleneck_tensor,
{resized_input_tensor: distorted_image_data})
bottleneck_values = np.squeeze(bottleneck_values)
ground_truth = np.zeros(class_count, dtype=np.float32)
ground_truth[label_index] = 1.0
bottlenecks.append(bottleneck_values)
ground_truths.append(ground_truth)
return bottlenecks, ground_truths
def variable_summaries(var):
with tf.name_scope('summaries'):
mean = tf.reduce_mean(var)
tf.summary.scalar('mean', mean)
with tf.name_scope('stddev'):
stddev = tf.sqrt(tf.reduce_mean(tf.square(var - mean)))
tf.summary.scalar('stddev', stddev)
tf.summary.scalar('max', tf.reduce_max(var))
tf.summary.scalar('min', tf.reduce_min(var))
tf.summary.histogram('histogram', var)
if (i % FLAGS.eval_step_interval) == 0 or is_last_step:
train_accuracy, cross_entropy_value = sess.run(
[evaluation_step, cross_entropy],
feed_dict={bottleneck_input: train_bottlenecks,
ground_truth_input: train_ground_truth})
tf.logging.info('%s: Step %d: Train accuracy = %.1f%%' %
(datetime.now(), i, train_accuracy * 100))
tf.logging.info('%s: Step %d: Cross entropy = %f' %
(datetime.now(), i, cross_entropy_value))
validation_bottlenecks, validation_ground_truth, _ = (
get_random_cached_bottlenecks(
sess, image_lists, FLAGS.validation_batch_size, 'validation',
FLAGS.bottleneck_dir, FLAGS.image_dir, jpeg_data_tensor,
decoded_image_tensor, resized_image_tensor, bottleneck_tensor,
FLAGS.architecture))
# Run a validation step and capture training summaries for TensorBoard
# with the `merged` op.
validation_summary, validation_accuracy = sess.run(
[merged, evaluation_step],
feed_dict={bottleneck_input: validation_bottlenecks,
ground_truth_input: validation_ground_truth})
validation_writer.add_summary(validation_summary, i)
tf.logging.info('%s: Step %d: Validation accuracy = %.1f%% (N=%d)' %
(datetime.now(), i, validation_accuracy * 100,
len(validation_bottlenecks)))
# Store intermediate results
intermediate_frequency = FLAGS.intermediate_store_frequency
default=10,
help='How often to evaluate the training results.'
)
parser.add_argument(
'--train_batch_size',
type=int,
default=100,
help='How many images to train on at a time.'
)
parser.add_argument(
'--test_batch_size',
type=int,
default=-1,
help="""\
How many images to test on. This test set is only used once, to evaluate
the final accuracy of the model after training completes.
A value of -1 causes the entire test set to be used, which leads to more
stable results across runs.\
"""
)
parser.add_argument(
'--validation_batch_size',
type=int,
default=100,
help="""\
How many images to use in an evaluation batch. This validation set is
used much more often than the test set, and is an early indicator of how
accurate the model is during training.
A value of -1 causes the entire validation set to be used, which leads to
more stable results across training iterations, but may be slower on large
training sets.\
"""
import argparse
import collections
from datetime import datetime
import hashlib
import os.path
import random
import re
import sys
import tarfile
import numpy as np
from six.moves import urllib
import tensorflow as tf
FLAGS = None
MAX_NUM_IMAGES_PER_CLASS = 2 ** 27 - 1 # ~134M
TYPES OF TESTS
Unit testing
Unit testing involves the design of test cases that validate that the internal
program logic is functioning properly, and that program inputs produce valid outputs.
All decision branches and internal code flow should be validated. It is the testing of
individual software units of the application
.it is done after the completion of an individual unit before integration. This is a
structural testing, that relies on knowledge of its construction and is invasive. Unit
tests perform basic tests at component level and test a specific business process,
application, and/or system configuration. Unit tests ensure that each unique path of a
business process performs accurately to the documented specifications and contains
clearly defined inputs and expected results.
Integration testing
Functional test
System testing ensures that the entire integrated software system meets
requirements. It tests a configuration to ensure known and predictable results. An
example of system testing is the configuration oriented system integration test.
System testing is based on process descriptions and flows, emphasizing pre-driven
process links and integration points.
White Box Testing is a testing in which in which the software tester has
knowledge of the inner workings, structure and language of the software, or at least
its purpose. It is purpose. It is used to test areas that cannot be reached from a black
box level.
Black Box Testing is testing the software without any knowledge of the inner
workings, structure or language of the module being tested. Black box tests, as most
other kinds of tests, must be written from a definitive source document, such as
specification or requirements document, such as specification or requirements
document. It is a testing in which the software under test is treated, as a black box
.you cannot ―see‖ into it. The test provides inputs and responds to outputs without
considering how the software works.
5.1 Unit Testing:
Unit testing is usually conducted as part of a combined code and unit test
phase of the software lifecycle, although it is not uncommon for coding and unit
testing to be conducted as two distinct phases.
Test objectives
All field entries must work properly.
Features to be tested
Verify that the entries are of the correct format
Test Results: All the test cases mentioned above passed successfully. No defects
encountered.
In above screen some bird’s images are there but we don’t know its name or species
name. So by uploading this image to application we can get their species name
Screen shots
To run this project double click on ‘run.bat’ file to get below screen
In above screen click on ‘Upload Bird Image’ button to upload bird image
In above screen i am uploading one image of bird called ‘457.jpg’. After upload will
get below screen
Now click on ‘Run DCNN Algorithm & View Identified Species’ button to know the
species name of uploaded bird
In above screen we got 5 related birds images of uploaded image and we can see the
species name of bird on title bar of image. So by uploading any image we can know
the name of bird. You can upload any image and get it name and uploading image
name should be as integer value.
Now click on ‘View Score Graph’ button to view the graph
In above graph we got matching score of all 5 related birds and in above graph x-axis
represents name of bird and y-axis represents matching score.
Accuracy value of this algorithm you can see in below screen
In above screen in selected text you can see Accuracy value.
CHAPTER 7