Open gordinmitya opened 3 years ago
it neither works when I do not touch output node. (don't specify as image type, set flexible size)
@aseemw tested with MultiArray input with dynamic size – it work just perfect! (while keeping output as image)
size_l = 128
size_u = 2048
flexible_shape_utils.set_multiarray_ndshape_range(spec, INPUT_NODE, [1,3,size_l,size_l], [1,3,size_u,size_u])
here's updated script: https://gist.github.com/gordinmitya/96a1b041bea18add4ec2e31907d11100
Any ideas?
I've exactly the same problem and I see that coreml runtime basically consider only the imageType width and height values and ignore the imageSizeRange. I tried also to remove the imageType width and height values. Apparently the model is exported successfully this way but the runtime then fail to compile the model.
These are the input/output spec for my model:
(name: "image"
type {
imageType {
width: 1024
height: 1024
colorSpace: RGB
imageSizeRange {
widthRange {
lowerBound: 256
upperBound: 1024
}
heightRange {
lowerBound: 256
upperBound: 1024
}
}
}
},
name: "460"
type {
imageType {
width: 1024
height: 1024
colorSpace: RGB
imageSizeRange {
widthRange {
lowerBound: 256
upperBound: 1024
}
heightRange {
lowerBound: 256
upperBound: 1024
}
}
}
})
As said any image with a size different than 1024x1024 fails with "coreml Error binding image input buffer image: -7" message
I appear to be having the same issue #992
I was able to work around the bug by using MultiArray input and flexible shape image output (as you mention). I am converting my input UIImage
to MLMultiArray
using Accelerate
vImageConvert_ARGB8888toPlanarF
. The overhead of the conversion is quite low for my purposes.
Obviously not as ideal as flexible input images just working, but for me at least it is a working solution until these bugs are (hopefully) fixed and at least I can move on for now.
@3DTOPO Thank you for workaround with Accelerate! How do you think is it the way CoreML convert UIImage internally? And could you provide small snippet how to use vImageConvert_ARGB8888toPlanarF in Swift?
You're welcome! Possibly. Please see the end of this thread for the solution: https://github.com/hollance/CoreMLHelpers/issues/5#issuecomment-726021906
Hi, Apologies if I'm hijacking.
If you use enumerated shapes does it work with ANE @gordinmitya ? I got it working with enumerated shape on a trivial/minimal network and while CPU & GPU work fine, ANE still refuses.
@alexrkr haven't got so far. Need to run the model at least somehow. So in your case model works on ANE when converted with fixed size but use CPU/GPU when converted with enumerated size, right?
Exactly, so when exporting with enumerated sizes it works fine on CPU/GPU but not on ANE. Fixed size works on all devices fine. I was hoping to find a reference in Apple's docs or someone who has gotten ANE to work with flexible input network, I'm assuming that's possible.
Mitya, did you find solution? I also can't use flexible input in my app, it returns Error binding image input buffer image: -7
Many thanks!
I'm trying to wrap up development of an update that I've spent 2 years working on. Is this glaring bug ever going to be addressed?
Otherwise I am facing shipping a product with a horrendous work around for a feature that is supposed to be supported. I can't express how frustrating this issue is and one of the most critical toolchains for my app development.
@aseemw tested with MultiArray input with dynamic size – it work just perfect! (while keeping output as image)
size_l = 128 size_u = 2048 flexible_shape_utils.set_multiarray_ndshape_range(spec, INPUT_NODE, [1,3,size_l,size_l], [1,3,size_u,size_u])
here's updated script: https://gist.github.com/gordinmitya/96a1b041bea18add4ec2e31907d11100
Any ideas?
HI! I can't get this to work either. Is there any other hack?
🐞Describe the bug
Unable to make flexible input size when converting from pytorch. I think it's related to https://github.com/apple/coremltools/issues/890 https://github.com/apple/coremltools/issues/880 and https://github.com/apple/coremltools/issues/756. I extend this to input ImageType and make simplest script to reproduce whole process.
RangeDim
to make input flexible from documentation just do not work at all! Getting:So the model is correct and framework do able to execute it with any size but only if enumerated in advance. This brings me to thoughts there's some flag or typo which ignores input range.
Trace
To Reproduce
System environment (please complete the following information):
This is critical bug!
Because some models just do not make much sense with fixed (even several enumerated) size!
I will be happy to provide any additional info required. Please, any help/workaround is appreciated!