MPolaris

Results 24 comments of MPolaris

maybe you can try this tool : https://github.com/MPolaris/onnx2tflite

Yes, I have a plan to support transformer-based network. But I have no time to do it lately, this work will be involved some tough questions about channel-changed. And so...

> 不好意思刚刚发现好像大家都是中国人...因为不知道怎么放图片所以可能没有办法很好地展示我这边跑代码的结果...如果大致用语言描述的话,所有的图片都非常模糊(虽然VAE本身就会比较模糊,但是用这个代码跑出来比一般的VAE还会模糊一些)而且所有的图片可以说都一样...是一个非常模糊的9的样子。我后来参照了别人的代码发现主要是损失函数使用MSE和decoder的最后一层使用了relu的缘故,mse的话因为算的是欧氏距离,在vae中其实很不合适,因为假设由两个一模一样的数字1,他们的位置可能就差了几个像素,我们会认为两个都是很好或者说很相近的图片,但是如果使用mse的话就会认为他们非常不相似,导致在多次运行之后,他们所生成的结果无论是形状还是位置都是趋于相同,这不利于VAE的生成。而sigmoid我是参照了别人的代码之后才改的,配合torch.nn.functional.binary_cross_entropy这个函数一起使用,最后达到了很好地效果,这个评论可能有些失礼,毕竟是在评价别人的代码,而且也有可能是我这边配置的问题,但是因为这个问题我确实是调了好几周,所以还是希望能写出来供大家参考,谢谢。 我觉得应该是latentloss和最终的loss应该先对batchsize进行累加torch.sum(latentloss,1),最后再合并loss,我这么更改之后,效果就很不错了,之前全都是一个样。 至于你说的binary_cross_entropy,我看到其他代码也用了这个,只是很好奇,因为‘标签’并不是总是0和1的,我自己更改之后,基本都是乱码。

I tested it on tf2.5, and same as you, it seems only support tf

You can use this tools, it will auto transform NCHW to NHWC: https://github.com/MPolaris/onnx2tflite

额,你们可以debug一下这里,并自己修改一下。 如果还有问题,可以传一个onnx来我看看。

Thanks for your report. I will test it carefully and try to repair it later.

Hello, your code is missing preprocessing and post-processing. In addition, the output of TFLite is channel-last, ONNX, and PyTorch is channel-first.

You'd better carefully check the dimensions of the output. For example, the output's shape is (B, C, H, W) in onnx, and in tflite is (B, H, W, C), so...

I don't know your output dimension, I just gave an example. If you are a 5-dimensional tensor, then it should be: ```python onnx_format_output = np.transpose(tflite_model_predictions1, (0, 4, 1, 2, 3))