IOPaint icon indicating copy to clipboard operation
IOPaint copied to clipboard

MAT fp16

Open ai1361720220000 opened this issue 1 year ago • 5 comments

Hi, SANSTER. Thanks for providing this awesome project, could you share MAT fp16 training code?

ai1361720220000 avatar Nov 27 '23 03:11 ai1361720220000

I did not train MAT model, I fixed the issue of fp16 overflow in the inference code. The related modifications are 7e028c39082cef45fcb8ce23cb871c121c763dd6 and the following two commits.

Sanster avatar Nov 27 '23 04:11 Sanster

I did not train MAT model, I fixed the issue of fp16 overflow in the inference code. The related modifications are 7e028c3 and the following two commits.

Thanks. Is it possible to retrain the model with fp16 in this way to get fp16 weight.

ai1361720220000 avatar Nov 27 '23 06:11 ai1361720220000

You don't need to train to obtain fp16 weights, just load the weights and convert them to fp16 before saving.

Sanster avatar Nov 27 '23 08:11 Sanster

You don't need to train to obtain fp16 weights, just load the weights and convert them to fp16 before saving.

I modified MAT original project according to your modification and used fp16 method for inference with fp32weight. However, the output will appear nan. I found that it is because nan in the output of _conv2d_wrapper layer or conv2d_resample.

ai1361720220000 avatar Nov 28 '23 03:11 ai1361720220000

Did you get a normal inpainting result in the end?

Did you use the changes in this commit? https://github.com/Sanster/lama-cleaner/commit/eb304ba69680a5c534ca07fe713baf100436dc5b

The fp16 result I tested in lama-cleaner was normal.

Sanster avatar Nov 29 '23 03:11 Sanster