ncnn icon indicating copy to clipboard operation
ncnn copied to clipboard

pnnx转模型,出现Segmentation fault (core dumped)

Open Z-Xiong opened this issue 2 years ago • 2 comments

error log | 日志或报错信息 | ログ

/home/zxiong/hd0/software/pnnx-20230420-ubuntu/pnnx ostrack.pt inputshape=[1,3,128,128],[1,3,256,256]
pnnxparam = ostrack.pnnx.param
pnnxbin = ostrack.pnnx.bin
pnnxpy = ostrack_pnnx.py
pnnxonnx = ostrack.pnnx.onnx
ncnnparam = ostrack.ncnn.param
ncnnbin = ostrack.ncnn.bin
ncnnpy = ostrack_ncnn.py
fp16 = 1
optlevel = 2
device = cpu
inputshape = [1,3,128,128]f32,[1,3,256,256]f32
inputshape2 = 
customop = 
moduleop = 
############# pass_level0
inline module = lib.models.layers.attn.Attention
inline module = lib.models.layers.attn_blocks.CEBlock
inline module = lib.models.layers.head.CenterPredictor
inline module = lib.models.layers.patch_embed.PatchEmbed
inline module = lib.models.ostrack.vit_ce.VisionTransformerCE
inline module = timm.layers.drop.DropPath
inline module = timm.layers.mlp.Mlp
inline module = torch.nn.modules.linear.Identity
inline module = lib.models.layers.attn.Attention
inline module = lib.models.layers.attn_blocks.CEBlock
inline module = lib.models.layers.head.CenterPredictor
inline module = lib.models.layers.patch_embed.PatchEmbed
inline module = lib.models.ostrack.vit_ce.VisionTransformerCE
inline module = timm.layers.drop.DropPath
inline module = timm.layers.mlp.Mlp
inline module = torch.nn.modules.linear.Identity

----------------

############# pass_level1
############# pass_level2
############# pass_level3
############# pass_level4
############# pass_level5
make_slice_expression input 87
make_slice_expression input 168
make_slice_expression input 246
make_slice_expression input 325
############# pass_ncnn
Segmentation fault (core dumped)

model | 模型 | モデル

https://github.com/botaoye/OSTrack

  1. 链接: https://pan.baidu.com/s/1zb99fqfkq5OVxjNslWy-Sw?pwd=r3pp 提取码: r3pp 复制这段内容后打开百度网盘手机App,操作更方便哦

how to reproduce | 复现步骤 | 再現方法

import torch
from lib.models.ostrack import build_ostrack


import os
import sys
import argparse

prj_path = os.path.join(os.path.dirname(__file__), '..')
if prj_path not in sys.path:
    sys.path.append(prj_path)

from lib.test.evaluation import Tracker
import os


def main():
    parser = argparse.ArgumentParser(description='Run the tracker on your webcam.')
    parser.add_argument('tracker_name', type=str, help='Name of tracking method.')
    parser.add_argument('tracker_param', type=str, help='Name of parameter file.')
    args = parser.parse_args()

    tracker = Tracker(args.tracker_name, args.tracker_param, "video")
    params = tracker.get_parameters()
    params.debug = 0
    ostracker = tracker.create_tracker(params)
    ostrack_net = ostracker.network

    with torch.no_grad():
        ostrack_net.eval()
        print(ostrack_net)
        z = torch.randn(1, 3, 128, 128)
        x = torch.randn(1, 3, 256, 256)
        mod = torch.jit.trace(ostrack_net, (z, x), strict=False)
        mod.save("ostrack.pt")
    os.system("/home/zxiong/hd0/software/pnnx-20230420-ubuntu/pnnx ostrack.pt inputshape=[1,3,128,128],[1,3,256,256]")

if __name__ == '__main__':
    main()
    # python torch2pnnx.py ostrack vitb_256_mae_ce_32x4_got10k_ep100

Z-Xiong avatar May 10 '23 10:05 Z-Xiong

same issue ,did you solved it?

zhongxiaoyu avatar Sep 28 '23 03:09 zhongxiaoyu

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx

nihui avatar Aug 05 '24 09:08 nihui