apple / apple/coremltools

PyTorch model to CoreML model and corresponding kCVPixelFormatType of CVPixelBuffer

Open
#1,843 3 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## ❓Question

I use coremltools to convert a PyTorch model to CoreML model and `kCVPixelFormatType` of `CVPixelBuffer` the model should receive confused me.
There are two scenarios:
1. Use the default `color_layout = ct.colorlayout.RGB` to convert the model. This CoreML model receives `CVPixelBuffer` with `kCVPixelFormatType_32ARGB` and works well. Besides, it outputs wrong answers when the `CVPixelBuffer`'s `kCVPixelFormatType` is `kCVPixelFormatType_32BGRA`.
2. Use `color_layout = ct.colorlayout.BGR` to convert the model. The CoreML model still outputs different and wrong answers when the input `CVPixelBuffer`'s
`kCVPixelFormatType` is `kCVPixelFormatType_32BGRA`.

I wonder how to convert the model and enable the CoreML model to correctly work on `CVPixelBuffer` with `kCVPixelFormatType_32BGRA` because it may take lots of steps to get `kCVPixelFormatType_32ARGB` format `CVPixelBuffer`.

Thank you!

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two PyTorch-to-CoreML conversions described in the issue, using both RGB and BGR color layouts and the two CVPixelBuffer pixel formats. Compare the model outputs for kCVPixelFormatType_32ARGB and kCVPixelFormatType_32BGRA. Done means the correct conversion or supported input behavior for BGRA is established and documented.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.