|
| 1 | +Shapevolve |
| 2 | +========== |
| 3 | + |
| 4 | +A genetic algorithm to recreate artworks using simple shapes, with |
| 5 | +Python 3. |
| 6 | + |
| 7 | +Evan Zheng, July 2020. |
| 8 | + |
| 9 | +Initially designed on Google Colab with Jupyter Notebooks. Module built |
| 10 | +with assistance from PyCharm. |
| 11 | + |
| 12 | +.. image:: https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/starrynightgif.gif |
| 13 | + |
| 14 | +Sample Results: |
| 15 | +--------------- |
| 16 | + |
| 17 | +The Starry Night: |
| 18 | + |
| 19 | +.. image:: https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/starrynight.png_result.png |
| 20 | + |
| 21 | +Mona Lisa: |
| 22 | + |
| 23 | +.. image:: https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/monalisa.jpg_result.png |
| 24 | + |
| 25 | +Girl with a Pearl Earring: |
| 26 | + |
| 27 | +.. image:: https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/pearlearring.jpg_result.png |
| 28 | + |
| 29 | +The Great Wave off Kanagawa: |
| 30 | + |
| 31 | +.. image:: https://raw.githubusercontent.com/richmondvan/Shapevolve/master/images/greatwave.jpg_result.png |
| 32 | + |
| 33 | +How to install and use: |
| 34 | +----------------------- |
| 35 | +Standalone executable: (Windows) |
| 36 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 37 | + |
| 38 | +Head over to `releases`_ and download the latest executable, ``shapevolve.exe``. |
| 39 | + |
| 40 | +In the command line: |
| 41 | + |
| 42 | +Change the directory using ``cd`` to where the executable is located. |
| 43 | + |
| 44 | +Then, run ``shapevolve.exe path/to/image_file.png`` to run the program with an image as input. |
| 45 | + |
| 46 | +You can also run ``shapevolve.exe -h`` to view additional options. |
| 47 | + |
| 48 | +Module: |
| 49 | +~~~~~~~ |
| 50 | + |
| 51 | +Install shapevolve from PyPI using the following command: |
| 52 | + |
| 53 | +``pip install shapevolve`` |
| 54 | + |
| 55 | +Here is some sample code to demonstrate how to use the module. |
| 56 | + |
| 57 | +:: |
| 58 | + |
| 59 | + from shapevolve.evolver import Evolver |
| 60 | + from PIL import Image |
| 61 | + |
| 62 | + evolver = Evolver(Image.open("path/to/image.png")) # Sets up the Evolver object. |
| 63 | + |
| 64 | + genome = evolver.evolve() # Evolves the genome. |
| 65 | + |
| 66 | + image = genome.render_scaled_image() # Gets a numpy array that represents the evolved image. |
| 67 | + |
| 68 | + genome.save_genome("path/to/save_checkpoint.pkl") # Saves the genome for later use. |
| 69 | + |
| 70 | +More sample code can be found in ``samples.py``, `here.`_ |
| 71 | + |
| 72 | +Here is a detailed `API reference.`_ |
| 73 | + |
| 74 | +Libraries and APIs used: |
| 75 | +------------------------ |
| 76 | + |
| 77 | +Third-party libraries used: |
| 78 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 79 | + |
| 80 | +- `NumPy`_ for numerical computation with matrices |
| 81 | +- `ColorThief`_ for grabbing color palettes from images |
| 82 | +- `Scikit-Image`_ for computing image simularity |
| 83 | +- `OpenCV`_ for building images from circles |
| 84 | +- `Pillow`_ for image preprocessing |
| 85 | +- `Matplotlib`_ for image display |
| 86 | +- `PyInstaller`_ for building an executable file. |
| 87 | + |
| 88 | +Built-in libraries used: |
| 89 | +~~~~~~~~~~~~~~~~~~~~~~~~ |
| 90 | + |
| 91 | +- `Pickle`_ for checkpoint saves and loads. |
| 92 | +- `Argparse`_ for the CLI interface. |
| 93 | + |
| 94 | +License: |
| 95 | +-------- |
| 96 | + |
| 97 | +See `LICENSE`_ file. |
| 98 | + |
| 99 | +Thanks: |
| 100 | +------- |
| 101 | + |
| 102 | +Ahmed Khalf’s `Circle-Evolution`_ module provided a great deal of |
| 103 | +inspiration. |
| 104 | + |
| 105 | +.. _releases: https://github.com/richmondvan/Shapevolve/releases |
| 106 | +.. _here.: https://github.com/richmondvan/Shapevolve/blob/master/shapevolve/samples.py |
| 107 | +.. _API reference.: https://richmondvan.github.io/Shapevolve/shapevolve.html |
| 108 | +.. _NumPy: https://numpy.org/ |
| 109 | +.. _ColorThief: https://github.com/fengsp/color-thief-py |
| 110 | +.. _Scikit-Image: https://scikit-image.org/ |
| 111 | +.. _OpenCV: https://opencv.org/ |
| 112 | +.. _Pillow: https://github.com/python-pillow/Pillow |
| 113 | +.. _Matplotlib: https://matplotlib.org/ |
| 114 | +.. _PyInstaller: https://www.pyinstaller.org/ |
| 115 | +.. _Pickle: https://docs.python.org/3/library/pickle.html |
| 116 | +.. _Argparse: https://docs.python.org/3/library/argparse.html |
| 117 | +.. _LICENSE: https://github.com/richmondvan/Shapevolve/blob/master/LICENSE |
| 118 | +.. _Circle-Evolution: https://github.com/ahmedkhalf/Circle-Evolution |
0 commit comments