Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hollance/InsideCoreML
Python script to examine Core ML's mlmodel files
https://github.com/hollance/InsideCoreML
Last synced: 3 months ago
JSON representation
Python script to examine Core ML's mlmodel files
- Host: GitHub
- URL: https://github.com/hollance/InsideCoreML
- Owner: hollance
- Created: 2017-06-17T08:53:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-17T08:55:38.000Z (over 7 years ago)
- Last Synced: 2024-04-27T23:57:22.670Z (7 months ago)
- Language: Python
- Size: 37.1 KB
- Stars: 64
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# Inside Core ML
This is a Python script that lets you look inside your Core ML **.mlmodel** files. Useful for troubleshooting and to satisfy the curious mind.
To use it:
```
python3 lookieloo.py name.mlmodel
```This will print a bunch of information about your model to stdout.
Requirements:
- Python 3
- protobuf**NOTE:** You will want to tweak the script to suit your own model. Right now it only prints information for models that are neural network classifiers (like Inception-v3). If you use a different type of model, you'll need to look at different fields.
The mlmodel spec is written in protobuf, so to learn more about the possible fields in your model you should check out the [Core ML model specification](https://docs-assets.developer.apple.com/coreml/documentation/mlmodel_specification.zip). For example, the possible fields for a convolution layer are documented in NeuralNetwork.proto, under `ConvolutionLayerParams`.
To see your entire model, enable the line:
```python
print(model)
```If you do this you should really pipe the output from the script to a file because it will include all the weights, so this is going to be a big data dump:
```
python3 lookieloo.py name.mlmodel > ~/Desktop/out.txt
```The current version of this script is made for **coremltools 0.3.0**. If you have a later version of coremltools, you will need to regenerate the **_pb2.py** files. Here's how to do this:
- [Download the latest Core ML model specification](https://docs-assets.developer.apple.com/coreml/documentation/mlmodel_specification.zip)
- From the mlmodel_specification folder, run the following command:```
protoc --python_out=/path/to/InsideCoreML *.proto
```Links: [coremltools](https://pypi.python.org/pypi/coremltools)