sovit-123 / fasterrcnn-pytorch-training-pipeline

PyTorch Faster R-CNN Object Detection on Custom Dataset
MIT License
223 stars 77 forks source link

What does the output mean when I convert to onnx? #112

Open DungHD-1997 opened 11 months ago

DungHD-1997 commented 11 months ago

I converted the file best_model.pth to onnx so that I can run onnx runtime on other platforms. But I still don't understand the meaning of the output when I view by netron . Can you explain it to me? Thank you!

image

sovit-123 commented 11 months ago

Hi @DungHD-1997 The output is the key name that we provide when exporting the model. You will find this code in the export.py file.

dynamic_axes={
            'input' : {0 : 'batch_size'},
            'output' : {0 : 'batch_size'}
        }

And this is the entire export function.

torch.onnx.export(
        model,
        x,
        os.path.join(OUT_DIR, args['out']),
        export_params=True,
        opset_version=11,
        do_constant_folding=True,
        input_names=['input'],
        output_names = ['output'],
        dynamic_axes={
            'input' : {0 : 'batch_size'},
            'output' : {0 : 'batch_size'}
        }
    )

That's where the output comes from.

DungHD-1997 commented 11 months ago

thank you very much, i have successfully run onnx on c# . One question is how can I add the clases name into export .onnx model properties?

sovit-123 commented 11 months ago

By default, I have not added that functionality. I will need to take a look at whether that's possible or not.

DungHD-1997 commented 11 months ago

If that's possible please inform me, thank you!

sovit-123 commented 11 months ago

Sure.