## TF-Keras (légacy)

`tf-keras` is the name given to Keras 2.x version. It is now hosted as a separate GitHub repo [here](https://github.com/keras-team/tf-keras). Though it's a legacy framework, there are still [4.5k+ models](https://huggingface.co/models?library=tf-keras&sort=trending) hosted on the Hub. These models can be loaded using the `huggingface_hub` library. You **must** have either `tf-keras` or `keras<3.x` installed on your machine.

Si vous êtes intéressé par la prise en charge de Keras 3.x, consultez [ce guide](./keras).

Une fois installé, il vous suffit d’utiliser la méthode `from_pretrained_keras` pour charger un modèle depuis le Hub. En savoir plus sur `from_pretrained_keras` [ici](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/mixins#huggingface_hub.from_pretrained_keras).

```py
from huggingface_hub import from_pretrained_keras

model = from_pretrained_keras("keras-io/mobile-vit-xxs")
prediction = model.predict(image)
prediction = tf.squeeze(tf.round(prediction))
print(f'The image is a {classes[(np.argmax(prediction))]}!')

<CopyLLMTxtMenu containerStyle="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"></CopyLLMTxtMenu>

# The image is a sunflower!
```

Vous pouvez également héberger votre modèle `tf-keras` sur le Hub. Toutefois, gardez à l’esprit que `tf-keras` est un framework obsolète. Pour atteindre le plus grand nombre d’utilisateurs, nous recommandons de créer votre modèle avec Keras 3.x et de le partager nativement, comme décrit ci-dessus. Pour plus de détails sur la mise en ligne de modèles `tf-keras`, consultez la documentation de [`push_to_hub_keras`](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/mixins#huggingface_hub.push_to_hub_keras).

```py
from huggingface_hub import push_to_hub_keras

push_to_hub_keras(model,
    "your-username/your-model-name",
    "your-tensorboard-log-directory",
    tags = ["object-detection", "some_other_tag"],
    **model_save_kwargs,
)
```

## Ressources supplémentaires

- [Dépôt GitHub](https://github.com/keras-team/tf-keras)
* Article de blog [Mettre Keras sur le 🤗 Hub pour l'entraînement collaboratif et la reproductibilité](https://merveenoyan.medium.com/putting-keras-on-hub-for-collaborative-training-and-reproducibility-9018301de877) (avril 2022)

