Forum Coordinators: RedPhantom
Poser - OFFICIAL F.A.Q (Last Updated: 2024 Nov 21 6:06 am)
OK, this is going to get a bit deep but it is necessary to understand how PoseGenie does what it does. A genetic algorithm is a method of arriving at a good solution for a problem that has a very large number of possible combinations. As an example, take the "nose touch" problem in the first image. There are a very large number of possible joint rotations involved in getting the Poser figure to touch the tip of a finger to it's nose. If the pose only uses the collar, shoulder, and forearm and you limit the rotations to whole numbers for -360 to 360 you get: 720 (integer degrees from -360 to 360) times 3 (x, y and z rotations) times 3 (number of body parts) = 6,480 combinations Only a very few of those 6,480 combinations are going to actually get the finger close to the nose. An even smaller number will look good since most will contort the limbs into un-natural configurations. But in fact, the number of possible combinations is much larger since Poser doesn't use whole number increments in the rotations. With just three places after the decimal you've now got: 6,480 times 1,000 = 6,480,000 possible combinations Granted, in most instances you wouldn't have a situation here all the joints could rotate from -360 to 360 but regardless you'd still end up with a very large number of possible combinations. Finding possible solutions when dealing with a very large number of combinations can be a daunting task. A genetic algorithm is useful in situtions like this because it can sift through the possible combinations and arrive a good solution (though not always the best solution). It does this by simulating the processes that living organisms use to pass on genetic traits. (more)
A GA (I'll be using GA for genetic algorithm from now on) uses this concept of chromosomes and genes as a mechanism for solving problems. The image is of a slightly different pose created using PoseGenie. The print window on the right shows the chromosome that was the best solution found when the script was run. You'll notice that down in the listing there is a section titled Genes. Each gene is composed of a body part name, a rotation name and a number that represents the number of degress for the named rotation. I'll get into how PoseGenie uses the chromosome later. I just wanted you to have an idea of what a GA chromosome looks like.
Typically, a GA will start by creating a number of chromosomes with values for the individual genes selected at random. This first set of chromosomes is the first generation of chromosomes. It then uses a fitness function to grade how well each individual chromosome performs at solving the task. Figuring out what the fitness function should test for is one of the more difficult tasks when building a GA. After all the chromosomes are graded, a predetermined number of the fittest chromosomes are selected and saved. Copies of these saved chromosomes are then used in a process called cross-over. Two chromosomes are selected from the most-fit group and the GA goes down the list of genes. At random points through the list, the GA plucks the gene from one chromosome and uses it to replace the corresponding gene in the other chromosome. During the replacement the gene that is being replaced is copied over to the other chromosome. So what you've got is a gene for gene replacement at random points between the two chromosomes. The result is two new chromosomes that have shared characteristics. The new chromosomes are saved and the process is repeated with two different chromosomes from the saved most-fit chromosomes. This process continues till a pre-determined number of new chromosomes are created. (more)
This new group of chromosomes has one other process performed on it called mutation. The GA takes each of the chromosomes and reads through the list of genes. At random, the GA will change the value in the gene. The probability of this change occuring is pretty low though since the GA only makes the change 0.001% of the time. So, what's the point of doing the cross-over and mutate steps? The cross-over step is basically the same as cross-breeding to produce plants or animals with desired characteristics. The mutate step is analogous to the mutation process that occurs in nature. Mutations don't happen very often and when they do the organism is usually worse off for it. Mutations that do work can create an organism or chromosome that is more fit then it's peers. At this point, we have three groups of chromosomes. The the original randomly created group, most-fit group and the group that resulted from the cross-over/mutate step. We're well on the to creating a new generation here but it needs to be filled out a bit. In a typical GA, the number of chromosomes the are selected to be in the most-fit group equals 40% of the original group. Since the cross-over/mutate step created an equal number of chromosomes, we now have 80% of the necessary total. The last 20% is created at random just like the original generation of chromosomes. These three groups are combined to form the next generation of chromosomes. This new generation is then graded using the fitness function and the whole process of most-fit selection and cross-over/mutate chromosome creation is repeated through a pre-determined number of generations. To recap: 1. Create the first generation of chromosomes. 2. Test the chromosomes with a fitness function. Rank according to fitness. 3. Select the top 40% based on rank and save the chromosomes. This is the most-fit group. 4. Use copies of the most-fit group chromosomes to do cross-over and mutation till the number of new chromosomes is equal to the number in the most-fit group. 5. Combine the most-fit group and the cross-over/mutate group then pad with new random chromosomes till the number is equal to the original generation of chromosomes. 6. Go back to step #2 with the new generation of chromosomes. Repeat until the pre-determined number of generations have been processed. 7. Do the fitness function one more time. The chromosome that ranks highest is the fittest of all tested. The result of this whole process is a single chromosome that is the most fit of all the chromosomes created during the time the GA was operating. (more)
As to the pose itself, this is a simple example using just the right arm, neck and head. More complex poses can be developed by breaking the body into sections and using PoseGenie on each section, positioning the Target and parenting the Seeker as necessary.
I was a bit surprised at the runtimes for the script. There's a lot going on in the script but poses like the one in the image usually take around a minute. It's sometimes necessary to run the script 2-3 times to get the best results. Much of how the pose ends up depends on the random selections for the first generation. It is possible that selections for the first generation do not contain the range of joint rotations necessary to give a desirable result even with the cross-overs and mutations. In GA jargon this is called hitting a local minima.
I'm planning on having this available in FreeStuff in another couple of weeks. The main script is solid but I don't like having to edit the text file used to describe the genes so I'm adding that functionality to the script's GUI. This script has taken several months to get in it's present form (with a detour to do the MeasureIt script) so another couple of weeks isn't going to matter. There will also be a PDF file included that has all of this background plus examples of how to use the script.
After PoseGenie is finished I'm thinking of writing a version that will use multiple Targets and Seekers. This one would be specific to creating hand poses (call it HandGenie maybe ... ;) ). Thanks for attention.
Credits:
Daisy figure by Thorne
Messy Hair by the Master Koz
Great effort :-) Now you can see why animators are WELL paid by cartoon studios :-D Just a thought: has the target to be close to the body or can it be placed anywere (with reason, obviusly)? And if it is too distant to be reached by the seeker, what's the possible outcome? A perfectly straight arm for example? Or a straight arm not too stright (almost bent), which in final could look more natural? Thank you.
Well, bushi, apart from giving me an enormous headache, you've also manged to impress me no end. It sounds terrific. Coupla questions. Any minimum hardware requirements to run this? Is it Python-based, therefore P5 only? Also, can the target be placed on a second figure, so that, for example, daisy can reach out to touch someone else? Kudos for the amazing work. Thinking out the box is so unusual. mac
Wow! Pretty elaborate. This would probably be real cool for making pose packs. Set up some generic ball locations then fire of N permutations. In fact a script I wanted to make would so something similar where you set the figure in one of your stock poses then fire of a randomizer which would slightly tweak each joint to get a different look. Thanks for sharing. I always enjoy seeing new uses for Python.
Yes!!! Thanks for getting back to this one, Bushi! This is fantastic! oh, I can't wait to play with it! maclean -- ProPack also supports Python. That was why I first went to Propack. All the other stuff was sorta like a bonus, lol. and Mason -- what have you got going on in your oven of late? Yer no slouch at this sorta stuff!
thou and I, my friend, can, in the most flunkey world, make, each of us, one non-flunkey, one hero, if we like: that will be two heroes to begin with. (Carlyle)
" Bushi you're a genius" I was thinking the same. Very impressive. mac - it should also run in P4PP if it's python based. Pro Pack supports python.
Coppula eam se non posit acceptera jocularum.
lucstef - There is another sphere prop that is placed in the scene when setting up for a pose. The Base is used at the beginning of a run to calculate a maximum distance from the Seeker to the Target. In the case of the above images, the Base is placed in the figure's chest and parented there. It's pretty much a housekeeping issue but gives the script a realistic frame of reference for the distance calculations. The pose that results from a distant Target depends on how the limits on the rotations are set. In the attached Koshini image, the Target was set closer to the sword handle then the left arm could reach. The results still worked well for the pose though. When posing the right arm, the Seeker (the red sphere) was posed onto the sword tip then parented to the right hand. There is a lot of flexability in the script for setting up the relationship between the Target and the Seeker.
maclean - Yes, it's a PoserPython script so should run fine on anything that runs P5 or the ProPack. And yes, you certainly can place the Target on a different figure and have the Seeker track to it. The figure that the Seeker is parented to is just a vehicle for moving the prop. All distance calculations are between the two props and don't involve the figures.
Awesome work, Bushi! Please forgive me, but I'm going to argue with a little bit of your mathematics. In post 2, you said that with three joints and restricting yourself to whole numbers of degrees in your rotations you would have 720 times 3 times 3 = 6,480 posible combinations. The formula should be 720 to the power of (3 times 3) = 51998697814229000000000000 possible combinations, which is a lot larger than 6,480. I would argue that you should use a 360 degree range instead of 720 (180 degrees in either direction is enough to cover the full 360 degree range of movement - no need to have two full circles). Then you wold have 360^9 = 101559956668416000000000 possible combinations, which is a quite a lot smaller, but still much larger than 6,480. If we then allow rotations to be specified to 3 decimal places, we have 360,000^9 = 101559956668416000000000000000000000000000000000000 possible combinations. Of course, this just makes your GA even more impressive and illustrates even more clearly why the GA approach is preferable to trying to test every single combination. Congratulations on some amazing work. This is a wonderful approach to the problem and I can see it's going to be very useful.
View Ajax's Gallery - View
Ajax's Freestuff - View
Ajax's Store -
Send Ajax a message
Well, it's OK if it's python. I have poser 5.... even if I've only opened it a couple of times to admire the interface! LOL. Well, I did pre-order it, but only installed it last week. If you can use this between figures, I can see it being great for things like posing figures to look at one another or pointing to another figure. I suppose the target can also be parented to an outside prop too, in which case, you can easily make a figure point a finger at (or give the finger to) something else within the scene. mac
I saw what you were doing the moment you mentioned genetic algorithms...remembered the work of Karl Sims, for isntance. I'd never thought of using this to arrive at a solution for a static pose! I'm amazed it runs so quickly, too. As for the sort process at the end of each generation, what about a variation that allows the user to pick instead? Thus a guided evolutionary process (shades of creationism!!) That way user input could train the evolving solution in ways that better suited an artistic goal (such as the elbow height issue you mentioned). This is revolutionary. Almost makes me want to run out and buy Pro-pack.
Ajax - (bushi slaps his forehead) No, of course your correct. It's in a 3d space so it would be cubed rather than just a multiple. Thanks for pointing that out! mac - The Target doesn't really need to be parented to a figure at all just the Seeker since that is the prop the GA is trying to get to the Target.
No, no.... Using that original formula of "720 (integer degrees from -360 to 360) times 3 (x, y and z rotations) times 3 (number of body parts) = 6,480 combinations" The problem isn't one of dimensions, it is in calculating the permutations. Take a single 6-sided die. One die has 6 possible positions. Two dice have 36 possible combinations. The answer isn't 6x2; it is 6^2 In this case we have, say, 360 possibilities on three axis on at least three joints (shoulder, elbow, wrist). (360^3)^3 or 360^9 equals 1.016 EE 23 (1 followed by 23 zeroes). If you added finger joints it might be, say, 360^12 and we get up to 4.7 EE 30 (sorry to change notation there; also known as 4.7 x 10^30, or maybe just 4,700,000,000,000,000,000,000,000,000,000 ). That's what Ajax is saying. Number of dimensions doesn't matter per se. It's the difference between multiplying and raising to a power! So be proud -- you've found a way to filter through a much, much greater number of choices than you thought!
nomuse - I'm not saying anymore about the number of possible combinations other then it is very large. Sticking my foot in my mouth twice is quite enough for one day, thank you. ;) As to a "guided evolutionary process" in a way that's pretty much built into the process. With the rotations controlled by max and min limits it's a simple task to alter the range of the results. With it only taking a minute or two to do a run and with the limits being available for change on the GUI, doing multiple runs to tune a pose is a good solution. To everyone that posted - Thank you for your comments and encouragement. Now all I have to do is get the thing finished so it can be put to work! :)
I don't understand a word of this but it looks like it's something cool. So I too will be waiting to see it and try it for myself :o) Great work! --- Heh now I just feel like when some of my high-educated friends discuss quantum-what-ever-it's-called-physics. You know where you try to not let TOO much fresh air in thru your gaping mouth ;o)
FREEBIES! | My Gallery | My Store | My FB | Tumblr |
You just can't put the words "Poserites" and "happy" in the same sentence - didn't you know that? LaurieA
 Using Poser since 2002. Currently at Version 11.1 - Win 10.
