Skip to content

ahmedfgad/GeneticArtist

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Genetic Artist

Automagically redraw any image into a painting by means of artificial evolution.

Key FeaturesHow to UseTry it Out!AcknowledgementsLicense

Key Features

  • Recreate any image through genetic algorithms: Genetic Artist uses genetic algorithms to recreate images by painting brushstrokes, resulting in unique and stunning artwork.
  • Customize the stroke library for any art style: You can provide a folder of stroke images for the program to use. Experiment with known art styles or create your own unique mixes.
  • Don't start on a blank canvas: The starting canvas image can be customized to help the artist recreate the image faster or experiment with the output.
  • Watch the creative process in action: A window opens by default, allowing you to watch the artist at work and see the progress brushstroke by brushstroke.
  • Free and open-source!: Every part of the Genetic Artist is accessible for you to experiment and tinker with. Don't be shy and contribute all you want!
  • Run on any platform: Genetic Artist is cross-platform and easy to run on any machine, whether it be Windows, macOS or Linux.

How to Use

To run this program you will need Python 3 with pip installed.

  1. Clone this repository or download it instead:
git clone https://github.com/ahmedfgad/GeneticArtist.git
  1. Go into the repository directory:
cd GeneticArtist
  1. Install the project's dependencies:
pip install -r requirements.txt
  1. Run the artist:
python src/main.py --target <Target Image> \
                   --strokes <Stroke Directory> \
                   --config <Config File> \
                   --iterations <Number of Strokes To Draw> \
                   --output <Ouptut Image>

To get a detailed output of what the program is doing add --verbose to the parameters.

To hide the preview window add --nogui to the parameters. In case you do want it, remember to press ESC to close it when the program is done.

Note

The GUI is still a prototype and will be changed shortly

Try it Out!

Ready to see the magic happen? Check out some examples of what you can create with Genetic Artist.

Example strokes, target images, and canvases are provided in the repository, so you can try out the program right away. Here are a few examples to get you started:

Night Sky

To create a painting of the night sky, navigate to the project folder and run the following command:

python src/main.py --target examples/targets/moon.jpg \
                   --strokes examples/strokes/ \
                   --canvas examples/canvases/white.jpg \
                   --config examples/configs/medium_quality.toml \
                   --iterations 256 \
                   --output outputs/my_moon256.png \
                   --verbose

This will produce a beautiful painting like the one shown below:

Lake Landscape

If you prefer a peaceful lake landscape, run this command instead:

python src/main.py --target examples/targets/lake.jpg \
                   --strokes examples/strokes/ \
                   --canvas examples/canvases/black.jpg \
                   --config examples/configs/high_quality.toml \
                   --iterations 256 \
                   --output outputs/my_lake256.png \
                   --verbose

The result will look something like this:

Monaliza

Use a canvas of the same size as the image. The used Monaliza image size is 512x512 and so the canvas size. Use this online tool to create blank images.

python src/main.py --target examples/targets/monaliza.jpg ^
                   --strokes examples/strokes/ ^
                   --canvas examples/canvases/white512.jpg ^
                   --config examples/configs/high_quality.toml ^
                   --iterations 6500 ^
                   --output outputs/monaliza.png ^
                   --verbose

This is the output.

Feel free to experiment with different target images, strokes, and canvases to see what unique creations you can come up with!

Acknowledgements

This project wouldn't be possible without the following open source packages:

  • PyGAD to power the image recreation process in our program.
  • OpenCV and Numpy to handle the image processing and manipulation tasks. Make sure to install OpenCV-Contrib.
  • Numba to accelerate the custom image processing functions.

The example images are provided by Pixabay:

This is in addition to the Monaliza image.

License

Genetic Artist is distributed under the MIT License. See LICENSE.md for more information.

About

Automatically redraw any image into a painting by means of artificial evolution using the genetic algorithm with PyGAD.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%