Interactive Evolutionary Computation in PythonHuman, simulated and AI evaluators. The easyiec toolbox

Chapter 9
Visual and creative applications

Art and design are where interactive evolution began, and where judgement is the whole point. This chapter presents the visual and creative problems of the package — fractals, generative art, artificial life, graphic and information design, photo grading, music and text — with the representations that make them evolvable and the features that let simulated viewers and AI judges evaluate them. Each section ends with a short session.

9.1 Representations for judged images

A problem for interactive evolution needs a genome whose small changes produce visible, coherent changes of the phenotype, and a phenotype that is worth looking at for most genomes. The creative problems of the package follow a few design rules learned from the literature and from building them. Genes act on perceptually meaningful quantities — hue, zoom, symmetry, branching angle — rather than on raw pixels; integer frequencies with a small detuning keep harmonograph curves closed instead of producing scribbles; drawings are fitted into the frame so that a mutation does not push the figure out of sight; and colour is separated from shape, so that a viewer can fix one and explore the other. Every problem renders into an RGB image of any size, which is what galleries, animations, image features and vision–language models need.

9.2 Fractals

Four fractal families are included (fig. 9.1). JuliaSet renders the filled Julia set of z↦z2+c with smooth (fractional escape-time) colouring; the constant c is parametrized in polar form around the boundary of the Mandelbrot set, where the interesting sets live, and presets reproduce the dendrite, the rabbit and a spiral. StrangeAttractor iterates the Clifford and de Jong maps and renders the orbit density with a logarithmic tone map. IFSFractal evolves iterated function systems of four affine maps [72], with Barnsley’s fern as a preset, and FractalFlame adds nonlinear variations and colour coordinates in the manner of Draves’ flame algorithm [73], the algorithm behind the evolved screen-saver Electric Sheep. A simulated viewer whose taste is given as target values of image features — bright, colourful, fairly complex — breeds attractors towards that mood within a dozen galleries; the cover of this book shows such a session with fractal flames.

Figure 9.1

Figure 9.1. Random genomes of the four fractal families: Julia sets, strange attractors, iterated function systems and fractal flames.

Open in ColabExample plot_01_fractals.py in the gallery

user = ei.SimulatedUser(problem, target={"brightness": 0.45, "colorfulness": 0.6, "complexity": 0.7}, noise=0.03, 
                        seed=1) 
result = ei.run(problem, InteractiveGA(pop_size=9), user, generations=12, seed=1)
   

9.3 Generative art

Compositional pattern-producing networks paint by evaluating a small network of periodic, symmetric and saturating functions at every pixel [74]; they are the representation of Picbreeder [12]. CPPNArt uses a fixed topology — inputs x, y, the radius, a bias and an optional angular input for k-fold symmetry, two hidden layers of six nodes with evolvable activation functions (sine, Gaussian, tanh, step and others) and an HSV colour output — so the genome of 99 real numbers suits every real-coded strategy, whereas Picbreeder evolved the topology itself. Harmonograph draws the trace of two damped pendulums per axis with integer frequency ratios and a small detuning; SuperShape draws layered logos with the superformula of Gielis [75]; CellularAutomaton grows textures from elementary and totalistic rules [76]. Quality-diversity search suits these problems: an interactive MAP-Elites archive over symmetry and colourfulness offers a repertoire instead of a single image (fig. 9.2).

Figure 9.2

Figure 9.2. The elites of an interactive MAP-Elites archive of CPPN images after 20 queries with a simulated viewer, one per niche of symmetry and colourfulness.

Open in ColabExample plot_02_generative_art.py in the gallery

9.4 Artificial life

Dawkins’ biomorphs [10] are recursive trees whose genes set the branch lengths and angles; Biomorph keeps the bilateral symmetry of the original by starting the recursion upwards, and the Watchmaker strategy of section 3.2 reproduces Dawkins’ program. LSystemPlant rewrites strings into plant architectures [77]; the genes choose one of six classic bracketed grammars and set the left and right branching angles, the number of rewriting steps, the shortening of segments, the tilt, thickness, leaves and colours, and semantic axes (“bushier”, “more upright”, “greener”) allow verbal steering. A simulated gardener who comments on the plants (“much more upright”, “thicker”) breeds them in ten galleries (fig. 9.3).

