keras-team / keras-cv

Industry-strength Computer Vision workflows with Keras
Other
1.01k stars 330 forks source link

Installing 0.6.4 from PyPI does not include stable_difussion inside models folder #2072

Closed jonbesga closed 1 year ago

jonbesga commented 1 year ago

Current Behavior:

pip install keras-cv to install latest version 0.6.4

Try to use anything related to stable diffusion like the tokenizer:

tokenizer = keras_cv.models.stable_diffusion.SimpleTokenizer()

It will complain with AttributeError: module 'keras_cv.models' has no attribute 'stable_diffusion'

Note that it works if I decide to do the following import keras_cv.src.models.stable_diffusion.SimpleTokenizer() where I use the src folder

Expected Behavior:

Import works correctly

Version: 0.6.4

jbischof commented 1 year ago

Thanks @jonbesga!

Has it worked in other versions or you just noticed now? If the former, please let us know which version.

aliftadvantage commented 1 year ago

Having the same issue. Was working in v0.6.1

Repro: Working in v0.6.1 - https://colab.research.google.com/drive/1brn2BhoRhr8LJ7_daB-F7Z_4Lq5bLAVi?usp=sharing Not working in v0.6.2 - https://colab.research.google.com/drive/1QgHiHTQ44fNnOzags5dxsN5Q3pG3PtxM?usp=sharing

jbischof commented 1 year ago

@aliftadvantage the colabs above aren't quite right because you never import keras_cv. However, I was able to replicate the bug after the import (colab).

@ianstenbit I don't see this error in my local dev environment. Could it be related to the new namex export system?

ianstenbit commented 1 year ago

This is caused by the fact that the non-top level components of StableDiffusion don't have @keras_cv_export tags on them.

They can be imported in the newer versions under keras_cv.src.models.stable_diffusion, and we can include a @keras_cv_export tag for them if we'd like to export them directly.

edit: To be clear, yes this is due to the use of Namex, as we're not currently explicitly exporting SD's component models in our API, only the top-level models.

jbischof commented 1 year ago

Interesting. I wonder if we should leave a note in our README because namex is very new and there is no src folder in our codebase to even hint at this.

ianstenbit commented 1 year ago

Interesting. I wonder if we should leave a note in our README because namex is very new and there is no src folder in our codebase to even hint at this.

We can also just export these symbols if we want, as it's clear that people are using them!

aliftadvantage commented 1 year ago

We can also just export these symbols if we want, as it's clear that people are using them!

+1! For example, it uses them in the keras fine-tuning stable diffusion guide: https://keras.io/examples/generative/finetune_stable_diffusion/

ianstenbit commented 1 year ago

We can also just export these symbols if we want, as it's clear that people are using them!

+1! For example, it uses them in the keras fine-tuning stable diffusion guide: https://keras.io/examples/generative/finetune_stable_diffusion/

Ahh yes -- let's include these then! If anyone would like to send a PR I will review it ASAP -- otherwise I'll send a fix tomorrow.