andrewhou1 / GeomConsistentFR

Official Code for Face Relighting with Geometrically Consistent Shadows (CVPR 2022)
https://openaccess.thecvf.com/content/CVPR2022/html/Hou_Face_Relighting_With_Geometrically_Consistent_Shadows_CVPR_2022_paper.html
MIT License
114 stars 17 forks source link

Question on the meaning of training_lightings #8

Closed Andy-YX closed 1 year ago

Andy-YX commented 1 year ago

Hello Andrew, amazing work!

I am trying to run the test code (test_relight_single_image.py). But since I am new to this area, I could not understand the meaning of training_lightings well. Based on your demo code, looks like the first element is fixed to be 0.5, and the other three elements are some floating numbers.

Could you please share the meanings of the elements in training_lightings, and their corresponding value ranges?

Thanks a lot!

andrewhou1 commented 1 year ago

Sure, so that first element you're referring to is the intensity of the ambient light. The other three elements are your lighting direction (x, y, and z). In our case, the coordinate convention is positive x points to the right, positive y points up, and positive z points out from the image. In principle, the ambient light can be any intensity you want since you decide what the target lighting should be. That means you can set it to 0.4, 0.6, 0.7, etc. For the lighting direction, the only requirement is that it is a normalized vector (any unit vector is ok).

andrewhou1 commented 1 year ago

Another note: as of now "test_relight_single_image.py" is using the ambient intensity estimated from the image by the model to perform relighting (assuming in most cases the user wants to preserve the ambient intensity of the original image and only change the lighting direction). If you would like to specify an ambient intensity as I mentioned above, you should modify this line:

ambient_light = SL_lin2[:, :, :, 0]-0.1

to something like "ambient_light = torch.tensor(0.5)". If you look carefully, we only pass the 2nd to 4th elements of training_lighting to the model so the first element of training_lighting actually is unused (can remain 0.5). Hope this helps!

Andy-YX commented 1 year ago

Thanks, that is much clearer now. Yes, I see that only the last three elements in training_lighting are passed to the model, which should be a unit vector.