How to train a custom object detection model which is compatible with ml kit library

I want to train a custom object detection model (hand detection).
I tried using Tensorflow’s Colab but it is not detecting any thing.
I used it in my android app but it says model is not compatible with ml kit library.
so can I make this model compatible with ml kit?
or how can I train a new model which is compatible with ml kit.
Thank you!

@Abdullah_Ilyas Welcome to tensorflow forum!

While your existing model not compatible with ML Kit might not work immediately, there are options to make it compatible or train a new model specifically for ML Kit.

Making your existing model compatible with ML Kit:

  1. Quantization: Quantize your model from FP32 to TFLite format.
  2. Model conversion: Use the TensorFlow Lite Converter to convert your TFLite model to a format compatible with ML Kit.
  3. Model optimization: Optimize the TFLite model for on-device inference using techniques like quantization-aware training or pruning.
  4. Input and output compatibility: Ensure your model’s input and output formats are compatible with ML Kit’s input image format and expected output format for hand detection.

Training a new model compatible with ML Kit:

  1. Choose a compatible model architecture: Select a model architecture supported by ML Kit, such as MobileNet v2 or EfficientNet.
  2. Pre-trained weights: Use pre-trained weights for the chosen architecture available on TensorFlow Hub.
  3. Custom training: Fine-tune the pre-trained model on your hand detection dataset using the TensorFlow Object Detection API.
  4. Export to TFLite: Export the trained model to TFLite format using the TensorFlow Lite Converter.
  5. Optimize for on-device inference: Apply optimization techniques like quantization-aware training or pruning to the TFLite model.

Here are some additional resources that can help you:

Specific considerations for hand detection:

  • Ensure your training data includes diverse hand poses, positions, and lighting conditions.
  • Adjust the model’s input size and resolution based on the desired hand detection accuracy and performance on your device.
  • Consider using data augmentation techniques like random cropping and flipping to improve the model’sgeneralizability.

Let us know if this helps!