I'm running into problems trying to use a PyTorch model exported as an ONNX model with Caffe2. Here is my export code
the_model = torchvision.models.densenet121(pretrained=True)
garbage, model_inputs = preprocessing("test.jpg")
torch_out = torch.onnx._export(the_model,
model_inputs,
"model_weights/chexnet-py.onnx",
export_params=True)
Now here is my testing code
model = onnx.load("model_weights/chexnet-py.onnx")
garbage, model_inputs = preprocessing("text.jpg")
prepared_backend = onnx_caffe2.backend.prepare(model)
W = {model.graph.input[0].name: model_inputs.numpy()}
c2_out = prepared_backend.run(W)[0]
This is returning the following error
ValueError: Don't know how to translate op Unsqueeze when running converted PyTorch Model
Additional information pytorch version 1.0.0a0+6f664d3 Caffe2 is latest version (attempted building from source, pip, and conda). All gave same result.