Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WiP] Switch Keras2 to tf_keras #2127

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion keras_cv/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@

keras.backend.name_scope = keras.name_scope
else:
from tensorflow import keras
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to be more conservative to enable people to use Keras 2 via tf.keras without having to install tf_keras:

  1. from tensorflow import keras
  2. if not hasattr(keras, "version"): then tf.keras is Keras 2. We use keras from TF.
  3. else: try to import tf_keras
  4. if not available: raise

import tf_keras as keras
except ImportError:
raise ImportError(
"Keras 2 requires the `tf_keras` package."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Using KerasCV with Keras 2"

"Please install it with `pip install tf_keras`."
)

if not hasattr(keras, "saving"):
keras.saving = types.SimpleNamespace()
Expand Down