Figure 9.3

Figure 9.3. Three galleries of L-system plants bred by an interactive GA with a simulated gardener who comments on the chosen plant; framed: chosen plants.

Open in ColabExample plot_03_artificial_life.py in the gallery

9.5 Design

Design problems mix judged qualities with computable constraints (fig. 9.4). ColorPalette evolves five colours — background, header, text and data series, accent — and previews them on a dashboard card; its default utility rewards the WCAG contrast ratio between text and background (at least 4.5:1) and between data series and background, and a spread of hues. ChartStyle evolves the visual encoding of a small chart with fixed data — colours, line widths, grid, fonts and chart type. ChernoffFace maps thirteen numbers to facial features [78], a classic of statistical graphics whose expressions people read instantly; it is also a psychometric stimulus: the curvature of the mouth controls how happy a face looks, which the audits of chapter 11 exploit. GraphLayout draws Zachary’s karate club network [79] by blending four base layouts (spring, Kamada–Kawai, spectral, circular), separating the two factions and setting sizes and colours, with edge crossings, edge-length uniformity and node overlap as objectives.

Figure 9.4

Figure 9.4. Random genomes of the four design problems: colour palettes on a mock-up chart, chart styles, Chernoff faces and drawings of Zachary’s karate club network.

Open in ColabExample plot_04_design.py in the gallery

9.6 Photo grading

Image enhancement is one of the oldest IEC applications in image processing [1]. ImageEnhancement processes a photograph (by default a cup of coffee from the scikit-image collection, or a synthetic scene) with eleven genes: exposure, contrast, saturation, colour temperature and tint, gamma, highlights, shadows, vignette, sharpening and hue shift. Its semantic axes are the words photographers use — brighter, warmer, more contrast, lift the shadows — so verbal steering works out of the box (section 5.5). The sequential gallery of Koyama, Sato and Goto [17], designed for exactly this task, reaches the hidden ideal grade of a simulated photographer after ten grid choices (fig. 9.5).

ideal = problem.space.denormalize(problem.ideal) 
user = ei.SimulatedUser(problem, target=ideal, noise=0.03, seed=5) 
res = ei.run(problem, SequentialGallery(grid=3), user, generations=10, seed=5) 
print(f"best utility {res.best_true:.3f} after {res.summary()[’queries’]} grid choices")
   
Figure 9.5. The neutral grade, the hidden ideal of a simulated photographer, and the grade found after ten choices from 3×3 galleries.

Open in ColabExample plot_05_photo_enhancement.py in the gallery

9.7 Music and text

The evaluator of a melody listens. Melody evolves sixteen-step melodies in a chosen scale and tempo, shown as piano rolls in galleries and rendered as WAV audio for a notebook player; GenJam, which evolved jazz solos interactively, is the classic of this genre [80]. The evaluator of a slogan reads. TextDesign evolves slogans for a topic: without a language model, variation recombines template phrases; with one, the model proposes variations of the chosen slogans — a language model as the variation operator, as in evolution through large models [81] — while a person, a simulated reader or another model judges. Text problems are evaluated by text-only judges through Problem.describe.

In a nutshell: Visual and creative applications

  • Creative problems act on perceptual quantities, keep drawings in frame and separate colour from shape, so that small mutations make visible, coherent changes.
  • Fractals, CPPNs, harmonographs, superformula logos and cellular automata cover the classics of evolutionary art; biomorphs and L-systems those of artificial life.
  • Palettes, chart styles, Chernoff faces and network drawings combine judged qualities with computable constraints; photo grading uses photographers’ words for steering.
  • Melodies and slogans extend the loop to listening and reading; a language model can serve as the variation operator.