This branch contains our code to export to CoreML models. The /model folder is the same as the master branch. The main exporting logics are in export_coreml.py.
At the time of this writing, CoreML's ResizeBilinear and Upsample ops don't not support dynamic scale parameters, so the downsample_ratio hyperparameter must be hardcoded.
Our export script is written to have input size fixed. The output coreml models require iOS14+, MacOS11+. If you have other requirements, feel free to modify the export script. Contributions are welcomed.
The following procedures were used to generate our CoreML models.
- Install dependencies
pip install -r requirements.txt- Use the export script. You can change the
resolutionanddownsample-ratioto fit your need. You can change quantization to one of[8, 16, 32], denotingint8,fp16, andfp32.
python export_coreml.py \
--model-variant mobilenetv3 \
--checkpoint rvm_mobilenetv3.pth \
--resolution 1920 1080 \
--downsample-ratio 0.25 \
--quantize-nbits 16 \
--output model.mlmodel