genetic algorithms and image classification

41
Genetic Algorithms George Bora UTCN December 4, 2013 George Bora (UTCN) Genetic Algorithms December 4, 2013 1 / 20

Upload: george-bora

Post on 07-Jul-2015

284 views

Category:

Technology


3 download

DESCRIPTION

A presentation I made for my course on genetic algorithms. The subject was trying to use them for image classification, the method was sort of working backwards generating shapes from the genome and then comparing them to the unclassified image. When the comparison was close enough I would then extract the classes for the image from the genome I used to create the shape which proved most similar.

TRANSCRIPT

Page 1: Genetic Algorithms and Image Classification

Genetic Algorithms

George Bora

UTCN

December 4, 2013

George Bora (UTCN) Genetic Algorithms December 4, 2013 1 / 20

Page 2: Genetic Algorithms and Image Classification

Computer Science to Evolutionary Computation

Within the vast field of computer science under it’s vast array of potentialapplications there exists the branch of artificial intelligence.

One of the sub-branches of artificial intelligence is evolutionarycomputation which seeks to achieve continuous optimization andcombinatorial optimization by incorporating knowledge of natural evolutionprocesses.

George Bora (UTCN) Genetic Algorithms December 4, 2013 2 / 20

Page 3: Genetic Algorithms and Image Classification

Computer Science to Evolutionary Computation

Within the vast field of computer science under it’s vast array of potentialapplications there exists the branch of artificial intelligence.

One of the sub-branches of artificial intelligence is evolutionarycomputation which seeks to achieve continuous optimization andcombinatorial optimization by incorporating knowledge of natural evolutionprocesses.

George Bora (UTCN) Genetic Algorithms December 4, 2013 2 / 20

Page 4: Genetic Algorithms and Image Classification

Basic Concepts from Biology

The basic building blocks for evolutionary computation, which have kepttheir names from their native science, are as follows:

genes

allele

chromosome

individual

mapping

mutation and crossover

fitness function

George Bora (UTCN) Genetic Algorithms December 4, 2013 3 / 20

Page 5: Genetic Algorithms and Image Classification

Genes

The element from which this method derives it name, as genes are thebasic building blocks of life.

So too in our search for the solution for various problems, genes are thebasic elements we switch around and juggle with in order to arrive at amore optimum solution.

George Bora (UTCN) Genetic Algorithms December 4, 2013 4 / 20

Page 6: Genetic Algorithms and Image Classification

Genes

The element from which this method derives it name, as genes are thebasic building blocks of life.

So too in our search for the solution for various problems, genes are thebasic elements we switch around and juggle with in order to arrive at amore optimum solution.

George Bora (UTCN) Genetic Algorithms December 4, 2013 4 / 20

Page 7: Genetic Algorithms and Image Classification

Allele

If genes are the basics of the solution in theory, alleles are the valuesencoded in genes are the ones we use in practice, when developingsoftware which uses genetic programming.

When the time has passed and the solution must effectively be built orinstantiated it is the allele which forms the blue print we go by.

In the original vision for genetic algorithms there was only 1 allele pergene, which was a binary value and was stored in a 1 bit, as the fieldprogressed all of those constrictions have been lifted.

George Bora (UTCN) Genetic Algorithms December 4, 2013 5 / 20

Page 8: Genetic Algorithms and Image Classification

Allele

If genes are the basics of the solution in theory, alleles are the valuesencoded in genes are the ones we use in practice, when developingsoftware which uses genetic programming.

When the time has passed and the solution must effectively be built orinstantiated it is the allele which forms the blue print we go by.

In the original vision for genetic algorithms there was only 1 allele pergene, which was a binary value and was stored in a 1 bit, as the fieldprogressed all of those constrictions have been lifted.

George Bora (UTCN) Genetic Algorithms December 4, 2013 5 / 20

Page 9: Genetic Algorithms and Image Classification

Allele

If genes are the basics of the solution in theory, alleles are the valuesencoded in genes are the ones we use in practice, when developingsoftware which uses genetic programming.

When the time has passed and the solution must effectively be built orinstantiated it is the allele which forms the blue print we go by.

In the original vision for genetic algorithms there was only 1 allele pergene, which was a binary value and was stored in a 1 bit, as the fieldprogressed all of those constrictions have been lifted.

George Bora (UTCN) Genetic Algorithms December 4, 2013 5 / 20

Page 10: Genetic Algorithms and Image Classification

Chromosome and Individual

As in nature an animal can not have it’s information encoded in a singlegene, in programming a solution which warrants genetic algorithms is notsimple enough as to be composed on 1 gene.

Chromosomes are the collection of genes, which make up the blueprintfrom which we will map our solution and create the individual.

If the chromosomes are the blue prints the individual is the ”end product”,to make an analogy with software engineering, and individual is to a classwhat a instance is to a object.

George Bora (UTCN) Genetic Algorithms December 4, 2013 6 / 20

Page 11: Genetic Algorithms and Image Classification

Chromosome and Individual

As in nature an animal can not have it’s information encoded in a singlegene, in programming a solution which warrants genetic algorithms is notsimple enough as to be composed on 1 gene.

Chromosomes are the collection of genes, which make up the blueprintfrom which we will map our solution and create the individual.

If the chromosomes are the blue prints the individual is the ”end product”,to make an analogy with software engineering, and individual is to a classwhat a instance is to a object.

George Bora (UTCN) Genetic Algorithms December 4, 2013 6 / 20

Page 12: Genetic Algorithms and Image Classification

Chromosome and Individual

As in nature an animal can not have it’s information encoded in a singlegene, in programming a solution which warrants genetic algorithms is notsimple enough as to be composed on 1 gene.

Chromosomes are the collection of genes, which make up the blueprintfrom which we will map our solution and create the individual.

If the chromosomes are the blue prints the individual is the ”end product”,to make an analogy with software engineering, and individual is to a classwhat a instance is to a object.

George Bora (UTCN) Genetic Algorithms December 4, 2013 6 / 20

Page 13: Genetic Algorithms and Image Classification

Mapping

The process by which we construct a individual from the chromosome wehave generated is called mapping, it is one of the important elements(alongside chromosome structure and fitness functions) we must considerbefore we implement our design.

Mapping and it’s complexity is often tied

with how we define our alleles,genes and chromosome as well as ourgenetic operations, a great deal of planning being required in order toproduce the best possible algorithm.

George Bora (UTCN) Genetic Algorithms December 4, 2013 7 / 20

Page 14: Genetic Algorithms and Image Classification

Mapping

The process by which we construct a individual from the chromosome wehave generated is called mapping, it is one of the important elements(alongside chromosome structure and fitness functions) we must considerbefore we implement our design. Mapping and it’s complexity is often tied

with how we define our alleles,genes and chromosome as well as ourgenetic operations, a great deal of planning being required in order toproduce the best possible algorithm.

George Bora (UTCN) Genetic Algorithms December 4, 2013 7 / 20

Page 15: Genetic Algorithms and Image Classification

Crossover

Crossover is one of the fundamental operations within the toolbox ofgenetic algorithms, and one of the most important methods by which wecan combine existing chromosomes to form new ones in the search for afit enough solution.

It involves separating each chromosome which takes

part into two parts, and then recombining parts from the different oldchromosomes to form the new set of chromosomes.

George Bora (UTCN) Genetic Algorithms December 4, 2013 8 / 20

Page 16: Genetic Algorithms and Image Classification

Crossover

Crossover is one of the fundamental operations within the toolbox ofgenetic algorithms, and one of the most important methods by which wecan combine existing chromosomes to form new ones in the search for afit enough solution. It involves separating each chromosome which takes

part into two parts, and then recombining parts from the different oldchromosomes to form the new set of chromosomes.

George Bora (UTCN) Genetic Algorithms December 4, 2013 8 / 20

Page 17: Genetic Algorithms and Image Classification

Mutation

Mutation is the changing of the allele of a gene to another one of it’spossible values.

This operation permits genetic algorithms to potentially

escape from local optimum solutions, a very important characteristic in thefield of artificial intelligence.

George Bora (UTCN) Genetic Algorithms December 4, 2013 9 / 20

Page 18: Genetic Algorithms and Image Classification

Mutation

Mutation is the changing of the allele of a gene to another one of it’spossible values. This operation permits genetic algorithms to potentially

escape from local optimum solutions, a very important characteristic in thefield of artificial intelligence.

George Bora (UTCN) Genetic Algorithms December 4, 2013 9 / 20

Page 19: Genetic Algorithms and Image Classification

Fitness Function

Via crossover and mutation we can create whole populations ofindividuals, potential solutions, and so the question arises when do westop the evolutionary cycle?

The answer being when we have reached a

certain vicinity of an ideal solution, but for this we need to evaluate howclose is any one individual to satisfying our demands and being the soughtafter solution.

George Bora (UTCN) Genetic Algorithms December 4, 2013 10 / 20

Page 20: Genetic Algorithms and Image Classification

Fitness Function

Via crossover and mutation we can create whole populations ofindividuals, potential solutions, and so the question arises when do westop the evolutionary cycle? The answer being when we have reached a

certain vicinity of an ideal solution, but for this we need to evaluate howclose is any one individual to satisfying our demands and being the soughtafter solution.

George Bora (UTCN) Genetic Algorithms December 4, 2013 10 / 20

Page 21: Genetic Algorithms and Image Classification

Fitness Function II

The implementation of the fitness function changes from one class ofproblems to another, standardization being much more difficult than withgenes, and is one of the most time consuming elements of geneticprogramming.

Writing the fitness function, which when given a chromosome will returnhow fit or close to the ideal it is, is one of the hardest yet essential tasks indeveloping a solution with genetic programming as it is the only way toclose the loop and choose a final solution.

George Bora (UTCN) Genetic Algorithms December 4, 2013 11 / 20

Page 22: Genetic Algorithms and Image Classification

Fitness Function II

The implementation of the fitness function changes from one class ofproblems to another, standardization being much more difficult than withgenes, and is one of the most time consuming elements of geneticprogramming.

Writing the fitness function, which when given a chromosome will returnhow fit or close to the ideal it is, is one of the hardest yet essential tasks indeveloping a solution with genetic programming as it is the only way toclose the loop and choose a final solution.

George Bora (UTCN) Genetic Algorithms December 4, 2013 11 / 20

Page 23: Genetic Algorithms and Image Classification

Genetic Algorithms vs Genetic Programming

Within this field there exist two very different paradigms, geneticalgorithms and genetic programming the most visible difference betweenthem being the structure of the chromosomes they produce.

Genetic algorithms work with a chromosome which is linear and often fixedin length, making them ideal for tunning the behavior of various solutions.

Genetic programming instead uses a tree-structured chromosome variablein size, which allows it to generate the structure of the solution as well asthe behavior.

George Bora (UTCN) Genetic Algorithms December 4, 2013 12 / 20

Page 24: Genetic Algorithms and Image Classification

Genetic Algorithms vs Genetic Programming

Within this field there exist two very different paradigms, geneticalgorithms and genetic programming the most visible difference betweenthem being the structure of the chromosomes they produce.

Genetic algorithms work with a chromosome which is linear and often fixedin length, making them ideal for tunning the behavior of various solutions.

Genetic programming instead uses a tree-structured chromosome variablein size, which allows it to generate the structure of the solution as well asthe behavior.

George Bora (UTCN) Genetic Algorithms December 4, 2013 12 / 20

Page 25: Genetic Algorithms and Image Classification

Genetic Algorithms vs Genetic Programming

Within this field there exist two very different paradigms, geneticalgorithms and genetic programming the most visible difference betweenthem being the structure of the chromosomes they produce.

Genetic algorithms work with a chromosome which is linear and often fixedin length, making them ideal for tunning the behavior of various solutions.

Genetic programming instead uses a tree-structured chromosome variablein size, which allows it to generate the structure of the solution as well asthe behavior.

George Bora (UTCN) Genetic Algorithms December 4, 2013 12 / 20

Page 26: Genetic Algorithms and Image Classification

The problem

The creation of a algorithm which is capable of classifying a target image,returning information about the general structure, size and color (thepre-defined classes) of the object present in the image.

Requirements:1 the use of genetic computing within the solution2 as high of a success rate as possible

George Bora (UTCN) Genetic Algorithms December 4, 2013 13 / 20

Page 27: Genetic Algorithms and Image Classification

The problem

The creation of a algorithm which is capable of classifying a target image,returning information about the general structure, size and color (thepre-defined classes) of the object present in the image.

Requirements:1 the use of genetic computing within the solution2 as high of a success rate as possible

George Bora (UTCN) Genetic Algorithms December 4, 2013 13 / 20

Page 28: Genetic Algorithms and Image Classification

Image classification

Image recognition, which can be classified as a sub-field of computervision, is a field concerned with the identification of objects and entitieswithin images.

Image classification is a classical image recognition problem in which thetask is to assign labels to images based their content or metadata.

George Bora (UTCN) Genetic Algorithms December 4, 2013 14 / 20

Page 29: Genetic Algorithms and Image Classification

Image classification

Image recognition, which can be classified as a sub-field of computervision, is a field concerned with the identification of objects and entitieswithin images.

Image classification is a classical image recognition problem in which thetask is to assign labels to images based their content or metadata.

George Bora (UTCN) Genetic Algorithms December 4, 2013 14 / 20

Page 30: Genetic Algorithms and Image Classification

The classes

The labels we apply are called classes and for this algorithm we havedefined 3 great families of classes:

form classes: for now we have defined classes for circles,triangles(isosceles) and circles although additions to these arerelatively easy to add due to our use of genetic algorithms

color classes: right now only red, green and blue are implementedalthough using the rgb format is also possible.

size classes: chosen arbitrarily.

George Bora (UTCN) Genetic Algorithms December 4, 2013 15 / 20

Page 31: Genetic Algorithms and Image Classification

The chromosome

The chromosome is fairly simplistic being formed out of:

a gene encoding the form.

a gene encoding the color.

a gene encoding the size.

George Bora (UTCN) Genetic Algorithms December 4, 2013 16 / 20

Page 32: Genetic Algorithms and Image Classification

Genes and Allele

The genes governing shapes at the moment can have the followingvalues: circle, triangle and square all identified by numeric codes.

The

genes governing color at the moment can accept any color defined by theSVG standard although they can also handle rgb codes, which wouldrequire 3 separate genes.

The genes governing size are again numeric codes which represent hardcoded categories of size.

George Bora (UTCN) Genetic Algorithms December 4, 2013 17 / 20

Page 33: Genetic Algorithms and Image Classification

Genes and Allele

The genes governing shapes at the moment can have the followingvalues: circle, triangle and square all identified by numeric codes. The

genes governing color at the moment can accept any color defined by theSVG standard although they can also handle rgb codes, which wouldrequire 3 separate genes.

The genes governing size are again numeric codes which represent hardcoded categories of size.

George Bora (UTCN) Genetic Algorithms December 4, 2013 17 / 20

Page 34: Genetic Algorithms and Image Classification

Genes and Allele

The genes governing shapes at the moment can have the followingvalues: circle, triangle and square all identified by numeric codes. The

genes governing color at the moment can accept any color defined by theSVG standard although they can also handle rgb codes, which wouldrequire 3 separate genes.

The genes governing size are again numeric codes which represent hardcoded categories of size.

George Bora (UTCN) Genetic Algorithms December 4, 2013 17 / 20

Page 35: Genetic Algorithms and Image Classification

Mapping

The mapping process is the most intensive one, in terms of time and linesof code needed, followed closely by calculating the fitness function.The process consists of:

creating a SVG file from the chromosome requires only the standardJava standard file API.

converting said .svg file to the .png (raster) format as the image weare trying to classify will be a raster image, requires calls to theInkscape API via Java’s system API.

George Bora (UTCN) Genetic Algorithms December 4, 2013 18 / 20

Page 36: Genetic Algorithms and Image Classification

Fitness function

As the result of the mapping is a image of a similar raster format like theone we seek to classify, the fitness function simply does a naivecomparison of the two images bit by bit.

It then normalizes the bit difference to a range between 0 and 1, asrequired by the genetic algorithm, this fitness being then used in thestandard manner for deciding which chromosomes pass into the nextgeneration.

George Bora (UTCN) Genetic Algorithms December 4, 2013 19 / 20

Page 37: Genetic Algorithms and Image Classification

Fitness function

As the result of the mapping is a image of a similar raster format like theone we seek to classify, the fitness function simply does a naivecomparison of the two images bit by bit.It then normalizes the bit difference to a range between 0 and 1, asrequired by the genetic algorithm, this fitness being then used in thestandard manner for deciding which chromosomes pass into the nextgeneration.

George Bora (UTCN) Genetic Algorithms December 4, 2013 19 / 20

Page 38: Genetic Algorithms and Image Classification

The cons

This procedure has a number of weak points:

genetic algorithms traditionally aren’t suited to image classification.

the speed of this procedure, is very low due to the calls to Inkscapeand the creation of numerous files (can be improved).

the fitness function relies on a very sensible and naive imagecomparison method (can be improved).

George Bora (UTCN) Genetic Algorithms December 4, 2013 20 / 20

Page 39: Genetic Algorithms and Image Classification

The pros

A number of points in it’s favour

the available class list, due to the classes being written in SVG, isvery easily extendable.

in it’s current form it requires only Java and Inkscape (a very availablesoftware).

there are a large number of image comparison methods which can beused for the fitness function.

George Bora (UTCN) Genetic Algorithms December 4, 2013 21 / 20

Page 40: Genetic Algorithms and Image Classification

The End

Thank your for your attention !

Any questions ?

George Bora (UTCN) Genetic Algorithms December 4, 2013 22 / 20

Page 41: Genetic Algorithms and Image Classification

The End

Thank your for your attention !

Any questions ?

George Bora (UTCN) Genetic Algorithms December 4, 2013 22 / 20