onnx file need to be compatible with nncase 0.2.0 or with nncase 0.1.0 for creating kmodel file. Can someone guide me how to convert pytorch model to onnx model. So that onnx model is compatible with nncase 0.2.0 or with nncase 0.1.0
onnx file need to be compatible with nncase 0.2.0 or with nncase 0.1.0 for creating kmodel file. Can someone guide me how to convert pytorch model to onnx model. So that onnx model is compatible with nncase 0.2.0 or with nncase 0.1.0
You need to define the input shape based on the model's expected input and use the torch.onnx.export
function to export the model to ONNX format.
Here’s an example:
dummy_input = torch.randn(1, 3, 224, 224) # Replace with the actual input shape torch.onnx.export(model, dummy_input, "model.onnx", opset_version=11, # nncase 0.2.0 supports ONNX opset version 11 input_names=["input"], output_names=["output"], dynamic_axes={"input": {0: "batch_size"}, "output": {0: "batch_size"}}) # For dynamic batching