-
Notifications
You must be signed in to change notification settings - Fork 261
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
KerasHub has mandatory dependency on tensorflow-text but it isn't mandatory #2101
Comments
+1 agree Can't install keras-hub when I have enforced tensorflow<2.18 on MacOS as tensorflow-text don't support that. |
Thanks for bringing this up! |
Thanks |
Shoot! I think we actually might need to roll this back. On a clean system, if you run import keras_hub
classifier = keras_hub.models.ImageClassifier.from_preset(
"resnet_50_imagenet",
) You would now get an error saying tensorflow is required (when trying to create image preprocessing layers). That's a breaking change I don't think we want! And even more confusing that the fix is to append "nlp" to the install line. |
Instead I think we need the following for now.
The better solution will need to be one of the following.
I know this is less than ideal, but hopefully we can start making progress towards making |
This disappointing. There really needs to be a version of KerasHub that doesn't have a mandatory dependency on tensorflow, for either of the reasons listed above. Even on linux, if KerasHub has a mandatory dependency on tensorflow, then it negates any the benefit of the multi-backend capability of Keras 3. For example, do you really want to spend time coordinating which versions of tensorflow and pytorch can be installed in the same venv with the same version of cuda/nocuda and all of the other dependencies? One interim question is whether it will work with tensorflow "core" as a mandatory (linux) dependency and tensorflow-text as an optional "nlp" dependency, if the main issue is KerasHub (as successor to KerasCV and KerasNLP) is advertised as a replacement for the discontinued tf.addons project, and that has to be taken into account too. It's not just a Keras wrapper for third-party models. At least as I understand it. |
Agreed, this too me is a big problem as I'd like to use another backend for my CV project... Which is one of the major "selling-points" of Keras 3. |
KerasHub doesn't necessarily need to be totally backend agnostic, just needs to respect to the backend selected for Keras itself. So if it depends on tf.data (for example) currently, then that should to be abstracted and adapted for the other backends. There may even already be something in Keras 3. |
@jamesmyatt @Lundez yeah the issue moreso than tf-text is that all preprocessing is currently run through tf.data. So So the expected use today is for the library is a cpu install of tensorflow with a gpu torch or jax (see here and here), or a gpu install of tf. Cuda version aligning across frameworks is indeed tricky, Colab and Kaggle do it but I wouldn't recommend for a local development. I agree tough this dep kinda sucks. Tensorflow is a huge binary. It would be great to relax this constraint, and thing things like our So for today...
|
I opened #2128 as a first step for this. |
Exciting. While I understand the issue that Keras Hub relies on TF Datasets, and the perks of efficient pipelines makes sense. The same could be said about making Keras multi-framework in 3.0, TF isn't a slow framework (if you apply XLA). I'm happy that the investigation starts now to drop the reliance as it'd be very welcome! Once again, thanks for initiating a move in the right direction! EDIT: I hope I find the time to look into #2128 |
Can tensorflow-text be removed as a mandatory dependency, please? e.g. move it to an optional dependency group, e.g. "nlp"
As far as I can tell, this dependency makes it impossible to either:
Both of these seem to be contrary to Keras 3's mission, especially if you only want the CV parts of KerasHub.
Furthermore, the NoTensorflow integration tests show that it's acceptable to manually uninstall tensorflow and tensorflow-text after installing keras-hub. But it's not possible to never install them in the first place.
I think this was tolerable when this package was KerasNLP (e.g. #1585, keras-team/keras#19542), but now that it's KerasHub, it's a serious issue.
The text was updated successfully, but these errors were encountered: