+0
Daily
999
stars
380
forks
29
watchers
2,144
prs
1,055
issues
83
releases
README
KerasHub: Multi-framework Pretrained Models
!Python
[!IMPORTANT]
📢 KerasNLP is now KerasHub! 📢 Read
the announcement.
KerasHub is a pretrained modeling library that aims to be simple, flexible,
and fast. The library provides Keras 3
implementations of popular model architectures, paired with a collection of
pretrained checkpoints available on Kaggle Models.
Models can be used with text, image, and audio data for generation, classification,
and many other built in tasks.
KerasHub is an extension of the core Keras API; KerasHub components are provided
as Layer and Model implementations. If you are familiar with Keras,
congratulations! You already understand most of KerasHub.
All models support JAX, TensorFlow, and PyTorch from a single model
definition and can be fine-tuned on GPUs and TPUs out of the box. Models can
be trained on individual accelerators with built-in PEFT techniques, or
fine-tuned at scale with model and data parallel training. See our
Getting Started guide
to start learning our API.
Quick Links
For everyone
- Home page
- Getting started
- Guides
- API documentation
- Pre-trained models
For contributors
- Call for Contributions
- Roadmap
- Contributing Guide
- Style Guide
- API Design Guide
Quickstart
Choose a backend:
python
import os
os.environ["KERAS_BACKEND"] = "jax" Or "tensorflow" or "torch"!
Import KerasHub and other libraries:
python
import keras
import keras_hub
import numpy as np
import tensorflow_datasets as tfds
Load a resnet model and use it to predict a label for an image:
python
classifier = keras_hub.models.ImageClassifier.from_preset(
"resnet_50_imagenet",
activation="softmax",
)
url = "https://upload.wikimedia.org/wikipedia/commons/a/aa/California_quail.jpg"
path = keras.utils.get_file(origin=url)
image = keras.utils.load_img(path)
preds = classifier.predict(np.array([image]))
print(keras_hub.utils.decode_imagenet_predictions(preds))
Load a Bert model and fine-tune it on IMDb movie reviews:
python
classifier = keras_hub.models.TextClassifier.from_preset(
"bert_base_en_uncased",
activation="softmax",
num_classes=2,
)
imdb_train, imdb_test = tfds.load(
"imdb_reviews",
split=["train", "test"],
as_supervised=True,
batch_size=16,
)
classifier.fit(imdb_train, validation_data=imdb_test)
preds = classifier.predict(["What an amazing movie!", "A total waste of time."])
print(preds)
Installation
To install the latest KerasHub release with Keras 3, simply run:
pip install --upgrade keras-hub
To install the latest nightly changes for both KerasHub and Keras, you can use
our nightly package.
pip install --upgrade keras-hub-nightly
Currently, installing KerasHub will always pull in TensorFlow for use of the
tf.data API for preprocessing. When pre-processing with tf.data, training
can still happen on any backend.
Visit the core Keras getting started page
for more information on installing Keras 3, accelerator support, and
compatibility with diffeTop issues
#2101KerasHub has mandatory dependency on tensorflow-text but it isn't mandatory16 comments · 2025-02-14#1835🚀 Contributing to KerasHub 🚀 14 comments · 2024-09-17#1030Improve samplers documentation14 comments · 2023-05-11#1630Distributed training not working (batch size calculation)12 comments · 2024-05-16#2392Add Qwen Image & Qwen Image Edit models10 comments · 2025-09-08#284`char_to_token` in `keras_nlp.tokenizers.Tokenizer`9 comments · 2022-08-07#2072Add DoRA support in KerasHub8 comments · 2025-02-04#2669CONTRIBUTING_MODELS.md is outdated7 comments · 2026-04-11
Discussions
#2347Plan for 3D variants of ImageNet models0 comments · 2025-07-27#2291Question regarding CNN usage for object detection.0 comments · 2025-06-06#2120Interest in Contributing to KerasHub for GSoC 20250 comments · 2025-02-28#2119Guidance on how to contribute (and GSOC 2025)0 comments · 2025-02-27#2094How to use custom input with backbones?0 comments · 2025-02-12#1995keras_cv.losses.IoULoss documentation not found0 comments · 2024-11-28#1987Getting error when trying to export GemmaCausalLM model to SavedModel format0 comments · 2024-11-18#1708AttributeError: module 'keras.saving' has no attribute 'register_keras_serializable'0 comments · 2024-07-25
Latest release
v0.33.0 v0.33.0 2026-11-03KerasHub v0.33.0 Release Notes
12NEW MODEL FAMILIES
29NEW PRESETS
52PULL REQUESTS
12CONTRIBUTORS
6FIRST-TIME CONTRIBUTORS
3BACKENDS
🧱ModernBERT8K-context encoder
🧭ModernBERT Embedsentence embeddings
📐MPNetsentence embeddings
💎EmbeddingGemma 2text · image · video · audio
🌀Diffusion Gemma26B MoE block diffusion
🖼️Mistral Small 3.x24B vision-language
📱Ministral 33B · 8B · 14B edge VLMs
🛠️Devstral Small 2agentic coding
🧠Magistral Smallreasoning
🛡️Shieldstralsafety cla