将模型导出到onnx时,如果输入是列表,如何设置输入格式?

问题描述 投票:0回答:0

问题在model_2,它使用

List[dict_1{}, dict_2{}]
作为输入,并且可以从模型中得到结果,但是当我使用相同的格式到onnx时,它只能得到
dict_1{}
作为输入,并显示错误

from detectron2.modeling import build_model
model_2 = build_model(cfg)
from detectron2.checkpoint import DetectionCheckpointer
checkpointer = DetectionCheckpointer(model)
checkpointer.load(cfg.MODEL.WEIGHTS)
input_1 = {"image": torch.randn(3,1132,800), "height": 1200, "width": 1000}
input_2 = {"image": torch.randn(3,1132,800), "height": 1200, "width": 1000}
prediction = model_2([input_1, input_2]) #it can get results


torch.onnx.export(
        model_2,
        [input_1, input_2], #actually, it only get input_1, a dict, as input
        "m2.onnx"
    )

因此,我想知道如果我有相同输入格式的正确运行模型,我应该在导出 onnx 时选择哪种格式输入?

python deep-learning pytorch
© www.soinside.com 2019 - 2024. All rights reserved.