PaddlePaddle / Paddle2ONNX

ONNX Model Exporter for PaddlePaddle
Apache License 2.0
736 stars 173 forks source link

paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet #353

Open 754467737 opened 3 years ago

754467737 commented 3 years ago

Traceback (most recent call last): File "/home/wangnan/anaconda3/envs/action-py3.7/bin/paddle2onnx", line 8, in sys.exit(main()) File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/command.py", line 155, in main operator_export_type=operator_export_type) File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/command.py", line 122, in program2onnx operator_export_type=operator_export_type) File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/convert.py", line 79, in program2onnx export_onnx(paddle_graph, save_file, opset_version, enable_onnx_checker, operator_export_type) File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/convert.py", line 33, in export_onnx onnx_graph = ONNXGraph.build(paddle_graph, opset_version, operator_export_type, verbose) File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/graph/onnx_graph.py", line 240, in build onnx_graph = ONNXGraph(paddle_graph, opset_version=opset_version, operator_export_type=operator_export_type) File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/graph/onnx_graph.py", line 79, in init self.update_opset_version() File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/graph/onnx_graph.py", line 194, in update_opset_version self.opset_version = OpMapper.get_recommend_opset_version(node_map, self.opset_version) File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/op_mapper/op_mapper.py", line 127, in get_recommend_opset_version recommend_opset_version = OpMapper.check_support_status(node_map, opset_version, True) File "/home/wangnan/anaconda3/envs/action-py3.7/lib/python3.7/site-packages/paddle2onnx/op_mapper/op_mapper.py", line 168, in check_support_status raise NotImplementedError(error_info) NotImplementedError: There's 1 ops are not supported yet =========== temporal_shift ===========

temporal_shift不支持。 想请教下,怎么改才能让他支持,debug看了下temporal_shift函数,一直都是一些注册器,具体内容看的眼花缭乱!求救!help!

yeliang2258 commented 3 years ago

您好,请问你的使用场景是?另外请提供一下你的模型,谢谢

754467737 commented 3 years ago

模型就是贵公司PaddleVideo项目里的pp-TSM呀,我使用的场景是人动作分类,数据集自己做的0-0

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年9月27日(星期一) 中午11:11 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353)

您好,请问你的使用场景是?另外请提供一下你的模型,谢谢

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

dengfenglai321 commented 3 years ago

请问解决了吗?我也遇到一样的问题, TSM的temporal_shift模块不支持转onnx

dengfenglai321 commented 3 years ago

模型就是贵公司PaddleVideo项目里的pp-TSM呀,我使用的场景是人动作分类,数据集自己做的0-0 ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年9月27日(星期一) 中午11:11 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353) 您好,请问你的使用场景是?另外请提供一下你的模型,谢谢 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

请问解决了吗?我也遇到一样的问题, TSM的temporal_shift模块不支持转onnx

754467737 commented 3 years ago

模型就是贵公司PaddleVideo项目里的pp-TSM呀,我使用的场景是人动作分类,数据集自己做的0-0 ------------------ 原始邮件 ------------------ 发件人: @.**>; 发送时间: 2021年9月27日(星期一) 中午11:11 收件人: @.**>; 抄送: @.**>; @.**>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353) 您好,请问你的使用场景是?另外请提供一下你的模型,谢谢 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

请问解决了吗?我也遇到一样的问题, TSM的temporal_shift模块不支持转onnx

解决了,自己写代码。利用paddle给的API解释文档,写了一个能转的就行。 代码如下: def temporal_shift_paddle(inputs, num_seg,num_seg_div):

进行切片准备

t, c, h, w = inputs.shape
n = int(t/8)
#分成几分
fold =  int(c * num_seg_div)
#进行切片
if (n<=0):
    raise('batch_size must be greater than 0')
elif n == 1 :
    #完成补0操作
    pad = paddle.zeros([1, c, h, w])
    pad_ = paddle.fluid.layers.concat((pad, inputs), 0)
    new_inputs = paddle.fluid.layers.concat((pad_, pad), 0)
    #切片
    #[64, 8, 56, 56]
    slice1 = new_inputs[:t, :fold, :, :]
    #[64, 8, 56, 56]
    slice2 = new_inputs[2:t + 2, fold:2 * fold, :, :]
    #[64, 48, 56, 56]
    slice3 = new_inputs[1:t + 1, 2 * fold:, :, :]
    out = paddle.fluid.layers.concat((slice1, slice2), 1)
    out = paddle.fluid.layers.concat((out, slice3), 1)
else:
    result = []
    # 完成补0操作
    for i in range(n):
        #找到对应的分块
        inputs_ = inputs[8*i:8*(i+1),:,:,:]
        pad1 = paddle.zeros([1, c, h, w])
        pad1_ = paddle.fluid.layers.concat((pad1, inputs_), 0)
        new_inputs_ = paddle.fluid.layers.concat((pad1_, pad1), 0)
        # 切片
        # [64, 8, 56, 56]
        slice1_ = new_inputs_[:t_, :fold, :, :]
        # [64, 8, 56, 56]
        slice2_ = new_inputs_[2:t_ + 2, fold:2 * fold, :, :]
        # [64, 48, 56, 56]
        slice3_ = new_inputs_[1:t_ + 1, 2 * fold:, :, :]
        out_ = paddle.fluid.layers.concat((slice1_, slice2_), 1)
        out_ = paddle.fluid.layers.concat((out_, slice3_), 1)
        result.append(out_)
    out = paddle.fluid.layers.concat((result[0], result[1]), 0)
    for j in range(2,len(result)):
        out = paddle.fluid.layers.concat((out, result[j]), 0)
return out
754467737 commented 3 years ago

git上已经回复你了,祝好运

------------------ 原始邮件 ------------------ 发件人: "PaddlePaddle/Paddle2ONNX" @.>; 发送时间: 2021年11月19日(星期五) 中午11:42 @.>; @.**@.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353)

模型就是贵公司PaddleVideo项目里的pp-TSM呀,我使用的场景是人动作分类,数据集自己做的0-0 … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年9月27日(星期一) 中午11:11 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353) 您好,请问你的使用场景是?另外请提供一下你的模型,谢谢 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

请问解决了吗?我也遇到一样的问题, TSM的temporal_shift模块不支持转onnx

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

dengfenglai321 commented 3 years ago

git上已经回复你了,祝好运 ------------------ 原始邮件 ------------------ 发件人: "PaddlePaddle/Paddle2ONNX" @.>; 发送时间: 2021年11月19日(星期五) 中午11:42 @.>; @.**@.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353) 模型就是贵公司PaddleVideo项目里的pp-TSM呀,我使用的场景是人动作分类,数据集自己做的0-0 … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年9月27日(星期一) 中午11:11 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353) 您好,请问你的使用场景是?另外请提供一下你的模型,谢谢 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. 请问解决了吗?我也遇到一样的问题, TSM的temporal_shift模块不支持转onnx — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

谢谢 我试下

754467737 commented 3 years ago

进行转的时候export_model.py中的值记得进行更改,

改为你需要的batch,不然就算转成功,在推理部分也会报错

------------------ 原始邮件 ------------------ 发件人: "PaddlePaddle/Paddle2ONNX" @.>; 发送时间: 2021年11月19日(星期五) 下午3:02 @.>; @.**@.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353)

git上已经回复你了,祝好运 … ------------------ 原始邮件 ------------------ 发件人: "PaddlePaddle/Paddle2ONNX" @.>; 发送时间: 2021年11月19日(星期五) 中午11:42 @.>; @.@.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353) 模型就是贵公司PaddleVideo项目里的pp-TSM呀,我使用的场景是人动作分类,数据集自己做的0-0 … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年9月27日(星期一) 中午11:11 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353) 您好,请问你的使用场景是?另外请提供一下你的模型,谢谢 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. 请问解决了吗?我也遇到一样的问题, TSM的temporal_shift模块不支持转onnx — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

谢谢 我试下

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

754467737 commented 3 years ago

发不了图,训练之后,利用export_model.py转推理这部分,静态输入把shape=[None, cfg.num_seg, 3, cfg.target_size, cfg.target_size]改成你需要的batch,不然会报错(大概是一些推理过程矩阵不对应的情况)

754467737 commented 3 years ago

抱歉抱歉0-0,少了t_,回答的时候手速太快直接删掉了0-0

def temporal_shift_paddle(inputs, num_seg,num_seg_div):

进行切片准备

t, c, h, w = inputs.shape n = int(t/8)

分成几分

fold = int(c * num_seg_div)

进行切片

if (n<=0): raise('batch_size must be greater than 0') elif n == 1 :

完成补0操作

pad = paddle.zeros([1, c, h, w]) pad_ = paddle.fluid.layers.concat((pad, inputs), 0) newinputs = paddle.fluid.layers.concat((pad, pad), 0)

切片

[64, 8, 56, 56]

slice1 = new_inputs[:t, :fold, :, :]

[64, 8, 56, 56]

slice2 = new_inputs[2:t + 2, fold:2 * fold, :, :]

[64, 48, 56, 56]

slice3 = new_inputs[1:t + 1, 2 * fold:, :, :] out = paddle.fluid.layers.concat((slice1, slice2), 1) out = paddle.fluid.layers.concat((out, slice3), 1) else: result = []

完成补0操作

for i in range(n):

找到对应的分块

