Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

How to convert MultiArray to image as input type #515

Closed
MarcSteven opened this issue Dec 9, 2019 · 4 comments
Closed

How to convert MultiArray to image as input type #515

MarcSteven opened this issue Dec 9, 2019 · 4 comments
Labels
question Response providing clarification needed. Will not be assigned to a release. (type)

Comments

@MarcSteven
Copy link

❓Question

How to convert MultiArray to Image as input type

System Information

  • If applicable
@MarcSteven MarcSteven added the question Response providing clarification needed. Will not be assigned to a release. (type) label Dec 9, 2019
@AnasArram
Copy link

AnasArram commented Dec 9, 2019

❓Question

How to convert MultiArray to Image as input type

System Information

  • If applicable

you need to pass the input name (image_input_names) as an argument as follow:

coreml_model = convert(model, target_ios='13', custom_conversion_functions={'Upsample': _convert_upsample}, image_input_names = ['input']

replace 'input' with your model input name

@MarcSteven
Copy link
Author

@AnasArram Thank you so much, can you show a whole example about it?

@MarcSteven
Copy link
Author

`#//
#// convert_input_to_image.py
#// AntsFaceDemo
#//
#// Created by Marc Zhao on 2019/12/12.
#// Copyright © 2019 AntsNetwork. All rights reserved.
#//

import coremltools
import coremltools.proto.FeatureTypes_pb2 as ft

spec = coremltools.utils.load_spec("FacialExpressionAnalysis.mlmodel") #please change the file name you are using

input = spec.description.input[0]
input.type.imageType.colorSpace = ft.ImageFeatureType.RGB
input.type.imageType.height = 224
input.type.imageType.width = 224

coremltools.utils.save_spec(spec,"FacialExpressionAnalysis.mlmodel")#Please change the file name using your own
`
This is all the solutions, but you must ensure the channel is 3, you can convert multiArray to image if you want.

@yonggunlee
Copy link

Hello, I don't know if this is still on going or not, but I have a question.
I see how we can change input&output type in coremltools.
I wonder if it can be happen in onnxmltools as well.
I have onnx model that takes [batchsize, img channel, img H, img W] which is multi array,
I also wish to change the input as image input as above question.
Can someone help me on it? I was trying to check inside of onnxmltools, but haven't found how.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Response providing clarification needed. Will not be assigned to a release. (type)
Projects
None yet
Development

No branches or pull requests

3 participants