apple / coremltools

Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.
https://coremltools.readme.io
BSD 3-Clause "New" or "Revised" License
4.46k stars 648 forks source link

Sometimes, the output image will be rotated? #2260

Open fg0521 opened 5 months ago

fg0521 commented 5 months ago

❓Question

when I use PIL.Image to input an image, I find the output will be rotated! It's horizontal and vertical flips! if I use opencv to read and convert to PIL.Image , the output will be normal! Then I use other different images, they are all normal. it is interesting! this is my convert function,I think it's right:

model = ct.convert(
        traced_model,
        convert_to="neuralnetwork",
        source='pytorch',
        inputs=[ct.ImageType(name="input",
                             shape=trace_input.shape,
                             channel_first=True,
                             color_layout=ct.colorlayout.RGB,
                             scale=1 / (255.0),
                             )],
        outputs=[ct.TensorType(name="output")],
    )

63537EC1-9154-42B6-BE60-BC3C8DA6DFA1

TobyRoseman commented 5 months ago

Can you share code to reproduce this result?