Registry / ai-ml / keras-hub

keras-hub

JSON →
library0.29.1pypypiunverified

The `keras-hub` library, version 0.27.1, was a wrapper released in 2019 to provide a convenient Keras API for loading models from TensorFlow Hub. It is now considered abandoned and is not compatible with modern Keras (3.x) or recent TensorFlow versions due to significant API changes and Python version requirements. Users should directly use the `tensorflow_hub` library with modern Keras installations.

pip install keras-hub
INSTALL
IMPORT
SIG · KERAS-HUB
K
keras-hub
ai-mlpythonv0.29.1
Install
40.4s avg
Import
Disk
2417MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.25.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 40.4s · import 0.000s · 2355.2MB
2417MB installed
● package 2417MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

KerasLayer
from keras_hub import KerasLayer
This was the primary import for the `keras-hub` wrapper. With modern Keras, you should import `KerasLayer` directly from `tensorflow_hub`.
url_to_feature_column
from keras_hub import url_to_feature_column
This was used for creating feature columns from Hub modules. Direct use of `tensorflow_hub.feature_column.url_to_feature_column` is now recommended.

This example illustrates how `KerasLayer` from `keras-hub` was intended to be used to integrate TensorFlow Hub modules into Keras models. **Please note: This code block is for historical context and is not runnable with Python 3.8+ or Keras 3.x due to the library's abandonment and dependency incompatibilities.** For a working example with modern Keras, refer to the 'warnings' section below which uses `tensorflow_hub` directly.

import keras from keras_hub import KerasLayer import tensorflow as tf # Required for data types and model building # This code block demonstrates the intended usage of keras-hub (0.27.1). # It is NOT runnable with modern Python (3.8+) or Keras 3.x without # specific, older TensorFlow/Keras versions and their corresponding # Python environment. # For a runnable example using modern Keras, see the 'warnings' section below. try: # Example: Use a pre-trained image feature vector module from TensorFlow Hub # Note: The actual module URL would need to be valid for the TensorFlow Hub # version compatible with keras-hub 0.27.1 (circa 2019). feature_extractor_url = "https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/4" # Create a KerasLayer from the Hub module # keras-hub's KerasLayer defaults trainable=False hub_layer = KerasLayer(feature_extractor_url, input_shape=(224, 224, 3)) # Build a simple Keras model model = keras.Sequential([ keras.Input(shape=(224, 224, 3)), hub_layer, keras.layers.Dense(2, activation='softmax') ]) model.summary() print(f"KerasLayer trainable: {hub_layer.trainable}") except ImportError: print("\n'keras-hub' or its dependencies not found. This library is abandoned.") print("Install with 'pip install keras-hub' requires older Python/TensorFlow environment.") except Exception as e: print(f"\nAn error occurred during keras-hub usage (likely due to environment incompatibility): {e}") # --- Modern Keras/TensorFlow Hub approach (RECOMMENDED) --- # For current environments, use tensorflow_hub directly: # import tensorflow_hub as hub # import keras # # feature_extractor_url_modern = "https://tfhub.dev/google/efficientnet/b0/feature-vector/1" # Example modern URL # hub_layer_modern = hub.KerasLayer(feature_extractor_url_modern, trainable=False, input_shape=(224, 224, 3)) # model_modern = keras.Sequential([ # keras.Input(shape=(224, 224, 3)), # hub_layer_modern, # keras.layers.Dense(2, activation='softmax') # ]) # model_modern.summary()
Debug
Known issues
breakingThe `keras-hub` library (0.27.1) is incompatible with Python 3.8+ and modern Keras (3.x) / TensorFlow (2.x) due to outdated dependencies and significant API changes. Attempting to use it will likely result in `ModuleNotFoundError`, `AttributeError`, or runtime crashes.
fix
Do not use `keras-hub` for new projects. Instead, directly import and use `KerasLayer` from `tensorflow_hub` for modern Keras installations. Ensure `tensorflow-hub` is installed: `pip install tensorflow-hub`.
affects: 0.27.1
deprecatedThe `keras-hub` package is abandoned, with its last release in 2019. It served as a thin wrapper for `tensorflow_hub.KerasLayer` and is no longer maintained or necessary with current Keras/TensorFlow versions.
fix
Migrate to using `tensorflow_hub` directly. The `tensorflow_hub.KerasLayer` provides the same core functionality and is actively maintained. For Keras 3.x and TensorFlow 2.x, the usage pattern is nearly identical to what `keras-hub` offered, but without the compatibility issues.
affects: 0.27.1
gotchaWhile `keras-hub.KerasLayer` defaulted `trainable=False`, `tensorflow_hub.KerasLayer` often defaults `trainable=True` for many feature vector modules. This subtle difference can lead to unexpected model training behavior if the `trainable` argument is not explicitly set.
fix
Always explicitly set the `trainable` argument when using `tensorflow_hub.KerasLayer` to ensure desired behavior. For example, `hub.KerasLayer(module_url, trainable=False, ...)`.
affects: 0.27.1 (when comparing to `tensorflow_hub` behavior)
Upgrade
Version history
0.29.1latest on PyPI · released Jun 2, 2026
Audit
Dependencies
tensorflow-hubrequiredCore functionality wrapped by this library; requires an old, compatible version of tensorflow-hub and TensorFlow.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
keras-hub — pip install keras-hub · libregistry