Convert Torch7 models into Apple CoreML format.
This tool helps convert Torch7 models into Apple CoreML format which can then be run on Apple devices.
fast-neural-style example app screenshot
Installation
pip install -U torch2coreml
In order to use this tool you need to have these installed: * Xcode 9 * python 2.7
If you want to run tests, you need MacOS High Sierra 10.13 installed.
Dependencies
coremltools (0.6.2+)
PyTorch
How to use
Using this library you can implement converter for your own model types. An example of such a converter is located at “example/fast-neural-style/convert-fast-neural-style.py”. To implement converters you should use single function “convert” from torch2coreml:
from torch2coreml import convert
This function is simple enough to be self-describing:
def convert(model,
input_shapes,
input_names=['input'],
output_names=['output'],
mode=None,
image_input_names=[],
preprocessing_args={},
image_output_names=[],
deprocessing_args={},
class_labels=None,
predicted_feature_name='classLabel',
unknown_layer_converter_fn=None)
Parameters
input_shapes: list of tuples Shapes of the input tensors.
Returns
model: A coreml model.
Currently supported
Models
Only Torch7 “nn” module is supported now.
Layers
List of Torch7 layers that can be converted into their CoreML equivalent:
Sequential
ConcatTable
SpatialConvolution
ELU
ReLU
SpatialBatchNormalization
Identity
CAddTable
SpatialFullConvolution
SpatialSoftMax
SpatialMaxPooling
SpatialAveragePooling
View
Linear
Tanh
MulConstant
SpatialZeroPadding
SpatialReflectionPadding
Narrow
SpatialUpSamplingNearest
SplitTable
License
Copyright (c) 2017 Prisma Labs, Inc. All rights reserved.
Use of this source code is governed by the MIT License that can be found in the LICENSE.txt file.
Metadata
Release files for torch2coreml 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torch2coreml-0.2.0-py2.7-none-any.whl | Details for torch2coreml-0.2.0-py2.7-none-any.whl |
Release files / torch2coreml-0.2.0-py2.7-none-any.whl
| Download URL | torch2coreml-0.2.0-py2.7-none-any.whl |
|---|---|
| Size | 12.2 kB |
|
SHA-256 checksum How to use checksums |
86f748be0b889f0952cfa1e850f20c74bdcc034bb7c5c477bc5f40d9d8f790e5
|
|
BLAKE2b-256 checksum How to use checksums |
4bf14d16dd03c483ce63e05f15b1b3bc6024abd6d6fe6636b53c060397cdf197
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for torch2coreml 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.