Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting RTDETR Object Detection Model to CoreML #2440

Open
ProfessorHT opened this issue Feb 5, 2025 · 0 comments
Open

Converting RTDETR Object Detection Model to CoreML #2440

ProfessorHT opened this issue Feb 5, 2025 · 0 comments
Labels
bug Unexpected behaviour that should be corrected (type)

Comments

@ProfessorHT
Copy link

I am trying to convert the RTDETR Object Detection model to CoreML for use in an iOS app. However, I am encountering a data type mismatch error during the conversion process.

The code i am using:

import torch 
import coremltools as ct
from transformers import RTDetrForObjectDetection

model = RTDetrForObjectDetection.from_pretrained("TMP-finetune/runs/Jan22_16-22-29")

example_input = (torch.rand(1, 3, 512, 512),)

# Generate ExportedProgram by exporting
exported_model = torch.export.export(model, example_input)

input_images = ct.ImageType(name="images", shape=example_input[0].shape)

# Convert the model
mlmodel = ct.convert(
    exported_model,
    inputs=[input_images]
)

# Save the Core ML model
mlmodel.save("best.mlmodel")

The error i am getting:

Image

I have tried searching for solutions but haven't found a way to resolve this data type mismatch issue. Any guidance or suggestions would be greatly appreciated.

I have also opened a related issue on another repository, which can be found here: huggingface/transformers#35905 (comment)

Thanks in advance

@ProfessorHT ProfessorHT added the bug Unexpected behaviour that should be corrected (type) label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behaviour that should be corrected (type)
Projects
None yet
Development

No branches or pull requests

1 participant