Created
November 7, 2023 21:21
-
-
Save ccgus/f3aff7e3088a3c4aa50b4ee40288d462 to your computer and use it in GitHub Desktop.
Making the Beby-Gan model quite a bit smaller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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