import os
import onnx
import torch
from onnxsim import simplify
onnx_file = "checkpoints/onnx/bevformer_tiny_epoch_24_cp.onnx"
onnx_sim_path = onnx_file.replace(".onnx", "_sim.onnx")
model = onnx.load(onnx_file)
model_sim, check = simplify(model)
assert check, "Simplified ONNX model could not be validated"
onnx.save(model_sim, onnx_sim_path)
code:
import os import onnx import torch from onnxsim import simplify
onnx_file = "checkpoints/onnx/bevformer_tiny_epoch_24_cp.onnx" onnx_sim_path = onnx_file.replace(".onnx", "_sim.onnx") model = onnx.load(onnx_file) model_sim, check = simplify(model) assert check, "Simplified ONNX model could not be validated" onnx.save(model_sim, onnx_sim_path)