File size: 478 Bytes
f687b59 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # fix_shape.py
from openvino import Core, save_model
import sys
model_path = sys.argv[1] # 输入模型路径
output_path = sys.argv[2] if len(sys.argv) > 2 else model_path
core = Core()
model = core.read_model(model_path)
# 重设形状为固定 [1, 512]
model.reshape({
"input_ids": [1, 512],
"attention_mask": [1, 512],
"token_type_ids": [1, 512],
})
save_model(model, output_path, compress_to_fp16=False)
print(f"Fixed-shape model saved to: {output_path}")
|