Arm backend: Fix conversion from uint8 to fp32 for img_class application#18607
Arm backend: Fix conversion from uint8 to fp32 for img_class application#18607gggekov wants to merge 1 commit intopytorch:mainfrom
Conversation
Change-Id: I8aca840519f61e3b37100f7fefa58f2e0bd65be9 Signed-off-by: George Gekov <george.gekov@arm.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18607
Note: Links to docs will display an error until the docs builds have been completed. ❌ 6 Cancelled Jobs, 4 Unrelated FailuresAs of commit 6efa5e8 with merge base 07c5a54 ( CANCELLED JOBS - The following jobs were cancelled. Please retry:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
This PR updates the image preprocessing used by the Arm Ethos-U image classification runtime example so that RGB pixel values are converted from uint8 [0..255] into fp32 values in the model’s expected [-1..1] range.
Changes:
- Adjust input normalization from
/ 255.0to/ 127.5 - 1to map[0..255] → [-1..1]. - Add explanatory comments describing the normalization rationale.
- Update the copyright header year range.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| data = np.array(img_channels_first, dtype=np.float32) / 255.0 | ||
| # The PIL Image function returns the image represented in the range [0;255]. | ||
| # However, the NN was trained on fp32 numbers in the range [-1;1]. | ||
| # To pass from [0;255] to [-1;1], we divide by 127.5(the middle of the range) |
There was a problem hiding this comment.
There’s a missing space in the comment: 127.5(the middle of the range) reads as a typo. Please add a space after 127.5 for readability.
| # To pass from [0;255] to [-1;1], we divide by 127.5(the middle of the range) | |
| # To pass from [0;255] to [-1;1], we divide by 127.5 (the middle of the range) |
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell