onnx-coreml
onnx-coreml copied to clipboard
Question about is_bgr flag
Hi~
We haved tried the following args for preprocessing_args, but the converted coreml model still requires BGRA input.
args = dict(is_bgr=False, red_bias=-1, green_bias=-1, blue_bias=-1, image_scale=2/255.0)
Are there any other settings affecting the input format? Thank you.
No other settings. What is the format the original onnx/torch model expects? If you set the is_bgr=True, then CoreML will convert the input image to BGRA during preprocessing.
Hi~
Our expected input format is RGB. But even we set is_bgr = False, the converted model still requires BGRA format when we import the model in Xcode.
Hi~
The BGRA format is shown in the comment of coreml model. The comment is described as "/// face_img as color (kCVPixelFormatType_32BGRA) image buffer, 112 pixels wide by 112 pixels high" (face_img is our input image name).
This comment is shown even we set is_bgr = False.
@aseemw Hi, I am confused about the "is_bgr" flag. I have trained my model use pytorch and the model input is rgb format and output is rgb format too. I convert the model from pytorch to onnx and then from onnx to mlmodel. When I convert it from onnx to mlmodel, I set is_bgr=False. In my xcode project, I give the rgb format image to the model, but the output image is bgr format. I wonder that the default format in coreml is bgr. if I set is_bgr=false, the coreml will swap the B and R channel?
@yizhaoyanbo as per https://github.com/apple/coremltools/blob/master/coremltools/models/neural_network/builder.py#L3206 if is_bgr is False then image output shoudl be BGR. Could you please share a snippet of a onnx model?