keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
62.13k stars 19.49k forks source link

AttributeError: module 'keras_nlp' has no attribute 'models' #20531

Open iwqculrbud opened 4 days ago

iwqculrbud commented 4 days ago
:1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' :1: SyntaxWarning: invalid escape sequence '\/' Traceback (most recent call last): File "C:\Users\wangshijiang\Desktop\deep_learning\project\llm\llm.py", line 68, in preprocessor = keras_nlp.models.DebertaV3Preprocessor.from_preset( ^^^^^^^^^^^^^^^^ AttributeError: module 'keras_nlp' has no attribute 'models' ![屏幕截图 2024-11-21 225847](https://github.com/user-attachments/assets/07c8aa91-208d-4849-8a84-92b6741553a7)
sachinprasadhs commented 4 days ago

keras-nlp has been renamed to keras-hub with the inclusion of image specific models , all the new development and future release will be as keras-hubpackage.

You can install keras-hub using !pip install -Uq keras-hub

and the code is working without any issues.

import keras_hub

preprocessor = keras_hub.models.DebertaV3Preprocessor.from_preset(
   preset= "deberta_v3_extra_small_en",
   sequence_length= 512,
)

Even it is working with keras-nlp as well, just that it will not have any latest update and there will not be any releases.

iwqculrbud commented 2 days ago

keras-nlp has been renamed to keras-hub with the inclusion of image specific models , all the new development and future release will be as keras-hubpackage.

You can install keras-hub using !pip install -Uq keras-hub

and the code is working without any issues.

import keras_hub

preprocessor = keras_hub.models.DebertaV3Preprocessor.from_preset(
   preset= "deberta_v3_extra_small_en",
   sequence_length= 512,
)

Even it is working with keras-nlp as well, just that it will not have any latest update and there will not be any releases.

It sometimes doesn't work locally or on colab. Why are you unwilling to pursue stability?

sachinprasadhs commented 6 hours ago

If you are facing this in local you could try to upgrade or install the Keras NLP or Keras Hub package using

pip install -U keras-nlp
pip install -U keras-hub

For colab, restart the runtime and follow the same steps.

For Keras Hub announcement and details check https://github.com/keras-team/keras-hub/issues/1831