Transformers documentation

機械学習アプリ

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

機械学習アプリ

機械学習アプリの構築と共有を迅速かつ容易に行うためのライブラリであるGradioは、Pipelineと統合されており、推論用のシンプルなインターフェースを素早く作成できます。

開始する前に、Gradioがインストールされていることを確認してください。

!pip install gradio

Create a pipeline for your task, and then pass it to Gradio’s Interface.from_pipeline function to create the interface. Gradio automatically determines the appropriate input and output components for a Pipeline.

launch を追加して、Web サーバーを作成し、アプリを起動します。

from transformers import pipeline
import gradio as gr

pipeline = pipeline("image-classification", model="google/vit-base-patch16-224")
gr.Interface.from_pipeline(pipeline).launch()

Webアプリはデフォルトでローカルサーバー上で実行されます。他のユーザーとアプリを共有するには、launchでshare=Trueを設定して、一時的なパブリックリンクを生成します。より永続的なソリューションとして、アプリをHugging Face Spacesにホストできます。

gr.Interface.from_pipeline(pipeline).launch(share=True)

上記のコードで作成されたSpaceは、Spaces上でホストされています。

Update on GitHub