Spaces:
Runtime error
Runtime error
Download quantize_fp16.py from Theeradon/efficientnet-b0-mlop: direct link, hf CLI and curl.
- Browser
- Download file 520 Bytes
-
https://huggingface.co/spaces/Theeradon/efficientnet-b0-mlop/resolve/main/quantize_fp16.py
- Command line
-
hf download hf://spaces/Theeradon/efficientnet-b0-mlop/quantize_fp16.py
-
curl -L -o quantize_fp16.py https://huggingface.co/spaces/Theeradon/efficientnet-b0-mlop/resolve/main/quantize_fp16.py
520 Bytes
| import os | |
| import onnx | |
| from onnxconverter_common import float16 | |
| # Configuration | |
| ONNX_MODEL_PATH = "model/efficientnet-b0.onnx" | |
| FP16_MODEL_PATH = "model/efficientnet-b0_fp16.onnx" | |
| print("Starting conversion to Float16 (FP16)...") | |
| # Load ONNX model | |
| model = onnx.load(ONNX_MODEL_PATH) | |
| # Convert model to Float16 | |
| model_fp16 = float16.convert_float_to_float16(model) | |
| # Save the FP16 model | |
| onnx.save(model_fp16, FP16_MODEL_PATH) | |
| print(f"FP16 conversion complete -> Size: {os.path.getsize(FP16_MODEL_PATH) / 1e6:.2f} MB") |