728x90
What Does Gradio Do?
One of the best ways to share your machine learning model, API, or data science workflow with others is to create an interactive app that allows your users or colleagues to try out the demo in their browsers.
Gradio allows you to build demos and share them, all in Python. And usually in just a few lines of code! So let's get started.
Install Gradio Package
!pip install gradio
!pip install transformers
Sentiment Analysis
text를 입력하면 감정(긍정/부정)을 평가하는 Apps
(Google Collab에서 테스트 가능함.)
import gradio as gr
import transformers
# Load the pre-trained sentiment analysis model
model = transformers.pipeline("sentiment-analysis")
# Define the Gradio interface
def sentiment_analysis(text):
result = model(text)[0]
label = result["label"]
score = result["score"]
return f"{label} with confidence score {score:.2f}"
iface = gr.Interface(fn=sentiment_analysis,
inputs=gr.inputs.Textbox(lines=5, label="Input text"),
outputs="text",
title="Sentiment Analysis")
# Launch the Gradio interface
iface.launch()
실행결과
Reference :
- Gradio Demos : https://gradio.app/demos/
- Gradio Documents : https://gradio.app/docs/
728x90
'Data Science > Machine Learning' 카테고리의 다른 글
[text classification] fasttext example (0) | 2024.04.24 |
---|---|
[PyTorch] PyTorch Tutorial Projects (0) | 2023.02.07 |
[Sound Analysis] Sound-data Preprocessing : Librosa (0) | 2023.01.03 |
[Data Labeling] Label-Studio Review (2) | 2022.09.08 |
Data Labeling Tools Each Type (0) | 2022.09.07 |
최근댓글