3

I have a requirement for a CoreML model to be compressed to =< 24MB. This is a neural net created with Turi Create. It is for object detection. As per Apple's Documentation, I've converted the model to a half precision model (this also has an issue right now with coremltools). I need to shave off ~4 MB. Downloading the model isn't an option.

  • 63.5 MB initially
  • 31.8 MB after half precision conversion
  • 28.9 MB after compression

Any other techniques or approaches I could try to get this any smaller?

1 Answers1

1

First thing I would do is try creating this model using the "sqeezenet" model option in Turi Create, instead of the ResNet50 one you appear to be using now. SqueezeNet will give similar results (possibly slightly worse) but the model will only be about 4 MB in total.

Matthijs Hollemans
  • 7,706
  • 2
  • 16
  • 23
  • My apologies but I didn't specify the this is an object detection model, not an image classification one. Turi's only option for object detection is darknet-yolo. I'll update the question. – Martin Powlette Jr Mar 29 '18 at 16:13
  • Ah, gotcha. The only other method I know of to make the model easier to compress is to quantize the (16-bit) weights so that there are only a limited number of different 16-bit values being used in the mlmodel file. That way zip sees more patterns in the data and has more opportunities for compressing them. There is no way to automatically do this right now, so you'll have to write code to load the mlmodel, quantize the weights, and write a new mlmodel output file. Accuracy might get a bit worse with this method too. – Matthijs Hollemans Mar 30 '18 at 09:38
  • oh okay. At a high level I understand what you're saying. I looked at the source for coremltools and the functions deleting with the actual conversion is beyond me. Any advice for approaching this? I might consider creating an issue on the github project. – Martin Powlette Jr Mar 30 '18 at 16:37