Skip to main content

A genetic algorithm to recreate artworks using simple shapes, with Python 3.

Project description

A genetic algorithm to recreate artworks using simple shapes, with Python 3.

Evan Zheng, July 2020.

Initially designed on Google Colab with Jupyter Notebooks. Module built with assistance from PyCharm.

./images/starrynightgif.gif

Sample Results:

The Starry Night:

./images/starrynight.png_result.png

Mona Lisa:

./images/monalisa.jpg_result.png

Girl with a Pearl Earring:

./images/pearlearring.jpg_result.png

The Great Wave off Kanagawa:

./images/greatwave.jpg_result.png

How to install and use:

Standalone executable: (Windows)

Head over to releases and download the latest executable, shapevolve.exe.

In the command line:

Change the directory using cd to where the executable is located.

Then, run shapevolve.exe path/to/image_file.png to run the program with an image as input.

You can also run shapevolve.exe -h to view additional options.

Module:

Install shapevolve from PyPI using the following command:

pip install shapevolve

Here is some sample code to demonstrate how to use the module.

from shapevolve.evolver import Evolver
from PIL import Image

evolver = Evolver(Image.open("path/to/image.png")) # Sets up the Evolver object.

genome = evolver.evolve() # Evolves the genome.

image = genome.render_scaled_image() # Gets a numpy array that represents the evolved image.

genome.save_genome("path/to/save_checkpoint.pkl") # Saves the genome for later use.

More sample code can be found in samples.py, here.

Here is a detailed API reference.

Libraries and APIs used:

Third-party libraries used:

Built-in libraries used:

  • Pickle for checkpoint saves and loads.

  • Argparse for the CLI interface.

License:

See LICENSE file.

Thanks:

Ahmed Khalf’s Circle-Evolution module provided a great deal of inspiration.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shapevolve-0.1.1.tar.gz (15.8 kB view details)

Uploaded Source

File details

Details for the file shapevolve-0.1.1.tar.gz.

File metadata

  • Download URL: shapevolve-0.1.1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

File hashes

Hashes for shapevolve-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8122512dbe70a0810a14968d22545361871d89db00c6bac42949bd26e01d1ba4
MD5 d194955339d96b2061a9f2385b12fabc
BLAKE2b-256 e8061cb84438f85c5b5194f383141aeef80d6becb2db2a0047fbb3b56f1b603a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page