Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Improve error handling for missing TensorFlow dependency in KerasCV#2435

Open
SamanehSaadat wants to merge 3 commits intokeras-team:masterfrom
SamanehSaadat:tf-check
Open

Improve error handling for missing TensorFlow dependency in KerasCV#2435
SamanehSaadat wants to merge 3 commits intokeras-team:masterfrom
SamanehSaadat:tf-check

Conversation

@SamanehSaadat
Copy link
Member

This PR addresses this issue: user doesn't have tensorflow installed and doesn't expect to get error as they're using pytorch backend.

raise ImportError(
"To use KerasCV, please install TensorFlow: `pip install tensorflow`. "
"The TensorFlow package is required for data preprocessing with any backend."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Will keras-cv always depend on tensorflow for data processing layers?

@@ -46,7 +46,14 @@
from tensorflow import split # noqa: F403, F401
Copy link
Contributor

Choose a reason for hiding this comment

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

These imports will also fail in case tensorflow is not installed. Making this same change across all the files makes it more hard to maintain. Instead, this should be wrapped around in some module like keras_cv/utils/conditional_imports.py and import tensorflow from this wrapper.

Copy link
Collaborator

@divyashreepathihalli divyashreepathihalli left a comment

Choose a reason for hiding this comment

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

Thanks Samaneh! looks like code reformatting is needed!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants