Giter VIP home page Giter VIP logo

genetic-algorithm-montage's Introduction

Genetic Algorithm for Self-Referential Image Approximation

Build Status Codacy Badge

Mona Lisa after 120'000 generations approximated with 260 individuals.

Introduction

One approach to solve the image matching problem is with some stochastic optimization approach, in which the search for the optimal solution involves randomness in some constructive way. If S denotes the (finite) set of all possible solutions, the task we consider is to maximize or minimize the objective function latex. In the case of maximization, on which we focus here, the problem is to find a configuration latex which satisfies

latex

Genetic Algorithm

Genetic algorithms operate on a set of individuals (solutions) which form a population for a determined generation, then either two individuals are selected and combined in a crossover operation or each individual is mutated.

We might refer to an approximate solution as a "candidate", or the solution's "DNA".

A genetic algorithm tries to solve the image matching problem by starting with a random population of 260 sets of DNA consisting in form of genes with a length of 5. A fitness function is used to identify the best and worst DNA. To get a measure of how similar two images are, we calculate the root-mean-square (RMS) value of the difference between the images. If the images are exactly identical, this value is zero.

latex

Crossover and mutations are randomly performed in order to generate new solutions. Then, based on a selection criterion, the strongest individuals (those with the best value of a performance metric) survive and remain for the next generation.

The process is repeated until some stopping conditions are fulfilled. In order to perform the selection of the individuals in the GA a fitness value needs to be defined. This fitness value measures the quality of the individuals and enables them to be compared.

Procedure

Computation time: 43 min @ Intel i9 9900k

Computation time: 59 min @ Intel i9 9900k

Results

Input Face ~100'000 generations Fitness Score
Mona Lisa: 93.071%
Girl with a Pearl Earring: 84.095%
Will Smith: 85.863%
Elon Musk: 81.632%
Rowan Atkinson: 89.364%
Marques Brownlee: 90.349%

Misc

Pseudo Code Flow chart

License

MIT License

Muriz Serifovic

genetic-algorithm-montage's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

genetic-algorithm-montage's Issues

Can't find Population class!

Hello Murgio

thank you for this application

every time I try to compile the FaceGen.java class I get this error

FaceGen.java:55: error: cannot find symbol
Population population = new Population(30, statusDirection);
^
symbol: class Population
location: class FaceGen
FaceGen.java:55: error: cannot find symbol
Population population = new Population(30, statusDirection);
^
symbol: class Population
location: class FaceGen
2 errors

thought the Population is there!

thank you.

mask.png and instance.png not found

i get errors that mask.png and instance.png can not be found. i just altered the paths, coppied my match.png twice and renamed it to mask.png and instance.png.

Its running now but barely changes the Image after each generation.

Run Multiple Threads Concurrently in Java

If you want to contribute here are some useful notes:

An implementation of multiple threads would be very useful to calculate the Fitness Score faster than with one worker process. The Fitness Score is crucial and thus a reduction of the time needed to calculate the fitness would tremendously reduce the time per generation.

The calculateFitness function is called in the Population class:

for(List<Integer> list : DNAList) { fitnessList.add(fitness.calculateFitness(list)); }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.