keras-team /keras-hub

Pretrained model hub for Keras 3.

★ 999⑂ 380👁 29⑃ 2,144● 1,055▤ 83
PythonApache-2.0Created 2020-05-28keras.io/keras_hub/
下载:v0.33.0v0.33.0 ↓0.33.02026-11-03
+0
日增长
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 diffe

Top issues

Discussions

Latest release

v0.33.0 v0.33.0 2026-11-03
KerasHub 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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON