Download fix_shape.py from xjackkx/ca: direct link, hf CLI and curl.
- Browser
- Download file 478 Bytes
-
https://huggingface.co/spaces/xjackkx/ca/resolve/main/fix_shape.py
- Command line
-
hf download hf://spaces/xjackkx/ca/fix_shape.py
-
curl -L -o fix_shape.py https://huggingface.co/spaces/xjackkx/ca/resolve/main/fix_shape.py
478 Bytes
| # 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}") | |