mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

Unable to convert the finetuned model to the Tflite format

Open TryCAEarvr opened this issue 8 months ago • 3 comments

Configure conversion parameters.

config = converter.ConversionConfig( input_ckpt="C:/Users/Z8/fine_tuned_science_gemma2b-it", ckpt_format="safetensors", model_type="GEMMA_2B", backend='gpu', output_dir="C:/Users/Z8/fine_tuned_science_gemma2b-it/out", combine_file_only=False, vocab_model_file='C:/Users/Z8/fine_tuned_science_gemma2b-it/tokenizer.json', output_tflite_file=f'C:/Users/Z8/fine_tuned_science_gemma2b-it/scigemma.bin', )

Start model conversion.

converter.convert_checkpoint(config)

print("Model converted successfully.")

Error:

AttributeError Traceback (most recent call last) Cell In[28], line 14 2 config = converter.ConversionConfig( 3 input_ckpt="C:/Users/Z8/fine_tuned_science_gemma2b-it", 4 ckpt_format="safetensors", (...) 10 output_tflite_file=f'C:/Users/Z8/fine_tuned_science_gemma2b-it/scigemma.bin', 11 ) 13 # Start model conversion.
---> 14 converter.convert_checkpoint(config) 16 print("Model converted successfully.")

AttributeError: module 'mediapipe.python._framework_bindings.model_ckpt_util' has no attribute 'GenerateGpuTfLite'

Getting these Attribute Error. Kindly provide your support in this regard.

TryCAEarvr avatar Mar 20 '25 05:03 TryCAEarvr

Hi @TryCAEarvr,

Could you please provide the complete example you are following to convert the fine-tuned model to TFLite format? If this process is supported and documented in our official documentation, we will be able to assist you more effectively. Additionally, if you can share the standalone code causing the above error, it will help us reproduce the issue and provide better support.

Thank you!!

kuaashish avatar Mar 20 '25 06:03 kuaashish

https://medium.com/google-developer-experts/part-3-deploy-gemma-on-android-5bac532c54b7

We have been using the above article as a reference to finetune the Gemma model. I am currently using Jupyter Notebook instead of Google Collab to train the AI model locally. While converting the fine tuned model I am getting an Attribute Error. This is the portion where I am encountering error.

Image

TryCAEarvr avatar Mar 20 '25 13:03 TryCAEarvr

Hi @yuhuichen1015,

Are you aware of the issue here? It seems there is a problem converting the fine-tuned Gemma 2B model to TFLite format. Do we support converting fine-tuned models to TFLite? If so, do we have a conversion script for this process?

Thank you!!

kuaashish avatar Mar 21 '25 06:03 kuaashish