Model or dataset
keras-team/keras-hub avatar
keras-team/keras-hub

KerasHub: One Model Definition, Three Backends, and a Kaggle Checkpoint Supply Chain

Pretrained model hub for Keras 3.

990 stars361 forksPythonApache-2.0

At a glance

What is it?
KerasHub is the renamed KerasNLP plus image and audio presets, built as Keras 3 Layer and Model classes that run on JAX, TensorFlow or PyTorch from the same source. It is convenient if you already write Keras, and awkward if you need a pipeline the preset API does not cover.
Who is it for?
Adopt KerasHub if your training loop is already Keras 3 and you want one architecture definition to run on JAX, TensorFlow or PyTorch without rewriting the model. Skip it if you depend on architectures or checkpoints outside the Kaggle Models collection, or if you need a stable API today: the README says that while the project stays in pre-release 0.y.z development it may break compatibility at any time.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The problem KerasHub addresses: pretrained weights without a framework rewrite

Most pretrained model distributions are tied to one runtime. A checkpoint published for PyTorch is loaded through PyTorch modules; a TensorFlow checkpoint goes through TensorFlow objects. If your training code is Keras 3 and you want to try a JAX backend, the model code is usually the part that blocks you. KerasHub's answer is to define each architecture once and let Keras 3 dispatch it to whichever backend is active. The README states that all models support JAX, TensorFlow and PyTorch from a single model definition. The library is an extension of core Keras: components are exposed as Layer and Model implementations, so anyone who has written a Keras layer already knows the shape of the API. The intended audience is therefore not people choosing a deep learning framework from scratch. It is people who have already chosen Keras 3, and who want pretrained text, image and audio models available as ordinary Keras objects they can call fit and predict on. The project was previously named KerasNLP; the README links to an announcement issue describing the rename, and the scope now covers image and audio alongside text.

Presets, backbones and tasks: the three layers of the API

The mechanism is a naming convention wrapped around a task class. A preset is a string such as resnet_50_imagenet or bert_base_en_uncased. You pass it to a task class constructor, and the class returns a Keras model with weights already loaded. In the image example, keras_hub.models.ImageClassifier.from_preset takes the preset name and an activation argument, and the resulting object is a normal classifier you can call predict on. In the text example, keras_hub.models.TextClassifier.from_preset takes a preset name, an activation, and num_classes, then accepts a tf.data pipeline directly in fit. Underneath, the architecture itself is a backbone object, and the task class is the backbone plus a task-specific head. That layering is what makes the same weights reusable for classification, generation and the other built-in tasks the README mentions. It also explains the main constraint: the task classes are opinions about how a model should be wired for a given job. If your output shape, loss or decoding logic does not match one of the built-in task heads, you work with the backbone directly and write the head yourself, which is where the convenience ends. The README does not enumerate every available preset, so the preset catalogue on the documentation site is the place to confirm what exists before designing around a name.

Getting it running: install, backend selection, and the import-order trap

Installation is one command: pip install --upgrade keras-hub. A nightly channel exists as keras-hub-nightly for unreleased changes in both KerasHub and Keras. The README notes a dependency detail worth knowing before you plan an environment: installing KerasHub always pulls in TensorFlow, because the tf.data API is used for preprocessing. That is a footprint cost even when you intend to train on JAX or PyTorch, and the README is explicit that preprocessing through tf.data does not force training onto the TensorFlow backend. Backend selection is an environment variable, not a constructor argument. You set KERAS_BACKEND to jax, tensorflow or torch, either in the shell with export KERAS_BACKEND=jax or in Python by assigning os.environ before imports. The README marks the ordering as important: the variable must be set before importing any Keras library, because it is read when Keras is first imported. Setting it after import keras_hub will not switch anything, and this is the single most common way a first run goes wrong. The quickstart also demonstrates keras.utils.get_file and keras.utils.load_img for pulling a single image over HTTP, and keras_hub.utils.decode_imagenet_predictions for turning raw logits into readable labels.

Versioning: pre-release semantics and what that means for saved models

The README states that KerasHub follows Semantic Versioning and plans to provide backwards compatibility guarantees for both code and saved models built with its components. Then it qualifies that plan: while the project remains in pre-release 0.y.z development, compatibility may be broken at any time and APIs should not be considered stable. Both statements are in the same section, and the second one governs today. The practical reading is that a 0.y.z version number is not a promise about your code surviving an upgrade. Saved models are the sharper risk. A Keras file that embeds a KerasHub layer depends on that layer's serialization behaviour, and the README's compatibility language does not carve out an exception for weights. If you pin a version and keep the artifact, you are fine. If you let pip resolve the newest release and then load a checkpoint produced months earlier, the compatibility guarantee is aspirational rather than contractual. The release cadence visible in the repository is fast: two stable releases in August 2026, roughly two weeks apart, plus a development tag. That pace is good for preset coverage and bad for anyone treating the API surface as fixed.

The licence boundary sits with the checkpoint, not the library

The library itself is Apache-2.0, which is permissive and includes a patent grant. That licence covers the KerasHub code. It does not automatically cover the weights. The README's disclaimer states that pretrained models are provided on an as-is basis without warranties, and that several underlying models are supplied by third parties under separate licences, listing BART, BLOOM, DeBERTa, DistilBERT, GPT-2, Llama, Mistral, OPT, RoBERTa, Whisper and XLM-RoBERTa. The distinction matters because those third-party terms vary widely, and some carry use restrictions that Apache-2.0 does not. The checkpoints are hosted on Kaggle Models, so the licence attached to a given preset is the one to read, not the repository's LICENSE file. This is not legal advice; it is a statement about where the relevant document lives. Teams that treat the repo licence as sufficient clearance for every preset will eventually ship something they should not have. The disclaimer is short, but it is the most consequential paragraph in the README for commercial users.

Where KerasHub is the wrong tool

The preset catalogue is the boundary. KerasHub ships implementations of specific architectures paired with specific checkpoints, and the README describes the collection as living on Kaggle Models. If the model you need is not in that collection, KerasHub does not help you load it, and you are back to framework-native code. The second limitation is the task head. Built-in tasks cover generation, classification and the other jobs the README names, but a custom objective means dropping to the backbone and writing the training step, at which point the library is providing an architecture definition rather than a workflow. The third is scale. The README says models can be fine-tuned at scale with model and data parallel training and trained on individual accelerators with built-in PEFT techniques, but it does not describe the configuration surface for either in the material available here. Anyone whose plan depends on multi-host parallelism should read the guides before assuming the preset API carries them there. Finally, the TensorFlow dependency pulled in at install time is a real cost in constrained or non-TensorFlow environments, even though the README is clear that training can still happen on any backend.

Hugging Face Transformers: the same job, a different centre of gravity

The obvious alternative is Hugging Face Transformers, and the difference is architectural rather than a matter of feature counts. Transformers is organized around a checkpoint registry and per-model Python classes, with the library's own tokenizers, pipelines and training utilities layered on top. It is not built as an extension of a single framework's type system, and it does not present a model as a Keras Layer that a Keras fit call can consume directly. KerasHub's bet is the opposite: the model is a Keras object first, and the multi-backend support falls out of Keras 3 rather than being implemented per model. That bet pays off when your training loop, callbacks, metrics and serialization are already Keras. It costs you when the model you want exists in the Transformers registry and has no KerasHub preset, because the migration path is not a flag. A reasonable split: choose KerasHub when the preset you need exists and the Keras object model is an asset; choose Transformers when breadth of checkpoints is the deciding factor and you are willing to manage the framework boundary yourself.

Who should adopt KerasHub, and what to confirm before the first commit

Adopt it if your code is Keras 3, your target architectures appear in the Kaggle Models collection, and you value being able to switch between JAX, TensorFlow and PyTorch by changing one environment variable rather than rewriting model code. The API surface is small enough to learn in an afternoon if you already write Keras, and the from_preset pattern means a working classifier is a few lines. Do not adopt it as a general checkpoint loader, as a stable long-term API, or as a way to reach model families outside the collection. Before committing, confirm three things. First, that the exact preset string you intend to use exists and that its third-party licence is acceptable, since the README lists eleven model families under separate terms. Second, that your code sets KERAS_BACKEND before the first Keras import, because the README says the value is read at import time. Third, that your dependency policy tolerates a 0.y.z library releasing roughly every two weeks, given the README's statement that compatibility may break at any time during pre-release development. If all three check out, the install is pip install --upgrade keras-hub and the first model is one from_preset call.

Editorial conclusion

Adopt KerasHub if your training loop is already Keras 3 and you want one architecture definition to run on JAX, TensorFlow or PyTorch without rewriting the model. Skip it if you depend on architectures or checkpoints outside the Kaggle Models collection, or if you need a stable API today: the README says that while the project stays in pre-release 0.y.z development it may break compatibility at any time. Verify first that the exact preset string you need exists on Kaggle Models, that the third-party licence attached to it is acceptable for your use, and that your environment sets KERAS_BACKEND before any Keras import, since setting it afterwards has no effect.

Official sources

  1. keras-team/keras-hub on GitHub
  2. License: Apache-2.0
  3. Project website
  4. README
  5. Releases
Community notes

Community notes