Gradio is an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitary Python function.
gr.Blocks
- кастомное приложение: базовый класс;gr.Interface
- input-output интерфейс;gr.ChatInterface
- чат-интерфейс;gr.TabbedInterface
- приложение, разделённое на несколько tab-секций. То есть несколько приложений внутри одного;Запуск любого приложения: gradio <filename.py>
или python <filename.py>
gr.Interface
— input-output приложение, позволяющее в интерактивном режиме взаимодействовать с пользователем.
import gradio as gr
import pandas as pd
df = pd.read_csv("examples/data/sales.csv")
def get_sample_dataframe(
sample_size,
):
return df.sample(sample_size)
demo = gr.Interface(
fn=get_sample_dataframe,
inputs=["number"], # inputs=[gr.Number()],
outputs=["dataframe"], # outputs=[gr.DataFrame()],
)
demo.launch()
input —>
—> output
Например gr.Image
может быть картинкой (np.ndarray), путём до файла с картинкой (str), списком путей до файлов (list[str]).