Genetic Programming: Mona Lisa Source Code and Binaries


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

60 thoughts on “Genetic Programming: Mona Lisa Source Code and Binaries

  1. Pingback: Genetic Programming: Mona Lisa FAQ « Roger Alsing Weblog

  2. Pingback: Genetic Gallery « Roger Alsing Weblog

  3. 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

  4. Seriously cool, thanks for the source!

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

  5. 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.

  6. 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! :)

  7. 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 :)

  8. 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

  9. Pingback: Sports, Betting and Training Blog. » Blog Archive » Free Qore Episode 7

  10. 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.

  11. 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.

  12. 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

  13. 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

  14. Pingback: Improving performance… « My Blog

  15. 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.

  16. 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.

  17. Pingback: Improving performance… « Dan Byström’s Weblog

  18. 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!

  19. 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.

  20. Pingback: What Is Google Adsense Program? | Make Money

  21. 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.

  22. Pingback: blog@kde» Blogarchiv » Genetische Programmierung: Evolution der Mona Lisa

  23. 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.

  24. 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.

  25. 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.

  26. 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”).

  27. 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)

  28. « 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.

  29. 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

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

    Plz its urgent.

    Thnx in advance.

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

  32. @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?

  33. Pingback: Interesting stuff for December 2008 « The Outer Hoard

  34. 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

  35. 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

  36. Hi Roger

    Your program is very interesting.
    I made a similar program, that is different in the way of image production and the GA structure.
    My images are produced with the letters (unicode), and my GA is based on Steady-State Genetic algorithm.

    Also, I speed up the fitness function, by cropping the changed pieces of new images.
    you can crop any polygon by a RECT from min(x,y) to max(x,y) of used points.

    That is interesting for me, to read your opinion about my program.

    My post about EvoPic:
    http://mohammadshams.blogspot.com/2010/04/evopic.html

    Download:
    http://www.mshams.ir/programs/EvoPicv1.0.rar?attredirects=0&d=1

  37. Pingback: Mona Lisa, algoritmos genéticos y HTML5: la evolución de una sonrisa en ALT1040 (Ciencia)

  38. Pingback: “进化”出来的蒙娜丽莎 « CodeWay:我的博客

  39. Pingback: HTML5 » Blog Archive » Mona Lisa, algoritmos genéticos y HTML5: la evolución de una sonrisa

  40. Pingback: Genetic Algorithms: Links And Resources (2) « Angel ”Java” Lopez on Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s