Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ Additional information regarding APIs, installation and dependencies and more ca
* [coremltools](https://github.com/apple/coremltools)
* [onnx-coreml](https://github.com/onnx/onnx-coreml)
* [tf-coreml](https://github.com/tf-coreml/tf-coreml)

2 changes: 1 addition & 1 deletion coremltools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
For more information: http://developer.apple.com/documentation/coreml
"""

__version__ = '3.0'
__version__ = '3.1'

# This is the basic Core ML specification format understood by iOS 11.0
SPECIFICATION_VERSION = 1
Expand Down
1 change: 0 additions & 1 deletion coremltools/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ def visualize_spec(self, port=None, input_shape_dict=None, title='CoreML Graph V

Returns
-------

None

Examples
Expand Down
13 changes: 6 additions & 7 deletions coremltools/test/neural_network/test_keras2.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def test_pooling(self):
# Create a simple Keras model
model = Sequential()
model.add(Conv2D(input_shape=(64, 64, 3),
filters=32, kernel_size=(5,5), strides=(1,1), activation=None,
filters=32, kernel_size=(5,5), strides=(1,1), activation=None,
padding='valid', use_bias=True))
model.add(MaxPooling2D(pool_size=(2,2)))

Expand Down Expand Up @@ -611,7 +611,7 @@ def test_sentiment_analysis(self):
self.assertTrue(spec.HasField('neuralNetwork'))

# Test the inputs and outputs
# We're giving state input and output so expect description to differ.
# We're giving state input and output so expect description to differ.
self.assertEquals(len(spec.description.input), len(input_names) + 2)
self.assertEquals(len(spec.description.output), len(output_names) + 2)

Expand Down Expand Up @@ -657,7 +657,7 @@ def test_batchnorm(self):
# Create a simple Keras model
model = Sequential()
model.add(Conv2D(input_shape=(64, 64, 3),
filters=32, kernel_size=(5,5), strides=(1,1), activation=None,
filters=32, kernel_size=(5,5), strides=(1,1), activation=None,
padding='valid', use_bias=True))
# epsilon in CoreML is currently fixed at 1e-5
model.add(BatchNormalization(epsilon=1e-5))
Expand Down Expand Up @@ -731,8 +731,8 @@ def test_image_processing(self):
# Create a simple Keras model
model = Sequential()
model.add(Conv2D(input_shape=(64, 64, 3),
filters=32, kernel_size=(5,5),
activation=None, padding='valid',
filters=32, kernel_size=(5,5),
activation=None, padding='valid',
strides=(1, 1), use_bias=True))
input_names = ['input']
output_names = ['output']
Expand Down Expand Up @@ -1270,7 +1270,7 @@ def test_updatable_model_flag_cce_string_sgd(self):
self.assertEqual(sgdopt.miniBatchSize.defaultValue, 16)
self.assertEqual(sgdopt.momentum.defaultValue, 0.0)


def test_updatable_model_flag_cce_sgd_string(self):
"""
Tests the 'respect_trainable' flag when used along with string
Expand Down Expand Up @@ -1344,4 +1344,3 @@ def test_updatable_model_flag_cce_adam_string(self):
self.assertAlmostEqual(adopt.miniBatchSize.defaultValue, 16)
self.assertAlmostEqual(adopt.beta1.defaultValue, 0.90, places=5)
self.assertAlmostEqual(adopt.beta2.defaultValue, 0.999, places=5)

15 changes: 8 additions & 7 deletions docs/APIExamples.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
docs/APIExamples.md
# API Code snippets

## Converting between MLModel and Spec

```python
import coremltools

Expand Down Expand Up @@ -52,7 +53,7 @@ print_network_spec(spec)

Another useful tool for visualizing CoreML models and models from other frameworks: [Netron](https://github.com/lutzroeder/netron)

## Printing the pre-processing parameters
## Printing the pre-processing parameters

This is useful for image based neural network models

Expand All @@ -77,7 +78,7 @@ print(nn.preprocessing)
## Changing MLMultiArray input/output datatypes

[Here](https://github.com/apple/coremltools/blob/d07421460f9f0ad1a2e9cf8b5248670358a24a1a/mlmodel/format/FeatureTypes.proto#L106 ) is the list of supported datatypes.
For instance, change the datatype from 'double' to 'float32':
For instance, change the datatype from 'double' to 'float32':

```python
import coremltools
Expand Down Expand Up @@ -115,7 +116,7 @@ import PIL.Image

model = coremltools.models.MLModel('path/to/the/saved/model.mlmodel')

Height = 20 # use the correct input image height
Height = 20 # use the correct input image height
Width = 60 # use the correct input image width


Expand All @@ -129,7 +130,7 @@ def load_image(path, resize_to=None):
return img_np, img


# load the image and resize using PIL utilities
# load the image and resize using PIL utilities
_, img = load_image('/path/to/image.jpg', resize_to=(Width, Height))
out_dict = model.predict({'image': img})

Expand All @@ -143,8 +144,8 @@ out_dict = model.predict({'image': pil_img})

## Building an mlmodel from scratch using Neural Network Builder

We can use the neural network builder class to construct a CoreML model. Lets look at an example of
making a tiny 2 layer model with a convolution layer (with random weights) and an activation.
We can use the neural network builder class to construct a CoreML model. Lets look at an example of
making a tiny 2 layer model with a convolution layer (with random weights) and an activation.

```python
import coremltools
Expand Down