Roger Alsing Weblog

Genetic Programming: Mona Lisa Source Code and Binaries

with 51 comments

evolisa

Source code and binaries are now published:
http://code.google.com/p/alsing/downloads/list

The code have been downgraded to .NET 2.0 but the solution files are still VS.NET 2008 format.

Many many thanks to my partner in crime Mats Helander for the .NET 2 port and Options / Serialization extensions. 
Do note that the number of polygons are now configurable, and the image above is composed of about 150 polygons.

Enjoy.

//Roger

Written by Roger Alsing

December 11, 2008 at 7:10 pm

Posted in .NET, C#

51 Responses

Subscribe to comments with RSS.

  1. [...] in DSL, Evolution, Life, Random « Genetic Programming: Evolution of Mona Lisa Genetic Programming: Mona Lisa Source Code and Binaries [...]

  2. Awesome, thank you. This will be fun to play around with.

    jeremiah

    December 11, 2008 at 7:20 pm

  3. Excellent, thank you so much.

    SamPL

    December 11, 2008 at 7:39 pm

  4. Thanks for putting this together! Really appreciated.

    RGiskard

    December 11, 2008 at 7:53 pm

  5. This is awesome. Thank you very very much! looking forward to playing with it today

    Matty B

    December 11, 2008 at 9:18 pm

  6. I put together my own version of your idea yesterday.. my images weren’t looking nearly as good as yours.. after looking at your source, i think the biggest difference was in size of change. Your mutations are much smaller. Now, looking back, that seems obvious, as it allows more room for incremental improvement. Mine would change drastically and would usually be a step backwards. Especially after 30,000 generations.

    Thanks for sharing this!!

    Jason

    Jason K

    December 11, 2008 at 9:55 pm

  7. can you send me a compiled version of it please?
    can’t get it to work here….=(
    jordan2_delta@hotmail.com
    thanks!

    Jay

    December 12, 2008 at 12:33 am

  8. Thanks so much for sharing. This will be fun to play with!

    Nolan Egly

    December 12, 2008 at 5:46 am

  9. Hi !

    I’m a french guy so sorry for my poor english ! ^^
    Could you add an option which can save each selected image of the process like this image of your weblog http://rogeralsing.files.wordpress.com/2008/12/evolutionofmonalisa1.gif ?
    (This selected : http://img296.imageshack.us/img296/3110/selectedtv7.jpg) ;)

    Thx a lot !

    Gael

    onisahkku

    December 12, 2008 at 7:47 am

  10. Seriously cool, thanks for the source!

    Jordan, you can download the compiled version from the link; it’s called ‘EvoLisaBin.zip’

    Russ C.

    December 12, 2008 at 8:01 am

  11. Great program, and great idea – been having a lot of fun with it.

    I agree with onisahkku (I think). It’d be great to have a feature that saves every nth selected image to a file automatically. You could make neat movies that way.

    Also, I’m looking forward to the export feature you mentioned – SVG, PNG, and/or JPEG. :)

    I looked into a CUDA implementation (that is, an on-GPU implementation), but it may be too big a bite for me to chew. It’d be pretty neat, though. I think it’d be loads faster.

    usernameguy

    December 12, 2008 at 9:06 am

  12. Another thing which is a great side effect of this toolkit is that it’s apparently possible to create an recognizable image of the mona lisa with just 150 flat 1-color polygons! Ask a human to produce that and s/he’ll likely have a hard time! :)

    Frans Bouma

    December 12, 2008 at 9:07 am

  13. Cool, the binary even works on Linux using Mono. Had to tell it where to find the equivalent of the gdiplus dll but after that it’s all fine.

    I’m still going to rewrite it in C++ when I get a chance, though :)

    Stephen Douglas

    December 12, 2008 at 9:28 am

  14. Man i think this is so interesting! Is there a tutorial anywhere for this? Id love to know how to write code like this!
    Thx

    Adrian

    December 12, 2008 at 9:39 am

  15. LOL i thought bin was some kind of code ^^’
    Thanks!
    Great thing to play with!

    Jay

    December 12, 2008 at 12:33 pm

  16. I’ve built a C++ version of the algorithm, it uses the same weights and probabilities of the Roger one for the mutations, if you are intrested the sources are available here:

    http://www.ggsoft.org/archives/genetic.zip

    Gabry

    December 12, 2008 at 5:32 pm

  17. The binary .zip file is 6.66kb – PROOF THAT THE DEVIL INVENTED EVOLUTION!!!

    Kris

    December 12, 2008 at 5:57 pm

  18. This is very cool. I think a multicore optimized version would be a very good lead-in to a Paint.NET effect plugin :)

    Rick Brewster

    December 12, 2008 at 6:56 pm

  19. [...] Genetic Programming: Mona Lisa Source Code and Binaries « Roger … [...]

  20. Thanks for sharing. I love to tinker with these kind of projects.

    I added a factor to the error calculation that comes from an “alpha map” calculated before the evolution starts. Currently I use local differences (basic edge detection) and closeness to the center as “enforcers” of errors. I didn’t do a scientific analysis, but I think this helps the algorithm to converge faster to a recognizable image. In my test runs, the 50K iteration Mona looks like your 350K mona and uses 56 polygons.

    Drop me a mail if you’re interested in the updated source code.

    Adrian #2

    December 13, 2008 at 12:56 am

  21. Hey, downloaded the source, was playing with it. I noticed that you often iterate without any mutation happening. But when you do this, you discard your cloned image. I made a quick change to the source to keep the image if it is unmutated, and there was a noticeable speed improvement.

    Just figured, for people trying to pump out pretty pictures, it might be a worthy tweak to the code.

    Charles Randall

    December 13, 2008 at 2:00 am

  22. Adrian #2 : I’m interested, but only if it’s a compiled binary version :D

    If you could send it on the web and give me a link, I’ll test it ^^

    Thx

    onisahkku

    December 13, 2008 at 4:39 am

  23. Really cool,

    I’m also a french guy, sorry for my english!

    I find your site by the link from M. Net! Je ne l’ai pas encore essayer le Rhino, mais je trouve que c’est une excellente idée, surtout car M+ ne marche vrment pas bien! (I said something about the Rss Hack for a french tv show)

    Impressionnant le programme que tu utilise, et c’est fou la progr génétique, je ne connaissais pas! Spécialement, les années de dév de GP sont en mm temps que la course a l’Espace (coincidence ?!?…)

    Lache pas! Et écoute M Net c’est le concours du bas de noel en +, je ne sais pas si tu a le mot moi il me manque une lettre!

    Good Bye everyone,
    Johnny boy

    Johnny boy

    December 13, 2008 at 11:40 am

  24. How do you get it to work? Running GenArt.exe in WinXP I get “The application failed to initialize properly (0xc0000135). Click on OK to terminate the application.

    Flesh-eating Dragon

    December 13, 2008 at 2:18 pm

  25. [...] Improving performance… By danbystrom …of Roger Alsing’s fitness function in the EvoLisa project. [...]

  26. I tried to run the .net binary, but my entire machine just stops. It took several minutes just to get the task manager up and kill the process. What’s going on here? I tried the Javascript version of this, but the .net version should be much faster.

    Michael

    December 13, 2008 at 10:29 pm

  27. I am totally not a computer programmer, so I don’t know whether I’m asking the impossible, or whether you’ve already done this and I don’t realize it. But is there a version of this program that will run on the Mac? I would love to play with it, but the MAc is all I’ve got.

    Isaac

    December 14, 2008 at 5:23 pm

  28. [...] Filed under: Programming — danbystrom @ 20:41 …of the fitness function in the EvoLisa project. In case you managed to miss it, EvoLisa is an already world famous project created by [...]

  29. Great! Many thanks. A few point for us newbies:

    1-There are too many options which I don´t really understand. I wouldn´t mnd less detail to obtain a faster result – which options should I change and in which direction?

    2-I would really like to try and print the resulting polygons in transparencies and then stack them. Can the resulting image be decomposed into the different underlying poligons?

    Thanks!

    Guiyo

    December 14, 2008 at 7:40 pm

  30. Hi,

    I downloaded “Evo-Lisa Source Code – LGPL – .NET 2.0″.
    Adding the files into an MS VS.NET 2005 project but it won’t compile.

    A lot of the syntax errors look very strange to me, as if this were still .NET 3.0?

    Thanks,

    James.

    James

    December 15, 2008 at 1:21 pm

  31. [...] Genetic Programming: Mona Lisa Source Code as well as Binaries « Roger … [...]

  32. Great tool, thanks very much for posting code and binary! Some functionality to export to SVG would be perfect. The SVG format is really simple for this, so it should be very straight forward to add it.

    Martin

    December 17, 2008 at 12:21 pm

  33. [...] nur 50 halbtransparenten Polygonen zeichnen? Mit dieser Fragestellung entwickelte Roger Alsing sein Tool, bei dem solche Ergebnisse, nach 571266 Generationen, 2,5 Stunden  Laufzeit und 119 Polygonen, zu [...]

  34. This could be truly interesting to create SVG file from bitmap picture. Even more interesting, it could creates compressed SVG file (SVGZ). I bet the compression ratio would be truly amazing.

    lplessard

    January 7, 2009 at 2:27 am

  35. 0) Setup a random DNA string (application start)

    1) Copy the current DNA sequence and mutate it slightly
    2) Use the new DNA to render polygons onto a canvas
    3) Compare the canvas to the source image
    4) If the new painting looks more like the source image than the previous painting did, then overwrite the current DNA with the new DNA
    5) repeat from 1
    ====
    To be correct this is not really a genetic algorithm – this is Hill Climbing. Roughly speaking HC differs from GA in several aspects:
    - in HC you have one solution, in GA you have pool of several solutions
    - in GA you not only mutate solutions, but also crossover two(or more) of solutions to get new solution.

    Andy

    January 9, 2009 at 6:25 pm

  36. Correct me if I’m wrong, but I think for it to be hill climbing it would need to rely on the derivative of the fitness function.

    lplessard

    January 11, 2009 at 2:58 am

  37. He is relying on the derivative in a primitive way.
    He is examining the delta of the fitness function between the parent and child, and choosing the one with the better fitness function (looking only at the sign of the derivative).

    He’s not trying to do any prediction, or scale his mutation parameters, or anything fancy — just hill climbing at it’s most basic (“am I higher or lower, keep going higher”).

    imposture

    January 17, 2009 at 8:50 pm

  38. I hope you are aware that none of the GA/GP approaches try to “predict” anything.

    That would not be evolution at all…
    And that tuning the mutation params are not a requirement for any of the algorithms.

    And that hillclimbers are based on a fixed size solution.
    While this app uses a dynamic sized (non computational) AST.

    This app does not fit directly under GA/GP since it lacks cross-over and the population size is too small.
    (Atleast in the non-clustered version)

    It also does not fit directly under HC because the solution is based on a dynamic sized AST, and got multiple mutation parameters and that HC requires you to _actually calculate a derivation_.

    (The sign of the derivation was a really weak argument since that could be applied to any GA/GP when killing off the weakest ones in the population too)

    Roger Alsing

    January 18, 2009 at 8:24 am

  39. an option to export to bmp, png, or jpg will be nice to the next version of this program

    TEd

    January 31, 2009 at 8:03 am

  40. « an option to export to bmp, png, or jpg will be nice to the next version of this program »

    That seems counterproductive ;-)

    I do hope that there will be an SVG export someday though. The style that this app produces is so much more appealing to me than other bitmap-to-vector converters, especially for images containing gradients.

    kex

    March 12, 2009 at 6:03 pm

  41. hello sir

    ur wrk z really nice,i appreciate it but i need to run it on .NET 2005 version, can you please help me out

    meghna

    March 20, 2009 at 3:29 pm

  42. meghna

    March 20, 2009 at 3:30 pm

  43. Can sumbody tell me if its possible to run this on windows using cpp….?

    Plz its urgent.

    Thnx in advance.

    neha

    March 25, 2009 at 6:45 pm

  44. How do you properly “save” the picture, or do you just print screen and crop it?

    Beau

    April 2, 2009 at 11:11 pm

  45. For those trying to compile http://rogeralsing.com/2008/12/11/genetic-programming-mona-lisa-source-code-and-binaries/#comment-701 from command line on Mac OSX

    1] download and install SDL framework
    2] copy SDLMain.m from the dmg’s devel-lite folder to the ‘genetic’ folder
    3] change Makefile:
    CXXFLAGS=-O3 -I/Library/Frameworks/SDL.framework/Headers
    LDFLAGS=SDLMain.m -framework SDL -framework Cocoa
    4] make

    Tim Knip

    May 8, 2009 at 12:27 am

  46. @Tim:
    Ah, this reminded me of why I’m not a computer science major any more… I did the first three things you suggested, but now I can’t figure out how to get the program to actually run. What do I need to do here?

    Freya

    October 10, 2009 at 4:11 pm

  47. [...] results of algorithmically evolving the Mona Lisa (There’s also software, but it doesn’t work on my [...]

  48. This is excellent,

    I’ve written a bunch of articles on C# corner experimenting with GA (some with GA’s and artwork), but this one takes the cake as far as art is concerned. I will definitely mention this in my C# Corner blog. (It would also be great if you were to write an article on C# Corner showing this cool project)!

    Best,

    -Mike

    Mike Gold

    December 19, 2009 at 6:21 am

  49. Hi,

    i really like this idea, and since i am a painter i would like to try this with some images, but since i am not programer i don’t understand where to download application(if there is one) and how to use it.
    Would appriciate if you can help me and show me links where to download.

    Thanks in advance

    M

    Mateja Petkovic

    February 7, 2010 at 1:09 pm


Leave a Reply