I added the metadata with image segmenter metadata writer TensorFlow Lite Metadata Writer API 2 script provided in TensorFlow docs and then later imported the model with Android studio model binding which generated the code for running inference and everything works fine.
Thanks.