Python:TensorFlow PNG编码
我试图找出原因,为什么此代码段返回false:
decodedBase64 = tf.io.decode_base64(imgBase64)
decodedBase64==tf.io.encode_png(tf.io.decode_png(decodedBase64))
可以压缩PNG图像并decode_png检测到它,因此我在encode_png中使用了不同的'compression ='值。我仍然在-1到9之间的所有值都被错误。
可以采取什么措施来检索正确的解码器64特性以使Encode_png< - > DECODE_PNG可逆?
I'm trying to figure out the reason, why this code snippet returns False:
decodedBase64 = tf.io.decode_base64(imgBase64)
decodedBase64==tf.io.encode_png(tf.io.decode_png(decodedBase64))
A png image can be compressed and decode_png detects it, so I used different 'compression=' values in encode_png. I still got False with all values between -1 to 9.
What can be done to retrieve correct decodedBase64 characteristics to make encode_png <-> decode_png reversible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对TensorFlow并不熟悉,您的代码无法尝试使用,因此我可能错了,如果是这样,我会删除答案。我还认为Base64编码和解码是一种红鲱鱼。我认为您实际上是在问为什么与TensorFlow进行编码时,您已经从已有的PNG中获得了不同的PNG。如果是这样,有几个可能的原因:
,如果您想要确定的而不是投机答案,则需要共享2个PNG-未修改。
I am not very familiar with tensorflow and your code is not runnable to be able to try it, so I may well be wrong and will delete my answer if so. I also think that the base64 encoding and decoding is something of a red herring. I think you are actually asking why you get a different PNG from one you already have when you encode with tensorflow. If so, there are several possible reasons:
Of course, if you want a definitive rather than speculative answer, you'd need to share the 2 PNGs - unmodified.