Hub documentation

在 Hugging Face 上使用 fastai

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

在 Hugging Face 上使用 fastai

fastai 是一个开源深度学习库,它利用 PyTorch 和 Python 提供高级组件,用于在文本、视觉和表格数据上训练快速且准确的神经网络,并达到最先进的输出效果。

在 Hub 中探索 fastai

您可以在模型页面左侧进行筛选,以查找fastai模型。

Hub 上的所有模型都具备以下功能:

  1. 自动生成的模型卡片,包含简要描述和有助于提高可发现性的元数据标签。
  2. 一个交互式小部件,可直接在浏览器中用于体验模型(适用于图像分类)
  3. 一个推理提供商小部件,允许发起推理请求(用于图像分类)。

使用现有模型

huggingface_hub 库是一个轻量级的 Python 客户端,提供了用于从 Hub 下载模型的实用函数。

pip install huggingface_hub["fastai"]

安装好该库后,您只需使用 from_pretrained_fastai 方法即可。该方法不仅会加载模型,还会验证模型保存时的 fastai 版本,这对于可复现性至关重要。

from huggingface_hub import from_pretrained_fastai

learner = from_pretrained_fastai("espejelomar/identify-my-cat")

_,_,probs = learner.predict(img)
print(f"Probability it's a cat: {100*probs[1].item():.2f}%")

# Probability it's a cat: 100.00%

如果你想了解如何加载特定模型,可以单击 Use in fastai,你将获得一个可用的代码片段来加载它!

共享您的模型

您可以使用 push_to_hub_fastai 方法来共享您的 fastai 模型。

from huggingface_hub import push_to_hub_fastai

push_to_hub_fastai(learner=learn, repo_id="espejelomar/identify-my-cat")

其他资源

Update on GitHub