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

Can't use .half() with new GFPGAN clean #50

Open
marcelodiaz558 opened this issue Aug 24, 2021 · 2 comments
Open

Can't use .half() with new GFPGAN clean #50

marcelodiaz558 opened this issue Aug 24, 2021 · 2 comments

Comments

@marcelodiaz558
Copy link

Hi! For the previous paper version, I was used to using FP16 weights with the model, which helped to have faster processing, now very weird results are generated if I apply model.half() and I use HalfTensors as the model input.

This is what I am doing:

For loading the model:

gfpgan = gfpgan.half()

For the model inputs:

cropped_faces_t = cropped_faces_t.half()

When I remove the above lines of codes everything works fine, but inference time is 44% bigger compared to the paper's version with half weights (looks like that quality isn't that good either, but that's another story). With .half() inference time is 20% bigger, but no result is generated.

These are the results I get:
image

@xinntao
Copy link
Member

xinntao commented Aug 29, 2021

We have also noticed this problem.

It is because this line:

return x * torch.rsqrt(torch.mean(x**2, dim=1, keepdim=True) + 1e-8)

this operation will have a numerical error when using half.

We may remove this line and fine-tune the model, so that the new model can also use the half inference.

@zhoumenghan
Copy link

We have also noticed this problem.

It is because this line:

return x * torch.rsqrt(torch.mean(x**2, dim=1, keepdim=True) + 1e-8)

this operation will have a numerical error when using half.

We may remove this line and fine-tune the model, so that the new model can also use the half inference.

any update about the half inference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants