Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gray model #13

Open
chenchunhu opened this issue Jan 2, 2024 · 4 comments
Open

gray model #13

chenchunhu opened this issue Jan 2, 2024 · 4 comments

Comments

@chenchunhu
Copy link

chenchunhu commented Jan 2, 2024

I used the model you provided and tried to convert it into an ncnn model, but an error occurred.
run

@linyicheng1
Copy link
Owner

Try use the model in pytorch first, and then convert it to ncnn.

@zhixuan4123
Copy link

I encountered the same problem. Could you please provide detailed instructions on how to convert it? Or offer relevant conversion code? Thank you!

@deepConnectionism
Copy link

I had the same problem:

I used the following command to convert to the NCNN model:

./onnx2ncnn /root/LET-NET/model/letnet-gray.onnx /root/LET-NET/model/letnet-gray.param /root/LET-NET/model/letnet-gray.bin
./ncnnoptimize /root/LET-NET/model/letnet-gray.param /root/LET-NET/model/letnet-gray.bin /root/LET-NET/model/letnet-gray-opt.param /root/LET-NET/model/letnet-gray-opt.bin 0

when I run vins-mono, meet:

find_blob_index_by_name score failed
Try
    ex.extract("27", out0);
    ex.extract("33", out1);
find_blob_index_by_name descriptor failed
Try
    ex.extract("27", out0);
    ex.extract("33", out1);
Segmentation fault (core dumped)

How Do I Fix This? Can you provide the conversion code?

@deepConnectionism
Copy link

I solved the problem:

import onnx

# 加载 ONNX 模型
model = onnx.load("letnet-gray.onnx")

# 获取图
graph = model.graph

# 修改输入节点名称
for input in graph.input:
    if input.name == 'input.1':
        input.name = 'input'

# 修改输出节点名称
for output in graph.output:
    if output.name == '33':
        output.name = 'descriptor'
    elif output.name == '27':
        output.name = 'score'

# 修改节点的输出名称
for node in graph.node:
    for i, input_name in enumerate(node.input):
        if input_name == 'input.1':
            node.input[i] = 'input'

    for i, output in enumerate(node.output):
        if output == '33':
            node.output[i] = 'descriptor'
        elif output == '27':
            node.output[i] = 'score'

# 保存修改后的模型
onnx.save(model, "letnet-gray-modify.onnx")

Then convert the model from onnx to NCNN.

But I found that feature tracking didn't get any better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants