How to convert a python TensorFlow model to tensorflow.js .json model in colab

I have been working for a day now trying to get a model that is created and saved in python on a colab environment to save in a tensorflow.js model.json format in that same environment.

I have been trying to convert using tensorflowjs. tensorflowjs.converters.converter does generate files, however, I always run into this error when trying to load “ValueError: An InputLayer should be passed either a batchInputShape or an inputShape.”

When converting I get this warning: “failed to lookup keras version from the file,
this is likely a weight only file”

Converted Model Using TensorFlow.JS Converter Not Working · Issue #8358 · tensorflow/tfjs · GitHub leads me to believe the issue is a bug due to the keras v3 format.

I have tried using tensorflow 2.15 to force keras v2, but then when install tensorflowjs it upgrades my environment back to keras v3.

tfjs.converters.save_keras_model producing model.json file that does not parse properly. · Issue #8328 · tensorflow/tfjs · GitHub recommends trying TF_USE_LEGACY_KERAS=1 but that doesn’t seem to work either and keras v3 get reinstalled

tfjs converter - not sure succesful or not · Issue #8375 · tensorflow/tfjs · GitHub confirms there is a bug in the converter but recomends using tensorflow_decision_forests==1.8.1 but I cant seem to get the example colab working on that one.

I have tried to install an older version of tensorflowjs to see if I could get a version that wont upgrade my keras version, however then I run into dependency conflicts with the primary tensorflow

I have read several posts that seem to indicate there are some breaking changes due to newer versions of tensorflow, tensorflowjs, and Colab, but I have struggling to figure it all out.

AI doesn’t seem to be nuanced enough about the versions to point me in the right direction.

What is the secret sauce to make this work. I imagine that I am not the only one trying to accomplish this.