Skip to content

Instantly share code, notes, and snippets.

@ccgus
Created November 7, 2023 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccgus/f3aff7e3088a3c4aa50b4ee40288d462 to your computer and use it in GitHub Desktop.
Save ccgus/f3aff7e3088a3c4aa50b4ee40288d462 to your computer and use it in GitHub Desktop.
Making the Beby-Gan model quite a bit smaller.
# Before running this, setup a python venv for everything:
# python3 -m venv coremltools-venv
# source coremltools-venv/bin/activate
# pip install -U coremltools
import coremltools as ct
from coremltools.models.neural_network import quantization_utils
# load full precision model
model_fp32 = ct.models.MLModel('Beby-GANx4.mlmodel')
model_fp16 = quantization_utils.quantize_weights(model_fp32, nbits=16)
model_fp16.save("Beby-GANx4fp16.mlmodel")
model_fp8 = quantization_utils.quantize_weights(model_fp32, nbits=8)
model_fp8.save("Beby-GANx4fp8.mlmodel")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment