Skip to main content

Shapevolve

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.

View on PyPI.

https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/starrynightgif.gif

Sample Results:

The Starry Night:

https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/starrynight.png_result.png

Mona Lisa:

https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/monalisa.jpg_result.png

Girl with a Pearl Earring:

https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/pearlearring.jpg_result.png

The Great Wave off Kanagawa:

https://raw.githubusercontent.com/richmondvan/Shapevolve/master/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.

Metadata

Release files for shapevolve 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shapevolve 0.1.4
File Size Uploaded
shapevolve-0.1.4.tar.gz 16.5 kB Details

Release files / shapevolve-0.1.4.tar.gz

Download URL shapevolve-0.1.4.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9c70b8a4d338a2fbc5a7e8b1a359a0dc0af9743bb482d3186dc7b3f386b59ac3
BLAKE2b-256 checksum
How to use checksums
05c1244fdd58ee5b11ce1962ec0f0741652040b5d148d5a1236511723034492c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

v0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page