Automatic Genetic Algorithm-Based Solver for Jigsaw Puzzles.
Clone repo:
git clone https://github.com/nemanja-m/gaps.git
cd gaps
Install requirements:
pip install -r requirements.txt
Install project in editable mode:
pip install -e .
To create puzzle from image use create_puzzle
script.
i.e.
create_puzzle images/butterfly.jpg --size=28 --destination=puzzle.jpg
will create puzzle from lena.jpg
where each puzzle piece is 28x28 pixels.
Run create_puzzle --help
for detailed help.
Puzzle is created from input image by shuffling pieces.
NOTE Created puzzle dimensions may be smaller then original image depending on given puzzle piece size. Maximum possible rectangle is cropped from original image.
In order to solve puzzles, use gaps
script.
i.e.
gaps --image=puzzle.jpg --size=28 --generations=20 --population=300
This will start genetic algorithm with initial population of 300 and 20 generations.
Following options are provided:
Option | Description |
---|---|
--image |
Path to puzzle |
--size |
Puzzle piece size in pixels |
--generations |
Number of generations for genetic algorithm |
--population |
Number of individuals in population |
--verbose |
Show best solution after each generation |
--save |
Save puzzle solution as image |
Run gaps --help
for detailed help.
This project as available as open source under the terms of the MIT License