inputs = inputs[8i:8(i+1),:,:,:] pad1 = paddle.zeros([1, c, h, w]) pad1 = paddle.fluid.layers.concat((pad1, inputs_), 0) newinputs = paddle.fluid.layers.concat((pad1, pad1), 0) t, c, h, w = inputs_.shape

切片

[64, 8, 56, 56]

slice1_ = newinputs[:t_, :fold, :, :]

[64, 8, 56, 56]

slice2_ = newinputs[2:t_ + 2, fold:2 * fold, :, :]

[64, 48, 56, 56]

slice3_ = newinputs[1:t + 1, 2 * fold:, :, :] out = paddle.fluid.layers.concat((slice1, slice2), 1) out = paddle.fluid.layers.concat((out, slice3), 1) result.append(out) out = paddle.fluid.layers.concat((result[0], result[1]), 0) for j in range(2,len(result)): out = paddle.fluid.layers.concat((out, result[j]), 0) return out

jiangjiajun commented 3 years ago

Hi, @754467737 我们准备了一份简单的问题调研(半分钟可完成),如有时间可帮忙完成调研,帮助Paddle2ONNX做得更好 https://iwenjuan.baidu.com/?code=r8hu2s

aureosun commented 2 years ago

@754467737 大佬,这部分pp-tsm转onnx使用这个工具怎么搞呀,从pytorch切过来几天不知道咋搞?求助

jiangjiajun commented 2 years ago

pip install paddle2onnx=1.0.0rc4 即可

754467737 commented 2 years ago

转onnx先使用export.py进行推理图的生成->要进行修改InputSpc中的batch_size -> 使用后学的转paddle2onnx进行转换 服务器上,实现推理图过程. 步骤大概是: 1.记得改export.py中InputSpc的batch_size,改成你需要的 2.python tools/export_model.py -c configs/recognition/pptsm/pptsm_k400_frames_uniform.yaml -p output/ppTSM/ppTSM_best.pdparams -o inference/ppTSM
3.paddle2onnx --model_dir ./inference/ppTSM/ --model_filename ppTSM.pdmodel --params_filename ppTSM.pdiparams --save_file ./to_onnx/1.onnx --opset_version 11 --enable_onnx_checker True 第三步需要安装paddle2onnx 第一步的那个你要看看你需要转的是哪个模型,比如pp-TSM:找到下边的函数 def get_input_spec(cfg, model_name): if model_name in ['ppTSM', 'TSM', 'TSN', 'ppTSN']: input_spec = [[ InputSpec(shape=[None, cfg.num_seg, 3, cfg.target_size, cfg.target_size], dtype='float32'), ]] 把None改成你的batch_size不然转不了

754467737 commented 2 years ago

转onnx先使用export.py进行推理图的生成->要进行修改InputSpc中的batch_size -> 使用后学的转paddle2onnx进行转换 服务器上,实现推理图过程. 步骤大概是: 1.记得改export.py中InputSpc的batch_size,改成你需要的 2.python tools/export_model.py -c configs/recognition/pptsm/pptsm_k400_frames_uniform.yaml -p output/ppTSM/ppTSM_best.pdparams -o inference/ppTSM
3.paddle2onnx --model_dir ./inference/ppTSM/ --model_filename ppTSM.pdmodel --params_filename ppTSM.pdiparams --save_file ./to_onnx/1.onnx --opset_version 11 --enable_onnx_checker True 第三步需要安装paddle2onnx 第一步的那个你要看看你需要转的是哪个模型,比如pp-TSM:找到下边的函数 def get_input_spec(cfg, model_name): if model_name in ['ppTSM', 'TSM', 'TSN', 'ppTSN']: input_spec = [[ InputSpec(shape=[None, cfg.num_seg, 3, cfg.target_size, cfg.target_size], dtype='float32'), ]] 把None改成你的batch_size不然转不了

aureosun commented 2 years ago

@754467737 export.py 和 export_model.py 是一个文件吧,都是 PaddleVideo\tools\export_model.py这个? 把paddle2onnx版本由0.9.8升级未1.0.0.rc3之后可以用了

754467737 commented 2 years ago

应该是一个叭,运行的是PaddleVideo\tools\export_model.py里的,能用就好

------------------ 原始邮件 ------------------ 发件人: "PaddlePaddle/Paddle2ONNX" @.>; 发送时间: 2022年8月29日(星期一) 下午3:25 @.>; @.**@.>; 主题: Re: [PaddlePaddle/Paddle2ONNX] paddle2onnx -> Paddle-Video下的pp-TSM模型中There's 1 ops are not supported yet (#353)

@754467737 export.py 和 export_model.py 是一个文件吧,都是 PaddleVideo\tools\export_model.py这个? 把paddle2onnx版本由0.9.8升级未1.0.0.rc3之后可以用了

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>