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

Open
opened 2026-01-29 21:40:14 +00:00 by claunia · 2 comments
Owner

Originally created by @marcelodiaz558 on GitHub (Aug 24, 2021).

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

Originally created by @marcelodiaz558 on GitHub (Aug 24, 2021). 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:** ```python gfpgan = gfpgan.half() ``` **For the model inputs:** ```python 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](https://user-images.githubusercontent.com/40875838/130692390-a7dc3fef-80b7-4673-ba2a-cb05f257f1a9.png)
Author
Owner

@xinntao commented on GitHub (Aug 29, 2021):

We have also noticed this problem.

It is because this line: d7cb9f77f1/gfpgan/archs/stylegan2_clean_arch.py (L21)

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.

@xinntao commented on GitHub (Aug 29, 2021): We have also noticed this problem. It is because this line: https://github.com/TencentARC/GFPGAN/blob/d7cb9f77f18b73599c8e5facd02f91cc8bc1140f/gfpgan/archs/stylegan2_clean_arch.py#L21 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.
Author
Owner

@zhoumenghan commented on GitHub (Feb 20, 2023):

We have also noticed this problem.

It is because this line:

d7cb9f77f1/gfpgan/archs/stylegan2_clean_arch.py (L21)

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?

@zhoumenghan commented on GitHub (Feb 20, 2023): > We have also noticed this problem. > > It is because this line: > > https://github.com/TencentARC/GFPGAN/blob/d7cb9f77f18b73599c8e5facd02f91cc8bc1140f/gfpgan/archs/stylegan2_clean_arch.py#L21 > > 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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#57