Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreground Scale for Any V2 #255

Open
math-artist opened this issue Nov 21, 2024 · 1 comment
Open

Foreground Scale for Any V2 #255

math-artist opened this issue Nov 21, 2024 · 1 comment
Labels

Comments

@math-artist
Copy link

First, thank you for this super useful app. I have only started using iw3 yesterday, and I already have over one hundred files converted (small files, many are samples for testing)

During my testing, I found annoying that the model Any_V2 seemed truncated when setting the foreground scale to 1. So, I have plot the curves to see what happens.

image

I use Any V2 in another project, and the depth maps close to 0 are the furthest, and the higher ones are closer. So, what foreground scale is doing, is it is flattening the background for a very small gain in the slope near 1. And that's exactly what I am seeing when I am using it. I think it's implemented backward.

I wrote this code derived from a function you made that has, I think, the correct transform for Any V2.

def inv_softplus01_edited(x, bias, scale):
    min_v = ((torch.zeros(1, dtype=x.dtype, device=x.device) - bias) * scale).expm1().clamp(min=1e-6).log()
    max_v = ((torch.ones(1, dtype=x.dtype, device=x.device) - bias) * scale).expm1().clamp(min=1e-6).log()
    v = ((1 - x - bias) * scale).expm1().clamp(min=1e-6).log()
    return 1 - (v - min_v) / (max_v - min_v)

image

@nagadomi
Copy link
Owner

Thanks for the info.
I too thought the current conversion curve for Depth-Anything was not good, but since I don't use it myself, I left it alone for a long time.
The current expression is just a smooth function of x > 0.5 ? (x - 0.5) * 2 : 0 as you say.
I will try to organize knowledge of that area at this time.

@nagadomi nagadomi added the iw3 label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants