A procedurally generated surrealist photoset
Generate images that resemble surrealist portrait photomontages in the style of Man Ray. Uses the following resources:
- The Flickr API and Internet Archive Commons account to grab period images
- Runs face detection (packaged with OpenCV http://opencv.org/) to identify human faces for candidate portraits
- Blends face and non-face images using some best guesses about optimal blending algorithms (multiply or screen work best)
The source code in this repository is in the public domain.
After dozens of code runs I selected my favorite images and laid them out into a book with two-page spreads. No changes were made to the images themselves. Browse all 140 pages online.
Source code installation
Generate your own book by tweaking parameters in the source code!
Set up a virtual environment:
Ensure that you have various image libraries installed (for OS X users,
brew install libjpeg and
brew install libpng).
Install the dependencies:
. ve/bin/activate python setup.py develop
Installing numpy and OpenCV are a huge pain. You've been warned.
This worked for me:
(Your version of OpenCV will be newer; link the files into your ve.)
In manray/init.py, update this:
CASCADE_FILE = '/usr/local/Cellar/opencv/22.214.171.124/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml'
If numpy doesn't install, uninstall python via brew and update it, setuptools, and pip.
pip install numpy should then work.
Get a Flickr API key and add it to a directory called
mkdir secret cat "FLICKR_KEY = 'YOUR-KEY-HERE'" > secret/__init__.py cat "FLICKR_SECRET = 'YOUR-SECRET-HERE'" >> secret/__init__.py
Run the program:
The program should go off and acquire a lot of images from Flickr and try to generate nice output. Depending on your search parameters you can expect to get around 10 decent images out of each run.
Once it runs, it will cache the resulting images (as local pickle files) in
manray/cache and pull a random set from those. Delete that directory to re-acquire the assets from Flickr.
The output will be in