Open ayes-vjanssen opened 11 months ago
@ayes-vjanssen thanks for using coremltools.
This is a good question,
in fact, coremltools doesn't support inputs
when then source model is milinternal
,
I believe this will be a useful feature request.
But in short, for now, the issue you are facing is expected.
@jakesabathia2 Thanks for checking!
Does this also mean that for now it is impossible to convert a MIL Program to a MLProgram that has an Image
as expected input? I cannot seem to find a way to specify an image as input spec in the line @mb.program(input_specs=[mb.TensorSpec(shape=(1,3,640,640))])
.
@ayes-vjanssen
You are correct, right now the ImageType
input can only be supported through pytorch / TF conversion
Before closing this issue and handing in a feature request I have a final question. I was able to modify the CoreML model after converting from MIL Program to ML Program as follows:
mlmodel = ct.convert(prog,
convert_to="mlprogram",
compute_precision=ct.precision.FLOAT16,)
spec = mlmodel.get_spec()
input = spec.description.input[0]
input.type.imageType.colorSpace = ct.proto.FeatureTypes_pb2.ImageFeatureType.RGB
input.type.imageType.height = 640
input.type.imageType.width = 640
mlmodel = ct.models.model.MLModel(spec, weights_dir=mlmodel.weights_dir)
mlmodel.save("simple_test.mlpackage")
This seems to give the expected result looking at the Xcode Predictions tab. @jakesabathia2 Is this a legit way of making sure the input is of type Image
?
❓Question
I am building a custom MIL program using the Python
Builder
class for MIL. As stated in the coremltools API Reference I am starting my custom program as follows:How can I assign a flexible input/enumerated input shape to the program?
It seems that converting the program to a MLPackage using
ct.convert()
and using the attributesinputs
and/oroutputs
do not affect the converted model. In the code snippet below I specifically renamed the input name tonew_a
. This code snippet will work just fine and will convert the program without any issues. However, if I open the MLProgram in Xcode and look at the Predictions tab I cannot see the changes applied to the input (see image bellow).Is there a way to give the program a flexible input?
Full code sample:
Environment: