apple / turicreate

Turi Create simplifies the development of custom machine learning models.
BSD 3-Clause "New" or "Revised" License
11.2k stars 1.14k forks source link

Support for quantization to reduce file size #1044

Closed hipwelljo closed 6 years ago

hipwelljo commented 6 years ago

A while ago I created an image classification model that ended up being about 100 MB in size, trained with just a few thousand images. At WWDC it was announced you can now quantize your Core ML models to significantly reduce the file size. It seems Create ML does this automatically. Anyways, I am wondering if Turi Create will automatically quantize weights, or is there a way to specify it should be quantized using 8, 4, or 1-bit? I understand there’s some trade offs with accuracy to consider, but my naive mind seems to think Turi Create could automatically quantize it based on the data to achieve the best results. Thanks!

srikris commented 6 years ago

CreateML uses a different base model by default. You can use the same base model as Create ML using the following:

model = turicreate.image_classifier.create(data, 
                      target='is_expensive', model = 'VisionFeaturePrint_Screen')

More details here: https://apple.github.io/turicreate/docs/api/generated/turicreate.image_classifier.create.html#turicreate.image_classifier.create

Some performance numbers are available here: https://apple.github.io/turicreate/docs/userguide/image_classifier/how-it-works.html