Oh cool - millions of broken script generated poses flooding all of the online stores, rather than hundreds of broken hand generated ones. snicker Nice work, Bushi. ;)
"I am a good person now and it feels... well, pretty much the same as I felt before (except that the headaches have gone away now that I'm not wearing control top pantyhose on my head anymore)"
Cool application of GA to a 3D problem. Genetic Algorithms have definitely proven to be great at stochastic optimization over constrained problems with very large search spaces. Have you considered trying to optimize over time as well, for animation purposes? Probably pretty difficult, as the search space explodes even more and a fitness function is probably harder to define. Might make for some interesting research tests though :) -Jeremy
Ironbear - How does that go ... every solution creates it's own problems. ;) shadownet - That's correct. All research work for this script is currently being done at a secret facility in South Korea. jwbaer - There is some optimization that occurs while the script is running. The genes in the new chromosomes that are in the 20% group I discussed above aren't generated like the genes in the first generation chromosomes. The genes in the first generation use the full range of the minimum/maximum limits. From the second generation on, the values for genes from the top 40% group are sorted to find the largest and small for each type of gene. These more limited mininum/maximum ranges are used to generate the new chromosomes to pad out that extra 20%. When I first tried this I was concerned that it might make the GA converge too quickly on a local minima. Fortunately, it is still loose enough to keep that from happening.
All too true, Bushi. ;) Howya doing, by the way? That's one of the main reasons I came out of [lurk mode] was to say "Hi" - haven't seen you around in freaking ages, man. Well.. that and to twit all the merchants, natch. I mean, you know it's a gonna happen, as sure as rain falls sideways in Texas. ;] I did mean the "nice work" not in a sarcastic way, by the way: that's an impressive technical acheivement, Bushi.
"I am a good person now and it feels... well, pretty much the same as I felt before (except that the headaches have gone away now that I'm not wearing control top pantyhose on my head anymore)"
Ironbear - I didn't take your comments as being sarcastic. I've seen you do that before and this wasn't it! ;) As to where I've been, suffice to say I had some pressing family issues that kept me away for several months. Marque - The script will be in the FreeStuff area in a couple of weeks or so. It currently uses a file to define which body parts are being used and the rotation limits for the parts. I'm moving that into the GUI so that they can be picked and set directly from the script.
"...suffice to say I had some pressing family issues that kept me away for several months" - bushi 'Nuff said. ;[ And... that's a shame. Hope everything worked out well for you and yours? Good to see you back online. You've been missed. Heh. That's the nice thing about old acquaintance: can speak off the top of the head and trust somewhat that the other guy will take it as it's meant, not as it reads. ;]
"I am a good person now and it feels... well, pretty much the same as I felt before (except that the headaches have gone away now that I'm not wearing control top pantyhose on my head anymore)"
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.