Skip to content

Latest commit

 

History

History
executable file
·
36 lines (28 loc) · 1.01 KB

README.md

File metadata and controls

executable file
·
36 lines (28 loc) · 1.01 KB

Image Segmenter ios

Core ML Image Segmentation on ios

Examples

mlmodel

Core ML model file are converted from deeplab MobileNetv2

Example

Download checkpoint and uncompress it

wget http://download.tensorflow.org/models/deeplabv3_mnv2_pascal_trainval_2018_01_29.tar.gz
tar xvf deeplabv3_mnv2_pascal_trainval_2018_01_29.tar.gz

Then convert to mlmodel with tfcoreml

import tfcoreml as tf_converter 
tf_converter.convert(
    tf_model_path = 'deeplabv3_mnv2_pascal_trainval/frozen_inference_graph.pb', 
    mlmodel_path = 'Deeplab.mlmodel', 
    image_input_names=["ImageTensor:0"], 
    output_feature_names = ['ResizeBilinear_3:0'], 
    input_name_shape_dict = {'ImageTensor:0' : [1, 513, 513, 3]}, 
    use_coreml_3 = False) 

Usage

 let sourceImg = UIImage.init(named: "test.jpg")!
 let segmentImg = sourceImg.segmentation()