CompressAI icon indicating copy to clipboard operation
CompressAI copied to clipboard

'utf-8' UnicodeDecodeError: codec can't decode byte oxd6 in position 1: invalid continuation byte When export to ONNX

Open YuKDseele opened this issue 1 year ago • 3 comments

Hi, I want to convert the 'ga', 'gs', 'ha', 'hs', 'entropy_bottleneck.compress' and 'gaussian_conditional.compress' from a compressai model into ONNX for export. However, I encountered this problem: 'utf-8' UnicodeDecodeError: codec can't decode byte oxd6 in position 1: invalid continuation byte. I tried commenting out the ANS encoder, and it seems to work fine, but I need the bitstream output. How can I fix this problem?

YuKDseele avatar May 11 '24 15:05 YuKDseele

I have reviewed my code again and it appears that the automatic decoding of bytes during the ONNX export is a default behavior, which may cause the problem I would like to understand how to prevent this from happening.

YuKDseele avatar May 11 '24 17:05 YuKDseele

I have reviewed my code again and it appears that the automatic decoding of bytes during the ONNX export is a default behavior, which may cause the problem I would like to understand how to prevent this from happening.

Hi, I had the same errors like yours ones, i tried to modify the output of function compress in Entropy Models class to make it return a Tensor instead of strings ( i use frombuffer function ), but the onnx model result was weird. Have you fix this problem, pls tell me

StuDDXT1610 avatar Oct 07 '24 07:10 StuDDXT1610

I have reviewed my code again and it appears that the automatic decoding of bytes during the ONNX export is a default behavior, which may cause the problem I would like to understand how to prevent this from happening.

Hi, I had the same errors like yours ones, i tried to modify the output of function compress in Entropy Models class to make it return a Tensor instead of strings ( i use frombuffer function ), but the onnx model result was weird. Have you fix this problem, pls tell me

Unfortunately, I did not solve this issue, which may be due to onnx not supporting CPP code (the ans encoder is built using CPP). I suggest using this part as post-processing (i.e. generate inputs and indexes, and finally encoding directly using the ans encoder)

YuKDseele avatar Oct 08 '24 14:10 YuKDseele