GitHunt

🎨 Interactive Evolutionary GAN Gallery

An interactive evolutionary visualization tool built with PyGame and a GAN generator (upconvGAN from circuit_toolkit).
You can explore generative images through human-guided CMA-ES optimization — click the images you like, evolve, and watch the generator’s latent mean shift!

Features

  • Interactive GUI with PyGame
  • 3Ă—3 or 4Ă—4 image grid on the right (configurable)
  • CMA-ES optimization loop — evolve latent codes based on your clicks
  • Mean visualizations: Shows both current (xmean) and previous (xold) CMA-ES population means
  • Keyboard & mouse shortcuts:
  • E — evolve using selected images
  • R — reset optimization
  • Left-click an image — toggle selection
  • “EVOLVE” / “RESET” buttons also available on the left panel

Dependencies

Make sure you have the following installed through pip, mamba or conda.

  • pygame
  • torch
  • numpy
    and the circuit_toolkit package (required for upconvGAN and CholeskyCMAES):
git clone https://github.com/PonceLab/circuit_toolkit && cd circuit_toolkit && pip install -e .

If you want GPU acceleration, ensure your PyTorch build supports CUDA or MPS (Mac).

How to Run

Clone or copy this script (e.g., evolve_gallery.py) and then run:

python evolve_gallery.py

When the window opens:

  1. Click on any images you like — they turn green.
  2. Press E or click EVOLVE — the gallery updates with new candidates.
  3. Repeat the process to steer the generator toward your preferred outputs.
  4. Press R or click Reset to restart evolution from random latents.

Configuration

You can modify key parameters at the top of the script:

Variable Description Default
GRID Number of images per row/column (3 or 4) 4
LATENT_DIM Dimensionality of the GAN latent space 4096
SCREEN_W, SCREEN_H PyGame window size 1280Ă—720
LEFT_UI_W Width of left control panel 360
init_sigma CMA-ES exploration step size 2.0
RIGHT_MARGIN, TOP_MARGIN, BOTTOM_MARGIN, GRID_GAP Layout spacing values various
G = upconvGAN("fc6") Model backbone (can change to "fc7", "fc8", etc.) "fc6"

If you use a different generator or optimizer, adapt the following lines:

from circuit_toolkit.GAN_utils import upconvGAN
from circuit_toolkit.Optimizers import CholeskyCMAES

How It Works

Each frame, the program:

  1. Displays GRID Ă— GRID images generated from random latent codes.
  2. Waits for user clicks (binary scores).
  3. Passes scores to CholeskyCMAES.step_simple().
  4. Generates new samples from the updated distribution.
  5. Renders the current mean (xmean) and previous mean (xold) in the left panel.

Over time, the means drift toward regions of latent space producing images you prefer — a simple form of human-in-the-loop evolution.

Example Screen


Left panel shows:

  • Current mean (xmean)
  • Previous mean (xold)
  • Help text and control buttons

Right panel shows:

  • Interactive GAN images
  • Clicked ones outlined in green
Animadversio/texture_evolution_click_driven | GitHunt