PeterL1n / RobustVideoMatting

Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!
https://peterl1n.github.io/RobustVideoMatting/
GNU General Public License v3.0
8.48k stars 1.13k forks source link

如何将 rvm_mobilenetv3.pth 转换成 rvm_mobilenetv3.tflite #9

Open droplet-js opened 3 years ago

droplet-js commented 3 years ago

请教一下如何转换 tflite 格式(这个问题困扰我好几天了,查阅了很多资料尝试了多种方式),不胜感激!

MichaelFan01 commented 3 years ago

请教一下如何转换 tflite 格式(这个问题困扰我好几天了,查阅了很多资料尝试了多种方式),不胜感激!

兄弟,你有之前的模型代码么,能不能发我一份~

PeterL1n commented 3 years ago

你有尝试用TensorFlow版本转换么,可能更简单。

droplet-js commented 3 years ago

按你提供的文档,pth转save_model再转tfjs模型均能成功。而save_model和tfjs模型转tflite都不能成功。切换过docker版的tensorflow/tensorflow:2.5,也不行。我是想在手机上尝试跑这个模式,然而无法转tflite和缺乏转int8型的torchscript的export.py,研究了一周多时间了,仍然没有头绪,这让我很是头疼。希望你能帮我解决这个问题,不胜感激。

PeterL1n commented 3 years ago

目前没有时间,你得自己研究了。

droplet-js commented 3 years ago

目前没有时间,你得自己研究了。

大神,python新手,木得头绪啊,指望着这个工程入个门呢 ...

droplet-js commented 3 years ago

请教一下如何转换 tflite 格式(这个问题困扰我好几天了,查阅了很多资料尝试了多种方式),不胜感激!

兄弟,你有之前的模型代码么,能不能发我一份~

兄die啊,直接 GitHub 搜索一下 RobustVideoMatting 不就好了

MichaelFan01 commented 3 years ago

请教一下如何转换 tflite 格式(这个问题困扰我好几天了,查阅了很多资料尝试了多种方式),不胜感激!

兄弟,你有之前的模型代码么,能不能发我一份~

兄die啊,直接 GitHub 搜索一下 RobustVideoMatting 不就好了

多谢指点,恍然大悟啊,我还在傻傻等待。。。

majinb0o commented 3 years ago

tensorflow2里面再搭一个一模一样的,拷贝参数,再比较一下输出不就行了

droplet-js commented 3 years ago

tensorflow2里面再搭一个一模一样的,拷贝参数,再比较一下输出不就行了

大佬,求 export.py,十年Android,半个月python,啥也不会,就会看看文档,不会写python代码啥的

cq186 commented 2 years ago

有没有能运行的tflite。转化报错如何解决: tensorflow.lite.python.convert_phase.ConverterError: :0: error: loc(callsite(callsite(callsite("cond_1@inference_call_10579" at "matting_network_wrapper/StatefulPartitionedCall@inferencewrapped_model_11240") at "StatefulPartitionedCall@inference_signature_wrapper_41312") at "StatefulPartitionedCall")): could not rewrite use of immutable bound input

:0: note: loc("StatefulPartitionedCall"): called from
PearlDzzz commented 2 years ago

tensorflow2里面再搭一个一模一样的,拷贝参数,再比较一下输出不就行了

您好啊,最近在做模型转换,请问大佬,是否可以将torch1.9训练的pth转成tensorflow2.0下的模型?需要哪些操作?

majinb0o commented 2 years ago

我是用pytorchcv和tf2cv搭一模一样的模型来训练然后直接拷贝参数转换就能得到一样的输出,相对误差小于1e-4。tflite只要用关掉实验flag就可以直接转换。

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年10月8日(星期五) 下午5:08 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [PeterL1n/RobustVideoMatting] 如何将 rvm_mobilenetv3.pth 转换成 rvm_mobilenetv3.tflite (#9)

tensorflow2里面再搭一个一模一样的,拷贝参数,再比较一下输出不就行了

您好啊,最近在做模型转换,请问大佬,是否可以将torch1.9训练的pth转成tensorflow2.0下的模型?需要哪些操作?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

PeterL1n commented 2 years ago

@ChristineRYY 这个 repo 已经提供了啊亲,看 tensorflow 分支,而且提供了 weights 转换代码。

PearlDzzz commented 2 years ago

@ChristineRYY 这个 repo 已经提供了啊亲,看 tensorflow 分支,而且提供了 weights 转换代码。

谢谢回复。 1、我使用该分支将pth转成tensorflow,但用Netron查看,结构比较奇怪,只能看到很多VarHandleOp和ReadVariableOP。请问是正常的吗? 2、转成的.pb可以直接用量化工具进行量化吗?需要怎么操作?