All Projects → prisma-ai → Torch2coreml

prisma-ai / Torch2coreml

Licence: mit
Torch7 -> CoreML

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Torch2coreml

Awesome Coreml Models
Collection of models for Core ML
Stars: ✭ 500 (+37.74%)
Mutual labels:  ai, coreml, ios11
Netron
Visualizer for neural network, deep learning, and machine learning models
Stars: ✭ 17,193 (+4636.36%)
Mutual labels:  ai, torch, coreml
Awesome Ml
Discover, download, compile & launch different image processing & style transfer CoreML models on iOS.
Stars: ✭ 142 (-60.88%)
Mutual labels:  ai, coreml, ios11
Styletransfer Ios
Stars: ✭ 155 (-57.3%)
Mutual labels:  ai, coreml, ios11
Texture nets
Code for "Texture Networks: Feed-forward Synthesis of Textures and Stylized Images" paper.
Stars: ✭ 1,147 (+215.98%)
Mutual labels:  torch, neural-style
Fast Neural Doodle
Faster neural doodle
Stars: ✭ 339 (-6.61%)
Mutual labels:  torch, neural-style
Windows Machine Learning
Samples and Tools for Windows ML.
Stars: ✭ 663 (+82.64%)
Mutual labels:  ai, coreml
Torch Models
Stars: ✭ 65 (-82.09%)
Mutual labels:  torch, neural-style
Deep Dream In Pytorch
Pytorch implementation of the DeepDream computer vision algorithm
Stars: ✭ 90 (-75.21%)
Mutual labels:  ai, torch
Cocoaai
🤖 The Cocoa Artificial Intelligence Lab
Stars: ✭ 134 (-63.09%)
Mutual labels:  ai, coreml
CoreML-samples
Sample code for Core ML using ResNet50 provided by Apple and a custom model generated by coremltools.
Stars: ✭ 38 (-89.53%)
Mutual labels:  ios11, coreml
Online Neural Doodle
Feedforward neural doodle
Stars: ✭ 183 (-49.59%)
Mutual labels:  torch, neural-style
Neural Style Audio Torch
Torch implementation for audio neural style.
Stars: ✭ 130 (-64.19%)
Mutual labels:  torch, neural-style
iOS11-Demos
Collection of samples and demos of features introduced in iOS 11
Stars: ✭ 16 (-95.59%)
Mutual labels:  ios11, coreml
Neural-Zoom
Infinite Zoom For Style Transfer
Stars: ✭ 34 (-90.63%)
Mutual labels:  torch, neural-style
inception
Real time image recognition using Core ML
Stars: ✭ 24 (-93.39%)
Mutual labels:  ios11, coreml
Gestureai Coreml Ios
Hand-gesture recognition on iOS app using CoreML
Stars: ✭ 145 (-60.06%)
Mutual labels:  coreml, ios11
Keras Openface
Keras-OpenFace is a project converting OpenFace from Torch implementation to a Keras version
Stars: ✭ 538 (+48.21%)
Mutual labels:  torch, coreml
CustomVisionMicrosoftToCoreMLDemoApp
This app recognises 3 hand signs - fist, high five and victory hand [ rock, paper, scissors basically :) ] with live feed camera. It uses a HandSigns.mlmodel which has been trained using Custom Vision from Microsoft.
Stars: ✭ 25 (-93.11%)
Mutual labels:  ios11, coreml
BabelCamera
Find out how to describe the things around you in another language with Core ML and the Vision framework in iOS 11! 👀
Stars: ✭ 13 (-96.42%)
Mutual labels:  ios11, coreml

Convert Torch7 models into Apple CoreML format.

Short tutorial

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

model: Torch7 model (loaded with PyTorch) | str
A trained Torch7 model loaded in python using PyTorch or path to file with model (*.t7).

input_shapes: list of tuples Shapes of the input tensors.

mode: str ('classifier', 'regressor' or None)
Mode of the converted coreml model:
'classifier', a NeuralNetworkClassifier spec will be constructed.
'regressor', a NeuralNetworkRegressor spec will be constructed.

preprocessing_args: dict
'is_bgr', 'red_bias', 'green_bias', 'blue_bias', 'gray_bias', 'image_scale' keys with the same meaning as https://apple.github.io/coremltools/generated/coremltools.models.neural_network.html#coremltools.models.neural_network.NeuralNetworkBuilder.set_pre_processing_parameters

deprocessing_args: dict
Same as 'preprocessing_args' but for deprocessing.

class_labels: A string or list of strings.
As a string it represents the name of the file which contains the classification labels (one per line). As a list of strings it represents a list of categories that map the index of the output of a neural network to labels in a classifier.

predicted_feature_name: str
Name of the output feature for the class labels exposed in the Core ML model (applies to classifiers only). Defaults to 'classLabel'

unknown_layer_converter_fn: function with signature:
(builder, name, layer, input_names, output_names)
builder: object - instance of NeuralNetworkBuilder class
name: str - generated layer name
layer: object - PyTorch (python) object for corresponding layer
input_names: list of strings
output_names: list of strings
Returns: list of strings for layer output names
Callback function to handle unknown for torch2coreml layers

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:

  1. Sequential
  2. ConcatTable
  3. SpatialConvolution
  4. ELU
  5. ReLU
  6. SpatialBatchNormalization
  7. Identity
  8. CAddTable
  9. SpatialFullConvolution
  10. SpatialSoftMax
  11. SpatialMaxPooling
  12. SpatialAveragePooling
  13. View
  14. Linear
  15. Tanh
  16. MulConstant
  17. SpatialZeroPadding
  18. SpatialReflectionPadding
  19. Narrow
  20. SpatialUpSamplingNearest
  21. 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].