How to load models from hub in tensorflow java

I imported tensorflow java into scala and i cant find any good tutorials about how to load models from the hub

Hi Ahmed,

TensorFlow Hub doesn’t have a java version that’s why there’s no tutorial.
Are you planning on creating models in scala or just use them?

in either case, you can download the model (from the browser or with a python script) and load it using regular TensorFlow, the assets have nothing specific to Hub.

okay well is there any tutoiral for loading models in tensorflow java and i am planning on training in python and using in scala but i wanted to see how to load models inside scala first before i went for the wholel plan . so coould u link me to some sources for loading models in scala thanks!

thanks i will take a look

Hi @lgusm and @ahmed_lone ,

the TensorFlow Java project have been moved to this repository, and you can find examples on how to load a saved model in Java but trained in Python at this location.

The link @lgusm was pointing to is for the deprecated Java client that was coming from the main TensorFlow repository and that is no longer supported.

Basically, any model available on the Hub that is running on the TensorFlow stack (and not TF Lite) should work in Java. If you encounter any issue, please raise an issue to the TF Java repository.

1 Like

how to see wether a model is running on tf stack ? i want to import this model after finetuning to scala : TensorFlow Hub

A bit unreleated but ArgMax  |  JVM  |  TensorFlow this is supposed to be a jvm doc but it has python examples what’s up with that

Thanks Karl!
I’ve deleted my reply to avoid pointing people to the wrong link

You’ll have different tabs per model format on the hub model page. For this one, only the TF tab is present so you should be fine.

A bit unreleated but ArgMax | JVM | TensorFlow this is supposed to be a jvm doc but it has python examples what’s up with that

That’s only because the documentation of all 1000+ operations of TF has not been rewritten to Java yet, which would require a lot of work, so it defaults to the Python one. The Java model repo I mentioned is probably the best place to start learning the Java API.

If you are interested to contribute to the project, even just for updating the documentation of some ops to Java, please feel free to submit your PR to the TF Java repo!

2 Likes