INNER CODE UNIT · Python
simplify_onnx
Nain57/Smart-AutoClicker · scripts/ocr-models/converters/onnx_simplify.py:53
def simplify_onnx(onnx_path, sim_path, shape=None):
"""
Simplifies an ONNX model using onnxsim.
:param onnx_path: Path to the input ONNX model.
:param sim_path: Path where the simplified model will be saved.
:param shape: Optional input shape to freeze (e.g., "1,3,48,320").
"""
cmd = ["onnxsim", onnx_path, sim_path]
if shape:
cmd += ["--overwrite-input-shape", shape]
print("\n=== Simplifying ONNX ===")
run(cmd)
# ----------------------------