Giter VIP home page Giter VIP logo

mosaiccompositionga's Introduction

Solving a Mosaic Art using Genetic Algorithm Approach

A Genetic Algorithm Approach to solve a shuffled image like a Mosaic Art using python.

Importance and working of the Project

The interesting nature of solving a jigsaw puzzle captures the attention of research workers for the past few years. They use the same technique for the reconstruction of different images. A process of creating an original image from a broken image. This technique has scope in satellite imaging, medical imaging, computer vision, augmented reality, image-based search engines, etc. In this project, we try out a new technique, which works the same as the process of solving a jigsaw puzzle. We use an approach known as the Genetic algorithm (GA), we are checking every tile edge and orientation distance for solving the image using the cosine function because it performs very well for high dimensional data.

A GA is a sort of optimization algorithm inspired by the natural selection process. Each piece of the puzzle can be represented as a gene and each configuration of the puzzle as a chromosome. The GA method generally begins with a population of randomly created chromosomes and then performs genetic operators such as selection, crossover, and mutation to generate new generations of chromosomes repeatedly. The aim is to identify the best chromosome that symbolizes the proper puzzle layout. GA gradually explores the solution space and converges toward the optimal solution. We also use two image classification models Visual Geometry Group (VGG16) and Alex Net for identifying the objects in the image. We compared the scores of both models during every generation result.

We took a random image from the internet and split it into 25 tiles. Then we applied random shuffle on the tiles and use the shuffle image as our input image. Different images require setting up different parameters in the main file. Those parameters are:

  • P_count: Number of Population.
  • range: Number of Generations.
  • retain: Percentage of choosing the best score individuals.
  • random_select: Random selection of parents for mutation.
  • mutate: Percentage of change in mutation.

For our input image, the GA solved the image in 30 generations. we selected the target value as 1.0, population count as 1000, generation cycle as 50, retain as 0.2, random select as 0.05, and mutation as 0.01 to get the desired results. The image below shows the shape of the image during generation 0 and after generation 30.

From gen 0 to gen 30

We recorded every generation's fitness score. Our fitness score started from 2.450096484 and reached 0.75 fitness score where it completely solved the image.

Score Plot

#Image Classification Comparision In this project, we also used two image classification models (AlexNet and VGG16) for detecting the objects on the image. This will help in applications like mosaic art reconstruction. We can use image classification models for detecting the objects in the images before reconstructing them. So we applied AlexNet and VGG16 on every image, starting from the shuffled image to the last generation image. These are the scores we get. Both models perform very well in detecting the object in the image but you can see the accuracy of VGG16 is better than Alex Net.

Image Model Comparison

Running of this Project

We did this whole project on Jupyter Notebook. If you want to run this project we recommend running it on Jupyter Notebook. For that you need to install:

  • Python 3.7
  • Anaconda
  • Install all the required packages using the "Requirement.txt" file.

mosaiccompositionga's People

Contributors

karanbhatt99 avatar omrusman avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.