Download build.py from pmarquees/blot-mini: direct link, hf CLI and curl.
- Browser
- Download file 799 Bytes
-
https://huggingface.co/pmarquees/blot-mini/resolve/main/build.py
- Command line
-
hf download hf://pmarquees/blot-mini/build.py
-
curl -L -o build.py https://huggingface.co/pmarquees/blot-mini/resolve/main/build.py
799 Bytes
| """Re-export the saved FP32 tensors without changing weights.npz.""" | |
| from pathlib import Path | |
| import numpy as np | |
| import coremltools as ct | |
| from coremltools.converters.mil import Builder as mb | |
| ROOT=Path(__file__).resolve().parent | |
| with np.load(ROOT/'weights.npz',allow_pickle=False) as z: | |
| W,b,o=z['W'],z['b'],z['o'] | |
| def network(features): | |
| h=mb.relu(x=mb.linear(x=features,weight=W,bias=b)) | |
| return mb.linear(x=h,weight=o[None,:],bias=np.array([-0.5],np.float32),name='scores') | |
| m=ct.convert(network,minimum_deployment_target=ct.target.iOS18, | |
| compute_precision=ct.precision.FLOAT32,skip_model_load=True) | |
| (ROOT/'bundle').mkdir(exist_ok=True) | |
| m.save(str(ROOT/'bundle/BlotHandwritten.mlpackage')) | |