Giter Club home page Giter Club logo

Comments (8)

simonhessner avatar simonhessner commented on August 15, 2024

I think I could use _divergence_reg_losses with different sigma_t values and mu_t as the regressed coordinate and then see which sigma_t has the lowest loss. That would be kind of a brute force approach, but better than nothing

from dsntnn.

anibali avatar anibali commented on August 15, 2024

If you look at the variance_reg_losses function you can find an example of calculating the variance of heatmaps:

dsntnn/dsntnn/__init__.py

Lines 233 to 262 in 4f20f5a

def variance_reg_losses(heatmaps, sigma_t):
"""Calculate the loss between heatmap variances and target variance.
Note that this is slightly different from the version used in the
DSNT paper. This version uses pixel units for variance, which
produces losses that are larger by a constant factor.
Args:
heatmaps (torch.Tensor): Heatmaps generated by the model
sigma_t (float): Target standard deviation (in pixels)
Returns:
Per-location sum of square errors for variance.
"""
# mu = E[X]
values = [normalized_linspace(d, dtype=heatmaps.dtype, device=heatmaps.device)
for d in heatmaps.size()[2:]]
mu = linear_expectation(heatmaps, values)
# var = E[(X - mu)^2]
values = [(a - b.squeeze(0)) ** 2 for a, b in zip(values, mu.split(1, -1))]
var = linear_expectation(heatmaps, values)
heatmap_size = torch.tensor(list(heatmaps.size()[2:]), dtype=var.dtype, device=var.device)
actual_variance = var * (heatmap_size / 2) ** 2
target_variance = sigma_t ** 2
sq_error = (actual_variance - target_variance) ** 2
return sq_error.sum(-1, keepdim=False)

I haven't tried using it this way myself, but it could be possible to use this sort of calculation as a proxy for confidence.

from dsntnn.

simonhessner avatar simonhessner commented on August 15, 2024

Very nice, have not seen this function. This seems to work pretty good in my first tests. Just have to find a nice way to transform it into values between 0 and 1, but I'll figure it out. Thank you!

from dsntnn.

briantse100 avatar briantse100 commented on August 15, 2024

@anibali, I use the function variance_reg_losses() with to get confidence. But the confidence is 0.05 very low with unnormalized_heatmaps and 3.9954e+08 very high with normalized_heatmaps. How to get normal landmark confidence? if I make traditional gauss heatmap like figure2b in the paper, the heatmap value is [0, 1], and I will try it.

from dsntnn.

anibali avatar anibali commented on August 15, 2024

You will need to calibrate the outputs from variance_reg_losses yourself. Keep in mind that it should have an inverse relationship with confidence (a large value indicates low confidence). It should be used with normalised heatmaps.

Note that this is not something that I have tried myself, so you will need to do some experimenting.

from dsntnn.

briantse100 avatar briantse100 commented on August 15, 2024

@anibali Thanks your replay. I have cablibrated the outputs and experimented. In the example of basic_usage.md, add three different points [24, 27] [28, 32] [32, 15]. But the three points output values have big difference, eg, 0.2, 0.02, 0.12. Is it normal? Cablibrate by abs(output - output_mean)/(max_output - min_output) and is it right? If only one point as input, this cablibrate method doesnot work.

If it can make gauss like function gaussian(img, pt, sigma) ? And I have a try.

from dsntnn.

anibali avatar anibali commented on August 15, 2024

You just have to experiment with your actual data. There is no way to tell whether the spread of numbers is meaningful for three points, you have to observe what the values are like for both good and bad predictions to see whether they are correlated.

from dsntnn.

briantse100 avatar briantse100 commented on August 15, 2024

ok, thanks, I have a try.

from dsntnn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.