eos icon indicating copy to clipboard operation
eos copied to clipboard

Convergence criterion for fitting function

Open wli75 opened this issue 8 years ago • 5 comments

You've mentioned adding a convergence criterion as a todo in fitting::fit_shape_and_pose. I'm interested in exploring this further. What do you suggest as the convergence condition?

I'm currently testing different number of iterations for a single image fitting. It seems that the fitting works best with 3-5 iterations, then it gets worse with 10 iterations. Image: audrey Fitting with 3 iterations: iter_3 Fitting with 10 iterations: iter_10

wli75 avatar Dec 28 '16 12:12 wli75

My observation is that it takes up to 50 or so iterations for the parameters to fully converge. However, visually, there is usually no difference after 5 or so iterations. See for example below graphs for one particular image. convergence_github

In your example image, it looks like it's overfitting a bit. How does it look after 50 iterations? The same as after 10? And the solution in this case would be to use a bit of a larger regularisation. What are you using for lambda, 30?

I'm a bit hesitant to introduce an automatic convergence criterion for this function, as it would be hard to choose one. If we stop when the parameter change is sufficiently small, it may run up to 50 iterations, which would not work for real-time applications anymore. If the desired output is just an accurate mesh, you can stop after 1-5 iterations, as after that there are no visual changes anymore (so the convergence criterion could e.g. be the landmark-reprojection error). So it really depends on the individual application. I'm very open to suggestions though! :-)

patrikhuber avatar Dec 28 '16 18:12 patrikhuber

I was using a regularisation of 15 in my previous example. You're right. I tried bumping it up to 100, and it works great on an image of 660x400 :D screen shot 2017-01-03 at 12 34 01 pm screen shot 2017-01-03 at 12 34 12 pm screen shot 2017-01-03 at 12 34 22 pm screen shot 2017-01-03 at 12 33 50 pm

I tried using the same image and lambda but with a smaller resolution of 640x360, and the result is less satisfactory. screen shot 2017-01-03 at 12 42 20 pm screen shot 2017-01-03 at 12 42 29 pm screen shot 2017-01-03 at 12 42 36 pm screen shot 2017-01-03 at 12 42 14 pm Adjusting lambda to 50, 300, 500 did not work either.

I can't see how lambda is related to the image resolution. Are there other parameters I should adjust depending on the image size? I tried adjusting distance_threshold in fitting::find_occluding_edge_correspondences, but I'm not sure how it should be calculated. The distance_threshold was 180 in my previous two examples.

wli75 avatar Jan 03 '17 10:01 wli75

Hmm, so you were changing the image resolution from 660x400 to 640x360? The uploaded images are of size 400x241 and 400x225, but it may well be that GitHub resizes the images. I am asking because I'm interested in whether you changed the aspect ratio - in second image you uploaded, the aspect ratio is changed, because the image only got rescaled in y-direction. So the face is basically squeezed to an unnatural one, and what may have happened is that the model can't explain this squeezed face very well, which may explain your result. Still, the squeezing in your example seems rather small, and I am surprised that the model can't simply explain that with its shape variation.

Can you double-check what the exact image resolutions are, and then try rescaling the image but keeping the aspect ratio?

The fitting in general is (or should be) independent of image resolution. distance_threshold should be as well - here, it is multiplied with the scale. I'm actually not 100% confident that that formula is right, which is why I added the note, but in my tests it seemed to do the right thing.

Also there's a note about the "units" of distance_threshold in the function documentation above.

patrikhuber avatar Jan 03 '17 10:01 patrikhuber

@wli75 Did you look at any of the things I mentioned and find out more?

In any case I'll leave this issue open as it would be a pretty nice addition to have an automatic convergence criterion :-)

patrikhuber avatar Mar 24 '17 22:03 patrikhuber

Apologies for the delay. I'm planning to look into this some time in late-April. I probably got some things mixed up with the resolutions of my test images.

wli75 avatar Mar 25 '17 19:03 wli75