Skip to content

code for exporting onnx model to tflite #45

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

dsbyprateekg
Copy link

@dsbyprateekg dsbyprateekg commented Mar 25, 2025

Using this code, I am able to convert my fine tuned model from onnx to tflite format. I have also added the inference code. This code has been tested in google colab notebook with A100 GPU.

Description

First I converted my fine tuned model to onnx format using below code-
from rfdetr import RFDETRBase
model = RFDETRBase(pretrain_weights="rf-detr_lego_model_30epochs.pth")
model.export()

Then I use following library for converting onnx model to tflite format: https://github.com/PINTO0309/onnx2tf
I also added inference code with converted tflite model to verify if its working as expected or not.

List any dependencies that are required for this change.

code has been tested in google colab notebook with A100 GPU.

Please delete options that are not relevant.

  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

I have tested the inference using converted tflite model and its output is as same as original fine tuned model.

Using this code, I am able to convert my fine tuned model from onnx to tflite format. I have also added the inference code. This code has been tested in google colab notebook with A100 GPU.
@probicheaux
Copy link
Collaborator

Hi, really cool, and thank you so much for this!

  1. can you move the notebook to a new dir notebooks
  2. would it be possible to add this new format as a keyword to the export command and do it there? no worries if not

…ooks/export_onnx_to_tflite_colab_notebook.ipynb

As per the suggestion, I created a new directory-notebooks.
@CLAassistant
Copy link

CLAassistant commented Apr 1, 2025

CLA assistant check
All committers have signed the CLA.

@dsbyprateekg
Copy link
Author

@probicheaux I have moved the notebook to a new dir notebooks.

@SkalskiP SkalskiP changed the base branch from main to develop April 3, 2025 08:54
@SkalskiP
Copy link
Collaborator

Hi @dsbyprateekg 👋🏻 thanks a lot for this PR! Looks like the code worked well for @gpokat in this issue — great job!

Any chance you could migrate it from the notebook into our export module?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants