Skip to content

Commit db7e321

Browse files
authored
Doc updates to switch branding to Keras 3 (keras-team#2092)
* Update README * Fix imports in docs * Update keras import instructions
1 parent f7608c6 commit db7e321

File tree

1 file changed

+49
-32
lines changed

1 file changed

+49
-32
lines changed

README.md

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66
![Tensorflow](https://img.shields.io/badge/tensorflow-v2.9.0+-success.svg)
77
[![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/keras-team/keras-cv/issues)
88

9-
KerasCV is a library of modular computer vision components that work natively
9+
KerasCV is a library of modular computer vision components that work natively
1010
with TensorFlow, JAX, or PyTorch. Built on [Keras Core](https://keras.io/keras_core/announcement/),
1111
these models, layers, metrics, callbacks, etc., can be trained and serialized
12-
in any framework and re-used in another without costly migrations. See "Using
13-
KerasCV with Keras Core" below for more details on multi-framework KerasCV.
12+
in any framework and re-used in another without costly migrations. See
13+
"Configuring your backend" below for more details on multi-framework KerasCV.
1414

1515
<img style="width: 440px; max-width: 90%;" src="https://storage.googleapis.com/keras-cv/guides/keras-cv-augmentations.gif">
1616

17-
KerasCV can be understood as a horizontal extension of the Keras API: the
18-
components are new first-party Keras objects that are too specialized to be
19-
added to core Keras. They receive the same level of polish and backwards
20-
compatibility guarantees as the core Keras API, and they are maintained by the
17+
KerasCV can be understood as a horizontal extension of the Keras API: the
18+
components are new first-party Keras objects that are too specialized to be
19+
added to core Keras. They receive the same level of polish and backwards
20+
compatibility guarantees as the core Keras API, and they are maintained by the
2121
Keras team.
2222

23-
Our APIs assist in common computer vision tasks such as data augmentation,
23+
Our APIs assist in common computer vision tasks such as data augmentation,
2424
classification, object detection, segmentation, image generation, and more.
25-
Applied computer vision engineers can leverage KerasCV to quickly assemble
26-
production-grade, state-of-the-art training and inference pipelines for all of
25+
Applied computer vision engineers can leverage KerasCV to quickly assemble
26+
production-grade, state-of-the-art training and inference pipelines for all of
2727
these common tasks.
2828

2929
## Quick Links
@@ -48,25 +48,48 @@ pip to install directly from the master branch on github:
4848
pip install git+https://github.com/keras-team/keras-cv.git tensorflow --upgrade
4949
```
5050

51-
## Using KerasCV with Keras Core
51+
## Configuring your backend
5252

53-
As of version `0.6.0`, KerasCV supports multiple backends with Keras Core out of
54-
the box. There are two ways to configure KerasCV to run with multi-backend
55-
support:
53+
**Keras 3** is an upcoming release of the Keras library which supports
54+
TensorFlow, Jax or Torch as backends. This is supported today in KerasNLP,
55+
but will not be enabled by default until the official release of Keras 3. If you
56+
`pip install keras-cv` and run a script or notebook without changes, you will
57+
be using TensorFlow and **Keras 2**.
5658

57-
1. Via the `KERAS_BACKEND` environment variable. If set, then KerasCV will be
58-
using Keras Core with the backend specified (e.g., `KERAS_BACKEND=jax`).
59-
2. Via the `.keras/keras.json` and `.keras/keras_cv.json` config files (which
60-
are automatically created the first time you import KerasCV):
61-
- Set your backend of choice in `.keras/keras.json`; e.g., `"backend": "jax"`.
62-
- Set `"multi_backend": True` in `.keras/keras_cv.json`.
59+
If you would like to enable a preview of the Keras 3 behavior, you can do
60+
so by setting the `KERAS_BACKEND` environment variable. For example:
6361

64-
Once that configuration step is done, you can just import KerasCV and start
62+
```shell
63+
export KERAS_BACKEND=jax
64+
```
65+
66+
Or in Colab, with:
67+
68+
```python
69+
import os
70+
os.environ["KERAS_BACKEND"] = "jax"
71+
72+
import keras_cv
73+
```
74+
75+
> [!IMPORTANT]
76+
> Make sure to set the `KERAS_BACKEND` before import any Keras libraries, it
77+
> will be used to set up Keras when it is first imported.
78+
Until the Keras 3 release, KerasCV will use a preview of Keras 3 on PyPI named
79+
[keras-core](https://pypi.org/project/keras-core/).
80+
81+
> [!IMPORTANT]
82+
> If you set `KERAS_BACKEND` variable, you should `import keras_core as keras`
83+
> instead of `import keras`. This is a temporary step until Keras 3 is out!
84+
To restore the default **Keras 2** behavior, `unset KERAS_BACKEND` before
85+
importing Keras and KerasCV.
86+
87+
Once that configuration step is done, you can just import KerasCV and start
6588
using it on top of your backend of choice:
6689

6790
```python
6891
import keras_cv
69-
import keras_core as keras
92+
from keras_cv.backend import keras
7093

7194
filepath = keras.utils.get_file(origin="https://i.imgur.com/gCNcJJI.jpg")
7295
image = np.array(keras.utils.load_img(filepath))
@@ -79,19 +102,13 @@ model = keras_cv.models.YOLOV8Detector.from_preset(
79102
predictions = model.predict(image_resized)
80103
```
81104

82-
Until Keras Core is officially released as Keras 3.0, KerasCV will use
83-
`tf.keras` as the default backend. To restore this default behavior, simply
84-
`unset KERAS_BACKEND` and ensure that `"multi_backend": False` or is unset in
85-
`.keras/keras_cv.json`. You will need to restart the Python runtime for changes
86-
to take effect.
87-
88105
## Quickstart
89106

90107
```python
91108
import tensorflow as tf
92109
import keras_cv
93110
import tensorflow_datasets as tfds
94-
import keras_core as keras
111+
from keras_cv.backend import keras
95112

96113
# Create a preprocessing pipeline with augmentations
97114
BATCH_SIZE = 16
@@ -157,9 +174,9 @@ We would like to leverage/outsource the Keras community not only for bug reporti
157174
but also for active development for feature delivery. To achieve this, here is the predefined
158175
process for how to contribute to this repository:
159176

160-
1) Contributors are always welcome to help us fix an issue, add tests, better documentation.
177+
1) Contributors are always welcome to help us fix an issue, add tests, better documentation.
161178
2) If contributors would like to create a backbone, we usually require a pre-trained weight set
162-
with the model for one dataset as the first PR, and a training script as a follow-up. The training script will preferably help us reproduce the results claimed from paper. The backbone should be generic but the training script can contain paper specific parameters such as learning rate schedules and weight decays. The training script will be used to produce leaderboard results.
179+
with the model for one dataset as the first PR, and a training script as a follow-up. The training script will preferably help us reproduce the results claimed from paper. The backbone should be generic but the training script can contain paper specific parameters such as learning rate schedules and weight decays. The training script will be used to produce leaderboard results.
163180
Exceptions apply to large transformer-based models which are difficult to train. If this is the case,
164181
contributors should let us know so the team can help in training the model or providing GCP resources.
165182
3) If contributors would like to create a meta arch, please try to be aligned with our roadmap and create a PR for design review to make sure the meta arch is modular.
@@ -185,7 +202,7 @@ An example of this can be found in the ImageNet classification training
185202
All results are reproducible using the training scripts in this repository.
186203

187204
Historically, many models have been trained on image datasets rescaled via manually
188-
crafted normalization schemes.
205+
crafted normalization schemes.
189206
The most common variant of manually crafted normalization scheme is subtraction of the
190207
imagenet mean pixel followed by standard deviation normalization based on the imagenet
191208
pixel standard deviation.

0 commit comments

Comments
 (0)