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

KerasCV on Google Colab #2376

Closed
innat opened this issue Mar 11, 2024 · 8 comments
Closed

KerasCV on Google Colab #2376

innat opened this issue Mar 11, 2024 · 8 comments
Assignees
Labels
type:Bug Something isn't working

Comments

@innat
Copy link
Contributor

innat commented Mar 11, 2024

Tried to install keras-cv in colab with latest packages but got the following issue. However, this might be issue with colab and not keras-cv - not sure!!

!pip install --upgrade keras-cv-nightly tf-nightly keras-nightly

import tensorflow as tf
tf.__version__
2.17.0-dev20240310

import keras
keras.__version__
3.1.0.dev2024031103

import keras_cv
keras_cv.__version__
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[<ipython-input-5-e37ee6d8d2a2>](https://localhost:8080/#) in <cell line: 1>()
----> 1 import keras_cv
      2 keras_cv.__version__

10 frames
[/usr/local/lib/python3.10/dist-packages/keras/api/_v2/keras/__internal__/backend/__init__.py](https://localhost:8080/#) in <module>
      1 """AUTOGENERATED. DO NOT EDIT."""
      2 
----> 3 from keras.src.backend import _initialize_variables as initialize_variables
      4 from keras.src.backend import track_variable

ImportError: cannot import name '_initialize_variables' from 'keras.src.backend' (/usr/local/lib/python3.10/dist-packages/keras/src/backend/__init__.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
@sachinprasadhs
Copy link
Collaborator

I was able to install all these packages in individual cell in colab, here is the Gist https://colab.sandbox.google.com/gist/sachinprasadhs/2c9a60d3e51bc986c37999c222675e87/2376.ipynb

@innat
Copy link
Contributor Author

innat commented Mar 11, 2024

Not exactly. Inspect the first post, the packages did install but import error for keras-cv.

@RichiDot
Copy link

I have encountered the same issue. Although the Keras packages appear to be installed, I'm facing difficulties importing the modules. For instance, I encountered this error:

ModuleNotFoundError                       
Traceback (most recent call last)
[<ipython-input-2-1a02c2e511a0>](https://localhost:8080/#) in <cell line: 10>()
      8 import tensorflow as tf
      9 import tensorflow.experimental.numpy as tnp
---> 10 from keras_cv.models.stable_diffusion.clip_tokenizer import SimpleTokenizer
     11 from keras_cv.models.stable_diffusion.diffusion_model import DiffusionModel
     12 from keras_cv.models.stable_diffusion.image_encoder import ImageEncoder

ModuleNotFoundError: No module named 'keras_cv.models.stable_diffusion.clip_tokenizer

@smitlg
Copy link
Contributor

smitlg commented Mar 22, 2024

I am trying to fix it in #2394. This isn't an issue on colab side.

@smitlg
Copy link
Contributor

smitlg commented Mar 22, 2024

I was able to install all these packages in individual cell in colab, here is the Gist https://colab.sandbox.google.com/gist/sachinprasadhs/2c9a60d3e51bc986c37999c222675e87/2376.ipynb

Installation should work fine. import keras_cv will fail.

@divyashreepathihalli
Copy link
Collaborator

Your colab already has a keras version installed, and when you reinstall a different version - you might get this error. Please restart session and then do import keras - that should work.

@smitlg
Copy link
Contributor

smitlg commented Mar 25, 2024

The failure comes from import keras_cv and keras_nlp is not installed.

@sachinprasadhs sachinprasadhs added the type:Bug Something isn't working label Apr 22, 2024
@scienceLabwork
Copy link

I have encountered the same issue. Although the Keras packages appear to be installed, I'm facing difficulties importing the modules. For instance, I encountered this error:

ModuleNotFoundError                       
Traceback (most recent call last)
[<ipython-input-2-1a02c2e511a0>](https://localhost:8080/#) in <cell line: 10>()
      8 import tensorflow as tf
      9 import tensorflow.experimental.numpy as tnp
---> 10 from keras_cv.models.stable_diffusion.clip_tokenizer import SimpleTokenizer
     11 from keras_cv.models.stable_diffusion.diffusion_model import DiffusionModel
     12 from keras_cv.models.stable_diffusion.image_encoder import ImageEncoder

ModuleNotFoundError: No module named 'keras_cv.models.stable_diffusion.clip_tokenizer

Try using src in between keras_cv and models while importing

from keras_cv.src.models.stable_diffusion.clip_tokenizer import SimpleTokenizer
from keras_cv.src.models.stable_diffusion.diffusion_model import DiffusionModel
from keras_cv.src.models.stable_diffusion.image_encoder import ImageEncoder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants