apple / apple/coremltools

Sometimes, the output image will be rotated?

Open
#2,260 1 comment 1 reaction 0 assignees View on GitHub
question
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## ❓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](https://github.com/apple/coremltools/assets/55678593/6193ab1a-863f-41c0-adcc-0c027c46c243)

Contributor guide

Open the contributing guide

Research direction

Start with the PIL.Image input path and the shown ct.convert ImageType configuration, then compare the affected image with the OpenCV-to-PIL path. Build a reproducible case around the affected image and conversion inputs; done means the converted output preserves the source orientation while other images remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
opencv, python, pytorch
Domain
machine-learning, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.