Converting keras model errors out
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 850
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 10
Description
## ❓Question
Trying to use coremltools to convert yolov8 keras (from keras cv github readme) but it errors out. https://github.com/keras-team/keras-cv
Since I haven't trained or tuned this model, wondering what could be going wrong that is causing this issue.
Is the issue specifying output types or will the converter automatically infer it?
```
model = keras_cv.models.YOLOV8Detector.from_preset(
"yolo_v8_m_pascalvoc",
bounding_box_format="xywh",
)
classifier_config = coremltools.ClassifierConfig(class_ids)
coreml_model = coremltools.converters.convert(model, convert_to="mlprogram",
inputs=[coremltools.ImageType(shape=(1, ROWS, COLS, 3,),
bias=[-1,-1,-1], scale=1/127.5)],
classifier_config=classifier_config
)
```
```
File "/Users/xxxxxx/coremltools-venv/lib/python3.11/site-packages/coremltools/converters/mil/mil/ops/defs/iOS15/classify.py", line 74, in type_inference r
aise ValueError(msg) ValueError: In op 'classify', number of classes must match the size of the tensor corresponding to 'probabilities'.
```
Contributor guide
Research direction
Start by reproducing the conversion with the Keras YOLOV8Detector snippet and the shown ClassifierConfig and ImageType settings. Inspect the model output shape alongside class_ids and the converter's classify operation to determine why their sizes differ. Done means identifying whether the inputs or converter behavior causes the mismatch and recording a reproducible resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100