Hub documentation

TF-Keras (phiên bản cũ)

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

TF-Keras (phiên bản cũ)

tf-keras là tên được đặt cho phiên bản Keras 2.x. Hiện tại, nó được lưu trữ như một kho GitHub riêng biệt tại đây. Mặc dù đây là một framework cũ, nhưng vẫn có hơn 4.5k mô hình được lưu trữ trên Hub. Các mô hình này có thể được tải bằng thư viện huggingface_hub. Bạn phải cài đặt tf-keras hoặc keras<3.x trên máy của mình.

Nếu bạn quan tâm đến hỗ trợ Keras 3.x, hãy xem hướng dẫn này.

Sau khi cài đặt, bạn chỉ cần sử dụng phương thức from_pretrained_keras để tải một mô hình từ Hub. Đọc thêm về from_pretrained_keras tại đây.

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!

Bạn cũng có thể lưu trữ mô hình tf-keras của mình trên Hub. Tuy nhiên, hãy lưu ý rằng tf-keras là một framework cũ. Để tiếp cận được nhiều người dùng nhất, chúng tôi khuyến nghị bạn tạo mô hình bằng Keras 3.x và chia sẻ nó một cách tự nhiên như đã mô tả ở trên. Để biết thêm chi tiết về việc tải lên các mô hình tf-keras, hãy xem tài liệu push_to_hub_keras.

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,
)

Tài nguyên bổ sung

Update on GitHub