Impossible to use tf-keras or keras version < 3.0
I can't use this model at all because when I pip install tf-keras or an older version of keras before version 3, tensorflow is installed which then installs a version of keras that is greater than version 3.
So you run into a loop of failure.
%pip uninstall tensorflow -y
%pip uninstall keras -y
%pip install tf-keras
from huggingface_hub import from_pretrained_keras
model = from_pretrained_keras("keras-io/bidirectional-lstm-imdb")
Then the error message is below.
ValueError Traceback (most recent call last)
Cell In[34], line 6
3 get_ipython().run_line_magic('pip', 'install tf-keras')
5 from huggingface_hub import from_pretrained_keras
----> 6 model = from_pretrained_keras("keras-io/bidirectional-lstm-imdb")
File c:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\huggingface_hub\keras_mixin.py:293, in from_pretrained_keras(*args, **kwargs)
240 def from_pretrained_keras(*args, **kwargs) -> "KerasModelHubMixin":
241 r"""
242 Instantiate a pretrained Keras model from a pre-trained model from the Hub.
243 The model is expected to be in SavedModel
format.
(...)
291
292 """
--> 293 return KerasModelHubMixin.from_pretrained(*args, **kwargs)
File c:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\huggingface_hub\utils_validators.py:114, in validate_hf_hub_args.._inner_fn(*args, **kwargs)
111 if check_use_auth_token:
112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs)
--> 114 return fn(*args, **kwargs)
File c:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\huggingface_hub\hub_mixin.py:571, in ModelHubMixin.from_pretrained(cls, pretrained_model_name_or_path, force_download, resume_download, proxies, token, cache_dir, local_files_only, revision, **model_kwargs)
568 if cls._hub_mixin_inject_config and "config" not in model_kwargs:
569 model_kwargs["config"] = config
...
216 "(note that your call_endpoint
"
217 "might have a different name)."
218 )
ValueError: File format not supported: filepath=C:\Users\user.cache\huggingface\hub\models--keras-io--bidirectional-lstm-imdb\snapshots\b747ad4fa29ee40fb6093799a4807a3a8d5fea2e. Keras 3 only supports V3 .keras
files and legacy H5 format files (.h5
extension). Note that the legacy SavedModel format is not supported by load_model()
in Keras 3. In order to reload a TensorFlow SavedModel as an inference-only layer in Keras 3, use keras.layers.TFSMLayer(C:\Users\user\.cache\huggingface\hub\models--keras-io--bidirectional-lstm-imdb\snapshots\b747ad4fa29ee40fb6093799a4807a3a8d5fea2e, call_endpoint='serving_default')
(note that your call_endpoint
might have a different name).
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...