Skip to content

Using Simulated Annealing, Hill Climbing, and Genetic Algorithms to recreate images using shapes 🤖 🧬

License

Notifications You must be signed in to change notification settings

rish-16/Metroplex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metroplex

Recreating pictures using shapes of different colours and sizes via Stochastic Optimization


Samples

Here are some sample images I converted using Metroplex. They aren't perfect by any chance. Lots of work left to do – but we'll get there.


Usage

Clone the repository and enter the src directory:

$ git clone https://github.com/rish-16/Metroplex.git
$ cd Metroplex
$ pip install -r requirements.txt
$ cd src
$ python main.py -i "./path_to_input_img.jpg" -o "./path_to_output_img.jpg" --solo
Flag Value Description
-i or --input String Path to input image
-o or --output String Path to output image (optional)

If not present, defaults to "<<filepath>>_output.jpg"
--solo N/A Whether output should be a side-to-side
comparison or generated image only

Defaults to False

Under the Hood

Metroplex uses a combination of Simulated Annealing, Mutations, and Hill Climbing to choose the optimal shapes. Starting from a blank white canvas, it creates a random shape and scores it. The shape is then mutated and scored again. If the new score is better than the original, we choose the mutated shape. Otherwise, we revert to the previous canvas configuration.

Normalized Root Mean Square Error (NRMSE) is used as an objective/scoring function. Over time, this value decays as the Canvas converges to the Target (or something close enough).

Canvas = Canvas + Shape
Loss = NRMSE(Target, Canvas)

License

MIT

About

Using Simulated Annealing, Hill Climbing, and Genetic Algorithms to recreate images using shapes 🤖 🧬

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published